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