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