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