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