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