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