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