]> git.lyx.org Git - lyx.git/blob - src/LyXRC.cpp
Add comment.
[lyx.git] / src / LyXRC.cpp
1 /**
2  * \file LyXRC.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author Jean-Marc Lasgouttes
8  * \author Angus Leeming
9  * \author John Levon
10  * \author André Pönitz
11  * \author Allan Rae
12  * \author Dekel Tsur
13  *
14  * Full author contact details are available in file CREDITS.
15  */
16
17 #include <config.h>
18
19 #include "LyXRC.h"
20
21 #include "ColorSet.h"
22 #include "Converter.h"
23 #include "FontEnums.h"
24 #include "Format.h"
25 #include "Lexer.h"
26 #include "LyX.h"
27 #include "Mover.h"
28 #include "Session.h"
29 #include "version.h"
30
31 #include "graphics/GraphicsTypes.h"
32
33 #include "support/convert.h"
34 #include "support/debug.h"
35 #include "support/environment.h"
36 #include "support/FileName.h"
37 #include "support/filetools.h"
38 #include "support/gettext.h"
39 #include "support/lstrings.h"
40 #include "support/os.h"
41 #include "support/Package.h"
42 #include "support/userinfo.h"
43
44 #include <fstream>
45 #include <iostream>
46 #include <algorithm>
47
48 using namespace std;
49 using namespace lyx::support;
50
51 namespace lyx {
52
53 namespace os = support::os;
54
55 namespace {
56
57 // when adding something to this array keep it sorted!
58 LexerKeyword lyxrcTags[] = {
59         { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
60         { "\\allow_geometry_session", LyXRC::RC_GEOMETRY_SESSION },
61         { "\\alternate_language", LyXRC::RC_ALT_LANG },
62         { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
63         { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
64         { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
65         { "\\autocorrection_math", LyXRC::RC_AUTOCORRECTION_MATH },
66         { "\\autosave", LyXRC::RC_AUTOSAVE },
67         { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
68         { "\\bibtex_alternatives", LyXRC::RC_BIBTEX_ALTERNATIVES },
69         { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
70         { "\\bind_file", LyXRC::RC_BINDFILE },
71         { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
72         { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
73         { "\\completion_cursor_text", LyXRC::RC_COMPLETION_CURSOR_TEXT },
74         { "\\completion_inline_delay", LyXRC::RC_COMPLETION_INLINE_DELAY },
75         { "\\completion_inline_dots", LyXRC::RC_COMPLETION_INLINE_DOTS },
76         { "\\completion_inline_math", LyXRC::RC_COMPLETION_INLINE_MATH },
77         { "\\completion_inline_text", LyXRC::RC_COMPLETION_INLINE_TEXT },
78         { "\\completion_popup_after_complete", LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE },
79         { "\\completion_popup_delay", LyXRC::RC_COMPLETION_POPUP_DELAY },
80         { "\\completion_popup_math", LyXRC::RC_COMPLETION_POPUP_MATH },
81         { "\\completion_popup_text", LyXRC::RC_COMPLETION_POPUP_TEXT },
82         { "\\converter", LyXRC::RC_CONVERTER },
83         { "\\converter_cache_maxage", LyXRC::RC_CONVERTER_CACHE_MAXAGE },
84         { "\\copier", LyXRC::RC_COPIER },
85         { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
86         { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
87         { "\\def_file", LyXRC::RC_DEFFILE },
88         { "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
89         { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
90         { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
91         { "\\default_view_format", LyXRC::RC_DEFAULT_VIEW_FORMAT },
92         { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
93         { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
94         { "\\document_path", LyXRC::RC_DOCUMENTPATH },
95         { "\\editor_alternatives", LyXRC::RC_EDITOR_ALTERNATIVES },
96         { "\\escape_chars", LyXRC::RC_ESC_CHARS },
97         { "\\example_path", LyXRC::RC_EXAMPLEPATH },
98         { "\\export_overwrite", LyXRC::RC_EXPORT_OVERWRITE },
99         { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
100         { "\\format", LyXRC::RC_FORMAT },
101         { "\\forward_search_dvi", LyXRC::RC_FORWARD_SEARCH_DVI },
102         { "\\forward_search_pdf", LyXRC::RC_FORWARD_SEARCH_PDF },
103         { "\\fullscreen_limit", LyXRC::RC_FULL_SCREEN_LIMIT },
104         { "\\fullscreen_menubar", LyXRC::RC_FULL_SCREEN_MENUBAR },
105         { "\\fullscreen_scrollbar", LyXRC::RC_FULL_SCREEN_SCROLLBAR },
106         { "\\fullscreen_tabbar", LyXRC::RC_FULL_SCREEN_TABBAR },
107         { "\\fullscreen_toolbars", LyXRC::RC_FULL_SCREEN_TOOLBARS },
108         { "\\fullscreen_width", LyXRC::RC_FULL_SCREEN_WIDTH },
109         { "\\group_layouts", LyXRC::RC_GROUP_LAYOUTS },
110         { "\\gui_language", LyXRC::RC_GUI_LANGUAGE },
111         { "\\hunspelldir_path", LyXRC::RC_HUNSPELLDIR_PATH },
112         { "\\index_alternatives", LyXRC::RC_INDEX_ALTERNATIVES },
113         { "\\index_command", LyXRC::RC_INDEX_COMMAND },
114         { "\\input", LyXRC::RC_INPUT },
115         { "\\jbibtex_command", LyXRC::RC_JBIBTEX_COMMAND },
116         { "\\jindex_command", LyXRC::RC_JINDEX_COMMAND },
117         { "\\kbmap", LyXRC::RC_KBMAP },
118         { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
119         { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
120         { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
121         { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
122         { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
123         { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
124         { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
125         { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
126         { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
127         { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
128         { "\\load_session", LyXRC::RC_LOADSESSION },
129         { "\\mac_dontswap_ctrl_meta", LyXRC::RC_MAC_DONTSWAP_CTRL_META },
130         { "\\mac_like_word_movement", LyXRC::RC_MAC_LIKE_WORD_MOVEMENT },
131         { "\\macro_edit_style", LyXRC::RC_MACRO_EDIT_STYLE },
132         { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
133         { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
134         { "\\mouse_wheel_speed", LyXRC::RC_MOUSE_WHEEL_SPEED },
135         { "\\nomencl_command", LyXRC::RC_NOMENCL_COMMAND },
136         { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
137         { "\\open_buffers_in_tabs", LyXRC::RC_OPEN_BUFFERS_IN_TABS },
138         { "\\paragraph_markers", LyXRC::RC_PARAGRAPH_MARKERS },
139         { "\\path_prefix", LyXRC::RC_PATH_PREFIX },
140         { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
141         { "\\plaintext_linelen", LyXRC::RC_PLAINTEXT_LINELEN },
142         { "\\plaintext_roff_command", LyXRC::RC_PLAINTEXT_ROFF_COMMAND },
143         { "\\preview", LyXRC::RC_PREVIEW },
144         { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
145         { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
146         { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
147         { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
148         { "\\print_command", LyXRC::RC_PRINT_COMMAND },
149         { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
150         { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
151         { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
152         { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
153         { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
154         { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
155         { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
156         { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
157         { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
158         { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
159         { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
160         { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
161         { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
162         { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
163         { "\\printer", LyXRC::RC_PRINTER },
164         { "\\rtl", LyXRC::RC_RTL_SUPPORT },
165         { "\\save_compressed", LyXRC::RC_SAVE_COMPRESSED },
166         { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
167         { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
168         { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
169         { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
170         { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
171         { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
172         { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
173         { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
174         { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
175         { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
176         { "\\scroll_below_document", LyXRC::RC_SCROLL_BELOW_DOCUMENT },
177         { "\\scroll_wheel_zoom", LyXRC::RC_SCROLL_WHEEL_ZOOM },
178         { "\\serverpipe", LyXRC::RC_SERVERPIPE },
179         { "\\set_color", LyXRC::RC_SET_COLOR },
180         { "\\show_banner", LyXRC::RC_SHOW_BANNER },
181         { "\\single_close_tab_button", LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON },
182         { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
183         { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
184         { "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY },
185         { "\\spellcheck_notes", LyXRC::RC_SPELLCHECK_NOTES },
186         { "\\spellchecker", LyXRC::RC_SPELLCHECKER },
187         { "\\splitindex_command", LyXRC::RC_SPLITINDEX_COMMAND },
188         { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
189         { "\\template_path", LyXRC::RC_TEMPLATEPATH },
190         { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
191         { "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS },
192         { "\\thesaurusdir_path", LyXRC::RC_THESAURUSDIRPATH },
193         { "\\ui_file", LyXRC::RC_UIFILE },
194         { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
195         { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
196         { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
197         { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
198         { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
199         { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
200         { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE },
201         // compatibility with versions older than 1.4.0 only
202         { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
203         { "\\use_system_colors", LyXRC::RC_USE_SYSTEM_COLORS },
204         // compatibility with versions older than 1.4.0 only
205         { "\\use_tempdir", LyXRC::RC_USETEMPDIR },
206         { "\\use_tooltip", LyXRC::RC_USE_TOOLTIP },
207         { "\\user_email", LyXRC::RC_USER_EMAIL },
208         { "\\user_name", LyXRC::RC_USER_NAME },
209         { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
210         // compatibility with versions older than 1.4.0 only
211         { "\\viewer", LyXRC::RC_VIEWER},
212         { "\\viewer_alternatives", LyXRC::RC_VIEWER_ALTERNATIVES },
213         { "\\visual_cursor" ,LyXRC::RC_VISUAL_CURSOR}
214 };
215
216 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(lyxrcTags[0]);
217
218 } // namespace anon
219
220
221 LyXRC::LyXRC()
222 {
223         setDefaults();
224 }
225
226
227 void LyXRC::setDefaults()
228 {
229         bind_file = "cua";
230         def_file = "default";
231         ui_file = "default";
232         // Get printer from the environment. If fail, use default "",
233         // assuming that everything is set up correctly.
234         printer = getEnv("PRINTER");
235         print_adapt_output = false;
236         print_command = "dvips";
237         print_evenpage_flag = "-B";
238         print_oddpage_flag = "-A";
239         print_pagerange_flag = "-pp";
240         print_copies_flag = "-c";
241         print_collcopies_flag = "-C";
242         print_reverse_flag = "-r";
243         print_landscape_flag = "-t landscape";
244         print_to_printer = "-P";
245         print_to_file = "-o ";
246         print_file_extension = ".ps";
247         print_paper_flag = "-t";
248         print_paper_dimension_flag = "-T";
249         document_path.erase();
250         view_dvi_paper_option.erase();
251         default_papersize = PAPER_DEFAULT;
252         default_view_format = "pdf2";
253         chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
254         bibtex_command = "bibtex";
255         fontenc = "default";
256         index_command = "makeindex -c -q";
257         nomencl_command = "makeindex -s nomencl.ist";
258         dpi = 75;
259         // Because a screen is typically wider than a piece of paper:
260         zoom = 150;
261         allow_geometry_session = true;
262         // Default LaTeX font size:
263         font_sizes[FONT_SIZE_TINY] = "5.0";
264         font_sizes[FONT_SIZE_SCRIPT] = "7.0";
265         font_sizes[FONT_SIZE_FOOTNOTE] = "8.0";
266         font_sizes[FONT_SIZE_SMALL] = "9.0";
267         font_sizes[FONT_SIZE_NORMAL] = "10.0";
268         font_sizes[FONT_SIZE_LARGE] = "12.0";
269         font_sizes[FONT_SIZE_LARGER] = "14.4";
270         font_sizes[FONT_SIZE_LARGEST] = "17.26";
271         font_sizes[FONT_SIZE_HUGE] = "20.74";
272         font_sizes[FONT_SIZE_HUGER] = "24.88";
273         use_scalable_fonts = true;
274         roman_font_name = "";
275         sans_font_name = "";
276         typewriter_font_name = "";
277         autosave = 300;
278         auto_region_delete = true;
279         auto_reset_options = false;
280         plaintext_linelen = 65;
281         mouse_wheel_speed = 1.0;
282         num_lastfiles = maxlastfiles;
283         check_lastfiles = true;
284         use_lastfilepos = true;
285         load_session = false;
286         make_backup = true;
287         save_compressed = false;
288         backupdir_path.erase();
289         display_graphics = true;
290         // Spellchecker settings:
291 // FIXME: this check should test the target platform (darwin)
292 #if defined(USE_MACOSX_PACKAGING)
293         spellchecker = "native";
294 #elif defined(USE_ASPELL)
295         spellchecker = "aspell";
296 #elif defined(USE_HUNSPELL)
297         spellchecker = "hunspell";
298 #else
299         spellchecker = "aspell";
300 #endif
301         spellchecker_accept_compound = false;
302         spellcheck_continuously = false;
303         spellcheck_notes = true;
304         use_kbmap = false;
305         rtl_support = true;
306         visual_cursor = false;
307         auto_number = true;
308         mark_foreign_language = true;
309         language_auto_begin = true;
310         language_auto_end = true;
311         language_global_options = true;
312         language_use_babel = true;
313         language_package = "\\usepackage{babel}";
314         language_command_begin = "\\selectlanguage{$$lang}";
315         language_command_local = "\\foreignlanguage{$$lang}{";
316         sort_layouts = false;
317         group_layouts = true;
318         default_language = "english";
319         gui_language = "auto";
320         show_banner = true;
321         windows_style_tex_paths = false;
322         tex_allows_spaces = false;
323         date_insert_format = "%x";
324         cursor_follows_scrollbar = false;
325         scroll_below_document = false;
326         scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_CTRL;
327         paragraph_markers = false;
328         mac_dontswap_ctrl_meta = false;
329         mac_like_word_movement = false;
330         macro_edit_style = MACRO_EDIT_INLINE_BOX;
331         dialogs_iconify_with_main = false;
332         preview = PREVIEW_OFF;
333         preview_hashed_labels  = false;
334         preview_scale_factor = 1.0;
335         use_converter_cache = true;
336         use_system_colors = false;
337         use_tooltip = true;
338         use_pixmap_cache = false;
339         converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
340         user_name = to_utf8(support::user_name());
341         user_email = to_utf8(support::user_email());
342         open_buffers_in_tabs = true;
343         single_close_tab_button = false;
344         forward_search_dvi = string();
345         forward_search_pdf = string();
346         export_overwrite = NO_FILES;
347
348         // Fullscreen settings
349         full_screen_limit = false;
350         full_screen_toolbars = true;
351         full_screen_tabbar = true;
352         full_screen_menubar = true;
353         full_screen_scrollbar = true;
354         full_screen_width = 700;
355
356         completion_cursor_text = true;
357         completion_popup_math = true;
358         completion_popup_text = false;
359         completion_popup_delay = 2.0;
360         completion_popup_after_complete = true;
361         autocorrection_math = false;
362         completion_inline_math = true;
363         completion_inline_text = false;
364         completion_inline_dots = -1;
365         completion_inline_delay = 0.2;
366         default_decimal_point = ".";
367 }
368
369
370 namespace {
371
372 void oldFontFormat(string & family, string & foundry)
373 {
374         if (family.empty() || family[0] != '-')
375                 return;
376         foundry = token(family, '-', 1);
377         family = token(family, '-', 2);
378         if (foundry == "*")
379                 foundry.erase();
380 }
381
382 } // namespace anon
383
384
385 int LyXRC::read(FileName const & filename)
386 {
387         Lexer lexrc(lyxrcTags);
388         if (lyxerr.debugging(Debug::PARSER))
389                 lexrc.printTable(lyxerr);
390
391         lexrc.setFile(filename);
392         if (!lexrc.isOK())
393                 return -2;
394
395         LYXERR(Debug::LYXRC, "Reading '" << filename << "'...");
396
397         return read(lexrc);
398 }
399
400
401 int LyXRC::read(istream & is)
402 {
403         Lexer lexrc(lyxrcTags);
404         if (lyxerr.debugging(Debug::PARSER))
405                 lexrc.printTable(lyxerr);
406
407         lexrc.setStream(is);
408         if (!lexrc.isOK())
409                 return -2;
410
411         LYXERR(Debug::LYXRC, "Reading istream...");
412
413         return read(lexrc);
414 }
415
416
417 int LyXRC::read(Lexer & lexrc)
418 {
419         if (!lexrc.isOK())
420                 return -2;
421
422         while (lexrc.isOK()) {
423                 // By using two switches we take advantage of the compiler
424                 // telling us if we have missed a LyXRCTags element in
425                 // the second switch.
426                 // Note that this also shows a problem with Lexer since it
427                 // helps us avoid taking advantage of the strictness of the
428                 // compiler.
429
430                 int le = lexrc.lex();
431                 switch (le) {
432                 case Lexer::LEX_UNDEF:
433                         lexrc.printError("Unknown tag `$$Token'");
434                         continue;
435                 case Lexer::LEX_FEOF:
436                         continue;
437                 default:
438                         break;
439                 }
440                 switch (static_cast<LyXRCTags>(le)) {
441                 case RC_INPUT: // Include file
442                         if (lexrc.next()) {
443                                 FileName const tmp =
444                                         libFileSearch(string(),
445                                                       lexrc.getString());
446                                 if (read(tmp)) {
447                                         lexrc.printError("Error reading "
448                                                          "included file: " + tmp.absFileName());
449                                 }
450                         }
451                         break;
452                 case RC_BINDFILE:
453                         if (lexrc.next())
454                                 bind_file = os::internal_path(lexrc.getString());
455                         break;
456
457                 case RC_DEFFILE:
458                         if (lexrc.next())
459                                 def_file = os::internal_path(lexrc.getString());
460                         break;
461
462                 case RC_UIFILE:
463                         if (lexrc.next())
464                                 ui_file = os::internal_path(lexrc.getString());
465                         break;
466
467                 case RC_AUTORESET_OPTIONS:
468                         lexrc >> auto_reset_options;
469                         break;
470
471                 case RC_DISPLAY_GRAPHICS:
472                         if (lexrc.next())
473                                 display_graphics = lexrc.getString() == "true";
474                         break;
475
476                 case RC_TEX_EXPECTS_WINDOWS_PATHS:
477                         lexrc >> windows_style_tex_paths;
478                         break;
479
480                 case RC_TEX_ALLOWS_SPACES:
481                         lexrc >> tex_allows_spaces;
482                         break;
483
484                 case RC_KBMAP:
485                         lexrc >> use_kbmap;
486                         break;
487
488                 case RC_KBMAP_PRIMARY:
489                         if (lexrc.next()) {
490                                 string const kmap(os::internal_path(lexrc.getString()));
491                                 if (!libFileSearch("kbd", kmap, "kmap").empty()
492                                           || kmap.empty()) {
493                                         primary_kbmap = kmap;
494                                 } else {
495                                         lexrc.printError("LyX: Keymap `$$Token' not found");
496                                 }
497                         }
498                         break;
499
500                 case RC_KBMAP_SECONDARY:
501                         if (lexrc.next()) {
502                                 string const kmap(os::internal_path(lexrc.getString()));
503                                 if (!libFileSearch("kbd", kmap, "kmap").empty()
504                                           || kmap.empty()) {
505                                         secondary_kbmap = kmap;
506                                 } else {
507                                         lexrc.printError("LyX: Keymap `$$Token' not found");
508                                 }
509                         }
510                         break;
511
512                 case RC_FONT_ENCODING:
513                         lexrc >> fontenc;
514                         break;
515
516                 case RC_PRINTER:
517                         lexrc >> printer;
518                         break;
519
520                 case RC_PRINT_COMMAND:
521                         if (lexrc.next(true)) {
522                                 print_command = lexrc.getString();
523                         }
524                         break;
525
526                 case RC_PRINTEVENPAGEFLAG:
527                         lexrc >> print_evenpage_flag;
528                         break;
529
530                 case RC_PRINTODDPAGEFLAG:
531                         lexrc >> print_oddpage_flag;
532                         break;
533
534                 case RC_PRINTPAGERANGEFLAG:
535                         lexrc >> print_pagerange_flag;
536                         break;
537
538                 case RC_PRINTCOPIESFLAG:
539                         lexrc >> print_copies_flag;
540                         break;
541
542                 case RC_PRINTCOLLCOPIESFLAG:
543                         lexrc >> print_collcopies_flag;
544                         break;
545
546                 case RC_PRINTREVERSEFLAG:
547                         lexrc >> print_reverse_flag;
548                         break;
549
550                 case RC_PRINTLANDSCAPEFLAG:
551                         lexrc >> print_landscape_flag;
552                         break;
553
554                 case RC_PRINTTOPRINTER:
555                         lexrc >> print_to_printer;
556                         break;
557
558                 case RC_PRINT_ADAPTOUTPUT:
559                         lexrc >> print_adapt_output;
560                         break;
561
562                 case RC_PRINTTOFILE:
563                         if (lexrc.next()) {
564                                 print_to_file = os::internal_path(lexrc.getString());
565                         }
566                         break;
567
568                 case RC_PRINTFILEEXTENSION:
569                         lexrc >> print_file_extension;
570                         break;
571
572                 case RC_PRINTEXSTRAOPTIONS:
573                         lexrc >> print_extra_options;
574                         break;
575
576                 case RC_PRINTSPOOL_COMMAND:
577                         if (lexrc.next(true)) {
578                                 print_spool_command = lexrc.getString();
579                         }
580                         break;
581
582                 case RC_PRINTSPOOL_PRINTERPREFIX:
583                         lexrc >> print_spool_printerprefix;
584                         break;
585
586                 case RC_PRINTPAPERDIMENSIONFLAG:
587                         lexrc >> print_paper_dimension_flag;
588                         break;
589
590                 case RC_PRINTPAPERFLAG:
591                         lexrc >> print_paper_flag;
592                         break;
593
594                 case RC_DEFAULT_PAPERSIZE:
595                         if (lexrc.next()) {
596                                 string const size = ascii_lowercase(lexrc.getString());
597                                 if (size == "usletter")
598                                         default_papersize = PAPER_USLETTER;
599                                 else if (size == "legal")
600                                         default_papersize = PAPER_USLEGAL;
601                                 else if (size == "executive")
602                                         default_papersize = PAPER_USEXECUTIVE;
603                                 else if (size == "a3")
604                                         default_papersize = PAPER_A3;
605                                 else if (size == "a4")
606                                         default_papersize = PAPER_A4;
607                                 else if (size == "a5")
608                                         default_papersize = PAPER_A5;
609                                 else if (size == "b5")
610                                         default_papersize = PAPER_B5;
611                                 else if (size == "default")
612                                         default_papersize = PAPER_DEFAULT;
613                         }
614                         break;
615
616                 case RC_VIEWDVI_PAPEROPTION:
617                         if (lexrc.next())
618                                 view_dvi_paper_option = lexrc.getString();
619                         else
620                                 view_dvi_paper_option.erase();
621                         break;
622
623                 case RC_CHKTEX_COMMAND:
624                         if (lexrc.next(true)) {
625                                 chktex_command = lexrc.getString();
626                         }
627                         break;
628
629                 case RC_BIBTEX_ALTERNATIVES:
630                         if (lexrc.next(true)) {
631                                 bibtex_alternatives.insert(lexrc.getString());
632                         }
633                         break;
634
635                 case RC_BIBTEX_COMMAND:
636                         if (lexrc.next(true)) {
637                                 bibtex_command = lexrc.getString();
638                         }
639                         break;
640
641                 case RC_JBIBTEX_COMMAND:
642                         if (lexrc.next(true)) {
643                                 jbibtex_command = lexrc.getString();
644                         }
645                         break;
646
647                 case RC_INDEX_ALTERNATIVES:
648                         if (lexrc.next(true)) {
649                                 index_alternatives.insert(lexrc.getString());
650                         }
651                         break;
652
653                 case RC_INDEX_COMMAND:
654                         if (lexrc.next(true)) {
655                                 index_command = lexrc.getString();
656                         }
657                         break;
658
659                 case RC_JINDEX_COMMAND:
660                         if (lexrc.next(true)) {
661                                 jindex_command = lexrc.getString();
662                         }
663                         break;
664
665                 case RC_SPLITINDEX_COMMAND:
666                         if (lexrc.next(true)) {
667                                 splitindex_command = lexrc.getString();
668                         }
669                         break;
670
671                 case RC_NOMENCL_COMMAND:
672                         if (lexrc.next(true)) {
673                                 nomencl_command = lexrc.getString();
674                         }
675                         break;
676
677                 case RC_SCREEN_DPI:
678                         lexrc >> dpi;
679                         break;
680
681                 case RC_SCREEN_ZOOM:
682                         lexrc >> zoom;
683                         break;
684
685                 case RC_GEOMETRY_SESSION:
686                         lexrc >> allow_geometry_session;
687                         break;
688
689                 case RC_SCREEN_FONT_SIZES:
690                         lexrc >> font_sizes[FONT_SIZE_TINY];
691                         lexrc >> font_sizes[FONT_SIZE_SCRIPT];
692                         lexrc >> font_sizes[FONT_SIZE_FOOTNOTE];
693                         lexrc >> font_sizes[FONT_SIZE_SMALL];
694                         lexrc >> font_sizes[FONT_SIZE_NORMAL];
695                         lexrc >> font_sizes[FONT_SIZE_LARGE];
696                         lexrc >> font_sizes[FONT_SIZE_LARGER];
697                         lexrc >> font_sizes[FONT_SIZE_LARGEST];
698                         lexrc >> font_sizes[FONT_SIZE_HUGE];
699                         lexrc >> font_sizes[FONT_SIZE_HUGER];
700                         break;
701
702                 case RC_SCREEN_FONT_SCALABLE:
703                         lexrc >> use_scalable_fonts;
704                         break;
705
706                 case RC_AUTOSAVE:
707                         lexrc >> autosave;
708                         break;
709
710                 case RC_DOCUMENTPATH:
711                         if (lexrc.next()) {
712                                 document_path = os::internal_path(lexrc.getString());
713                                 document_path = expandPath(document_path);
714                         }
715                         break;
716
717                 case RC_EXAMPLEPATH:
718                         if (lexrc.next()) {
719                                 example_path = os::internal_path(lexrc.getString());
720                                 example_path = expandPath(example_path);
721                         }
722                         break;
723
724                 case RC_TEMPLATEPATH:
725                         if (lexrc.next()) {
726                                 template_path = os::internal_path(lexrc.getString());
727                                 template_path = expandPath(template_path);
728                         }
729                         break;
730
731                 case RC_TEMPDIRPATH:
732                         if (lexrc.next()) {
733                                 tempdir_path = os::internal_path(lexrc.getString());
734                                 tempdir_path = expandPath(tempdir_path);
735                         }
736                         break;
737
738                 case RC_THESAURUSDIRPATH:
739                         if (lexrc.next()) {
740                                 thesaurusdir_path = os::internal_path(lexrc.getString());
741                                 thesaurusdir_path = expandPath(thesaurusdir_path);
742                         }
743                         break;
744
745                 case RC_HUNSPELLDIR_PATH:
746                         if (lexrc.next()) {
747                                 hunspelldir_path = os::internal_path(lexrc.getString());
748                                 hunspelldir_path = expandPath(hunspelldir_path);
749                         }
750                         break;
751
752                 case RC_USELASTFILEPOS:
753                         lexrc >> use_lastfilepos;
754                         break;
755
756                 case RC_LOADSESSION:
757                         lexrc >> load_session;
758                         break;
759
760                 case RC_MOUSE_WHEEL_SPEED:
761                         lexrc >> mouse_wheel_speed;
762                         break;
763
764                 case RC_COMPLETION_INLINE_DELAY:
765                         lexrc >> completion_inline_delay;
766                         break;
767
768                 case RC_COMPLETION_INLINE_MATH:
769                         lexrc >> completion_inline_math;
770                         break;
771
772                 case RC_COMPLETION_INLINE_TEXT:
773                         lexrc >> completion_inline_text;
774                         break;
775
776                 case RC_COMPLETION_INLINE_DOTS:
777                         lexrc >> completion_inline_dots;
778                         break;
779
780                 case RC_AUTOCORRECTION_MATH:
781                         lexrc >> autocorrection_math;
782                         break;
783
784                 case RC_COMPLETION_POPUP_DELAY:
785                         lexrc >> completion_popup_delay;
786                         break;
787
788                 case RC_COMPLETION_POPUP_MATH:
789                         lexrc >> completion_popup_math;
790                         break;
791
792                 case RC_COMPLETION_POPUP_TEXT:
793                         lexrc >> completion_popup_text;
794                         break;
795
796                 case RC_COMPLETION_CURSOR_TEXT:
797                         lexrc >> completion_cursor_text;
798                         break;
799
800                 case RC_COMPLETION_POPUP_AFTER_COMPLETE:
801                         lexrc >> completion_popup_after_complete;
802                         break;
803
804                 case RC_NUMLASTFILES:
805                         lexrc >> num_lastfiles;
806                         break;
807
808                 case RC_CHECKLASTFILES:
809                         lexrc >> check_lastfiles;
810                         break;
811
812                 case RC_SCREEN_FONT_ROMAN:
813                         if (lexrc.next()) {
814                                 roman_font_name = lexrc.getString();
815                                 oldFontFormat(roman_font_name,
816                                               roman_font_foundry);
817                         }
818                         break;
819
820                 case RC_SCREEN_FONT_SANS:
821                         if (lexrc.next()) {
822                                 sans_font_name = lexrc.getString();
823                                 oldFontFormat(sans_font_name, sans_font_foundry);
824                         }
825                         break;
826
827                 case RC_SCREEN_FONT_TYPEWRITER:
828                         if (lexrc.next()) {
829                                 typewriter_font_name = lexrc.getString();
830                                 oldFontFormat(typewriter_font_name,
831                                               typewriter_font_foundry);
832                         }
833                         break;
834
835                 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
836                         lexrc >> roman_font_foundry;
837                         break;
838
839                 case RC_SCREEN_FONT_SANS_FOUNDRY:
840                         lexrc >> sans_font_foundry;
841                         break;
842
843                 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
844                         lexrc >> typewriter_font_foundry;
845                         break;
846
847                 case RC_SET_COLOR: {
848                         if (!lexrc.next()) {
849                                 lexrc.printError("Missing color tag.");
850                                 break;
851                         }
852                         string lyx_name = lexrc.getString();
853
854                         if (!lexrc.next()) {
855                                 lexrc.printError("Missing color name for color: `$$Token'");
856                                 break;
857                         }
858                         string x11_name = lexrc.getString();
859
860                         ColorCode const col =
861                                 lcolor.getFromLyXName(lyx_name);
862                         if (col == Color_none ||
863                             col == Color_inherit ||
864                             col == Color_ignore)
865                                 break;
866
867                         if (!lcolor.setColor(col, x11_name))
868                                 LYXERR0("Bad lyxrc set_color for " << lyx_name);
869                         break;
870                 }
871
872                 case RC_AUTOREGIONDELETE:
873                         // Auto region delete defaults to true
874                         lexrc >> auto_region_delete;
875                         break;
876
877                 case RC_SERVERPIPE:
878                         if (lexrc.next()) {
879                                 lyxpipes = os::internal_path(lexrc.getString());
880                                 lyxpipes = expandPath(lyxpipes);
881                         }
882                         break;
883
884                 case RC_CURSOR_FOLLOWS_SCROLLBAR:
885                         lexrc >> cursor_follows_scrollbar;
886                         break;
887
888                 case RC_SCROLL_BELOW_DOCUMENT:
889                         lexrc >> scroll_below_document;
890                         break;
891
892                 case RC_PARAGRAPH_MARKERS:
893                         lexrc >> paragraph_markers;
894                         break;
895
896                 case RC_MAC_DONTSWAP_CTRL_META:
897                         lexrc >> mac_dontswap_ctrl_meta;
898                         break;
899
900                 case RC_MAC_LIKE_WORD_MOVEMENT:
901                         lexrc >> mac_like_word_movement;
902                         break;
903
904                 case RC_MACRO_EDIT_STYLE:
905                         if (lexrc.next()) {
906                                 switch (lexrc.getInteger()) {
907                                 case 0: macro_edit_style = MACRO_EDIT_INLINE_BOX; break;
908                                 case 1: macro_edit_style = MACRO_EDIT_INLINE; break;
909                                 case 2: macro_edit_style = MACRO_EDIT_LIST; break;
910                                 }
911                         }
912                         break;
913
914                 case RC_DIALOGS_ICONIFY_WITH_MAIN:
915                         lexrc >> dialogs_iconify_with_main;
916                         break;
917
918                 case RC_PLAINTEXT_LINELEN:
919                         lexrc >> plaintext_linelen;
920                         break;
921                         // Spellchecker settings:
922                 case RC_ACCEPT_COMPOUND:
923                         lexrc >> spellchecker_accept_compound;
924                         break;
925                 case RC_USE_SYSTEM_COLORS:
926                         lexrc >> use_system_colors;
927                         break;
928                 case RC_USE_TOOLTIP:
929                         lexrc >> use_tooltip;
930                         break;
931                 case RC_USE_PIXMAP_CACHE:
932                         lexrc >> use_pixmap_cache;
933                         break;
934                 case RC_SPELLCHECKER:
935                         lexrc >> spellchecker;
936                         break;
937                 case RC_ALT_LANG:
938                         lexrc >> spellchecker_alt_lang;
939                         break;
940                 case RC_ESC_CHARS:
941                         lexrc >> spellchecker_esc_chars;
942                         break;
943                 case RC_SPELLCHECK_CONTINUOUSLY:
944                         lexrc >> spellcheck_continuously;
945                         break;
946                 case RC_SPELLCHECK_NOTES:
947                         lexrc >> spellcheck_notes;
948                         break;
949                 case RC_MAKE_BACKUP:
950                         lexrc >> make_backup;
951                         break;
952                 case RC_SAVE_COMPRESSED:
953                         lexrc >> save_compressed;
954                         break;
955                 case RC_BACKUPDIR_PATH:
956                         if (lexrc.next()) {
957                                 backupdir_path = os::internal_path(lexrc.getString());
958                                 backupdir_path = expandPath(backupdir_path);
959                         }
960                         break;
961                 case RC_DEFAULT_DECIMAL_POINT:
962                         lexrc >> default_decimal_point;
963                         break;
964                 case RC_DATE_INSERT_FORMAT:
965                         lexrc >> date_insert_format;
966                         break;
967                 case RC_LANGUAGE_PACKAGE:
968                         lexrc >> language_package;
969                         break;
970                 case RC_LANGUAGE_AUTO_BEGIN:
971                         lexrc >> language_auto_begin;
972                         break;
973                 case RC_LANGUAGE_AUTO_END:
974                         lexrc >> language_auto_end;
975                         break;
976                 case RC_LANGUAGE_GLOBAL_OPTIONS:
977                         lexrc >> language_global_options;
978                         break;
979                 case RC_LANGUAGE_USE_BABEL:
980                         lexrc >> language_use_babel;
981                         break;
982                 case RC_LANGUAGE_COMMAND_BEGIN:
983                         lexrc >> language_command_begin;
984                         break;
985                 case RC_LANGUAGE_COMMAND_END:
986                         lexrc >> language_command_end;
987                         break;
988                 case RC_LANGUAGE_COMMAND_LOCAL:
989                         lexrc >> language_command_local;
990                         break;
991                 case RC_RTL_SUPPORT:
992                         lexrc >> rtl_support;
993                         break;
994                 case RC_VISUAL_CURSOR:
995                         lexrc >> visual_cursor;
996                         break;
997                 case RC_AUTO_NUMBER:
998                         lexrc >> auto_number;
999                         break;
1000                 case RC_MARK_FOREIGN_LANGUAGE:
1001                         lexrc >> mark_foreign_language;
1002                         break;
1003
1004                 case RC_COPIER: {
1005                         string fmt, command;
1006                         if (lexrc.next())
1007                                 fmt = lexrc.getString();
1008                         if (lexrc.next(true))
1009                                 command = lexrc.getString();
1010                         setMover(fmt, command);
1011                         break;
1012                 }
1013
1014                 case RC_CONVERTER: {
1015                         string from, to, command, flags;
1016                         if (lexrc.next())
1017                                 from = lexrc.getString();
1018                         if (lexrc.next())
1019                                 to = lexrc.getString();
1020                         if (lexrc.next(true))
1021                                 command = lexrc.getString();
1022                         if (lexrc.next())
1023                                 flags = lexrc.getString();
1024                         if (command.empty())
1025                                 theConverters().erase(from, to);
1026                         else
1027                                 theConverters().add(from, to, command, flags);
1028                         break;
1029                 }
1030                 // compatibility with versions older than 1.4.0 only
1031                 case RC_VIEWER: {
1032                         string format, command;
1033                         lexrc >> format >> command;
1034                         formats.setViewer(format, command);
1035                         break;
1036                 }
1037                 case RC_FORMAT: {
1038                         string format, extension, prettyname, shortcut;
1039                         lexrc >> format >> extension >> prettyname >> shortcut;
1040                         string viewer, editor;
1041                         if (lexrc.next(true))
1042                                 viewer = lexrc.getString();
1043                         if (lexrc.next(true))
1044                                 editor = lexrc.getString();
1045                         string flags;
1046                         // Hack to ensure compatibility with versions older
1047                         // than 1.5.0
1048                         int le = lexrc.lex();
1049                         if (le != Lexer::LEX_FEOF && le != Lexer::LEX_UNDEF) {
1050                                 flags = lexrc.getString();
1051                                 if (le != Lexer::LEX_DATA) {
1052                                         // We have got a known token.
1053                                         // Therefore this is an old style
1054                                         // format definition without
1055                                         // flags.
1056                                         lexrc.pushToken(flags);
1057                                         flags.erase();
1058                                 }
1059                         }
1060                         int flgs = Format::none;
1061                         while (!flags.empty()) {
1062                                 string flag;
1063                                 flags = split(flags, flag, ',');
1064                                 if (flag == "document")
1065                                         flgs |= Format::document;
1066                                 else if (flag == "vector")
1067                                         flgs |= Format::vector;
1068                                 else
1069                                         LYXERR0("Ignoring unknown flag `"
1070                                                << flag << "' for format `"
1071                                                << format << "'.");
1072                         }
1073                         if (prettyname.empty()) {
1074                                 if (theConverters().formatIsUsed(format))
1075                                         LYXERR0("Can't delete format " << format);
1076                                 else
1077                                         formats.erase(format);
1078                         } else {
1079                                 formats.add(format, extension, prettyname,
1080                                             shortcut, viewer, editor, flgs);
1081                         }
1082                         break;
1083                 }
1084                 case RC_VIEWER_ALTERNATIVES:  {
1085                         string format, command;
1086                         if (lexrc.next())
1087                                 format = lexrc.getString();
1088                         if (lexrc.eatLine())
1089                                 command = lexrc.getString();
1090                         viewer_alternatives[format].insert(command);
1091                         break;
1092                 }
1093                 case RC_EDITOR_ALTERNATIVES:  {
1094                         string format, command;
1095                         lexrc >> format >> command;
1096                         editor_alternatives[format].insert(command);
1097                         break;
1098                 }
1099
1100                 case RC_DEFAULT_VIEW_FORMAT:
1101                         lexrc >> default_view_format;
1102                         break;
1103                         
1104                 case RC_DEFAULT_LANGUAGE:
1105                         lexrc >> default_language;
1106                         break;
1107
1108                 case RC_GUI_LANGUAGE:
1109                         lexrc >> gui_language;
1110                         break;
1111
1112                 case RC_SHOW_BANNER:
1113                         lexrc >> show_banner;
1114                         break;
1115
1116                 case RC_PREVIEW:
1117                         if (lexrc.next()) {
1118                                 string const tmp = lexrc.getString();
1119                                 if (tmp == "true" || tmp == "on")
1120                                         preview = PREVIEW_ON;
1121                                 else if (tmp == "no_math")
1122                                         preview = PREVIEW_NO_MATH;
1123                                 else {
1124                                         preview = PREVIEW_OFF;
1125                                         if (tmp != "false" && tmp != "off")
1126                                                 LYXERR0("Unrecognized preview status \""
1127                                                        << tmp << '\n');
1128                                 }
1129                         }
1130                         break;
1131
1132                 case RC_PREVIEW_HASHED_LABELS:
1133                         lexrc >> preview_hashed_labels;
1134                         break;
1135
1136                 case RC_PREVIEW_SCALE_FACTOR:
1137                         lexrc >> preview_scale_factor;
1138                         break;
1139
1140                 case RC_USER_NAME:
1141                         lexrc >> user_name;
1142                         break;
1143                 case RC_USER_EMAIL:
1144                         lexrc >> user_email;
1145                         break;
1146
1147                 case RC_PATH_PREFIX:
1148                         lexrc >> path_prefix;
1149                         break;
1150
1151                 case RC_USE_CONVERTER_CACHE:
1152                         lexrc >> use_converter_cache;
1153                         break;
1154                 case RC_CONVERTER_CACHE_MAXAGE:
1155                         lexrc >> converter_cache_maxage;
1156                         break;
1157
1158                 case RC_SORT_LAYOUTS:
1159                         lexrc >> sort_layouts;
1160                         break;
1161                 case RC_GROUP_LAYOUTS:
1162                         lexrc >> group_layouts;
1163                         break;
1164                 case RC_FULL_SCREEN_LIMIT:
1165                         lexrc >> full_screen_limit;
1166                         break;
1167                 case RC_FULL_SCREEN_TOOLBARS:
1168                         lexrc >> full_screen_toolbars;
1169                         break;
1170                 case RC_FULL_SCREEN_SCROLLBAR:
1171                         lexrc >> full_screen_scrollbar;
1172                         break;
1173                 case RC_FULL_SCREEN_TABBAR:
1174                         lexrc >> full_screen_tabbar;
1175                         break;
1176                 case RC_FULL_SCREEN_MENUBAR:
1177                         lexrc >> full_screen_menubar;
1178                         break;
1179                 case RC_FULL_SCREEN_WIDTH:
1180                         lexrc >> full_screen_width;
1181                         break;
1182                 case RC_OPEN_BUFFERS_IN_TABS:
1183                         lexrc >> open_buffers_in_tabs;
1184                         break;
1185                 case RC_SINGLE_CLOSE_TAB_BUTTON:
1186                         lexrc >> single_close_tab_button;
1187                         break;
1188                 case RC_FORWARD_SEARCH_DVI:
1189                         if (lexrc.next(true)) 
1190                                 forward_search_dvi = lexrc.getString();
1191                         break;
1192                 case RC_FORWARD_SEARCH_PDF:
1193                         if (lexrc.next(true)) 
1194                                 forward_search_pdf = lexrc.getString();
1195                         break;
1196                 case RC_EXPORT_OVERWRITE:
1197                         if (lexrc.next()) {
1198                                 string const tmp = lexrc.getString();
1199                                 if (tmp == "all" || tmp == "true")
1200                                         export_overwrite = ALL_FILES;
1201                                 else if (tmp == "main")
1202                                         export_overwrite = MAIN_FILE;
1203                                 else {
1204                                         export_overwrite = NO_FILES;
1205                                         if (tmp != "ask" && tmp != "false")
1206                                                 LYXERR0("Unrecognized export_overwrite status \""
1207                                                        << tmp << '"');
1208                                 }
1209                         }
1210                         break;
1211                 case RC_SCROLL_WHEEL_ZOOM:
1212                         if (lexrc.next()) {
1213                                 string const tmp = lexrc.getString();
1214                                 if (tmp == "ctrl")
1215                                         scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_CTRL;
1216                                 else if (tmp == "shift")
1217                                         scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_SHIFT;
1218                                 else if (tmp == "alt")
1219                                         scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_ALT;
1220                                 else {
1221                                         scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_OFF;
1222                                         if (tmp != "off" && tmp != "false")
1223                                                 LYXERR0("Unrecognized scroll_wheel_zoom status \""
1224                                                        << tmp << '"');
1225                                 }
1226                         }
1227                         break;
1228
1229                 // Obsoteted in 1.4.0
1230                 case RC_USETEMPDIR:
1231                 // Obsoleted in 2.0
1232                 case RC_SPELL_COMMAND:
1233                 case RC_PERS_DICT:
1234                 case RC_PLAINTEXT_ROFF_COMMAND: 
1235                 case RC_USE_ALT_LANG:
1236                 case RC_USE_ESC_CHARS:
1237                 case RC_USE_INP_ENC:
1238                 case RC_USE_PERS_DICT:
1239                 case RC_USE_SPELL_LIB:
1240                         LYXERR(Debug::LYXRC, "Skipping obsolete tag `" 
1241                                << lexrc.getString() << "'.");
1242                         lexrc.next(true);
1243                         break;
1244
1245                 case RC_LAST:
1246                         break; // this is just a dummy
1247                 }
1248         }
1249
1250         /// Update converters data-structures
1251         theConverters().update(formats);
1252         theConverters().buildGraph();
1253
1254         return 0;
1255 }
1256
1257
1258 void LyXRC::write(FileName const & filename, bool ignore_system_lyxrc) const
1259 {
1260         ofstream ofs(filename.toFilesystemEncoding().c_str());
1261         if (ofs)
1262                 write(ofs, ignore_system_lyxrc);
1263 }
1264
1265
1266 void LyXRC::print() const
1267 {
1268         if (lyxerr.debugging())
1269                 write(lyxerr, false);
1270         else
1271                 write(cout, false);
1272 }
1273
1274
1275 class SameMover {
1276 public:
1277         typedef pair<string, SpecialisedMover> Data;
1278
1279         SameMover(Data const & comparison)
1280                 : comparison_(comparison) {}
1281
1282         bool operator()(Data const & data) const
1283         {
1284                 return data.first == comparison_.first &&
1285                         data.second.command() == comparison_.second.command();
1286         }
1287
1288 private:
1289         Data comparison_;
1290 };
1291
1292
1293 namespace {
1294
1295         // Escape \ and " so that LyXLex can read the string later
1296         string escapeCommand(string const & str) {
1297                 return subst(subst(str , "\\", "\\\\"), 
1298                              "\"", "\\\"");
1299         }
1300
1301 }
1302
1303
1304 void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) const
1305 {
1306         LyXRCTags tag = RC_LAST;
1307         
1308         if (!name.empty()) {
1309                 for (int i = 0; i != lyxrcCount; ++i)
1310                         if ("\\" + name == lyxrcTags[i].tag)
1311                                 tag = static_cast<LyXRCTags>(lyxrcTags[i].code);
1312         }
1313
1314         if (tag == RC_LAST)
1315                 os << "# LyX " << lyx_version
1316                    << " generated this file. If you want to make your own\n"
1317                    << "# modifications you should do them from inside LyX and save.\n"
1318                    << "\n";
1319
1320         // Why the switch you might ask. It is a trick to ensure that all
1321         // the elements in the LyXRCTags enum are handled. As you can see
1322         // there are no breaks at all. So it is just a huge fall-through.
1323         // The nice thing is that we will get a warning from the compiler
1324         // if we forget an element.
1325         switch (tag) {
1326         case RC_LAST:
1327         case RC_INPUT:
1328                 // input/include files are not done here
1329         case RC_BINDFILE:
1330                 if (ignore_system_lyxrc ||
1331                     bind_file != system_lyxrc.bind_file) {
1332                         string const path = os::external_path(bind_file);
1333                         os << "\\bind_file \"" << path << "\"\n";
1334                 }
1335                 if (tag != RC_LAST)
1336                         break;
1337
1338         case RC_DEFFILE:
1339                 if (ignore_system_lyxrc ||
1340                     def_file != system_lyxrc.def_file) {
1341                         string const path = os::external_path(def_file);
1342                         os << "\\def_file \"" << path << "\"\n";
1343                 }
1344                 if (tag != RC_LAST)
1345                         break;
1346
1347                 //
1348                 // Misc Section
1349                 //
1350                 os << "\n#\n"
1351                    << "# MISC SECTION ######################################\n"
1352                    << "#\n\n";
1353                 // bind files are not done here.
1354
1355         case RC_PATH_PREFIX:
1356                 if (ignore_system_lyxrc ||
1357                     path_prefix != system_lyxrc.path_prefix) {
1358                         os << "\\path_prefix \"" << path_prefix << "\"\n";
1359                 }
1360                 if (tag != RC_LAST)
1361                         break;
1362         case RC_UIFILE:
1363                 if (ignore_system_lyxrc ||
1364                     ui_file != system_lyxrc.ui_file) {
1365                         string const path = os::external_path(ui_file);
1366                         os << "\\ui_file \"" << path << "\"\n";
1367                 }
1368                 if (tag != RC_LAST)
1369                         break;
1370         case RC_AUTOREGIONDELETE:
1371                 if (ignore_system_lyxrc ||
1372                     auto_region_delete != system_lyxrc.auto_region_delete) {
1373                         os << "# Set to false to inhibit automatic replacement of\n"
1374                            << "# the current selection.\n"
1375                            << "\\auto_region_delete " << convert<string>(auto_region_delete)
1376                            << '\n';
1377                 }
1378                 if (tag != RC_LAST)
1379                         break;
1380         case RC_AUTORESET_OPTIONS:
1381                 if (ignore_system_lyxrc ||
1382                     auto_reset_options != system_lyxrc.auto_reset_options) {
1383                         os << "# Set to false to inhibit automatic reset of\n"
1384                            << "# the class options to defaults on class change.\n"
1385                            << "\\auto_reset_options "
1386                            << convert<string>(auto_reset_options)
1387                            << '\n';
1388                 }
1389                 if (tag != RC_LAST)
1390                         break;
1391         case RC_AUTOSAVE:
1392                 if (ignore_system_lyxrc ||
1393                     autosave != system_lyxrc.autosave) {
1394                         os << "# The time interval between auto-saves in seconds.\n"
1395                            << "\\autosave " << autosave << '\n';
1396                 }
1397                 if (tag != RC_LAST)
1398                         break;
1399         case RC_DISPLAY_GRAPHICS:
1400                 if (ignore_system_lyxrc ||
1401                     display_graphics != system_lyxrc.display_graphics) {
1402                         os << "# Display graphics within LyX\n"
1403                            << "# true|false\n"
1404                            << "\\display_graphics "
1405                            << (display_graphics ? "true" : "false")
1406                            << '\n';
1407                 }
1408                 if (tag != RC_LAST)
1409                         break;
1410         case RC_SORT_LAYOUTS:
1411                 if (ignore_system_lyxrc ||
1412                     sort_layouts != system_lyxrc.sort_layouts) {
1413                         os << "# Sort layouts alphabetically.\n"
1414                            << "\\sort_layouts " << convert<string>(sort_layouts) << '\n';
1415                 }
1416                 if (tag != RC_LAST)
1417                         break;
1418         case RC_GROUP_LAYOUTS:
1419                 if (ignore_system_lyxrc ||
1420                     group_layouts != system_lyxrc.group_layouts) {
1421                         os << "# Group layouts by their category.\n"
1422                            << "\\group_layouts " << convert<string>(group_layouts) << '\n';
1423                 }
1424                 if (tag != RC_LAST)
1425                         break;
1426         case RC_VIEWDVI_PAPEROPTION:
1427                 if (ignore_system_lyxrc ||
1428                     view_dvi_paper_option
1429                     != system_lyxrc.view_dvi_paper_option) {
1430                         os << "# Options used to specify paper size to the\n"
1431                            << "# view_dvi_command (e.g. -paper)\n"
1432                            << "\\view_dvi_paper_option \""
1433                            << view_dvi_paper_option << "\"\n";
1434                 }
1435                 if (tag != RC_LAST)
1436                         break;
1437         case RC_DEFAULT_PAPERSIZE:
1438                 if (ignore_system_lyxrc ||
1439                     default_papersize != system_lyxrc.default_papersize) {
1440                         os << "# The default papersize to use.\n"
1441                            << "\\default_papersize \"";
1442                         switch (default_papersize) {
1443                         case PAPER_DEFAULT:
1444                                 os << "default"; break;
1445                         case PAPER_USLETTER:
1446                                 os << "usletter"; break;
1447                         case PAPER_USLEGAL:
1448                                 os << "legal"; break;
1449                         case PAPER_USEXECUTIVE:
1450                                 os << "executive"; break;
1451                         case PAPER_A3:
1452                                 os << "a3"; break;
1453                         case PAPER_A4:
1454                                 os << "a4"; break;
1455                         case PAPER_A5:
1456                                 os << "a5"; break;
1457                         case PAPER_B5:
1458                                 os << "b5"; break;
1459                         case PAPER_CUSTOM:
1460                         case PAPER_A0:
1461                         case PAPER_A1:
1462                         case PAPER_A2:
1463                         case PAPER_A6:
1464                         case PAPER_B0:
1465                         case PAPER_B1:
1466                         case PAPER_B2:
1467                         case PAPER_B3:
1468                         case PAPER_B4:
1469                         case PAPER_B6:
1470                         case PAPER_C0:
1471                         case PAPER_C1:
1472                         case PAPER_C2:
1473                         case PAPER_C3:
1474                         case PAPER_C4:
1475                         case PAPER_C5:
1476                         case PAPER_C6:
1477                         case PAPER_JISB0:
1478                         case PAPER_JISB1:
1479                         case PAPER_JISB2:
1480                         case PAPER_JISB3:
1481                         case PAPER_JISB4:
1482                         case PAPER_JISB5:
1483                         case PAPER_JISB6: break;
1484                         }
1485                         os << "\"\n";
1486                 }
1487                 if (tag != RC_LAST)
1488                         break;
1489         case RC_CHKTEX_COMMAND:
1490                 if (ignore_system_lyxrc ||
1491                     chktex_command != system_lyxrc.chktex_command) {
1492                         os << "\\chktex_command \"" << escapeCommand(chktex_command) << "\"\n";
1493                 }
1494                 if (tag != RC_LAST)
1495                         break;
1496         case RC_BIBTEX_ALTERNATIVES: {
1497                 CommandSet::const_iterator it = bibtex_alternatives.begin();
1498                 CommandSet::const_iterator end = bibtex_alternatives.end();
1499                 for ( ; it != end; ++it) {
1500                         if (ignore_system_lyxrc
1501                             || !system_lyxrc.bibtex_alternatives.count(*it))
1502                                 os << "\\bibtex_alternatives \""
1503                                    << *it << "\"\n";
1504                 }
1505                 if (tag != RC_LAST)
1506                         break;
1507         }
1508         case RC_BIBTEX_COMMAND:
1509                 if (ignore_system_lyxrc ||
1510                     bibtex_command != system_lyxrc.bibtex_command) {
1511                         os << "\\bibtex_command \"" << escapeCommand(bibtex_command) << "\"\n";
1512                 }
1513                 if (tag != RC_LAST)
1514                         break;
1515         case RC_JBIBTEX_COMMAND:
1516                 if (ignore_system_lyxrc ||
1517                     jbibtex_command != system_lyxrc.jbibtex_command) {
1518                         os << "\\jbibtex_command \"" << escapeCommand(jbibtex_command) << "\"\n";
1519                 }
1520                 if (tag != RC_LAST)
1521                         break;
1522         case RC_INDEX_ALTERNATIVES: {
1523                 CommandSet::const_iterator it = index_alternatives.begin();
1524                 CommandSet::const_iterator end = index_alternatives.end();
1525                 for ( ; it != end; ++it) {
1526                         if (ignore_system_lyxrc
1527                             || !system_lyxrc.index_alternatives.count(*it))
1528                                 os << "\\index_alternatives \""
1529                                    << *it << "\"\n";
1530                 }
1531                 if (tag != RC_LAST)
1532                         break;
1533         }
1534         case RC_INDEX_COMMAND:
1535                 if (ignore_system_lyxrc ||
1536                     index_command != system_lyxrc.index_command) {
1537                         os << "\\index_command \"" << escapeCommand(index_command) << "\"\n";
1538                 }
1539                 if (tag != RC_LAST)
1540                         break;
1541         case RC_JINDEX_COMMAND:
1542                 if (ignore_system_lyxrc ||
1543                     jindex_command != system_lyxrc.jindex_command) {
1544                         os << "\\jindex_command \"" << escapeCommand(jindex_command) << "\"\n";
1545                 }
1546                 if (tag != RC_LAST)
1547                         break;
1548         case RC_SPLITINDEX_COMMAND:
1549                 if (ignore_system_lyxrc ||
1550                     splitindex_command != system_lyxrc.splitindex_command) {
1551                         os << "\\splitindex_command \"" << escapeCommand(splitindex_command) << "\"\n";
1552                 }
1553                 if (tag != RC_LAST)
1554                         break;
1555         case RC_NOMENCL_COMMAND:
1556                 if (ignore_system_lyxrc ||
1557                     nomencl_command != system_lyxrc.nomencl_command) {
1558                         os << "\\nomencl_command \"" << escapeCommand(nomencl_command) << "\"\n";
1559                 }
1560                 if (tag != RC_LAST)
1561                         break;
1562         case RC_TEX_EXPECTS_WINDOWS_PATHS:
1563                 if (ignore_system_lyxrc ||
1564                     windows_style_tex_paths != system_lyxrc.windows_style_tex_paths) {
1565                         os << "\\tex_expects_windows_paths "
1566                            << convert<string>(windows_style_tex_paths) << '\n';
1567                 }
1568                 if (tag != RC_LAST)
1569                         break;
1570         case RC_TEX_ALLOWS_SPACES:
1571                 if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
1572                         os << "\\tex_allows_spaces "
1573                            << convert<string>(tex_allows_spaces) << '\n';
1574                 }
1575                 if (tag != RC_LAST)
1576                         break;
1577         case RC_KBMAP:
1578                 if (ignore_system_lyxrc ||
1579                     use_kbmap != system_lyxrc.use_kbmap) {
1580                         os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1581                 }
1582                 if (tag != RC_LAST)
1583                         break;
1584         case RC_KBMAP_PRIMARY:
1585                 if (ignore_system_lyxrc ||
1586                     primary_kbmap != system_lyxrc.primary_kbmap) {
1587                         string const path = os::external_path(primary_kbmap);
1588                         os << "\\kbmap_primary \"" << path << "\"\n";
1589                 }
1590                 if (tag != RC_LAST)
1591                         break;
1592         case RC_KBMAP_SECONDARY:
1593                 if (ignore_system_lyxrc ||
1594                     secondary_kbmap != system_lyxrc.secondary_kbmap) {
1595                         string const path = os::external_path(secondary_kbmap);
1596                         os << "\\kbmap_secondary \"" << path << "\"\n";
1597                 }
1598                 if (tag != RC_LAST)
1599                         break;
1600         case RC_SERVERPIPE:
1601                 if (ignore_system_lyxrc ||
1602                     lyxpipes != system_lyxrc.lyxpipes) {
1603                         string const path = os::external_path(lyxpipes);
1604                         os << "\\serverpipe \"" << path << "\"\n";
1605                 }
1606                 if (tag != RC_LAST)
1607                         break;
1608         case RC_DATE_INSERT_FORMAT:
1609                 if (ignore_system_lyxrc ||
1610                     date_insert_format != system_lyxrc.date_insert_format) {
1611                         os << "\\date_insert_format \"" << date_insert_format
1612                            << "\"\n";
1613                 }
1614                 if (tag != RC_LAST)
1615                         break;
1616
1617         case RC_USER_NAME:
1618                 os << "\\user_name \"" << user_name << "\"\n";
1619                 if (tag != RC_LAST)
1620                         break;
1621
1622         case RC_USER_EMAIL:
1623                 os << "\\user_email \"" << user_email << "\"\n";
1624                 if (tag != RC_LAST)
1625                         break;
1626
1627         case RC_SHOW_BANNER:
1628                 if (ignore_system_lyxrc ||
1629                     show_banner != system_lyxrc.show_banner) {
1630                         os << "\\show_banner " << convert<string>(show_banner) << '\n';
1631                 }
1632                 if (tag != RC_LAST)
1633                         break;
1634
1635         case RC_PREVIEW:
1636                 if (ignore_system_lyxrc ||
1637                     preview != system_lyxrc.preview) {
1638                         string status;
1639                         switch (preview) {
1640                         case PREVIEW_ON:
1641                                 status = "on";
1642                                 break;
1643                         case PREVIEW_NO_MATH:
1644                                 status = "no_math";
1645                                 break;
1646                         case PREVIEW_OFF:
1647                                 status = "off";
1648                                 break;
1649                         }
1650                         os << "\\preview " << status << '\n';
1651                 }
1652                 if (tag != RC_LAST)
1653                         break;
1654
1655         case RC_PREVIEW_HASHED_LABELS:
1656                 if (ignore_system_lyxrc ||
1657                     preview_hashed_labels !=
1658                     system_lyxrc.preview_hashed_labels) {
1659                         os << "\\preview_hashed_labels "
1660                            << convert<string>(preview_hashed_labels) << '\n';
1661                 }
1662                 if (tag != RC_LAST)
1663                         break;
1664
1665         case RC_PREVIEW_SCALE_FACTOR:
1666                 if (ignore_system_lyxrc ||
1667                     preview_scale_factor != system_lyxrc.preview_scale_factor) {
1668                         os << "\\preview_scale_factor "
1669                            << preview_scale_factor << '\n';
1670                 }
1671                 if (tag != RC_LAST)
1672                         break;
1673
1674         case RC_USE_CONVERTER_CACHE:
1675                 if (ignore_system_lyxrc ||
1676                     use_converter_cache != system_lyxrc.use_converter_cache) {
1677                         os << "\\use_converter_cache "
1678                            << convert<string>(use_converter_cache) << '\n';
1679                 }
1680                 if (tag != RC_LAST)
1681                         break;
1682
1683         case RC_CONVERTER_CACHE_MAXAGE:
1684                 if (ignore_system_lyxrc ||
1685                     converter_cache_maxage != system_lyxrc.converter_cache_maxage) {
1686                         os << "\\converter_cache_maxage "
1687                            << converter_cache_maxage << '\n';
1688                 }
1689                 if (tag != RC_LAST)
1690                         break;
1691
1692                 os << "\n#\n"
1693                    << "# SCREEN & FONTS SECTION ############################\n"
1694                    << "#\n\n";
1695
1696         case RC_SCREEN_DPI:
1697                 if (ignore_system_lyxrc ||
1698                     dpi != system_lyxrc.dpi) {
1699                         os << "\\screen_dpi " << dpi << '\n';
1700                 }
1701                 if (tag != RC_LAST)
1702                         break;
1703         case RC_SCREEN_ZOOM:
1704                 if (ignore_system_lyxrc ||
1705                     zoom != system_lyxrc.zoom) {
1706                         os << "\\screen_zoom " << zoom << '\n';
1707                 }
1708                 if (tag != RC_LAST)
1709                         break;
1710         case RC_GEOMETRY_SESSION:
1711                 if (ignore_system_lyxrc ||
1712                     allow_geometry_session != system_lyxrc.allow_geometry_session) {
1713                         os << "\\allow_geometry_session " << convert<string>(allow_geometry_session)
1714                            << '\n';
1715                 }
1716                 if (tag != RC_LAST)
1717                         break;
1718         case RC_CURSOR_FOLLOWS_SCROLLBAR:
1719                 if (ignore_system_lyxrc ||
1720                     cursor_follows_scrollbar
1721                     != system_lyxrc.cursor_follows_scrollbar) {
1722                         os << "\\cursor_follows_scrollbar "
1723                            << convert<string>(cursor_follows_scrollbar) << '\n';
1724                 }
1725                 if (tag != RC_LAST)
1726                         break;
1727         case RC_SCROLL_BELOW_DOCUMENT:
1728                 if (ignore_system_lyxrc ||
1729                     scroll_below_document
1730                     != system_lyxrc.scroll_below_document) {
1731                         os << "\\scroll_below_document "
1732                            << convert<string>(scroll_below_document) << '\n';
1733                 }
1734                 if (tag != RC_LAST)
1735                         break;
1736         case RC_PARAGRAPH_MARKERS:
1737                 if (ignore_system_lyxrc ||
1738                         paragraph_markers
1739                     != system_lyxrc.paragraph_markers) {
1740                         os << "\\paragraph_markers "
1741                            << convert<string>(paragraph_markers) << '\n';
1742                 }
1743                 if (tag != RC_LAST)
1744                         break;
1745         case RC_MAC_DONTSWAP_CTRL_META:
1746                 if (ignore_system_lyxrc ||
1747                     mac_dontswap_ctrl_meta
1748                     != system_lyxrc.mac_dontswap_ctrl_meta) {
1749                         os << "\\mac_dontswap_ctrl_meta "
1750                            << convert<string>(mac_dontswap_ctrl_meta) << '\n';
1751                 }
1752                 if (tag != RC_LAST)
1753                         break;
1754         case RC_MAC_LIKE_WORD_MOVEMENT:
1755                 if (ignore_system_lyxrc ||
1756                     mac_like_word_movement
1757                     != system_lyxrc.mac_like_word_movement) {
1758                         os << "\\mac_like_word_movement "
1759                            << convert<string>(mac_like_word_movement) << '\n';
1760                 }
1761                 if (tag != RC_LAST)
1762                         break;
1763         case RC_MACRO_EDIT_STYLE:
1764                 if (ignore_system_lyxrc ||
1765                     macro_edit_style
1766                     != system_lyxrc.macro_edit_style) {
1767                         os << "\\macro_edit_style ";
1768                         switch (macro_edit_style) {
1769                         case MACRO_EDIT_INLINE_BOX: os << "0\n"; break;
1770                         case MACRO_EDIT_INLINE: os << "1\n"; break;
1771                         case MACRO_EDIT_LIST: os << "2\n"; break;
1772                         }
1773                 }
1774                 if (tag != RC_LAST)
1775                         break;
1776         case RC_DIALOGS_ICONIFY_WITH_MAIN:
1777                 if (ignore_system_lyxrc ||
1778                     dialogs_iconify_with_main
1779                    != system_lyxrc.dialogs_iconify_with_main) {
1780                         os << "\\dialogs_iconify_with_main "
1781                           <<  convert<string>(dialogs_iconify_with_main) << '\n';
1782                 }
1783                 if (tag != RC_LAST)
1784                         break;
1785         case RC_SCREEN_FONT_ROMAN:
1786                 if (ignore_system_lyxrc ||
1787                     roman_font_name != system_lyxrc.roman_font_name) {
1788                         os << "\\screen_font_roman \"" << roman_font_name
1789                            << "\"\n";
1790                 }
1791                 if (tag != RC_LAST)
1792                         break;
1793         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1794                 if (ignore_system_lyxrc ||
1795                     roman_font_foundry != system_lyxrc.roman_font_foundry) {
1796                         os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1797                            << "\"\n";
1798                 }
1799                 if (tag != RC_LAST)
1800                         break;
1801         case RC_SCREEN_FONT_SANS:
1802                 if (ignore_system_lyxrc ||
1803                     sans_font_name != system_lyxrc.sans_font_name) {
1804                         os << "\\screen_font_sans \"" << sans_font_name
1805                            << "\"\n";
1806                 }
1807                 if (tag != RC_LAST)
1808                         break;
1809         case RC_SCREEN_FONT_SANS_FOUNDRY:
1810                 if (ignore_system_lyxrc ||
1811                     sans_font_foundry != system_lyxrc.sans_font_foundry) {
1812                         os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1813                            << "\"\n";
1814                 }
1815                 if (tag != RC_LAST)
1816                         break;
1817         case RC_SCREEN_FONT_TYPEWRITER:
1818                 if (ignore_system_lyxrc ||
1819                     typewriter_font_name != system_lyxrc.typewriter_font_name) {
1820                         os << "\\screen_font_typewriter \""
1821                            << typewriter_font_name << "\"\n";
1822                 }
1823                 if (tag != RC_LAST)
1824                         break;
1825         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1826                 if (ignore_system_lyxrc ||
1827                     typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1828                         os << "\\screen_font_typewriter_foundry \""
1829                            << typewriter_font_foundry << "\"\n";
1830                 }
1831                 if (tag != RC_LAST)
1832                         break;
1833
1834         case RC_SCREEN_FONT_SCALABLE:
1835                 if (ignore_system_lyxrc ||
1836                     use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1837                         os << "\\screen_font_scalable "
1838                            << convert<string>(use_scalable_fonts)
1839                            << '\n';
1840                 }
1841                 if (tag != RC_LAST)
1842                         break;
1843         case RC_SCREEN_FONT_SIZES:
1844                 if (ignore_system_lyxrc ||
1845                     font_sizes[FONT_SIZE_TINY]
1846                     != system_lyxrc.font_sizes[FONT_SIZE_TINY] ||
1847                     font_sizes[FONT_SIZE_SCRIPT]
1848                     != system_lyxrc.font_sizes[FONT_SIZE_SCRIPT] ||
1849                     font_sizes[FONT_SIZE_FOOTNOTE]
1850                     != system_lyxrc.font_sizes[FONT_SIZE_FOOTNOTE] ||
1851                     font_sizes[FONT_SIZE_SMALL]
1852                     != system_lyxrc.font_sizes[FONT_SIZE_SMALL] ||
1853                     font_sizes[FONT_SIZE_NORMAL]
1854                     != system_lyxrc.font_sizes[FONT_SIZE_NORMAL] ||
1855                     font_sizes[FONT_SIZE_LARGE]
1856                     != system_lyxrc.font_sizes[FONT_SIZE_LARGE] ||
1857                     font_sizes[FONT_SIZE_LARGER]
1858                     != system_lyxrc.font_sizes[FONT_SIZE_LARGER] ||
1859                     font_sizes[FONT_SIZE_LARGEST]
1860                     != system_lyxrc.font_sizes[FONT_SIZE_LARGEST] ||
1861                     font_sizes[FONT_SIZE_HUGE]
1862                     != system_lyxrc.font_sizes[FONT_SIZE_HUGE] ||
1863                     font_sizes[FONT_SIZE_HUGER]
1864                     != system_lyxrc.font_sizes[FONT_SIZE_HUGER]) {
1865                         os.setf(ios::fixed);
1866                         os.precision(2);
1867                         os << "\\screen_font_sizes"
1868                            << ' ' << font_sizes[FONT_SIZE_TINY]
1869                            << ' ' << font_sizes[FONT_SIZE_SCRIPT]
1870                            << ' ' << font_sizes[FONT_SIZE_FOOTNOTE]
1871                            << ' ' << font_sizes[FONT_SIZE_SMALL]
1872                            << ' ' << font_sizes[FONT_SIZE_NORMAL]
1873                            << ' ' << font_sizes[FONT_SIZE_LARGE]
1874                            << ' ' << font_sizes[FONT_SIZE_LARGER]
1875                            << ' ' << font_sizes[FONT_SIZE_LARGEST]
1876                            << ' ' << font_sizes[FONT_SIZE_HUGE]
1877                            << ' ' << font_sizes[FONT_SIZE_HUGER]
1878                            << '\n';
1879                 }
1880                 if (tag != RC_LAST)
1881                         break;
1882         case RC_FULL_SCREEN_LIMIT:
1883                 if (ignore_system_lyxrc ||
1884                     full_screen_limit != system_lyxrc.full_screen_limit) {
1885                         os << "\\fullscreen_limit "
1886                            << convert<string>(full_screen_limit)
1887                            << '\n';
1888                 }
1889                 if (tag != RC_LAST)
1890                         break;
1891         case RC_FULL_SCREEN_TOOLBARS:
1892                 if (ignore_system_lyxrc ||
1893                     full_screen_toolbars != system_lyxrc.full_screen_toolbars) {
1894                         os << "\\fullscreen_toolbars "
1895                            << convert<string>(full_screen_toolbars)
1896                            << '\n';
1897                 }
1898                 if (tag != RC_LAST)
1899                         break;
1900         case RC_FULL_SCREEN_SCROLLBAR:
1901                 if (ignore_system_lyxrc ||
1902                     full_screen_scrollbar != system_lyxrc.full_screen_scrollbar) {
1903                         os << "\\fullscreen_scrollbar "
1904                            << convert<string>(full_screen_scrollbar)
1905                            << '\n';
1906                 }
1907                 if (tag != RC_LAST)
1908                         break;
1909         case RC_FULL_SCREEN_TABBAR:
1910                 if (ignore_system_lyxrc ||
1911                     full_screen_tabbar != system_lyxrc.full_screen_tabbar) {
1912                         os << "\\fullscreen_tabbar "
1913                            << convert<string>(full_screen_tabbar)
1914                            << '\n';
1915                 }
1916                 if (tag != RC_LAST)
1917                         break;
1918         case RC_FULL_SCREEN_MENUBAR:
1919                 if (ignore_system_lyxrc ||
1920                     full_screen_menubar != system_lyxrc.full_screen_menubar) {
1921                         os << "\\fullscreen_menubar "
1922                            << convert<string>(full_screen_menubar)
1923                            << '\n';
1924                 }
1925                 if (tag != RC_LAST)
1926                         break;
1927         case RC_FULL_SCREEN_WIDTH:
1928                 if (ignore_system_lyxrc ||
1929                     full_screen_width != system_lyxrc.full_screen_width) {
1930                         os << "\\fullscreen_width "
1931                            << convert<string>(full_screen_width)
1932                            << '\n';
1933                 }
1934                 if (tag != RC_LAST)
1935                         break;
1936         case RC_OPEN_BUFFERS_IN_TABS:
1937                 if (ignore_system_lyxrc ||
1938                     open_buffers_in_tabs != system_lyxrc.open_buffers_in_tabs) {
1939                         os << "\\open_buffers_in_tabs "
1940                            << convert<string>(open_buffers_in_tabs)
1941                            << '\n';
1942                 }
1943                 if (tag != RC_LAST)
1944                         break;
1945         case RC_SINGLE_CLOSE_TAB_BUTTON:
1946                 if (ignore_system_lyxrc ||
1947                     single_close_tab_button != system_lyxrc.single_close_tab_button) {
1948                         os << "\\single_close_tab_button "
1949                            << convert<string>(single_close_tab_button)
1950                            << '\n';
1951                 }
1952                 if (tag != RC_LAST)
1953                         break;
1954         case RC_FORWARD_SEARCH_DVI:
1955                 if (ignore_system_lyxrc ||
1956                     forward_search_dvi != system_lyxrc.forward_search_dvi) {
1957                         os << "\\forward_search_dvi \"" << escapeCommand(forward_search_dvi) << "\"\n";
1958                 }
1959                 if (tag != RC_LAST)
1960                         break;
1961         case RC_FORWARD_SEARCH_PDF:
1962                 if (ignore_system_lyxrc ||
1963                     forward_search_pdf != system_lyxrc.forward_search_pdf) {
1964                         os << "\\forward_search_pdf \"" << escapeCommand(forward_search_pdf) << "\"\n";
1965                 }
1966                 if (tag != RC_LAST)
1967                         break;
1968
1969         os << "\n#\n"
1970                         << "# COLOR SECTION ###################################\n"
1971                         << "#\n\n";
1972
1973         case RC_SET_COLOR:
1974                 for (int i = 0; i < Color_ignore; ++i) {
1975                         ColorCode lc = static_cast<ColorCode>(i);
1976                         string const col = lcolor.getX11Name(lc);
1977                         if (ignore_system_lyxrc
1978                             || col != system_lcolor.getX11Name(lc)) {
1979                                 os << "\\set_color \""
1980                                    << lcolor.getLyXName(lc) << "\" \""
1981                                    << col << "\"\n";
1982                         }
1983                 }
1984                 if (tag != RC_LAST)
1985                         break;
1986
1987                 os << "\n#\n"
1988                    << "# PRINTER SECTION ###################################\n"
1989                    << "#\n\n";
1990
1991         case RC_PRINTER:
1992                 if (ignore_system_lyxrc ||
1993                     printer != system_lyxrc.printer) {
1994                         os << "\\printer \"" << printer << "\"\n";
1995                 }
1996                 if (tag != RC_LAST)
1997                         break;
1998         case RC_PRINT_ADAPTOUTPUT:
1999                 if (ignore_system_lyxrc ||
2000                     print_adapt_output != system_lyxrc.print_adapt_output) {
2001                         os << "\\print_adapt_output "
2002                            << convert<string>(print_adapt_output)
2003                            << '\n';
2004                 }
2005                 if (tag != RC_LAST)
2006                         break;
2007         case RC_PRINT_COMMAND:
2008                 if (ignore_system_lyxrc ||
2009                     print_command != system_lyxrc.print_command) {
2010                         os << "\\print_command \"" << escapeCommand(print_command) << "\"\n";
2011                 }
2012                 if (tag != RC_LAST)
2013                         break;
2014         case RC_PRINTEXSTRAOPTIONS:
2015                 if (ignore_system_lyxrc ||
2016                     print_extra_options != system_lyxrc.print_extra_options) {
2017                         os << "\\print_extra_options \"" << print_extra_options
2018                            << "\"\n";
2019                 }
2020                 if (tag != RC_LAST)
2021                         break;
2022         case RC_PRINTSPOOL_COMMAND:
2023                 if (ignore_system_lyxrc ||
2024                     print_spool_command != system_lyxrc.print_spool_command) {
2025                         os << "\\print_spool_command \"" << escapeCommand(print_spool_command)
2026                            << "\"\n";
2027                 }
2028                 if (tag != RC_LAST)
2029                         break;
2030         case RC_PRINTSPOOL_PRINTERPREFIX:
2031                 if (ignore_system_lyxrc ||
2032                     print_spool_printerprefix
2033                     != system_lyxrc.print_spool_printerprefix) {
2034                         os << "\\print_spool_printerprefix \""
2035                            << print_spool_printerprefix << "\"\n";
2036                 }
2037                 if (tag != RC_LAST)
2038                         break;
2039         case RC_PRINTEVENPAGEFLAG:
2040                 if (ignore_system_lyxrc ||
2041                     print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
2042                         os << "\\print_evenpage_flag \"" << print_evenpage_flag
2043                            << "\"\n";
2044                 }
2045                 if (tag != RC_LAST)
2046                         break;
2047         case RC_PRINTODDPAGEFLAG:
2048                 if (ignore_system_lyxrc ||
2049                     print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
2050                         os << "\\print_oddpage_flag \"" << print_oddpage_flag
2051                            << "\"\n";
2052                 }
2053                 if (tag != RC_LAST)
2054                         break;
2055         case RC_PRINTREVERSEFLAG:
2056                 if (ignore_system_lyxrc ||
2057                     print_reverse_flag != system_lyxrc.print_reverse_flag) {
2058                         os << "\\print_reverse_flag \"" << print_reverse_flag
2059                            << "\"\n";
2060                 }
2061                 if (tag != RC_LAST)
2062                         break;
2063         case RC_PRINTLANDSCAPEFLAG:
2064                 if (ignore_system_lyxrc ||
2065                     print_landscape_flag != system_lyxrc.print_landscape_flag) {
2066                         os << "\\print_landscape_flag \"" << print_landscape_flag
2067                            << "\"\n";
2068                 }
2069                 if (tag != RC_LAST)
2070                         break;
2071         case RC_PRINTPAGERANGEFLAG:
2072                 if (ignore_system_lyxrc ||
2073                     print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
2074                         os << "\\print_pagerange_flag \"" << print_pagerange_flag
2075                            << "\"\n";
2076                 }
2077                 if (tag != RC_LAST)
2078                         break;
2079         case RC_PRINTCOPIESFLAG:
2080                 if (ignore_system_lyxrc ||
2081                     print_copies_flag != system_lyxrc.print_copies_flag) {
2082                         os << "\\print_copies_flag \"" << print_copies_flag
2083                            << "\"\n";
2084                 }
2085                 if (tag != RC_LAST)
2086                         break;
2087         case RC_PRINTCOLLCOPIESFLAG:
2088                 if (ignore_system_lyxrc ||
2089                     print_collcopies_flag
2090                     != system_lyxrc.print_collcopies_flag) {
2091                         os << "\\print_collcopies_flag \""
2092                            << print_collcopies_flag
2093                            << "\"\n";
2094                 }
2095                 if (tag != RC_LAST)
2096                         break;
2097         case RC_PRINTPAPERFLAG:
2098                 if (ignore_system_lyxrc ||
2099                     print_paper_flag != system_lyxrc.print_paper_flag) {
2100                         os << "\\print_paper_flag \"" << print_paper_flag
2101                            << "\"\n";
2102                 }
2103                 if (tag != RC_LAST)
2104                         break;
2105         case RC_PRINTPAPERDIMENSIONFLAG:
2106                 if (ignore_system_lyxrc ||
2107                     print_paper_dimension_flag
2108                     != system_lyxrc.print_paper_dimension_flag) {
2109                         os << "\\print_paper_dimension_flag \""
2110                            << print_paper_dimension_flag << "\"\n";
2111                 }
2112                 if (tag != RC_LAST)
2113                         break;
2114         case RC_PRINTTOPRINTER:
2115                 if (ignore_system_lyxrc ||
2116                     print_to_printer != system_lyxrc.print_to_printer) {
2117                         os << "\\print_to_printer \"" << print_to_printer
2118                            << "\"\n";
2119                 }
2120                 if (tag != RC_LAST)
2121                         break;
2122         case RC_PRINTTOFILE:
2123                 if (ignore_system_lyxrc ||
2124                     print_to_file != system_lyxrc.print_to_file) {
2125                         string const path = os::external_path(print_to_file);
2126                         os << "\\print_to_file \"" << path << "\"\n";
2127                 }
2128                 if (tag != RC_LAST)
2129                         break;
2130         case RC_PRINTFILEEXTENSION:
2131                 if (ignore_system_lyxrc ||
2132                     print_file_extension != system_lyxrc.print_file_extension) {
2133                         os << "\\print_file_extension \""
2134                            << print_file_extension
2135                            << "\"\n";
2136                 }
2137                 if (tag != RC_LAST)
2138                         break;
2139
2140                 os << "\n#\n"
2141                    << "# TEX SECTION #######################################\n"
2142                    << "#\n\n";
2143
2144         case RC_FONT_ENCODING:
2145                 if (ignore_system_lyxrc ||
2146                     fontenc != system_lyxrc.fontenc) {
2147                         os << "\\font_encoding \"" << fontenc << "\"\n";
2148                 }
2149                 if (tag != RC_LAST)
2150                         break;
2151
2152                 os << "\n#\n"
2153                    << "# FILE SECTION ######################################\n"
2154                    << "#\n\n";
2155
2156         case RC_DOCUMENTPATH:
2157                 if (ignore_system_lyxrc ||
2158                     document_path != system_lyxrc.document_path) {
2159                         string const path = os::external_path(document_path);
2160                         os << "\\document_path \"" << path << "\"\n";
2161                 }
2162                 if (tag != RC_LAST)
2163                         break;
2164         case RC_USELASTFILEPOS:
2165                 if (ignore_system_lyxrc ||
2166                     use_lastfilepos != system_lyxrc.use_lastfilepos) {
2167                         os << "\\use_lastfilepos " << convert<string>(use_lastfilepos)
2168                            << '\n';
2169                 }
2170                 if (tag != RC_LAST)
2171                         break;
2172         case RC_LOADSESSION:
2173                 if (ignore_system_lyxrc ||
2174                     load_session != system_lyxrc.load_session) {
2175                         os << "\\load_session " << convert<string>(load_session)
2176                            << "\n";
2177                 }
2178                 if (tag != RC_LAST)
2179                         break;
2180         case RC_MOUSE_WHEEL_SPEED:
2181                 if (ignore_system_lyxrc ||
2182                     mouse_wheel_speed != system_lyxrc.mouse_wheel_speed) {
2183                         os << "\\mouse_wheel_speed " << mouse_wheel_speed << '\n';
2184                 }
2185                 if (tag != RC_LAST)
2186                         break;
2187         case RC_COMPLETION_INLINE_DELAY:
2188                 if (ignore_system_lyxrc ||
2189                     completion_inline_delay != system_lyxrc.completion_inline_delay) {
2190                         os << "\\completion_inline_delay " << completion_inline_delay << '\n';
2191                 }
2192                 if (tag != RC_LAST)
2193                         break;
2194         case RC_COMPLETION_INLINE_MATH:
2195                 if (ignore_system_lyxrc ||
2196                     completion_inline_math != system_lyxrc.completion_inline_math) {
2197                         os << "\\completion_inline_math "
2198                                 << convert<string>(completion_inline_math) << '\n';
2199                 }
2200                 if (tag != RC_LAST)
2201                         break;
2202         case RC_COMPLETION_INLINE_TEXT:
2203                 if (ignore_system_lyxrc ||
2204                     completion_inline_text != system_lyxrc.completion_inline_text) {
2205                         os << "\\completion_inline_text "
2206                                 << convert<string>(completion_inline_text) << '\n';
2207                 }
2208                 if (tag != RC_LAST)
2209                         break;
2210         case RC_COMPLETION_INLINE_DOTS:
2211                 if (ignore_system_lyxrc ||
2212                     completion_inline_dots != system_lyxrc.completion_inline_dots) {
2213                         os << "\\completion_inline_dots "
2214                                 << convert<string>(completion_inline_dots) << '\n';
2215                 }
2216                 if (tag != RC_LAST)
2217                         break;
2218         case RC_AUTOCORRECTION_MATH:
2219                 if (ignore_system_lyxrc ||
2220                     autocorrection_math != system_lyxrc.autocorrection_math) {
2221                         os << "\\autocorrection_math "
2222                                 << convert<string>(autocorrection_math) << '\n';
2223                 }
2224                 if (tag != RC_LAST)
2225                         break;
2226         case RC_COMPLETION_POPUP_DELAY:
2227                 if (ignore_system_lyxrc ||
2228                     completion_popup_delay != system_lyxrc.completion_popup_delay) {
2229                         os << "\\completion_popup_delay " << completion_popup_delay << '\n';
2230                 }
2231                 if (tag != RC_LAST)
2232                         break;
2233         case RC_COMPLETION_POPUP_MATH:
2234                 if (ignore_system_lyxrc ||
2235                     completion_popup_math != system_lyxrc.completion_popup_math) {
2236                         os << "\\completion_popup_math "
2237                                 << convert<string>(completion_popup_math) << '\n';
2238                 }
2239                 if (tag != RC_LAST)
2240                         break;
2241         case RC_COMPLETION_POPUP_TEXT:
2242                 if (ignore_system_lyxrc ||
2243                     completion_popup_text != system_lyxrc.completion_popup_text) {
2244                         os << "\\completion_popup_text "
2245                                 << convert<string>(completion_popup_text) << '\n';
2246                 }
2247                 if (tag != RC_LAST)
2248                         break;
2249         case RC_COMPLETION_CURSOR_TEXT:
2250                 if (ignore_system_lyxrc ||
2251                     completion_cursor_text != system_lyxrc.completion_cursor_text) {
2252                         os << "\\completion_cursor_text "
2253                            << convert<string>(completion_cursor_text) << '\n';
2254                 }
2255                 if (tag != RC_LAST)
2256                         break;
2257         case RC_COMPLETION_POPUP_AFTER_COMPLETE:
2258                 if (ignore_system_lyxrc ||
2259                     completion_popup_after_complete
2260                     != system_lyxrc.completion_popup_after_complete) {
2261                         os << "\\completion_popup_after_complete "
2262                                 << convert<string>(completion_popup_after_complete) << '\n';
2263                 }
2264                 if (tag != RC_LAST)
2265                         break;
2266         case RC_NUMLASTFILES:
2267                 if (ignore_system_lyxrc ||
2268                     num_lastfiles != system_lyxrc.num_lastfiles) {
2269                         os << "\\num_lastfiles " << num_lastfiles << '\n';
2270                 }
2271                 if (tag != RC_LAST)
2272                         break;
2273         case RC_CHECKLASTFILES:
2274                 if (ignore_system_lyxrc ||
2275                     check_lastfiles != system_lyxrc.check_lastfiles) {
2276                         os << "\\check_lastfiles " << convert<string>(check_lastfiles)
2277                            << '\n';
2278                 }
2279                 if (tag != RC_LAST)
2280                         break;
2281         case RC_EXAMPLEPATH:
2282                 if (ignore_system_lyxrc ||
2283                     example_path != system_lyxrc.example_path) {
2284                         string const path = os::external_path(example_path);
2285                         os << "\\example_path \"" << path << "\"\n";
2286                 }
2287                 if (tag != RC_LAST)
2288                         break;
2289         case RC_TEMPLATEPATH:
2290                 if (ignore_system_lyxrc ||
2291                     template_path != system_lyxrc.template_path) {
2292                         string const path = os::external_path(template_path);
2293                         os << "\\template_path \"" << path << "\"\n";
2294                 }
2295                 if (tag != RC_LAST)
2296                         break;
2297         case RC_TEMPDIRPATH:
2298                 if (ignore_system_lyxrc ||
2299                     tempdir_path != system_lyxrc.tempdir_path) {
2300                         string const path = os::external_path(tempdir_path);
2301                         os << "\\tempdir_path \"" << path << "\"\n";
2302                 }
2303                 if (tag != RC_LAST)
2304                         break;
2305         case RC_THESAURUSDIRPATH:
2306                 if (ignore_system_lyxrc ||
2307                     thesaurusdir_path != system_lyxrc.thesaurusdir_path) {
2308                         string const path = os::external_path(thesaurusdir_path);
2309                         os << "\\thesaurusdir_path \"" << path << "\"\n";
2310                 }
2311                 if (tag != RC_LAST)
2312                         break;
2313         case RC_HUNSPELLDIR_PATH:
2314                 if (ignore_system_lyxrc ||
2315                     hunspelldir_path != system_lyxrc.hunspelldir_path) {
2316                         string const path = os::external_path(hunspelldir_path);
2317                         os << "\\hunspelldir_path \"" << path << "\"\n";
2318                 }
2319                 if (tag != RC_LAST)
2320                         break;
2321         case RC_USETEMPDIR:
2322                 if (tag != RC_LAST)
2323                         break;
2324                 // Ignore it
2325         case RC_PLAINTEXT_ROFF_COMMAND: // Obsoleted in 2.0
2326                 if (tag != RC_LAST)
2327                         break;
2328         case RC_PLAINTEXT_LINELEN:
2329                 if (ignore_system_lyxrc ||
2330                     plaintext_linelen != system_lyxrc.plaintext_linelen) {
2331                         os << "\\plaintext_linelen " << plaintext_linelen << '\n';
2332                 }
2333                 if (tag != RC_LAST)
2334                         break;
2335         case RC_MAKE_BACKUP:
2336                 if (ignore_system_lyxrc ||
2337                     make_backup != system_lyxrc.make_backup) {
2338                         os << "\\make_backup " << convert<string>(make_backup) << '\n';
2339                 }
2340                 if (tag != RC_LAST)
2341                         break;
2342         case RC_SAVE_COMPRESSED:
2343                 if (ignore_system_lyxrc ||
2344                     save_compressed != system_lyxrc.save_compressed) {
2345                         os << "\\save_compressed " << convert<string>(save_compressed) << '\n';
2346                 }
2347                 if (tag != RC_LAST)
2348                         break;
2349         case RC_BACKUPDIR_PATH:
2350                 if (ignore_system_lyxrc ||
2351                     backupdir_path != system_lyxrc.backupdir_path) {
2352                         string const path = os::external_path(backupdir_path);
2353                         os << "\\backupdir_path \"" << path << "\"\n";
2354                 }
2355                 if (tag != RC_LAST)
2356                         break;
2357
2358                 os << "\n#\n"
2359                    << "# PLAIN TEXT EXPORT SECTION ##############################\n"
2360                    << "#\n\n";
2361
2362                 os << "\n#\n"
2363                    << "# SPELLCHECKER SECTION ##############################\n"
2364                    << "#\n\n";
2365
2366         case RC_SPELL_COMMAND:
2367         case RC_USE_SPELL_LIB:
2368                 // Obsoleted in 2.0
2369                 if (tag != RC_LAST)
2370                         break;
2371         case RC_ACCEPT_COMPOUND:
2372                 if (ignore_system_lyxrc ||
2373                     spellchecker_accept_compound != system_lyxrc.spellchecker_accept_compound) {
2374                         os << "\\accept_compound " << convert<string>(spellchecker_accept_compound)
2375                            << '\n';
2376                 }
2377                 if (tag != RC_LAST)
2378                         break;
2379         case RC_USE_ALT_LANG:
2380                 // Obsoleted in 2.0
2381                 if (tag != RC_LAST)
2382                         break;
2383         case RC_ALT_LANG:
2384                 if (ignore_system_lyxrc ||
2385                     spellchecker_alt_lang != system_lyxrc.spellchecker_alt_lang) {
2386                         os << "\\alternate_language \"" << spellchecker_alt_lang
2387                            << "\"\n";
2388                 }
2389                 if (tag != RC_LAST)
2390                         break;
2391         case RC_USE_ESC_CHARS:
2392                 if (tag != RC_LAST)
2393                         break;
2394         case RC_ESC_CHARS:
2395                 if (ignore_system_lyxrc ||
2396                     spellchecker_esc_chars != system_lyxrc.spellchecker_esc_chars) {
2397                         os << "\\escape_chars \"" << spellchecker_esc_chars << "\"\n";
2398                 }
2399                 if (tag != RC_LAST)
2400                         break;
2401         case RC_USE_PERS_DICT:
2402                 // obsoleted in 2.0
2403                 if (tag != RC_LAST)
2404                         break;
2405         case RC_USE_SYSTEM_COLORS:
2406                 if (ignore_system_lyxrc ||
2407                     use_system_colors != system_lyxrc.use_system_colors) {
2408                         os << "\\use_system_colors "
2409                            << convert<string>(use_system_colors)
2410                            << '\n';
2411                 }
2412                 if (tag != RC_LAST)
2413                         break;
2414         case RC_USE_TOOLTIP:
2415                 if (ignore_system_lyxrc ||
2416                     use_tooltip != system_lyxrc.use_tooltip) {
2417                         os << "\\use_tooltip "
2418                            << convert<string>(use_tooltip)
2419                            << '\n';
2420                 }
2421                 if (tag != RC_LAST)
2422                         break;
2423         case RC_USE_PIXMAP_CACHE:
2424                 if (ignore_system_lyxrc ||
2425                     use_pixmap_cache != system_lyxrc.use_pixmap_cache) {
2426                         os << "\\use_pixmap_cache "
2427                            << convert<string>(use_pixmap_cache)
2428                            << '\n';
2429                 }
2430                 if (tag != RC_LAST)
2431                         break;
2432         case RC_PERS_DICT:
2433                 // obsoleted in 2.0
2434                 if (tag != RC_LAST)
2435                         break;
2436         case RC_USE_INP_ENC:
2437                 // obsoleted in 2.0
2438                 if (tag != RC_LAST)
2439                         break;
2440
2441                 os << "\n#\n"
2442                    << "# LANGUAGE SUPPORT SECTION ##########################\n"
2443                    << "#\n\n";
2444                 if (tag != RC_LAST)
2445                         break;
2446
2447         case RC_DEFAULT_DECIMAL_POINT:
2448                 if (ignore_system_lyxrc ||
2449                     default_decimal_point != system_lyxrc.default_decimal_point) {
2450                         os << "\\default_decimal_point " << default_decimal_point << '\n';
2451                 }
2452                 if (tag != RC_LAST)
2453                         break;
2454
2455         case RC_SPELLCHECKER:
2456                 if (ignore_system_lyxrc ||
2457                     spellchecker != system_lyxrc.spellchecker) {
2458                         os << "\\spellchecker " << spellchecker << '\n';
2459                 }
2460                 if (tag != RC_LAST)
2461                         break;
2462
2463         case RC_SPELLCHECK_CONTINUOUSLY:
2464                 if (ignore_system_lyxrc ||
2465                     spellcheck_continuously != system_lyxrc.spellcheck_continuously) {
2466                         os << "\\spellcheck_continuously " << convert<string>(spellcheck_continuously)
2467                            << '\n';
2468                 }
2469                 if (tag != RC_LAST)
2470                         break;
2471
2472         case RC_SPELLCHECK_NOTES:
2473                 if (ignore_system_lyxrc ||
2474                     spellcheck_notes != system_lyxrc.spellcheck_notes) {
2475                         os << "\\spellcheck_notes " << convert<string>(spellcheck_notes)
2476                            << '\n';
2477                 }
2478                 if (tag != RC_LAST)
2479                         break;
2480
2481         case RC_RTL_SUPPORT:
2482                 if (ignore_system_lyxrc ||
2483                     rtl_support != system_lyxrc.rtl_support) {
2484                         os << "\\rtl " << convert<string>(rtl_support) << '\n';
2485                 }
2486                 if (tag != RC_LAST)
2487                         break;
2488         case RC_VISUAL_CURSOR:
2489                 if (ignore_system_lyxrc ||
2490                         visual_cursor != system_lyxrc.visual_cursor) {
2491                         os << "\\visual_cursor " << convert<string>(visual_cursor) << '\n';
2492                 }
2493                 if (tag != RC_LAST)
2494                         break;
2495         case RC_LANGUAGE_PACKAGE:
2496                 if (ignore_system_lyxrc ||
2497                     language_package != system_lyxrc.language_package) {
2498                         os << "\\language_package \"" << language_package
2499                            << "\"\n";
2500                 }
2501                 if (tag != RC_LAST)
2502                         break;
2503         case RC_LANGUAGE_GLOBAL_OPTIONS:
2504                 if (ignore_system_lyxrc ||
2505                     language_global_options
2506                     != system_lyxrc.language_global_options) {
2507                         os << "\\language_global_options \""
2508                            << convert<string>(language_global_options)
2509                            << "\"\n";
2510                 }
2511                 if (tag != RC_LAST)
2512                         break;
2513         case RC_LANGUAGE_USE_BABEL:
2514                 if (ignore_system_lyxrc ||
2515                     language_use_babel != system_lyxrc.language_use_babel) {
2516                         os << "\\language_use_babel \""
2517                            << convert<string>(language_use_babel)
2518                            << "\"\n";
2519                 }
2520                 if (tag != RC_LAST)
2521                         break;
2522         case RC_LANGUAGE_COMMAND_BEGIN:
2523                 if (ignore_system_lyxrc ||
2524                     language_command_begin
2525                     != system_lyxrc.language_command_begin) {
2526                         os << "\\language_command_begin \""
2527                            << language_command_begin
2528                            << "\"\n";
2529                 }
2530                 if (tag != RC_LAST)
2531                         break;
2532         case RC_LANGUAGE_COMMAND_END:
2533                 if (ignore_system_lyxrc ||
2534                     language_command_end
2535                     != system_lyxrc.language_command_end) {
2536                         os << "\\language_command_end \"" << language_command_end
2537                            << "\"\n";
2538                 }
2539                 if (tag != RC_LAST)
2540                         break;
2541         case RC_LANGUAGE_COMMAND_LOCAL:
2542                 if (ignore_system_lyxrc ||
2543                     language_command_local
2544                     != system_lyxrc.language_command_local) {
2545                         os << "\\language_command_local \""
2546                            << language_command_local
2547                            << "\"\n";
2548                 }
2549                 if (tag != RC_LAST)
2550                         break;
2551         case RC_LANGUAGE_AUTO_BEGIN:
2552                 if (ignore_system_lyxrc ||
2553                     language_auto_begin != system_lyxrc.language_auto_begin) {
2554                         os << "\\language_auto_begin "
2555                            << convert<string>(language_auto_begin) << '\n';
2556                 }
2557                 if (tag != RC_LAST)
2558                         break;
2559         case RC_LANGUAGE_AUTO_END:
2560                 if (ignore_system_lyxrc ||
2561                     language_auto_end != system_lyxrc.language_auto_end) {
2562                         os << "\\language_auto_end "
2563                            << convert<string>(language_auto_end) << '\n';
2564                 }
2565                 if (tag != RC_LAST)
2566                         break;
2567         case RC_MARK_FOREIGN_LANGUAGE:
2568                 if (ignore_system_lyxrc ||
2569                     mark_foreign_language
2570                     != system_lyxrc.mark_foreign_language) {
2571                         os << "\\mark_foreign_language " <<
2572                                 convert<string>(mark_foreign_language) << '\n';
2573                 }
2574                 if (tag != RC_LAST)
2575                         break;
2576
2577                 os << "\n#\n"
2578                    << "# 2nd MISC SUPPORT SECTION ##########################\n"
2579                    << "#\n\n";
2580
2581         case RC_AUTO_NUMBER:
2582                 if (ignore_system_lyxrc ||
2583                     auto_number != system_lyxrc.auto_number) {
2584                         os << "\\auto_number " << convert<string>(auto_number) << '\n';
2585                 }
2586                 if (tag != RC_LAST)
2587                         break;
2588         case RC_DEFAULT_LANGUAGE:
2589                 if (ignore_system_lyxrc ||
2590                     default_language != system_lyxrc.default_language) {
2591                         os << "\\default_language " << default_language << '\n';
2592                 }
2593                 if (tag != RC_LAST)
2594                         break;
2595         case RC_GUI_LANGUAGE:
2596                 if (ignore_system_lyxrc ||
2597                     gui_language != system_lyxrc.gui_language) {
2598                         os << "\\gui_language " << gui_language << '\n';
2599                 }
2600                 if (tag != RC_LAST)
2601                         break;
2602         case RC_EXPORT_OVERWRITE:
2603                 if (ignore_system_lyxrc ||
2604                     export_overwrite != system_lyxrc.export_overwrite) {
2605                         string status;
2606                         switch (export_overwrite) {
2607                         case NO_FILES:
2608                                 status = "ask";
2609                                 break;
2610                         case MAIN_FILE:
2611                                 status = "main";
2612                                 break;
2613                         case ALL_FILES:
2614                                 status = "all";
2615                                 break;
2616                         }
2617                         os << "\\export_overwrite " << status << '\n';
2618                 }
2619                 if (tag != RC_LAST)
2620                         break;
2621
2622         case RC_SCROLL_WHEEL_ZOOM:
2623                 if (ignore_system_lyxrc ||
2624                         scroll_wheel_zoom != system_lyxrc.scroll_wheel_zoom) {
2625                         string status;
2626                         switch (scroll_wheel_zoom) {
2627                         case SCROLL_WHEEL_ZOOM_OFF:
2628                                 status = "off";
2629                                 break;
2630                         case SCROLL_WHEEL_ZOOM_CTRL:
2631                                 status = "ctrl";
2632                                 break;
2633                         case SCROLL_WHEEL_ZOOM_SHIFT:
2634                                 status = "shift";
2635                                 break;
2636                         case SCROLL_WHEEL_ZOOM_ALT:
2637                                 status = "alt";
2638                                 break;
2639                         }
2640                         os << "\\scroll_wheel_zoom " << status << '\n';
2641                 }
2642                 if (tag != RC_LAST)
2643                         break;
2644
2645                 os << "\n#\n"
2646                    << "# FORMATS SECTION ##########################\n"
2647                    << "#\n\n";
2648
2649         case RC_FORMAT:
2650                 // New/modified formats
2651                 for (Formats::const_iterator cit = formats.begin();
2652                      cit != formats.end(); ++cit) {
2653                         Format const * format =
2654                                 system_formats.getFormat(cit->name());
2655                         if (!format ||
2656                             format->extension() != cit->extension() ||
2657                             format->prettyname() != cit->prettyname() ||
2658                             format->shortcut() != cit->shortcut() ||
2659                             format->viewer() != cit->viewer() ||
2660                             format->editor() != cit->editor() ||
2661                             format->documentFormat() != cit->documentFormat() ||
2662                             format->vectorFormat() != cit->vectorFormat()) {
2663                                 os << "\\format \"" << cit->name() << "\" \""
2664                                    << cit->extension() << "\" \""
2665                                    << cit->prettyname() << "\" \""
2666                                    << cit->shortcut() << "\" \""
2667                                    << escapeCommand(cit->viewer()) << "\" \""
2668                                    << escapeCommand(cit->editor()) << "\" \"";
2669                                 vector<string> flags;
2670                                 if (cit->documentFormat())
2671                                         flags.push_back("document");
2672                                 if (cit->vectorFormat())
2673                                         flags.push_back("vector");
2674                                 os << getStringFromVector(flags);
2675                                 os << "\"\n";
2676                         }
2677                 }
2678
2679                 // Look for deleted formats
2680                 for (Formats::const_iterator cit = system_formats.begin();
2681                      cit != system_formats.end(); ++cit)
2682                         if (!formats.getFormat(cit->name()))
2683                                 os << "\\format \"" << cit->name()
2684                                    << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
2685                 if (tag != RC_LAST)
2686                         break;
2687         case RC_VIEWER_ALTERNATIVES: {
2688                 Alternatives::const_iterator it = viewer_alternatives.begin();
2689                 Alternatives::const_iterator const en = viewer_alternatives.end();
2690                 Alternatives::const_iterator const sysend = 
2691                                 system_lyxrc.viewer_alternatives.end();
2692                 for (; it != en; ++it) {
2693                         string const & fmt = it->first;
2694                         CommandSet const & cmd = it->second;
2695                         CommandSet::const_iterator sit = cmd.begin();
2696                         CommandSet::const_iterator const sen = cmd.end();
2697                         Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
2698                                         system_lyxrc.viewer_alternatives.begin() : // we won't use it in this case
2699                                         system_lyxrc.viewer_alternatives.find(fmt);
2700                         for (; sit != sen; ++sit) {
2701                                 string const & cmd = *sit;
2702                                 if (ignore_system_lyxrc 
2703                                     || sysfmt == sysend               // format not found
2704                                          || sysfmt->second.count(cmd) == 0 // this command not found
2705                                    )
2706                                         os << "\\viewer_alternatives " << fmt << " " << cmd << "\n";
2707                         }
2708                 }
2709                 if (tag != RC_LAST)
2710                         break;
2711         }
2712         case RC_EDITOR_ALTERNATIVES: {
2713                 Alternatives::const_iterator it = editor_alternatives.begin();
2714                 Alternatives::const_iterator const en = editor_alternatives.end();
2715                 Alternatives::const_iterator const sysend = 
2716                                 system_lyxrc.editor_alternatives.end();
2717                 for (; it != en; ++it) {
2718                         string const & fmt = it->first;
2719                         CommandSet const & cmd = it->second;
2720                         CommandSet::const_iterator sit = cmd.begin();
2721                         CommandSet::const_iterator const sen = cmd.end();
2722                         Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
2723                                         system_lyxrc.editor_alternatives.begin() : // we won't use it in this case
2724                                         system_lyxrc.editor_alternatives.find(fmt);
2725                         for (; sit != sen; ++sit) {
2726                                 string const & cmd = *sit;
2727                                 if (ignore_system_lyxrc 
2728                                     || sysfmt == sysend               // format not found
2729                                     || sysfmt->second.count(cmd) == 0 // this command not found
2730                                    )
2731                                         os << "\\editor_alternatives " << fmt << " " << cmd << "\n";
2732                         }
2733                 }
2734                 if (tag != RC_LAST)
2735                         break;
2736         }
2737         case RC_DEFAULT_VIEW_FORMAT:
2738                 if (ignore_system_lyxrc ||
2739                     default_view_format != system_lyxrc.default_view_format) {
2740                         os << "\\default_view_format " << default_view_format << '\n';
2741                 }
2742                 if (tag != RC_LAST)
2743                         break;
2744         case RC_VIEWER:
2745                 // Ignore it
2746                 if (tag != RC_LAST)
2747                         break;
2748
2749                 os << "\n#\n"
2750                    << "# CONVERTERS SECTION ##########################\n"
2751                    << "#\n\n";
2752
2753         case RC_CONVERTER:
2754                 // Look for new converters
2755                 for (Converters::const_iterator cit = theConverters().begin();
2756                      cit != theConverters().end(); ++cit) {
2757                         Converter const * converter =
2758                                 theSystemConverters().getConverter(cit->from,
2759                                                                cit->to);
2760                         if (!converter ||
2761                             converter->command != cit->command ||
2762                             converter->flags != cit->flags)
2763                                 os << "\\converter \"" << cit->from << "\" \""
2764                                    << cit->to << "\" \""
2765                                    << escapeCommand(cit->command) << "\" \""
2766                                    << cit->flags << "\"\n";
2767                 }
2768
2769                 // New/modifed converters
2770                 for (Converters::const_iterator cit = theSystemConverters().begin();
2771                      cit != theSystemConverters().end(); ++cit)
2772                         if (!theConverters().getConverter(cit->from, cit->to))
2773                                 os << "\\converter \"" << cit->from
2774                                    << "\" \"" << cit->to << "\" \"\" \"\"\n";
2775                 if (tag != RC_LAST)
2776                         break;
2777         
2778         case RC_COPIER:
2779                 if (tag == RC_LAST)
2780                         os << "\n#\n"
2781                            << "# COPIERS SECTION ##########################\n"
2782                            << "#\n\n";
2783
2784                 // Look for new movers
2785                 Movers::const_iterator const sysbegin = theSystemMovers().begin();
2786                 Movers::const_iterator const sysend = theSystemMovers().end();
2787                 Movers::const_iterator it = theMovers().begin();
2788                 Movers::const_iterator end = theMovers().end();
2789
2790                 for (; it != end; ++it) {
2791                         Movers::const_iterator const sysit =
2792                                 find_if(sysbegin, sysend, SameMover(*it));
2793                         if (sysit == sysend) {
2794                                 string const & fmt = it->first;
2795                                 string const & command =
2796                                         it->second.command();
2797
2798                                 os << "\\copier " << fmt
2799                                    << " \"" << escapeCommand(command) << "\"\n";
2800                         }
2801                 }
2802                 if (tag != RC_LAST)
2803                         break;
2804
2805                 // We don't actually delete SpecialisedMover(s) from the
2806                 // map, just clear their 'command', so there's no need
2807                 // to test for anything else.
2808         }
2809
2810         os.flush();
2811 }
2812
2813
2814 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
2815 {
2816         // Why the switch you might ask. It is a trick to ensure that all
2817         // the elements in the LyXRCTags enum is handled. As you can see
2818         // there are no breaks at all. So it is just a huge fall-through.
2819         // The nice thing is that we will get a warning from the compiler
2820         // if we forget an element.
2821         LyXRC::LyXRCTags tag = LyXRC::RC_LAST;
2822         switch (tag) {
2823         case LyXRC::RC_ACCEPT_COMPOUND:
2824         case LyXRC::RC_ALT_LANG:
2825         case LyXRC::RC_PLAINTEXT_LINELEN:
2826         case LyXRC::RC_PLAINTEXT_ROFF_COMMAND:
2827         case LyXRC::RC_AUTOCORRECTION_MATH:
2828         case LyXRC::RC_AUTOREGIONDELETE:
2829         case LyXRC::RC_AUTORESET_OPTIONS:
2830         case LyXRC::RC_AUTOSAVE:
2831         case LyXRC::RC_AUTO_NUMBER:
2832         case LyXRC::RC_BACKUPDIR_PATH:
2833         case LyXRC::RC_BIBTEX_ALTERNATIVES:
2834         case LyXRC::RC_BIBTEX_COMMAND:
2835         case LyXRC::RC_BINDFILE:
2836         case LyXRC::RC_CHECKLASTFILES:
2837         case LyXRC::RC_COMPLETION_CURSOR_TEXT:
2838         case LyXRC::RC_COMPLETION_INLINE_DELAY:
2839         case LyXRC::RC_COMPLETION_INLINE_DOTS:
2840         case LyXRC::RC_COMPLETION_INLINE_MATH:
2841         case LyXRC::RC_COMPLETION_INLINE_TEXT:
2842         case LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE:
2843         case LyXRC::RC_COMPLETION_POPUP_DELAY:
2844         case LyXRC::RC_COMPLETION_POPUP_MATH:
2845         case LyXRC::RC_COMPLETION_POPUP_TEXT:
2846         case LyXRC::RC_USELASTFILEPOS:
2847         case LyXRC::RC_LOADSESSION:
2848         case LyXRC::RC_CHKTEX_COMMAND:
2849         case LyXRC::RC_CONVERTER:
2850         case LyXRC::RC_CONVERTER_CACHE_MAXAGE:
2851         case LyXRC::RC_COPIER:
2852         case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
2853         case LyXRC::RC_SCROLL_BELOW_DOCUMENT:
2854         case LyXRC::RC_DATE_INSERT_FORMAT:
2855         case LyXRC::RC_DEFAULT_LANGUAGE:
2856         case LyXRC::RC_GUI_LANGUAGE:
2857         case LyXRC::RC_DEFAULT_PAPERSIZE:
2858         case LyXRC::RC_DEFAULT_VIEW_FORMAT:
2859         case LyXRC::RC_DEFFILE:
2860         case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN:
2861         case LyXRC::RC_DISPLAY_GRAPHICS:
2862         case LyXRC::RC_DOCUMENTPATH:
2863                 if (lyxrc_orig.document_path != lyxrc_new.document_path) {
2864                         FileName path(lyxrc_new.document_path);
2865                         if (path.exists() && path.isDirectory())
2866                                 package().document_dir() = FileName(lyxrc.document_path);
2867                 }
2868         case LyXRC::RC_EDITOR_ALTERNATIVES:
2869         case LyXRC::RC_ESC_CHARS:
2870         case LyXRC::RC_EXAMPLEPATH:
2871         case LyXRC::RC_FONT_ENCODING:
2872         case LyXRC::RC_FORMAT:
2873         case LyXRC::RC_GROUP_LAYOUTS:
2874         case LyXRC::RC_HUNSPELLDIR_PATH:
2875         case LyXRC::RC_INDEX_ALTERNATIVES:
2876         case LyXRC::RC_INDEX_COMMAND:
2877         case LyXRC::RC_JBIBTEX_COMMAND:
2878         case LyXRC::RC_JINDEX_COMMAND:
2879         case LyXRC::RC_NOMENCL_COMMAND:
2880         case LyXRC::RC_INPUT:
2881         case LyXRC::RC_KBMAP:
2882         case LyXRC::RC_KBMAP_PRIMARY:
2883         case LyXRC::RC_KBMAP_SECONDARY:
2884         case LyXRC::RC_LANGUAGE_AUTO_BEGIN:
2885         case LyXRC::RC_LANGUAGE_AUTO_END:
2886         case LyXRC::RC_LANGUAGE_COMMAND_BEGIN:
2887         case LyXRC::RC_LANGUAGE_COMMAND_END:
2888         case LyXRC::RC_LANGUAGE_COMMAND_LOCAL:
2889         case LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS:
2890         case LyXRC::RC_LANGUAGE_PACKAGE:
2891         case LyXRC::RC_LANGUAGE_USE_BABEL:
2892         case LyXRC::RC_MAC_DONTSWAP_CTRL_META:
2893         case LyXRC::RC_MAC_LIKE_WORD_MOVEMENT:
2894         case LyXRC::RC_MACRO_EDIT_STYLE:
2895         case LyXRC::RC_MAKE_BACKUP:
2896         case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
2897         case LyXRC::RC_MOUSE_WHEEL_SPEED:
2898         case LyXRC::RC_NUMLASTFILES:
2899         case LyXRC::RC_PARAGRAPH_MARKERS:
2900         case LyXRC::RC_PATH_PREFIX:
2901                 if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) {
2902                         prependEnvPath("PATH", lyxrc.path_prefix);
2903                 }
2904         case LyXRC::RC_PERS_DICT:
2905         case LyXRC::RC_PREVIEW:
2906         case LyXRC::RC_PREVIEW_HASHED_LABELS:
2907         case LyXRC::RC_PREVIEW_SCALE_FACTOR:
2908         case LyXRC::RC_PRINTCOLLCOPIESFLAG:
2909         case LyXRC::RC_PRINTCOPIESFLAG:
2910         case LyXRC::RC_PRINTER:
2911         case LyXRC::RC_PRINTEVENPAGEFLAG:
2912         case LyXRC::RC_PRINTEXSTRAOPTIONS:
2913         case LyXRC::RC_PRINTFILEEXTENSION:
2914         case LyXRC::RC_PRINTLANDSCAPEFLAG:
2915         case LyXRC::RC_PRINTODDPAGEFLAG:
2916         case LyXRC::RC_PRINTPAGERANGEFLAG:
2917         case LyXRC::RC_PRINTPAPERDIMENSIONFLAG:
2918         case LyXRC::RC_PRINTPAPERFLAG:
2919         case LyXRC::RC_PRINTREVERSEFLAG:
2920         case LyXRC::RC_PRINTSPOOL_COMMAND:
2921         case LyXRC::RC_PRINTSPOOL_PRINTERPREFIX:
2922         case LyXRC::RC_PRINTTOFILE:
2923         case LyXRC::RC_PRINTTOPRINTER:
2924         case LyXRC::RC_PRINT_ADAPTOUTPUT:
2925         case LyXRC::RC_PRINT_COMMAND:
2926         case LyXRC::RC_RTL_SUPPORT:
2927         case LyXRC::RC_SAVE_COMPRESSED:
2928         case LyXRC::RC_SCREEN_DPI:
2929         case LyXRC::RC_SCREEN_FONT_ROMAN:
2930         case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
2931         case LyXRC::RC_SCREEN_FONT_SANS:
2932         case LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY:
2933         case LyXRC::RC_SCREEN_FONT_SCALABLE:
2934         case LyXRC::RC_SCREEN_FONT_SIZES:
2935         case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
2936         case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2937         case LyXRC::RC_GEOMETRY_SESSION:
2938         case LyXRC::RC_SCREEN_ZOOM:
2939         case LyXRC::RC_SERVERPIPE:
2940         case LyXRC::RC_SET_COLOR:
2941         case LyXRC::RC_SHOW_BANNER:
2942         case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
2943         case LyXRC::RC_SPELL_COMMAND:
2944         case LyXRC::RC_SPELLCHECKER:
2945         case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
2946         case LyXRC::RC_SPELLCHECK_NOTES:
2947         case LyXRC::RC_SPLITINDEX_COMMAND:
2948         case LyXRC::RC_TEMPDIRPATH:
2949         case LyXRC::RC_TEMPLATEPATH:
2950         case LyXRC::RC_TEX_ALLOWS_SPACES:
2951         case LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS:
2952                 if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
2953                         os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
2954                 }
2955         case LyXRC::RC_THESAURUSDIRPATH:
2956         case LyXRC::RC_UIFILE:
2957         case LyXRC::RC_USER_EMAIL:
2958         case LyXRC::RC_USER_NAME:
2959         case LyXRC::RC_USETEMPDIR:
2960         case LyXRC::RC_USE_ALT_LANG:
2961         case LyXRC::RC_USE_CONVERTER_CACHE:
2962         case LyXRC::RC_USE_ESC_CHARS:
2963         case LyXRC::RC_USE_INP_ENC:
2964         case LyXRC::RC_USE_PERS_DICT:
2965         case LyXRC::RC_USE_SYSTEM_COLORS:
2966         case LyXRC::RC_USE_TOOLTIP:
2967         case LyXRC::RC_USE_PIXMAP_CACHE:
2968         case LyXRC::RC_USE_SPELL_LIB:
2969         case LyXRC::RC_VIEWDVI_PAPEROPTION:
2970         case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON:
2971         case LyXRC::RC_SORT_LAYOUTS:
2972         case LyXRC::RC_FULL_SCREEN_LIMIT:
2973         case LyXRC::RC_FULL_SCREEN_SCROLLBAR:
2974         case LyXRC::RC_FULL_SCREEN_MENUBAR:
2975         case LyXRC::RC_FULL_SCREEN_TABBAR:
2976         case LyXRC::RC_FULL_SCREEN_TOOLBARS:
2977         case LyXRC::RC_FULL_SCREEN_WIDTH:
2978         case LyXRC::RC_VISUAL_CURSOR:
2979         case LyXRC::RC_VIEWER:
2980         case LyXRC::RC_VIEWER_ALTERNATIVES:
2981         case LyXRC::RC_FORWARD_SEARCH_DVI:
2982         case LyXRC::RC_FORWARD_SEARCH_PDF:
2983         case LyXRC::RC_EXPORT_OVERWRITE:
2984         case LyXRC::RC_DEFAULT_DECIMAL_POINT:
2985         case LyXRC::RC_SCROLL_WHEEL_ZOOM:
2986         case LyXRC::RC_LAST:
2987                 break;
2988         }
2989 }
2990
2991
2992 #if 0
2993 string const LyXRC::getDescription(LyXRCTags tag)
2994 {
2995         docstring str;
2996
2997         switch (tag) {
2998         case RC_ACCEPT_COMPOUND:
2999                 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
3000                 break;
3001
3002         case RC_ALT_LANG:
3003         case RC_USE_ALT_LANG:
3004                 str = _("Specify an alternate language. The default is to use the language of the document.");
3005                 break;
3006
3007         case RC_PLAINTEXT_ROFF_COMMAND:
3008                 str = _("Use to define an external program to render tables in plain text output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"\" is specified, an internal routine is used.");
3009                 break;
3010
3011         case RC_PLAINTEXT_LINELEN:
3012                 str = _("The maximum line length of exported plain text/LaTeX/SGML files. If set to 0, paragraphs are output in a single line; if the line length is > 0, paragraphs are separated by a blank line.");
3013                 break;
3014
3015         case RC_AUTOREGIONDELETE:
3016                 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
3017                 break;
3018
3019         case RC_AUTORESET_OPTIONS:
3020                 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
3021                 break;
3022
3023         case RC_AUTOSAVE:
3024                 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
3025                 break;
3026
3027         case RC_AUTO_NUMBER:
3028                 break;
3029
3030         case RC_BACKUPDIR_PATH:
3031                 str = _("The path for storing backup files. If it is an empty string, LyX will store the backup file in the same directory as the original file.");
3032                 break;
3033
3034         case RC_BIBTEX_COMMAND:
3035                 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
3036                 break;
3037
3038         case RC_JBIBTEX_COMMAND:
3039                 str = _("Define the options of the bibtex program for PLaTeX (Japanese LaTeX).");
3040                 break;
3041
3042         case RC_BINDFILE:
3043                 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
3044                 break;
3045
3046         case RC_CHECKLASTFILES:
3047                 str = _("Select to check whether the lastfiles still exist.");
3048                 break;
3049
3050         case RC_CHKTEX_COMMAND:
3051                 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
3052                 break;
3053
3054         case RC_CONVERTER:
3055                 break;
3056
3057         case RC_COPIER:
3058                 break;
3059
3060         case RC_CURSOR_FOLLOWS_SCROLLBAR:
3061                 str = _("LyX normally doesn't update the cursor position if you move the scrollbar. Set to true if you'd prefer to always have the cursor on screen.");
3062                 break;
3063
3064         case RC_SCROLL_BELOW_DOCUMENT:
3065                 str = _("LyX normally doesn't allow the user to scroll further than the bottom of the document. Set to true if you prefer to scroll the bottom of the document to the top of the screen");
3066                 break;
3067
3068         case RC_MAC_DONTSWAP_CTRL_META:
3069                 str = _("Make Apple key act as Meta and Control key as Ctrl.");
3070                 break;
3071
3072         case RC_MAC_LIKE_WORD_MOVEMENT:
3073                 str = _("Use the Mac OS X conventions for the word-level cursor movement");
3074                 break;
3075
3076         case RC_SHOW_MACRO_LABEL:
3077                 str = _("Show a small box around a Math Macro with the macro name when the cursor is inside.");
3078                 break;
3079
3080         case RC_DATE_INSERT_FORMAT:
3081                 //xgettext:no-c-format
3082                 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
3083                 break;
3084
3085         case RC_DEFFILE:
3086                 str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories.");
3087                 break;
3088
3089         case RC_DEFAULT_VIEW_FORMAT:
3090                 str = _("The default format used with LFUN_BUFFER_[VIEW|UPDATE].");
3091                 break;
3092
3093         case RC_DEFAULT_LANGUAGE:
3094                 str = _("New documents will be assigned this language.");
3095                 break;
3096
3097         case RC_DEFAULT_PAPERSIZE:
3098                 str = _("Specify the default paper size.");
3099                 break;
3100
3101         case RC_DIALOGS_ICONIFY_WITH_MAIN:
3102                 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
3103                 break;
3104
3105         case RC_DISPLAY_GRAPHICS:
3106                 str = _("Select how LyX will display any graphics.");
3107                 break;
3108
3109         case RC_DOCUMENTPATH:
3110                 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
3111                 break;
3112
3113         case RC_ESC_CHARS:
3114         case RC_USE_ESC_CHARS:
3115                 str = _("Specify additional chars that can be part of a word.");
3116                 break;
3117
3118         case RC_EXAMPLEPATH:
3119                 str = _("The path that LyX will set when offering to choose an example. An empty value selects the directory LyX was started from.");
3120                 break;
3121
3122         case RC_FONT_ENCODING:
3123                 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
3124                 break;
3125
3126         case RC_FORMAT:
3127                 break;
3128
3129         case RC_INDEX_COMMAND:
3130                 str = _("Define the options of makeindex (cf. man makeindex) or select an alternative compiler. E.g., using xindy/make-rules, the command string would be \"makeindex.sh -m $$lang\".");
3131                 break;
3132
3133         case RC_JINDEX_COMMAND:
3134                 str = _("Define the options of the index program for PLaTeX (Japanese LaTeX).");
3135                 break;
3136
3137         case RC_NOMENCL_COMMAND:
3138                 str = _("Define the options of makeindex (cf. man makeindex) to be used for nomenclatures. This might differ from the index processing options.");
3139                 break;
3140
3141         case RC_INPUT:
3142                 break;
3143
3144         case RC_KBMAP:
3145         case RC_KBMAP_PRIMARY:
3146         case RC_KBMAP_SECONDARY:
3147                 str = _("Use this to set the correct mapping file for your keyboard. You'll need this if you for instance want to type German documents on an American keyboard.");
3148                 break;
3149
3150         case RC_LANGUAGE_AUTO_BEGIN:
3151                 str = _("Select if a language switching command is needed at the beginning of the document.");
3152                 break;
3153
3154         case RC_LANGUAGE_AUTO_END:
3155                 str = _("Select if a language switching command is needed at the end of the document.");
3156                 break;
3157
3158         case RC_LANGUAGE_COMMAND_BEGIN:
3159                 str = _("The LaTeX command for changing from the language of the document to another language. E.g. \\selectlanguage{$$lang} where $$lang is substituted by the name of the second language.");
3160                 break;
3161
3162         case RC_LANGUAGE_COMMAND_END:
3163                 str = _("The LaTeX command for changing back to the language of the document.");
3164                 break;
3165
3166         case RC_LANGUAGE_COMMAND_LOCAL:
3167                 str = _("The LaTeX command for local changing of the language.");
3168                 break;
3169
3170         case RC_LANGUAGE_GLOBAL_OPTIONS:
3171                 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
3172                 break;
3173
3174         case RC_LANGUAGE_PACKAGE:
3175                 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
3176                 break;
3177
3178         case RC_LANGUAGE_USE_BABEL:
3179                 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
3180                 break;
3181
3182         case RC_USELASTFILEPOS:
3183                 str = _("De-select if you do not want LyX to scroll to saved position.");
3184                 break;
3185
3186         case RC_LOADSESSION:
3187                 str = _("De-select to prevent loading files opened from the last LyX session.");
3188                 break;
3189
3190         case RC_MAKE_BACKUP:
3191                 str = _("De-select if you don't want LyX to create backup files.");
3192                 break;
3193
3194         case RC_MARK_FOREIGN_LANGUAGE:
3195                 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
3196                 break;
3197
3198         case RC_MOUSE_WHEEL_SPEED:
3199                 str = bformat(_("The scrolling speed of the mouse wheel."),
3200                       maxlastfiles);
3201                 break;
3202
3203         case RC_COMPLETION_POPUP_DELAY:
3204                 str = _("The completion popup delay.");
3205                 break;
3206
3207         case RC_COMPLETION_POPUP_MATH:
3208                 str = _("Select to display the completion popup in math mode.");
3209                 break;
3210
3211         case RC_COMPLETION_POPUP_TEXT:
3212                 str = _("Select to display the completion popup in text mode.");
3213                 break;
3214
3215         case RC_COMPLETION_POPUP_AFTER_COMPLETE:
3216                 str = _("Show the completion popup without delay after non-unique completion attempt.");
3217                 break;
3218
3219         case RC_COMPLETION_POPUP_TEXT:
3220                 str = _("Show a small triangle on the cursor to indicate that a completion is available.");
3221                 break;
3222
3223         case RC_COMPLETION_POPUP_DELAY:
3224                 str = _("The inline completion delay.");
3225                 break;
3226
3227         case RC_COMPLETION_INLINE_MATH:
3228                 str = _("Select to display the inline completion in math mode.");
3229                 break;
3230
3231         case RC_COMPLETION_INLINE_TEXT:
3232                 str = _("Select to display the inline completion in text mode.");
3233                 break;
3234
3235         case RC_COMPLETION_INLINE_DOTS:
3236                 str = _("Use \"...\" to shorten long completions.");
3237                 break;
3238
3239         case RC_AUTOCORRECTION_MATH:
3240                 str = _("Allow TeXMacs shorthand, like => converting to \Rightarrow.");
3241                 break;
3242
3243         case RC_NUMLASTFILES:
3244                 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."),
3245                         maxlastfiles);
3246                 break;
3247
3248         case RC_PATH_PREFIX:
3249                 str = _("Specify those directories which should be "
3250                          "prepended to the PATH environment variable. "
3251                          "Use the OS native format.");
3252                 break;
3253
3254         case RC_PREVIEW:
3255                 str = _("Shows a typeset preview of things such as math");
3256                 break;
3257
3258         case RC_PREVIEW_HASHED_LABELS:
3259                 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
3260                 break;
3261
3262         case RC_PREVIEW_SCALE_FACTOR:
3263                 str = _("Scale the preview size to suit.");
3264                 break;
3265
3266         case RC_PRINTCOLLCOPIESFLAG:
3267                 str = _("The option for specifying whether the copies should be collated.");
3268                 break;
3269
3270         case RC_PRINTCOPIESFLAG:
3271                 str = _("The option for specifying the number of copies to print.");
3272                 break;
3273
3274         case RC_PRINTER:
3275                 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
3276                 break;
3277
3278         case RC_PRINTEVENPAGEFLAG:
3279                 str = _("The option to print only even pages.");
3280                 break;
3281
3282         case RC_PRINTEXSTRAOPTIONS:
3283                 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
3284                 break;
3285
3286         case RC_PRINTFILEEXTENSION:
3287                 str = _("Extension of printer program output file. Usually \".ps\".");
3288                 break;
3289
3290         case RC_PRINTLANDSCAPEFLAG:
3291                 str = _("The option to print out in landscape.");
3292                 break;
3293
3294         case RC_PRINTODDPAGEFLAG:
3295                 str = _("The option to print only odd pages.");
3296                 break;
3297
3298         case RC_PRINTPAGERANGEFLAG:
3299                 str = _("The option for specifying a comma-separated list of pages to print.");
3300                 break;
3301
3302         case RC_PRINTPAPERDIMENSIONFLAG:
3303                                    str = _("Option to specify the dimensions of the print paper.");
3304                 break;
3305
3306         case RC_PRINTPAPERFLAG:
3307                 str = _("The option to specify paper type.");
3308                 break;
3309
3310         case RC_PRINTREVERSEFLAG:
3311                 str = _("The option to reverse the order of the pages printed.");
3312                 break;
3313
3314         case RC_PRINTSPOOL_COMMAND:
3315                 str = _("When set, this printer option automatically prints to a file and then calls a separate print spooling program on that file with the given name and arguments.");
3316                 break;
3317
3318         case RC_PRINTSPOOL_PRINTERPREFIX:
3319                 str = _("If you specify a printer name in the print dialog, the following argument is prepended along with the printer name after the spool command.");
3320                 break;
3321
3322         case RC_PRINTTOFILE:
3323                 str = _("Option to pass to the print program to print to a file.");
3324                 break;
3325
3326         case RC_PRINTTOPRINTER:
3327                 str = _("Option to pass to the print program to print on a specific printer.");
3328                 break;
3329
3330         case RC_PRINT_ADAPTOUTPUT:
3331                 str = _("Select for LyX to pass the name of the destination printer to your print command.");
3332                 break;
3333
3334         case RC_PRINT_COMMAND:
3335                 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
3336                 break;
3337
3338         case RC_RTL_SUPPORT:
3339                 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
3340                 break;
3341
3342         case RC_VISUAL_CURSOR:
3343                 str = _("Select to have visual bidi cursor movement, unselect for logical movement.");
3344                 break;
3345
3346         case RC_SCREEN_DPI:
3347                 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
3348                 break;
3349
3350         case RC_SCREEN_FONT_ROMAN:
3351         case RC_SCREEN_FONT_SANS:
3352         case RC_SCREEN_FONT_TYPEWRITER:
3353                 str = _("The screen fonts used to display the text while editing.");
3354                 break;
3355
3356         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
3357         case RC_SCREEN_FONT_SANS_FOUNDRY:
3358         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
3359                 break;
3360
3361         case RC_SCREEN_FONT_SCALABLE:
3362                 str = _("Allow bitmap fonts to be resized. If you are using a bitmap font, selecting this option may make some fonts look blocky in LyX. Deselecting this option makes LyX use the nearest bitmap font size available, instead of scaling.");
3363                 break;
3364
3365         case RC_SCREEN_FONT_SIZES:
3366                 str = _("The font sizes used for calculating the scaling of the screen fonts.");
3367                 break;
3368
3369         case RC_SCREEN_ZOOM:
3370                 //xgettext:no-c-format
3371                 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
3372                 break;
3373
3374         case RC_GEOMETRY_SESSION:
3375                 str = _("Allow session manager to save and restore windows geometry.");
3376                 break;
3377
3378         case RC_SERVERPIPE:
3379                 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
3380                 break;
3381
3382         case RC_SET_COLOR:
3383                 break;
3384
3385         case RC_SHOW_BANNER:
3386                 str = _("De-select if you don't want the startup banner.");
3387                 break;
3388
3389         case RC_TEMPDIRPATH:
3390                 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
3391                 break;
3392
3393         case RC_THESAURUSDIRPATH:
3394                 str = _("This is the place where the files of the thesaurus library reside.");
3395                 break;
3396
3397         case RC_TEMPLATEPATH:
3398                 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
3399                 break;
3400
3401         case RC_TEX_ALLOWS_SPACES:
3402                 break;
3403
3404         case RC_TEX_EXPECTS_WINDOWS_PATHS:
3405                 break;
3406
3407         case RC_UIFILE:
3408                 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
3409                 break;
3410
3411         case RC_USER_EMAIL:
3412                 break;
3413
3414         case RC_USER_NAME:
3415                 break;
3416
3417         case RC_USETEMPDIR:
3418                 break;
3419
3420         case RC_USE_USE_SYSTEM_COLORS:
3421                 str = _("Enable use the system colors for some things like main window background and selection.");
3422                 break;
3423
3424         case RC_USE_TOOLTIP:
3425                 str = _("Enable the automatic appearance of tool tips in the work area.");
3426                 break;
3427
3428         case RC_USE_PIXMAP_CACHE:
3429                 str = _("Enable the pixmap cache that might improve performance on Mac and Windows.");
3430                 break;
3431
3432         case RC_USE_SPELL_LIB:
3433                 break;
3434
3435         case RC_VIEWDVI_PAPEROPTION:
3436                 _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
3437                 break;
3438
3439         case RC_VIEWER:
3440                 break;
3441
3442         case RC_LAST:
3443                 break;
3444         }
3445
3446         return str;
3447 }
3448 #endif
3449
3450
3451 // The global instance
3452 LyXRC lyxrc;
3453
3454 // The global copy of the system lyxrc entries (everything except preferences)
3455 LyXRC system_lyxrc;
3456
3457
3458 } // namespace lyx