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