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