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