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