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