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