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