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