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