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