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