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