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