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