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