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