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