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