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