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