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