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