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