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