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