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