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