]> git.lyx.org Git - lyx.git/blob - src/LyXRC.cpp
319d21692b54b155e9acdae489c3b9007887b0db
[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                         if (lexrc.next(true)) 
1163                                 forward_search = lexrc.getString();
1164                         break;
1165
1166                 // Obsoteted in 1.4.0
1167                 case RC_USETEMPDIR:
1168                 // Obsoleted in 2.0
1169                 case RC_SPELL_COMMAND:
1170                 case RC_PERS_DICT:
1171                 case RC_PLAINTEXT_ROFF_COMMAND: 
1172                 case RC_USE_ALT_LANG:
1173                 case RC_USE_ESC_CHARS:
1174                 case RC_USE_INP_ENC:
1175                 case RC_USE_PERS_DICT:
1176                 case RC_USE_SPELL_LIB:
1177                         LYXERR(Debug::LYXRC, "Skipping obsolete tag `" 
1178                                << lexrc.getString() << "'.");
1179                         lexrc.next(true);
1180                         break;
1181
1182                 case RC_LAST:
1183                         break; // this is just a dummy
1184                 }
1185         }
1186
1187         /// Update converters data-structures
1188         theConverters().update(formats);
1189         theConverters().buildGraph();
1190
1191         return 0;
1192 }
1193
1194
1195 void LyXRC::write(FileName const & filename, bool ignore_system_lyxrc) const
1196 {
1197         ofstream ofs(filename.toFilesystemEncoding().c_str());
1198         if (ofs)
1199                 write(ofs, ignore_system_lyxrc);
1200 }
1201
1202
1203 void LyXRC::print() const
1204 {
1205         if (lyxerr.debugging())
1206                 write(lyxerr, false);
1207         else
1208                 write(cout, false);
1209 }
1210
1211
1212 class SameMover {
1213 public:
1214         typedef pair<string, SpecialisedMover> Data;
1215
1216         SameMover(Data const & comparison)
1217                 : comparison_(comparison) {}
1218
1219         bool operator()(Data const & data) const
1220         {
1221                 return data.first == comparison_.first &&
1222                         data.second.command() == comparison_.second.command();
1223         }
1224
1225 private:
1226         Data comparison_;
1227 };
1228
1229
1230 namespace {
1231
1232         // Escape \ and " so that LyXLex can read the string later
1233         string escapeCommand(string const & str) {
1234                 return subst(subst(str , "\\", "\\\\"), 
1235                              "\"", "\\\"");
1236         }
1237
1238 }
1239
1240
1241 void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) const
1242 {
1243         LyXRCTags tag = RC_LAST;
1244         
1245         if (!name.empty()) {
1246                 for (int i = 0; i != lyxrcCount; ++i)
1247                         if ("\\" + name == lyxrcTags[i].tag)
1248                                 tag = static_cast<LyXRCTags>(lyxrcTags[i].code);
1249         }
1250
1251         if (tag == RC_LAST)
1252                 os << "# LyX " << lyx_version
1253                    << " generated this file. If you want to make your own\n"
1254                    << "# modifications you should do them from inside LyX and save.\n"
1255                    << "\n";
1256
1257         // Why the switch you might ask. It is a trick to ensure that all
1258         // the elements in the LyXRCTags enum are handled. As you can see
1259         // there are no breaks at all. So it is just a huge fall-through.
1260         // The nice thing is that we will get a warning from the compiler
1261         // if we forget an element.
1262         switch (tag) {
1263         case RC_LAST:
1264         case RC_INPUT:
1265                 // input/include files are not done here
1266         case RC_BINDFILE:
1267                 if (ignore_system_lyxrc ||
1268                     bind_file != system_lyxrc.bind_file) {
1269                         string const path = os::external_path(bind_file);
1270                         os << "\\bind_file \"" << path << "\"\n";
1271                 }
1272                 if (tag != RC_LAST)
1273                         break;
1274
1275         case RC_DEFFILE:
1276                 if (ignore_system_lyxrc ||
1277                     def_file != system_lyxrc.def_file) {
1278                         string const path = os::external_path(def_file);
1279                         os << "\\def_file \"" << path << "\"\n";
1280                 }
1281                 if (tag != RC_LAST)
1282                         break;
1283
1284                 //
1285                 // Misc Section
1286                 //
1287                 os << "\n#\n"
1288                    << "# MISC SECTION ######################################\n"
1289                    << "#\n\n";
1290                 // bind files are not done here.
1291
1292         case RC_PATH_PREFIX:
1293                 if (ignore_system_lyxrc ||
1294                     path_prefix != system_lyxrc.path_prefix) {
1295                         os << "\\path_prefix \"" << path_prefix << "\"\n";
1296                 }
1297                 if (tag != RC_LAST)
1298                         break;
1299         case RC_UIFILE:
1300                 if (ignore_system_lyxrc ||
1301                     ui_file != system_lyxrc.ui_file) {
1302                         string const path = os::external_path(ui_file);
1303                         os << "\\ui_file \"" << path << "\"\n";
1304                 }
1305                 if (tag != RC_LAST)
1306                         break;
1307         case RC_AUTOREGIONDELETE:
1308                 if (ignore_system_lyxrc ||
1309                     auto_region_delete != system_lyxrc.auto_region_delete) {
1310                         os << "# Set to false to inhibit automatic replacement of\n"
1311                            << "# the current selection.\n"
1312                            << "\\auto_region_delete " << convert<string>(auto_region_delete)
1313                            << '\n';
1314                 }
1315                 if (tag != RC_LAST)
1316                         break;
1317         case RC_AUTORESET_OPTIONS:
1318                 if (ignore_system_lyxrc ||
1319                     auto_reset_options != system_lyxrc.auto_reset_options) {
1320                         os << "# Set to false to inhibit automatic reset of\n"
1321                            << "# the class options to defaults on class change.\n"
1322                            << "\\auto_reset_options "
1323                            << convert<string>(auto_reset_options)
1324                            << '\n';
1325                 }
1326                 if (tag != RC_LAST)
1327                         break;
1328         case RC_AUTOSAVE:
1329                 if (ignore_system_lyxrc ||
1330                     autosave != system_lyxrc.autosave) {
1331                         os << "# The time interval between auto-saves in seconds.\n"
1332                            << "\\autosave " << autosave << '\n';
1333                 }
1334                 if (tag != RC_LAST)
1335                         break;
1336         case RC_DISPLAY_GRAPHICS:
1337                 if (ignore_system_lyxrc ||
1338                     display_graphics != system_lyxrc.display_graphics) {
1339                         os << "# Display graphics within LyX\n"
1340                            << "# true|false\n"
1341                            << "\\display_graphics "
1342                            << (display_graphics ? "true" : "false")
1343                            << '\n';
1344                 }
1345                 if (tag != RC_LAST)
1346                         break;
1347         case RC_SORT_LAYOUTS:
1348                 if (ignore_system_lyxrc ||
1349                     sort_layouts != system_lyxrc.sort_layouts) {
1350                         os << "# Sort layouts alphabetically.\n"
1351                            << "\\sort_layouts " << convert<string>(sort_layouts) << '\n';
1352                 }
1353                 if (tag != RC_LAST)
1354                         break;
1355         case RC_GROUP_LAYOUTS:
1356                 if (ignore_system_lyxrc ||
1357                     group_layouts != system_lyxrc.group_layouts) {
1358                         os << "# Group layouts by their category.\n"
1359                            << "\\group_layouts " << convert<string>(group_layouts) << '\n';
1360                 }
1361                 if (tag != RC_LAST)
1362                         break;
1363         case RC_VIEWDVI_PAPEROPTION:
1364                 if (ignore_system_lyxrc ||
1365                     view_dvi_paper_option
1366                     != system_lyxrc.view_dvi_paper_option) {
1367                         os << "# Options used to specify paper size to the\n"
1368                            << "# view_dvi_command (e.g. -paper)\n"
1369                            << "\\view_dvi_paper_option \""
1370                            << view_dvi_paper_option << "\"\n";
1371                 }
1372                 if (tag != RC_LAST)
1373                         break;
1374         case RC_DEFAULT_PAPERSIZE:
1375                 if (ignore_system_lyxrc ||
1376                     default_papersize != system_lyxrc.default_papersize) {
1377                         os << "# The default papersize to use.\n"
1378                            << "\\default_papersize \"";
1379                         switch (default_papersize) {
1380                         case PAPER_DEFAULT:
1381                                 os << "default"; break;
1382                         case PAPER_USLETTER:
1383                                 os << "usletter"; break;
1384                         case PAPER_USLEGAL:
1385                                 os << "legal"; break;
1386                         case PAPER_USEXECUTIVE:
1387                                 os << "executive"; break;
1388                         case PAPER_A3:
1389                                 os << "a3"; break;
1390                         case PAPER_A4:
1391                                 os << "a4"; break;
1392                         case PAPER_A5:
1393                                 os << "a5"; break;
1394                         case PAPER_B5:
1395                                 os << "b5"; break;
1396                         case PAPER_CUSTOM:
1397                         case PAPER_B3:
1398                         case PAPER_B4: break;
1399                         }
1400                         os << "\"\n";
1401                 }
1402                 if (tag != RC_LAST)
1403                         break;
1404         case RC_CHKTEX_COMMAND:
1405                 if (ignore_system_lyxrc ||
1406                     chktex_command != system_lyxrc.chktex_command) {
1407                         os << "\\chktex_command \"" << escapeCommand(chktex_command) << "\"\n";
1408                 }
1409                 if (tag != RC_LAST)
1410                         break;
1411         case RC_BIBTEX_ALTERNATIVES: {
1412                 CommandSet::const_iterator it = bibtex_alternatives.begin();
1413                 CommandSet::const_iterator end = bibtex_alternatives.end();
1414                 for ( ; it != end; ++it) {
1415                         if (ignore_system_lyxrc
1416                             || !system_lyxrc.bibtex_alternatives.count(*it))
1417                                 os << "\\bibtex_alternatives \""
1418                                    << *it << "\"\n";
1419                 }
1420                 if (tag != RC_LAST)
1421                         break;
1422         }
1423         case RC_BIBTEX_COMMAND:
1424                 if (ignore_system_lyxrc ||
1425                     bibtex_command != system_lyxrc.bibtex_command) {
1426                         os << "\\bibtex_command \"" << escapeCommand(bibtex_command) << "\"\n";
1427                 }
1428                 if (tag != RC_LAST)
1429                         break;
1430         case RC_JBIBTEX_COMMAND:
1431                 if (ignore_system_lyxrc ||
1432                     jbibtex_command != system_lyxrc.jbibtex_command) {
1433                         os << "\\jbibtex_command \"" << escapeCommand(jbibtex_command) << "\"\n";
1434                 }
1435                 if (tag != RC_LAST)
1436                         break;
1437         case RC_INDEX_ALTERNATIVES: {
1438                 CommandSet::const_iterator it = index_alternatives.begin();
1439                 CommandSet::const_iterator end = index_alternatives.end();
1440                 for ( ; it != end; ++it) {
1441                         if (ignore_system_lyxrc
1442                             || !system_lyxrc.index_alternatives.count(*it))
1443                                 os << "\\index_alternatives \""
1444                                    << *it << "\"\n";
1445                 }
1446                 if (tag != RC_LAST)
1447                         break;
1448         }
1449         case RC_INDEX_COMMAND:
1450                 if (ignore_system_lyxrc ||
1451                     index_command != system_lyxrc.index_command) {
1452                         os << "\\index_command \"" << escapeCommand(index_command) << "\"\n";
1453                 }
1454                 if (tag != RC_LAST)
1455                         break;
1456         case RC_JINDEX_COMMAND:
1457                 if (ignore_system_lyxrc ||
1458                     jindex_command != system_lyxrc.jindex_command) {
1459                         os << "\\jindex_command \"" << escapeCommand(jindex_command) << "\"\n";
1460                 }
1461                 if (tag != RC_LAST)
1462                         break;
1463         case RC_SPLITINDEX_COMMAND:
1464                 if (ignore_system_lyxrc ||
1465                     splitindex_command != system_lyxrc.splitindex_command) {
1466                         os << "\\splitindex_command \"" << escapeCommand(splitindex_command) << "\"\n";
1467                 }
1468                 if (tag != RC_LAST)
1469                         break;
1470         case RC_NOMENCL_COMMAND:
1471                 if (ignore_system_lyxrc ||
1472                     nomencl_command != system_lyxrc.nomencl_command) {
1473                         os << "\\nomencl_command \"" << escapeCommand(nomencl_command) << "\"\n";
1474                 }
1475                 if (tag != RC_LAST)
1476                         break;
1477         case RC_TEX_EXPECTS_WINDOWS_PATHS:
1478                 if (ignore_system_lyxrc ||
1479                     windows_style_tex_paths != system_lyxrc.windows_style_tex_paths) {
1480                         os << "\\tex_expects_windows_paths "
1481                            << convert<string>(windows_style_tex_paths) << '\n';
1482                 }
1483                 if (tag != RC_LAST)
1484                         break;
1485         case RC_TEX_ALLOWS_SPACES:
1486                 if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
1487                         os << "\\tex_allows_spaces "
1488                            << convert<string>(tex_allows_spaces) << '\n';
1489                 }
1490                 if (tag != RC_LAST)
1491                         break;
1492         case RC_KBMAP:
1493                 if (ignore_system_lyxrc ||
1494                     use_kbmap != system_lyxrc.use_kbmap) {
1495                         os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1496                 }
1497                 if (tag != RC_LAST)
1498                         break;
1499         case RC_KBMAP_PRIMARY:
1500                 if (ignore_system_lyxrc ||
1501                     primary_kbmap != system_lyxrc.primary_kbmap) {
1502                         string const path = os::external_path(primary_kbmap);
1503                         os << "\\kbmap_primary \"" << path << "\"\n";
1504                 }
1505                 if (tag != RC_LAST)
1506                         break;
1507         case RC_KBMAP_SECONDARY:
1508                 if (ignore_system_lyxrc ||
1509                     secondary_kbmap != system_lyxrc.secondary_kbmap) {
1510                         string const path = os::external_path(secondary_kbmap);
1511                         os << "\\kbmap_secondary \"" << path << "\"\n";
1512                 }
1513                 if (tag != RC_LAST)
1514                         break;
1515         case RC_SERVERPIPE:
1516                 if (ignore_system_lyxrc ||
1517                     lyxpipes != system_lyxrc.lyxpipes) {
1518                         string const path = os::external_path(lyxpipes);
1519                         os << "\\serverpipe \"" << path << "\"\n";
1520                 }
1521                 if (tag != RC_LAST)
1522                         break;
1523         case RC_DATE_INSERT_FORMAT:
1524                 if (ignore_system_lyxrc ||
1525                     date_insert_format != system_lyxrc.date_insert_format) {
1526                         os << "\\date_insert_format \"" << date_insert_format
1527                            << "\"\n";
1528                 }
1529                 if (tag != RC_LAST)
1530                         break;
1531
1532         case RC_USER_NAME:
1533                 os << "\\user_name \"" << user_name << "\"\n";
1534                 if (tag != RC_LAST)
1535                         break;
1536
1537         case RC_USER_EMAIL:
1538                 os << "\\user_email \"" << user_email << "\"\n";
1539                 if (tag != RC_LAST)
1540                         break;
1541
1542         case RC_SHOW_BANNER:
1543                 if (ignore_system_lyxrc ||
1544                     show_banner != system_lyxrc.show_banner) {
1545                         os << "\\show_banner " << convert<string>(show_banner) << '\n';
1546                 }
1547                 if (tag != RC_LAST)
1548                         break;
1549
1550         case RC_PREVIEW:
1551                 if (ignore_system_lyxrc ||
1552                     preview != system_lyxrc.preview) {
1553                         string status;
1554                         switch (preview) {
1555                         case PREVIEW_ON:
1556                                 status = "on";
1557                                 break;
1558                         case PREVIEW_NO_MATH:
1559                                 status = "no_math";
1560                                 break;
1561                         case PREVIEW_OFF:
1562                                 status = "off";
1563                                 break;
1564                         }
1565                         os << "\\preview " << status << '\n';
1566                 }
1567                 if (tag != RC_LAST)
1568                         break;
1569
1570         case RC_PREVIEW_HASHED_LABELS:
1571                 if (ignore_system_lyxrc ||
1572                     preview_hashed_labels !=
1573                     system_lyxrc.preview_hashed_labels) {
1574                         os << "\\preview_hashed_labels "
1575                            << convert<string>(preview_hashed_labels) << '\n';
1576                 }
1577                 if (tag != RC_LAST)
1578                         break;
1579
1580         case RC_PREVIEW_SCALE_FACTOR:
1581                 if (ignore_system_lyxrc ||
1582                     preview_scale_factor != system_lyxrc.preview_scale_factor) {
1583                         os << "\\preview_scale_factor "
1584                            << preview_scale_factor << '\n';
1585                 }
1586                 if (tag != RC_LAST)
1587                         break;
1588
1589         case RC_USE_CONVERTER_CACHE:
1590                 if (ignore_system_lyxrc ||
1591                     use_converter_cache != system_lyxrc.use_converter_cache) {
1592                         os << "\\use_converter_cache "
1593                            << convert<string>(use_converter_cache) << '\n';
1594                 }
1595                 if (tag != RC_LAST)
1596                         break;
1597
1598         case RC_CONVERTER_CACHE_MAXAGE:
1599                 if (ignore_system_lyxrc ||
1600                     converter_cache_maxage != system_lyxrc.converter_cache_maxage) {
1601                         os << "\\converter_cache_maxage "
1602                            << converter_cache_maxage << '\n';
1603                 }
1604                 if (tag != RC_LAST)
1605                         break;
1606
1607                 os << "\n#\n"
1608                    << "# SCREEN & FONTS SECTION ############################\n"
1609                    << "#\n\n";
1610
1611         case RC_SCREEN_DPI:
1612                 if (ignore_system_lyxrc ||
1613                     dpi != system_lyxrc.dpi) {
1614                         os << "\\screen_dpi " << dpi << '\n';
1615                 }
1616                 if (tag != RC_LAST)
1617                         break;
1618         case RC_SCREEN_ZOOM:
1619                 if (ignore_system_lyxrc ||
1620                     zoom != system_lyxrc.zoom) {
1621                         os << "\\screen_zoom " << zoom << '\n';
1622                 }
1623                 if (tag != RC_LAST)
1624                         break;
1625         case RC_GEOMETRY_SESSION:
1626                 if (ignore_system_lyxrc ||
1627                     allow_geometry_session != system_lyxrc.allow_geometry_session) {
1628                         os << "\\allow_geometry_session " << convert<string>(allow_geometry_session)
1629                            << '\n';
1630                 }
1631                 if (tag != RC_LAST)
1632                         break;
1633         case RC_CURSOR_FOLLOWS_SCROLLBAR:
1634                 if (ignore_system_lyxrc ||
1635                     cursor_follows_scrollbar
1636                     != system_lyxrc.cursor_follows_scrollbar) {
1637                         os << "\\cursor_follows_scrollbar "
1638                            << convert<string>(cursor_follows_scrollbar) << '\n';
1639                 }
1640                 if (tag != RC_LAST)
1641                         break;
1642         case RC_SCROLL_BELOW_DOCUMENT:
1643                 if (ignore_system_lyxrc ||
1644                     scroll_below_document
1645                     != system_lyxrc.scroll_below_document) {
1646                         os << "\\scroll_below_document "
1647                            << convert<string>(scroll_below_document) << '\n';
1648                 }
1649                 if (tag != RC_LAST)
1650                         break;
1651         case RC_PARAGRAPH_MARKERS:
1652                 if (ignore_system_lyxrc ||
1653                         paragraph_markers
1654                     != system_lyxrc.paragraph_markers) {
1655                         os << "\\paragraph_markers "
1656                            << convert<string>(paragraph_markers) << '\n';
1657                 }
1658                 if (tag != RC_LAST)
1659                         break;
1660         case RC_MAC_LIKE_WORD_MOVEMENT:
1661                 if (ignore_system_lyxrc ||
1662                     mac_like_word_movement
1663                     != system_lyxrc.mac_like_word_movement) {
1664                         os << "\\mac_like_word_movement "
1665                            << convert<string>(mac_like_word_movement) << '\n';
1666                 }
1667                 if (tag != RC_LAST)
1668                         break;
1669         case RC_MACRO_EDIT_STYLE:
1670                 if (ignore_system_lyxrc ||
1671                     macro_edit_style
1672                     != system_lyxrc.macro_edit_style) {
1673                         os << "\\macro_edit_style ";
1674                         switch (macro_edit_style) {
1675                         case MACRO_EDIT_INLINE_BOX: os << "0\n"; break;
1676                         case MACRO_EDIT_INLINE: os << "1\n"; break;
1677                         case MACRO_EDIT_LIST: os << "2\n"; break;
1678                         }
1679                 }
1680                 if (tag != RC_LAST)
1681                         break;
1682         case RC_DIALOGS_ICONIFY_WITH_MAIN:
1683                 if (ignore_system_lyxrc ||
1684                     dialogs_iconify_with_main
1685                    != system_lyxrc.dialogs_iconify_with_main) {
1686                         os << "\\dialogs_iconify_with_main "
1687                           <<  convert<string>(dialogs_iconify_with_main) << '\n';
1688                 }
1689                 if (tag != RC_LAST)
1690                         break;
1691         case RC_SCREEN_FONT_ROMAN:
1692                 if (ignore_system_lyxrc ||
1693                     roman_font_name != system_lyxrc.roman_font_name) {
1694                         os << "\\screen_font_roman \"" << roman_font_name
1695                            << "\"\n";
1696                 }
1697                 if (tag != RC_LAST)
1698                         break;
1699         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1700                 if (ignore_system_lyxrc ||
1701                     roman_font_foundry != system_lyxrc.roman_font_foundry) {
1702                         os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1703                            << "\"\n";
1704                 }
1705                 if (tag != RC_LAST)
1706                         break;
1707         case RC_SCREEN_FONT_SANS:
1708                 if (ignore_system_lyxrc ||
1709                     sans_font_name != system_lyxrc.sans_font_name) {
1710                         os << "\\screen_font_sans \"" << sans_font_name
1711                            << "\"\n";
1712                 }
1713                 if (tag != RC_LAST)
1714                         break;
1715         case RC_SCREEN_FONT_SANS_FOUNDRY:
1716                 if (ignore_system_lyxrc ||
1717                     sans_font_foundry != system_lyxrc.sans_font_foundry) {
1718                         os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1719                            << "\"\n";
1720                 }
1721                 if (tag != RC_LAST)
1722                         break;
1723         case RC_SCREEN_FONT_TYPEWRITER:
1724                 if (ignore_system_lyxrc ||
1725                     typewriter_font_name != system_lyxrc.typewriter_font_name) {
1726                         os << "\\screen_font_typewriter \""
1727                            << typewriter_font_name << "\"\n";
1728                 }
1729                 if (tag != RC_LAST)
1730                         break;
1731         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1732                 if (ignore_system_lyxrc ||
1733                     typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1734                         os << "\\screen_font_typewriter_foundry \""
1735                            << typewriter_font_foundry << "\"\n";
1736                 }
1737                 if (tag != RC_LAST)
1738                         break;
1739
1740         case RC_SCREEN_FONT_SCALABLE:
1741                 if (ignore_system_lyxrc ||
1742                     use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1743                         os << "\\screen_font_scalable "
1744                            << convert<string>(use_scalable_fonts)
1745                            << '\n';
1746                 }
1747                 if (tag != RC_LAST)
1748                         break;
1749         case RC_SCREEN_FONT_SIZES:
1750                 if (ignore_system_lyxrc ||
1751                     font_sizes[FONT_SIZE_TINY]
1752                     != system_lyxrc.font_sizes[FONT_SIZE_TINY] ||
1753                     font_sizes[FONT_SIZE_SCRIPT]
1754                     != system_lyxrc.font_sizes[FONT_SIZE_SCRIPT] ||
1755                     font_sizes[FONT_SIZE_FOOTNOTE]
1756                     != system_lyxrc.font_sizes[FONT_SIZE_FOOTNOTE] ||
1757                     font_sizes[FONT_SIZE_SMALL]
1758                     != system_lyxrc.font_sizes[FONT_SIZE_SMALL] ||
1759                     font_sizes[FONT_SIZE_NORMAL]
1760                     != system_lyxrc.font_sizes[FONT_SIZE_NORMAL] ||
1761                     font_sizes[FONT_SIZE_LARGE]
1762                     != system_lyxrc.font_sizes[FONT_SIZE_LARGE] ||
1763                     font_sizes[FONT_SIZE_LARGER]
1764                     != system_lyxrc.font_sizes[FONT_SIZE_LARGER] ||
1765                     font_sizes[FONT_SIZE_LARGEST]
1766                     != system_lyxrc.font_sizes[FONT_SIZE_LARGEST] ||
1767                     font_sizes[FONT_SIZE_HUGE]
1768                     != system_lyxrc.font_sizes[FONT_SIZE_HUGE] ||
1769                     font_sizes[FONT_SIZE_HUGER]
1770                     != system_lyxrc.font_sizes[FONT_SIZE_HUGER]) {
1771                         os.setf(ios::fixed);
1772                         os.precision(2);
1773                         os << "\\screen_font_sizes"
1774                            << ' ' << font_sizes[FONT_SIZE_TINY]
1775                            << ' ' << font_sizes[FONT_SIZE_SCRIPT]
1776                            << ' ' << font_sizes[FONT_SIZE_FOOTNOTE]
1777                            << ' ' << font_sizes[FONT_SIZE_SMALL]
1778                            << ' ' << font_sizes[FONT_SIZE_NORMAL]
1779                            << ' ' << font_sizes[FONT_SIZE_LARGE]
1780                            << ' ' << font_sizes[FONT_SIZE_LARGER]
1781                            << ' ' << font_sizes[FONT_SIZE_LARGEST]
1782                            << ' ' << font_sizes[FONT_SIZE_HUGE]
1783                            << ' ' << font_sizes[FONT_SIZE_HUGER]
1784                            << '\n';
1785                 }
1786                 if (tag != RC_LAST)
1787                         break;
1788         case RC_FULL_SCREEN_LIMIT:
1789                 if (ignore_system_lyxrc ||
1790                     full_screen_limit != system_lyxrc.full_screen_limit) {
1791                         os << "\\fullscreen_limit "
1792                            << convert<string>(full_screen_limit)
1793                            << '\n';
1794                 }
1795                 if (tag != RC_LAST)
1796                         break;
1797         case RC_FULL_SCREEN_TOOLBARS:
1798                 if (ignore_system_lyxrc ||
1799                     full_screen_toolbars != system_lyxrc.full_screen_toolbars) {
1800                         os << "\\fullscreen_toolbars "
1801                            << convert<string>(full_screen_toolbars)
1802                            << '\n';
1803                 }
1804                 if (tag != RC_LAST)
1805                         break;
1806         case RC_FULL_SCREEN_SCROLLBAR:
1807                 if (ignore_system_lyxrc ||
1808                     full_screen_scrollbar != system_lyxrc.full_screen_scrollbar) {
1809                         os << "\\fullscreen_scrollbar "
1810                            << convert<string>(full_screen_scrollbar)
1811                            << '\n';
1812                 }
1813                 if (tag != RC_LAST)
1814                         break;
1815         case RC_FULL_SCREEN_TABBAR:
1816                 if (ignore_system_lyxrc ||
1817                     full_screen_tabbar != system_lyxrc.full_screen_tabbar) {
1818                         os << "\\fullscreen_tabbar "
1819                            << convert<string>(full_screen_tabbar)
1820                            << '\n';
1821                 }
1822                 if (tag != RC_LAST)
1823                         break;
1824         case RC_FULL_SCREEN_MENUBAR:
1825                 if (ignore_system_lyxrc ||
1826                     full_screen_menubar != system_lyxrc.full_screen_menubar) {
1827                         os << "\\fullscreen_menubar "
1828                            << convert<string>(full_screen_menubar)
1829                            << '\n';
1830                 }
1831                 if (tag != RC_LAST)
1832                         break;
1833         case RC_FULL_SCREEN_WIDTH:
1834                 if (ignore_system_lyxrc ||
1835                     full_screen_width != system_lyxrc.full_screen_width) {
1836                         os << "\\fullscreen_width "
1837                            << convert<string>(full_screen_width)
1838                            << '\n';
1839                 }
1840                 if (tag != RC_LAST)
1841                         break;
1842         case RC_OPEN_BUFFERS_IN_TABS:
1843                 if (ignore_system_lyxrc ||
1844                     open_buffers_in_tabs != system_lyxrc.open_buffers_in_tabs) {
1845                         os << "\\open_buffers_in_tabs "
1846                            << convert<string>(open_buffers_in_tabs)
1847                            << '\n';
1848                 }
1849                 if (tag != RC_LAST)
1850                         break;
1851         case RC_SINGLE_CLOSE_TAB_BUTTON:
1852                 if (ignore_system_lyxrc ||
1853                     single_close_tab_button != system_lyxrc.single_close_tab_button) {
1854                         os << "\\single_close_tab_button "
1855                            << convert<string>(single_close_tab_button)
1856                            << '\n';
1857                 }
1858                 if (tag != RC_LAST)
1859                         break;
1860         case RC_FORWARD_SEARCH:
1861                 if (ignore_system_lyxrc ||
1862                     forward_search != system_lyxrc.forward_search) {
1863                         os << "\\forward_search \"" << escapeCommand(forward_search) << "\"\n";
1864                 }
1865                 if (tag != RC_LAST)
1866                         break;
1867
1868         os << "\n#\n"
1869                         << "# COLOR SECTION ###################################\n"
1870                         << "#\n\n";
1871
1872         case RC_SET_COLOR:
1873                 for (int i = 0; i < Color_ignore; ++i) {
1874                         ColorCode lc = static_cast<ColorCode>(i);
1875                         string const col = lcolor.getX11Name(lc);
1876                         if (ignore_system_lyxrc
1877                             || col != system_lcolor.getX11Name(lc)) {
1878                                 os << "\\set_color \""
1879                                    << lcolor.getLyXName(lc) << "\" \""
1880                                    << col << "\"\n";
1881                         }
1882                 }
1883                 if (tag != RC_LAST)
1884                         break;
1885
1886                 os << "\n#\n"
1887                    << "# PRINTER SECTION ###################################\n"
1888                    << "#\n\n";
1889
1890         case RC_PRINTER:
1891                 if (ignore_system_lyxrc ||
1892                     printer != system_lyxrc.printer) {
1893                         os << "\\printer \"" << printer << "\"\n";
1894                 }
1895                 if (tag != RC_LAST)
1896                         break;
1897         case RC_PRINT_ADAPTOUTPUT:
1898                 if (ignore_system_lyxrc ||
1899                     print_adapt_output != system_lyxrc.print_adapt_output) {
1900                         os << "\\print_adapt_output "
1901                            << convert<string>(print_adapt_output)
1902                            << '\n';
1903                 }
1904                 if (tag != RC_LAST)
1905                         break;
1906         case RC_PRINT_COMMAND:
1907                 if (ignore_system_lyxrc ||
1908                     print_command != system_lyxrc.print_command) {
1909                         os << "\\print_command \"" << escapeCommand(print_command) << "\"\n";
1910                 }
1911                 if (tag != RC_LAST)
1912                         break;
1913         case RC_PRINTEXSTRAOPTIONS:
1914                 if (ignore_system_lyxrc ||
1915                     print_extra_options != system_lyxrc.print_extra_options) {
1916                         os << "\\print_extra_options \"" << print_extra_options
1917                            << "\"\n";
1918                 }
1919                 if (tag != RC_LAST)
1920                         break;
1921         case RC_PRINTSPOOL_COMMAND:
1922                 if (ignore_system_lyxrc ||
1923                     print_spool_command != system_lyxrc.print_spool_command) {
1924                         os << "\\print_spool_command \"" << escapeCommand(print_spool_command)
1925                            << "\"\n";
1926                 }
1927                 if (tag != RC_LAST)
1928                         break;
1929         case RC_PRINTSPOOL_PRINTERPREFIX:
1930                 if (ignore_system_lyxrc ||
1931                     print_spool_printerprefix
1932                     != system_lyxrc.print_spool_printerprefix) {
1933                         os << "\\print_spool_printerprefix \""
1934                            << print_spool_printerprefix << "\"\n";
1935                 }
1936                 if (tag != RC_LAST)
1937                         break;
1938         case RC_PRINTEVENPAGEFLAG:
1939                 if (ignore_system_lyxrc ||
1940                     print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1941                         os << "\\print_evenpage_flag \"" << print_evenpage_flag
1942                            << "\"\n";
1943                 }
1944                 if (tag != RC_LAST)
1945                         break;
1946         case RC_PRINTODDPAGEFLAG:
1947                 if (ignore_system_lyxrc ||
1948                     print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1949                         os << "\\print_oddpage_flag \"" << print_oddpage_flag
1950                            << "\"\n";
1951                 }
1952                 if (tag != RC_LAST)
1953                         break;
1954         case RC_PRINTREVERSEFLAG:
1955                 if (ignore_system_lyxrc ||
1956                     print_reverse_flag != system_lyxrc.print_reverse_flag) {
1957                         os << "\\print_reverse_flag \"" << print_reverse_flag
1958                            << "\"\n";
1959                 }
1960                 if (tag != RC_LAST)
1961                         break;
1962         case RC_PRINTLANDSCAPEFLAG:
1963                 if (ignore_system_lyxrc ||
1964                     print_landscape_flag != system_lyxrc.print_landscape_flag) {
1965                         os << "\\print_landscape_flag \"" << print_landscape_flag
1966                            << "\"\n";
1967                 }
1968                 if (tag != RC_LAST)
1969                         break;
1970         case RC_PRINTPAGERANGEFLAG:
1971                 if (ignore_system_lyxrc ||
1972                     print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1973                         os << "\\print_pagerange_flag \"" << print_pagerange_flag
1974                            << "\"\n";
1975                 }
1976                 if (tag != RC_LAST)
1977                         break;
1978         case RC_PRINTCOPIESFLAG:
1979                 if (ignore_system_lyxrc ||
1980                     print_copies_flag != system_lyxrc.print_copies_flag) {
1981                         os << "\\print_copies_flag \"" << print_copies_flag
1982                            << "\"\n";
1983                 }
1984                 if (tag != RC_LAST)
1985                         break;
1986         case RC_PRINTCOLLCOPIESFLAG:
1987                 if (ignore_system_lyxrc ||
1988                     print_collcopies_flag
1989                     != system_lyxrc.print_collcopies_flag) {
1990                         os << "\\print_collcopies_flag \""
1991                            << print_collcopies_flag
1992                            << "\"\n";
1993                 }
1994                 if (tag != RC_LAST)
1995                         break;
1996         case RC_PRINTPAPERFLAG:
1997                 if (ignore_system_lyxrc ||
1998                     print_paper_flag != system_lyxrc.print_paper_flag) {
1999                         os << "\\print_paper_flag \"" << print_paper_flag
2000                            << "\"\n";
2001                 }
2002                 if (tag != RC_LAST)
2003                         break;
2004         case RC_PRINTPAPERDIMENSIONFLAG:
2005                 if (ignore_system_lyxrc ||
2006                     print_paper_dimension_flag
2007                     != system_lyxrc.print_paper_dimension_flag) {
2008                         os << "\\print_paper_dimension_flag \""
2009                            << print_paper_dimension_flag << "\"\n";
2010                 }
2011                 if (tag != RC_LAST)
2012                         break;
2013         case RC_PRINTTOPRINTER:
2014                 if (ignore_system_lyxrc ||
2015                     print_to_printer != system_lyxrc.print_to_printer) {
2016                         os << "\\print_to_printer \"" << print_to_printer
2017                            << "\"\n";
2018                 }
2019                 if (tag != RC_LAST)
2020                         break;
2021         case RC_PRINTTOFILE:
2022                 if (ignore_system_lyxrc ||
2023                     print_to_file != system_lyxrc.print_to_file) {
2024                         string const path = os::external_path(print_to_file);
2025                         os << "\\print_to_file \"" << path << "\"\n";
2026                 }
2027                 if (tag != RC_LAST)
2028                         break;
2029         case RC_PRINTFILEEXTENSION:
2030                 if (ignore_system_lyxrc ||
2031                     print_file_extension != system_lyxrc.print_file_extension) {
2032                         os << "\\print_file_extension \""
2033                            << print_file_extension
2034                            << "\"\n";
2035                 }
2036                 if (tag != RC_LAST)
2037                         break;
2038
2039                 os << "\n#\n"
2040                    << "# TEX SECTION #######################################\n"
2041                    << "#\n\n";
2042
2043         case RC_FONT_ENCODING:
2044                 if (ignore_system_lyxrc ||
2045                     fontenc != system_lyxrc.fontenc) {
2046                         os << "\\font_encoding \"" << fontenc << "\"\n";
2047                 }
2048                 if (tag != RC_LAST)
2049                         break;
2050
2051                 os << "\n#\n"
2052                    << "# FILE SECTION ######################################\n"
2053                    << "#\n\n";
2054
2055         case RC_DOCUMENTPATH:
2056                 if (ignore_system_lyxrc ||
2057                     document_path != system_lyxrc.document_path) {
2058                         string const path = os::external_path(document_path);
2059                         os << "\\document_path \"" << path << "\"\n";
2060                 }
2061                 if (tag != RC_LAST)
2062                         break;
2063         case RC_USELASTFILEPOS:
2064                 if (ignore_system_lyxrc ||
2065                     use_lastfilepos != system_lyxrc.use_lastfilepos) {
2066                         os << "\\use_lastfilepos " << convert<string>(use_lastfilepos)
2067                            << '\n';
2068                 }
2069                 if (tag != RC_LAST)
2070                         break;
2071         case RC_LOADSESSION:
2072                 if (ignore_system_lyxrc ||
2073                     load_session != system_lyxrc.load_session) {
2074                         os << "\\load_session " << convert<string>(load_session)
2075                            << "\n";
2076                 }
2077                 if (tag != RC_LAST)
2078                         break;
2079         case RC_MOUSE_WHEEL_SPEED:
2080                 if (ignore_system_lyxrc ||
2081                     mouse_wheel_speed != system_lyxrc.mouse_wheel_speed) {
2082                         os << "\\mouse_wheel_speed " << mouse_wheel_speed << '\n';
2083                 }
2084                 if (tag != RC_LAST)
2085                         break;
2086         case RC_COMPLETION_INLINE_DELAY:
2087                 if (ignore_system_lyxrc ||
2088                     completion_inline_delay != system_lyxrc.completion_inline_delay) {
2089                         os << "\\completion_inline_delay " << completion_inline_delay << '\n';
2090                 }
2091                 if (tag != RC_LAST)
2092                         break;
2093         case RC_COMPLETION_INLINE_MATH:
2094                 if (ignore_system_lyxrc ||
2095                     completion_inline_math != system_lyxrc.completion_inline_math) {
2096                         os << "\\completion_inline_math "
2097                                 << convert<string>(completion_inline_math) << '\n';
2098                 }
2099                 if (tag != RC_LAST)
2100                         break;
2101         case RC_COMPLETION_INLINE_TEXT:
2102                 if (ignore_system_lyxrc ||
2103                     completion_inline_text != system_lyxrc.completion_inline_text) {
2104                         os << "\\completion_inline_text "
2105                                 << convert<string>(completion_inline_text) << '\n';
2106                 }
2107                 if (tag != RC_LAST)
2108                         break;
2109         case RC_COMPLETION_INLINE_DOTS:
2110                 if (ignore_system_lyxrc ||
2111                     completion_inline_dots != system_lyxrc.completion_inline_dots) {
2112                         os << "\\completion_inline_dots "
2113                                 << convert<string>(completion_inline_dots) << '\n';
2114                 }
2115                 if (tag != RC_LAST)
2116                         break;
2117         case RC_AUTOCORRECTION_MATH:
2118                 if (ignore_system_lyxrc ||
2119                     autocorrection_math != system_lyxrc.autocorrection_math) {
2120                         os << "\\autocorrection_math "
2121                                 << convert<string>(autocorrection_math) << '\n';
2122                 }
2123                 if (tag != RC_LAST)
2124                         break;
2125         case RC_COMPLETION_POPUP_DELAY:
2126                 if (ignore_system_lyxrc ||
2127                     completion_popup_delay != system_lyxrc.completion_popup_delay) {
2128                         os << "\\completion_popup_delay " << completion_popup_delay << '\n';
2129                 }
2130                 if (tag != RC_LAST)
2131                         break;
2132         case RC_COMPLETION_POPUP_MATH:
2133                 if (ignore_system_lyxrc ||
2134                     completion_popup_math != system_lyxrc.completion_popup_math) {
2135                         os << "\\completion_popup_math "
2136                                 << convert<string>(completion_popup_math) << '\n';
2137                 }
2138                 if (tag != RC_LAST)
2139                         break;
2140         case RC_COMPLETION_POPUP_TEXT:
2141                 if (ignore_system_lyxrc ||
2142                     completion_popup_text != system_lyxrc.completion_popup_text) {
2143                         os << "\\completion_popup_text "
2144                                 << convert<string>(completion_popup_text) << '\n';
2145                 }
2146                 if (tag != RC_LAST)
2147                         break;
2148         case RC_COMPLETION_CURSOR_TEXT:
2149                 if (ignore_system_lyxrc ||
2150                     completion_cursor_text != system_lyxrc.completion_cursor_text) {
2151                         os << "\\completion_cursor_text "
2152                            << convert<string>(completion_cursor_text) << '\n';
2153                 }
2154                 if (tag != RC_LAST)
2155                         break;
2156         case RC_COMPLETION_POPUP_AFTER_COMPLETE:
2157                 if (ignore_system_lyxrc ||
2158                     completion_popup_after_complete
2159                     != system_lyxrc.completion_popup_after_complete) {
2160                         os << "\\completion_popup_after_complete "
2161                                 << convert<string>(completion_popup_after_complete) << '\n';
2162                 }
2163                 if (tag != RC_LAST)
2164                         break;
2165         case RC_NUMLASTFILES:
2166                 if (ignore_system_lyxrc ||
2167                     num_lastfiles != system_lyxrc.num_lastfiles) {
2168                         os << "\\num_lastfiles " << num_lastfiles << '\n';
2169                 }
2170                 if (tag != RC_LAST)
2171                         break;
2172         case RC_CHECKLASTFILES:
2173                 if (ignore_system_lyxrc ||
2174                     check_lastfiles != system_lyxrc.check_lastfiles) {
2175                         os << "\\check_lastfiles " << convert<string>(check_lastfiles)
2176                            << '\n';
2177                 }
2178                 if (tag != RC_LAST)
2179                         break;
2180         case RC_EXAMPLEPATH:
2181                 if (ignore_system_lyxrc ||
2182                     example_path != system_lyxrc.example_path) {
2183                         string const path = os::external_path(example_path);
2184                         os << "\\example_path \"" << path << "\"\n";
2185                 }
2186                 if (tag != RC_LAST)
2187                         break;
2188         case RC_TEMPLATEPATH:
2189                 if (ignore_system_lyxrc ||
2190                     template_path != system_lyxrc.template_path) {
2191                         string const path = os::external_path(template_path);
2192                         os << "\\template_path \"" << path << "\"\n";
2193                 }
2194                 if (tag != RC_LAST)
2195                         break;
2196         case RC_TEMPDIRPATH:
2197                 if (ignore_system_lyxrc ||
2198                     tempdir_path != system_lyxrc.tempdir_path) {
2199                         string const path = os::external_path(tempdir_path);
2200                         os << "\\tempdir_path \"" << path << "\"\n";
2201                 }
2202                 if (tag != RC_LAST)
2203                         break;
2204         case RC_THESAURUSDIRPATH:
2205                 if (ignore_system_lyxrc ||
2206                     thesaurusdir_path != system_lyxrc.thesaurusdir_path) {
2207                         string const path = os::external_path(thesaurusdir_path);
2208                         os << "\\thesaurusdir_path \"" << path << "\"\n";
2209                 }
2210                 if (tag != RC_LAST)
2211                         break;
2212         case RC_HUNSPELLDIR_PATH:
2213                 if (ignore_system_lyxrc ||
2214                     hunspelldir_path != system_lyxrc.hunspelldir_path) {
2215                         string const path = os::external_path(hunspelldir_path);
2216                         os << "\\hunspelldir_path \"" << path << "\"\n";
2217                 }
2218                 if (tag != RC_LAST)
2219                         break;
2220         case RC_USETEMPDIR:
2221                 if (tag != RC_LAST)
2222                         break;
2223                 // Ignore it
2224         case RC_PLAINTEXT_ROFF_COMMAND: // Obsoleted in 2.0
2225                 if (tag != RC_LAST)
2226                         break;
2227         case RC_PLAINTEXT_LINELEN:
2228                 if (ignore_system_lyxrc ||
2229                     plaintext_linelen != system_lyxrc.plaintext_linelen) {
2230                         os << "\\plaintext_linelen " << plaintext_linelen << '\n';
2231                 }
2232                 if (tag != RC_LAST)
2233                         break;
2234         case RC_MAKE_BACKUP:
2235                 if (ignore_system_lyxrc ||
2236                     make_backup != system_lyxrc.make_backup) {
2237                         os << "\\make_backup " << convert<string>(make_backup) << '\n';
2238                 }
2239                 if (tag != RC_LAST)
2240                         break;
2241         case RC_SAVE_COMPRESSED:
2242                 if (ignore_system_lyxrc ||
2243                     save_compressed != system_lyxrc.save_compressed) {
2244                         os << "\\save_compressed " << convert<string>(save_compressed) << '\n';
2245                 }
2246                 if (tag != RC_LAST)
2247                         break;
2248         case RC_BACKUPDIR_PATH:
2249                 if (ignore_system_lyxrc ||
2250                     backupdir_path != system_lyxrc.backupdir_path) {
2251                         string const path = os::external_path(backupdir_path);
2252                         os << "\\backupdir_path \"" << path << "\"\n";
2253                 }
2254                 if (tag != RC_LAST)
2255                         break;
2256
2257                 os << "\n#\n"
2258                    << "# PLAIN TEXT EXPORT SECTION ##############################\n"
2259                    << "#\n\n";
2260
2261                 os << "\n#\n"
2262                    << "# SPELLCHECKER SECTION ##############################\n"
2263                    << "#\n\n";
2264
2265         case RC_SPELL_COMMAND:
2266         case RC_USE_SPELL_LIB:
2267                 // Obsoleted in 2.0
2268                 if (tag != RC_LAST)
2269                         break;
2270         case RC_ACCEPT_COMPOUND:
2271                 if (ignore_system_lyxrc ||
2272                     spellchecker_accept_compound != system_lyxrc.spellchecker_accept_compound) {
2273                         os << "\\accept_compound " << convert<string>(spellchecker_accept_compound)
2274                            << '\n';
2275                 }
2276                 if (tag != RC_LAST)
2277                         break;
2278         case RC_USE_ALT_LANG:
2279                 // Obsoleted in 2.0
2280                 if (tag != RC_LAST)
2281                         break;
2282         case RC_ALT_LANG:
2283                 if (ignore_system_lyxrc ||
2284                     spellchecker_alt_lang != system_lyxrc.spellchecker_alt_lang) {
2285                         os << "\\alternate_language \"" << spellchecker_alt_lang
2286                            << "\"\n";
2287                 }
2288                 if (tag != RC_LAST)
2289                         break;
2290         case RC_USE_ESC_CHARS:
2291                 if (tag != RC_LAST)
2292                         break;
2293         case RC_ESC_CHARS:
2294                 if (ignore_system_lyxrc ||
2295                     spellchecker_esc_chars != system_lyxrc.spellchecker_esc_chars) {
2296                         os << "\\escape_chars \"" << spellchecker_esc_chars << "\"\n";
2297                 }
2298                 if (tag != RC_LAST)
2299                         break;
2300         case RC_USE_PERS_DICT:
2301                 // obsoleted in 2.0
2302                 if (tag != RC_LAST)
2303                         break;
2304         case RC_USE_TOOLTIP:
2305                 if (ignore_system_lyxrc ||
2306                     use_tooltip != system_lyxrc.use_tooltip) {
2307                         os << "\\use_tooltip "
2308                            << convert<string>(use_tooltip)
2309                            << '\n';
2310                 }
2311                 if (tag != RC_LAST)
2312                         break;
2313         case RC_USE_PIXMAP_CACHE:
2314                 if (ignore_system_lyxrc ||
2315                     use_pixmap_cache != system_lyxrc.use_pixmap_cache) {
2316                         os << "\\use_pixmap_cache "
2317                            << convert<string>(use_pixmap_cache)
2318                            << '\n';
2319                 }
2320                 if (tag != RC_LAST)
2321                         break;
2322         case RC_PERS_DICT:
2323                 // obsoleted in 2.0
2324                 if (tag != RC_LAST)
2325                         break;
2326         case RC_USE_INP_ENC:
2327                 // obsoleted in 2.0
2328                 if (tag != RC_LAST)
2329                         break;
2330
2331                 os << "\n#\n"
2332                    << "# LANGUAGE SUPPORT SECTION ##########################\n"
2333                    << "#\n\n";
2334                 if (tag != RC_LAST)
2335                         break;
2336
2337         case RC_SPELLCHECKER:
2338                 if (ignore_system_lyxrc ||
2339                     spellchecker != system_lyxrc.spellchecker) {
2340                         os << "\\spellchecker " << spellchecker << '\n';
2341                 }
2342                 if (tag != RC_LAST)
2343                         break;
2344
2345         case RC_SPELLCHECK_CONTINUOUSLY:
2346                 if (ignore_system_lyxrc ||
2347                     spellcheck_continuously != system_lyxrc.spellcheck_continuously) {
2348                         os << "\\spellcheck_continuously " << convert<string>(spellcheck_continuously)
2349                            << '\n';
2350                 }
2351                 if (tag != RC_LAST)
2352                         break;
2353
2354         case RC_SPELLCHECK_NOTES:
2355                 if (ignore_system_lyxrc ||
2356                     spellcheck_notes != system_lyxrc.spellcheck_notes) {
2357                         os << "\\spellcheck_notes " << convert<string>(spellcheck_notes)
2358                            << '\n';
2359                 }
2360                 if (tag != RC_LAST)
2361                         break;
2362
2363         case RC_RTL_SUPPORT:
2364                 if (ignore_system_lyxrc ||
2365                     rtl_support != system_lyxrc.rtl_support) {
2366                         os << "\\rtl " << convert<string>(rtl_support) << '\n';
2367                 }
2368                 if (tag != RC_LAST)
2369                         break;
2370         case RC_VISUAL_CURSOR:
2371                 if (ignore_system_lyxrc ||
2372                         visual_cursor != system_lyxrc.visual_cursor) {
2373                         os << "\\visual_cursor " << convert<string>(visual_cursor) << '\n';
2374                 }
2375                 if (tag != RC_LAST)
2376                         break;
2377         case RC_LANGUAGE_PACKAGE:
2378                 if (ignore_system_lyxrc ||
2379                     language_package != system_lyxrc.language_package) {
2380                         os << "\\language_package \"" << language_package
2381                            << "\"\n";
2382                 }
2383                 if (tag != RC_LAST)
2384                         break;
2385         case RC_LANGUAGE_GLOBAL_OPTIONS:
2386                 if (ignore_system_lyxrc ||
2387                     language_global_options
2388                     != system_lyxrc.language_global_options) {
2389                         os << "\\language_global_options \""
2390                            << convert<string>(language_global_options)
2391                            << "\"\n";
2392                 }
2393                 if (tag != RC_LAST)
2394                         break;
2395         case RC_LANGUAGE_USE_BABEL:
2396                 if (ignore_system_lyxrc ||
2397                     language_use_babel != system_lyxrc.language_use_babel) {
2398                         os << "\\language_use_babel \""
2399                            << convert<string>(language_use_babel)
2400                            << "\"\n";
2401                 }
2402                 if (tag != RC_LAST)
2403                         break;
2404         case RC_LANGUAGE_COMMAND_BEGIN:
2405                 if (ignore_system_lyxrc ||
2406                     language_command_begin
2407                     != system_lyxrc.language_command_begin) {
2408                         os << "\\language_command_begin \""
2409                            << language_command_begin
2410                            << "\"\n";
2411                 }
2412                 if (tag != RC_LAST)
2413                         break;
2414         case RC_LANGUAGE_COMMAND_END:
2415                 if (ignore_system_lyxrc ||
2416                     language_command_end
2417                     != system_lyxrc.language_command_end) {
2418                         os << "\\language_command_end \"" << language_command_end
2419                            << "\"\n";
2420                 }
2421                 if (tag != RC_LAST)
2422                         break;
2423         case RC_LANGUAGE_COMMAND_LOCAL:
2424                 if (ignore_system_lyxrc ||
2425                     language_command_local
2426                     != system_lyxrc.language_command_local) {
2427                         os << "\\language_command_local \""
2428                            << language_command_local
2429                            << "\"\n";
2430                 }
2431                 if (tag != RC_LAST)
2432                         break;
2433         case RC_LANGUAGE_AUTO_BEGIN:
2434                 if (ignore_system_lyxrc ||
2435                     language_auto_begin != system_lyxrc.language_auto_begin) {
2436                         os << "\\language_auto_begin "
2437                            << convert<string>(language_auto_begin) << '\n';
2438                 }
2439                 if (tag != RC_LAST)
2440                         break;
2441         case RC_LANGUAGE_AUTO_END:
2442                 if (ignore_system_lyxrc ||
2443                     language_auto_end != system_lyxrc.language_auto_end) {
2444                         os << "\\language_auto_end "
2445                            << convert<string>(language_auto_end) << '\n';
2446                 }
2447                 if (tag != RC_LAST)
2448                         break;
2449         case RC_MARK_FOREIGN_LANGUAGE:
2450                 if (ignore_system_lyxrc ||
2451                     mark_foreign_language
2452                     != system_lyxrc.mark_foreign_language) {
2453                         os << "\\mark_foreign_language " <<
2454                                 convert<string>(mark_foreign_language) << '\n';
2455                 }
2456                 if (tag != RC_LAST)
2457                         break;
2458
2459                 os << "\n#\n"
2460                    << "# 2nd MISC SUPPORT SECTION ##########################\n"
2461                    << "#\n\n";
2462
2463         case RC_AUTO_NUMBER:
2464                 if (ignore_system_lyxrc ||
2465                     auto_number != system_lyxrc.auto_number) {
2466                         os << "\\auto_number " << convert<string>(auto_number) << '\n';
2467                 }
2468                 if (tag != RC_LAST)
2469                         break;
2470         case RC_DEFAULT_LANGUAGE:
2471                 if (ignore_system_lyxrc ||
2472                     default_language != system_lyxrc.default_language) {
2473                         os << "\\default_language " << default_language << '\n';
2474                 }
2475                 if (tag != RC_LAST)
2476                         break;
2477         case RC_GUI_LANGUAGE:
2478                 if (ignore_system_lyxrc ||
2479                     gui_language != system_lyxrc.gui_language) {
2480                         os << "\\gui_language " << gui_language << '\n';
2481                 }
2482                 if (tag != RC_LAST)
2483                         break;
2484
2485                 os << "\n#\n"
2486                    << "# FORMATS SECTION ##########################\n"
2487                    << "#\n\n";
2488
2489         case RC_FORMAT:
2490                 // New/modified formats
2491                 for (Formats::const_iterator cit = formats.begin();
2492                      cit != formats.end(); ++cit) {
2493                         Format const * format =
2494                                 system_formats.getFormat(cit->name());
2495                         if (!format ||
2496                             format->extension() != cit->extension() ||
2497                             format->prettyname() != cit->prettyname() ||
2498                             format->shortcut() != cit->shortcut() ||
2499                             format->viewer() != cit->viewer() ||
2500                             format->editor() != cit->editor() ||
2501                             format->documentFormat() != cit->documentFormat() ||
2502                             format->vectorFormat() != cit->vectorFormat()) {
2503                                 os << "\\format \"" << cit->name() << "\" \""
2504                                    << cit->extension() << "\" \""
2505                                    << cit->prettyname() << "\" \""
2506                                    << cit->shortcut() << "\" \""
2507                                    << escapeCommand(cit->viewer()) << "\" \""
2508                                    << escapeCommand(cit->editor()) << "\" \"";
2509                                 vector<string> flags;
2510                                 if (cit->documentFormat())
2511                                         flags.push_back("document");
2512                                 if (cit->vectorFormat())
2513                                         flags.push_back("vector");
2514                                 os << getStringFromVector(flags);
2515                                 os << "\"\n";
2516                         }
2517                 }
2518
2519                 // Look for deleted formats
2520                 for (Formats::const_iterator cit = system_formats.begin();
2521                      cit != system_formats.end(); ++cit)
2522                         if (!formats.getFormat(cit->name()))
2523                                 os << "\\format \"" << cit->name()
2524                                    << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
2525                 if (tag != RC_LAST)
2526                         break;
2527         case RC_VIEWER_ALTERNATIVES: {
2528                 Alternatives::const_iterator it = viewer_alternatives.begin();
2529                 Alternatives::const_iterator const en = viewer_alternatives.end();
2530                 Alternatives::const_iterator const sysend = 
2531                                 system_lyxrc.viewer_alternatives.end();
2532                 for (; it != en; ++it) {
2533                         string const & fmt = it->first;
2534                         CommandSet const & cmd = it->second;
2535                         CommandSet::const_iterator sit = cmd.begin();
2536                         CommandSet::const_iterator const sen = cmd.end();
2537                         Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
2538                                         system_lyxrc.viewer_alternatives.begin() : // we won't use it in this case
2539                                         system_lyxrc.viewer_alternatives.find(fmt);
2540                         for (; sit != sen; ++sit) {
2541                                 string const & cmd = *sit;
2542                                 if (ignore_system_lyxrc 
2543                                     || sysfmt == sysend               // format not found
2544                                          || sysfmt->second.count(cmd) == 0 // this command not found
2545                                    )
2546                                         os << "\\viewer_alternatives " << fmt << " " << cmd << "\n";
2547                         }
2548                 }
2549                 if (tag != RC_LAST)
2550                         break;
2551         }
2552         case RC_EDITOR_ALTERNATIVES: {
2553                 Alternatives::const_iterator it = editor_alternatives.begin();
2554                 Alternatives::const_iterator const en = editor_alternatives.end();
2555                 Alternatives::const_iterator const sysend = 
2556                                 system_lyxrc.editor_alternatives.end();
2557                 for (; it != en; ++it) {
2558                         string const & fmt = it->first;
2559                         CommandSet const & cmd = it->second;
2560                         CommandSet::const_iterator sit = cmd.begin();
2561                         CommandSet::const_iterator const sen = cmd.end();
2562                         Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
2563                                         system_lyxrc.editor_alternatives.begin() : // we won't use it in this case
2564                                         system_lyxrc.editor_alternatives.find(fmt);
2565                         for (; sit != sen; ++sit) {
2566                                 string const & cmd = *sit;
2567                                 if (ignore_system_lyxrc 
2568                                     || sysfmt == sysend               // format not found
2569                                     || sysfmt->second.count(cmd) == 0 // this command not found
2570                                    )
2571                                         os << "\\editor_alternatives " << fmt << " " << cmd << "\n";
2572                         }
2573                 }
2574                 if (tag != RC_LAST)
2575                         break;
2576         }
2577         case RC_DEFAULT_VIEW_FORMAT:
2578                 if (ignore_system_lyxrc ||
2579                     default_view_format != system_lyxrc.default_view_format) {
2580                         os << "\\default_view_format " << default_view_format << '\n';
2581                 }
2582                 if (tag != RC_LAST)
2583                         break;
2584         case RC_VIEWER:
2585                 // Ignore it
2586                 if (tag != RC_LAST)
2587                         break;
2588
2589                 os << "\n#\n"
2590                    << "# CONVERTERS SECTION ##########################\n"
2591                    << "#\n\n";
2592
2593         case RC_CONVERTER:
2594                 // Look for new converters
2595                 for (Converters::const_iterator cit = theConverters().begin();
2596                      cit != theConverters().end(); ++cit) {
2597                         Converter const * converter =
2598                                 theSystemConverters().getConverter(cit->from,
2599                                                                cit->to);
2600                         if (!converter ||
2601                             converter->command != cit->command ||
2602                             converter->flags != cit->flags)
2603                                 os << "\\converter \"" << cit->from << "\" \""
2604                                    << cit->to << "\" \""
2605                                    << escapeCommand(cit->command) << "\" \""
2606                                    << cit->flags << "\"\n";
2607                 }
2608
2609                 // New/modifed converters
2610                 for (Converters::const_iterator cit = theSystemConverters().begin();
2611                      cit != theSystemConverters().end(); ++cit)
2612                         if (!theConverters().getConverter(cit->from, cit->to))
2613                                 os << "\\converter \"" << cit->from
2614                                    << "\" \"" << cit->to << "\" \"\" \"\"\n";
2615                 if (tag != RC_LAST)
2616                         break;
2617         
2618         case RC_COPIER:
2619                 if (tag == RC_LAST)
2620                         os << "\n#\n"
2621                            << "# COPIERS SECTION ##########################\n"
2622                            << "#\n\n";
2623
2624                 // Look for new movers
2625                 Movers::const_iterator const sysbegin = theSystemMovers().begin();
2626                 Movers::const_iterator const sysend = theSystemMovers().end();
2627                 Movers::const_iterator it = theMovers().begin();
2628                 Movers::const_iterator end = theMovers().end();
2629
2630                 for (; it != end; ++it) {
2631                         Movers::const_iterator const sysit =
2632                                 find_if(sysbegin, sysend, SameMover(*it));
2633                         if (sysit == sysend) {
2634                                 string const & fmt = it->first;
2635                                 string const & command =
2636                                         it->second.command();
2637
2638                                 os << "\\copier " << fmt
2639                                    << " \"" << escapeCommand(command) << "\"\n";
2640                         }
2641                 }
2642                 if (tag != RC_LAST)
2643                         break;
2644
2645                 // We don't actually delete SpecialisedMover(s) from the
2646                 // map, just clear their 'command', so there's no need
2647                 // to test for anything else.
2648         }
2649
2650         os.flush();
2651 }
2652
2653
2654 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
2655 {
2656         // Why the switch you might ask. It is a trick to ensure that all
2657         // the elements in the LyXRCTags enum is handled. As you can see
2658         // there are no breaks at all. So it is just a huge fall-through.
2659         // The nice thing is that we will get a warning from the compiler
2660         // if we forget an element.
2661         LyXRC::LyXRCTags tag = LyXRC::RC_LAST;
2662         switch (tag) {
2663         case LyXRC::RC_ACCEPT_COMPOUND:
2664         case LyXRC::RC_ALT_LANG:
2665         case LyXRC::RC_PLAINTEXT_LINELEN:
2666         case LyXRC::RC_PLAINTEXT_ROFF_COMMAND:
2667         case LyXRC::RC_AUTOCORRECTION_MATH:
2668         case LyXRC::RC_AUTOREGIONDELETE:
2669         case LyXRC::RC_AUTORESET_OPTIONS:
2670         case LyXRC::RC_AUTOSAVE:
2671         case LyXRC::RC_AUTO_NUMBER:
2672         case LyXRC::RC_BACKUPDIR_PATH:
2673         case LyXRC::RC_BIBTEX_ALTERNATIVES:
2674         case LyXRC::RC_BIBTEX_COMMAND:
2675         case LyXRC::RC_BINDFILE:
2676         case LyXRC::RC_CHECKLASTFILES:
2677         case LyXRC::RC_COMPLETION_CURSOR_TEXT:
2678         case LyXRC::RC_COMPLETION_INLINE_DELAY:
2679         case LyXRC::RC_COMPLETION_INLINE_DOTS:
2680         case LyXRC::RC_COMPLETION_INLINE_MATH:
2681         case LyXRC::RC_COMPLETION_INLINE_TEXT:
2682         case LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE:
2683         case LyXRC::RC_COMPLETION_POPUP_DELAY:
2684         case LyXRC::RC_COMPLETION_POPUP_MATH:
2685         case LyXRC::RC_COMPLETION_POPUP_TEXT:
2686         case LyXRC::RC_USELASTFILEPOS:
2687         case LyXRC::RC_LOADSESSION:
2688         case LyXRC::RC_CHKTEX_COMMAND:
2689         case LyXRC::RC_CONVERTER:
2690         case LyXRC::RC_CONVERTER_CACHE_MAXAGE:
2691         case LyXRC::RC_COPIER:
2692         case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
2693         case LyXRC::RC_SCROLL_BELOW_DOCUMENT:
2694         case LyXRC::RC_DATE_INSERT_FORMAT:
2695         case LyXRC::RC_DEFAULT_LANGUAGE:
2696         case LyXRC::RC_GUI_LANGUAGE:
2697         case LyXRC::RC_DEFAULT_PAPERSIZE:
2698         case LyXRC::RC_DEFAULT_VIEW_FORMAT:
2699         case LyXRC::RC_DEFFILE:
2700         case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN:
2701         case LyXRC::RC_DISPLAY_GRAPHICS:
2702         case LyXRC::RC_DOCUMENTPATH:
2703                 if (lyxrc_orig.document_path != lyxrc_new.document_path) {
2704                         FileName path(lyxrc_new.document_path);
2705                         if (path.exists() && path.isDirectory())
2706                                 package().document_dir() = FileName(lyxrc.document_path);
2707                 }
2708         case LyXRC::RC_EDITOR_ALTERNATIVES:
2709         case LyXRC::RC_ESC_CHARS:
2710         case LyXRC::RC_EXAMPLEPATH:
2711         case LyXRC::RC_FONT_ENCODING:
2712         case LyXRC::RC_FORMAT:
2713         case LyXRC::RC_GROUP_LAYOUTS:
2714         case LyXRC::RC_HUNSPELLDIR_PATH:
2715         case LyXRC::RC_INDEX_ALTERNATIVES:
2716         case LyXRC::RC_INDEX_COMMAND:
2717         case LyXRC::RC_JBIBTEX_COMMAND:
2718         case LyXRC::RC_JINDEX_COMMAND:
2719         case LyXRC::RC_NOMENCL_COMMAND:
2720         case LyXRC::RC_INPUT:
2721         case LyXRC::RC_KBMAP:
2722         case LyXRC::RC_KBMAP_PRIMARY:
2723         case LyXRC::RC_KBMAP_SECONDARY:
2724         case LyXRC::RC_LANGUAGE_AUTO_BEGIN:
2725         case LyXRC::RC_LANGUAGE_AUTO_END:
2726         case LyXRC::RC_LANGUAGE_COMMAND_BEGIN:
2727         case LyXRC::RC_LANGUAGE_COMMAND_END:
2728         case LyXRC::RC_LANGUAGE_COMMAND_LOCAL:
2729         case LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS:
2730         case LyXRC::RC_LANGUAGE_PACKAGE:
2731         case LyXRC::RC_LANGUAGE_USE_BABEL:
2732         case LyXRC::RC_MAC_LIKE_WORD_MOVEMENT:
2733         case LyXRC::RC_MACRO_EDIT_STYLE:
2734         case LyXRC::RC_MAKE_BACKUP:
2735         case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
2736         case LyXRC::RC_MOUSE_WHEEL_SPEED:
2737         case LyXRC::RC_NUMLASTFILES:
2738         case LyXRC::RC_PARAGRAPH_MARKERS:
2739         case LyXRC::RC_PATH_PREFIX:
2740                 if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) {
2741                         prependEnvPath("PATH", lyxrc.path_prefix);
2742                 }
2743         case LyXRC::RC_PERS_DICT:
2744         case LyXRC::RC_PREVIEW:
2745         case LyXRC::RC_PREVIEW_HASHED_LABELS:
2746         case LyXRC::RC_PREVIEW_SCALE_FACTOR:
2747         case LyXRC::RC_PRINTCOLLCOPIESFLAG:
2748         case LyXRC::RC_PRINTCOPIESFLAG:
2749         case LyXRC::RC_PRINTER:
2750         case LyXRC::RC_PRINTEVENPAGEFLAG:
2751         case LyXRC::RC_PRINTEXSTRAOPTIONS:
2752         case LyXRC::RC_PRINTFILEEXTENSION:
2753         case LyXRC::RC_PRINTLANDSCAPEFLAG:
2754         case LyXRC::RC_PRINTODDPAGEFLAG:
2755         case LyXRC::RC_PRINTPAGERANGEFLAG:
2756         case LyXRC::RC_PRINTPAPERDIMENSIONFLAG:
2757         case LyXRC::RC_PRINTPAPERFLAG:
2758         case LyXRC::RC_PRINTREVERSEFLAG:
2759         case LyXRC::RC_PRINTSPOOL_COMMAND:
2760         case LyXRC::RC_PRINTSPOOL_PRINTERPREFIX:
2761         case LyXRC::RC_PRINTTOFILE:
2762         case LyXRC::RC_PRINTTOPRINTER:
2763         case LyXRC::RC_PRINT_ADAPTOUTPUT:
2764         case LyXRC::RC_PRINT_COMMAND:
2765         case LyXRC::RC_RTL_SUPPORT:
2766         case LyXRC::RC_SAVE_COMPRESSED:
2767         case LyXRC::RC_SCREEN_DPI:
2768         case LyXRC::RC_SCREEN_FONT_ROMAN:
2769         case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
2770         case LyXRC::RC_SCREEN_FONT_SANS:
2771         case LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY:
2772         case LyXRC::RC_SCREEN_FONT_SCALABLE:
2773         case LyXRC::RC_SCREEN_FONT_SIZES:
2774         case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
2775         case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2776         case LyXRC::RC_GEOMETRY_SESSION:
2777         case LyXRC::RC_SCREEN_ZOOM:
2778         case LyXRC::RC_SERVERPIPE:
2779         case LyXRC::RC_SET_COLOR:
2780         case LyXRC::RC_SHOW_BANNER:
2781         case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
2782         case LyXRC::RC_SPELL_COMMAND:
2783         case LyXRC::RC_SPELLCHECKER:
2784         case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
2785         case LyXRC::RC_SPELLCHECK_NOTES:
2786         case LyXRC::RC_SPLITINDEX_COMMAND:
2787         case LyXRC::RC_TEMPDIRPATH:
2788         case LyXRC::RC_TEMPLATEPATH:
2789         case LyXRC::RC_TEX_ALLOWS_SPACES:
2790         case LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS:
2791                 if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
2792                         os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
2793                 }
2794         case LyXRC::RC_THESAURUSDIRPATH:
2795         case LyXRC::RC_UIFILE:
2796         case LyXRC::RC_USER_EMAIL:
2797         case LyXRC::RC_USER_NAME:
2798         case LyXRC::RC_USETEMPDIR:
2799         case LyXRC::RC_USE_ALT_LANG:
2800         case LyXRC::RC_USE_CONVERTER_CACHE:
2801         case LyXRC::RC_USE_ESC_CHARS:
2802         case LyXRC::RC_USE_INP_ENC:
2803         case LyXRC::RC_USE_PERS_DICT:
2804         case LyXRC::RC_USE_TOOLTIP:
2805         case LyXRC::RC_USE_PIXMAP_CACHE:
2806         case LyXRC::RC_USE_SPELL_LIB:
2807         case LyXRC::RC_VIEWDVI_PAPEROPTION:
2808         case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON:
2809         case LyXRC::RC_SORT_LAYOUTS:
2810         case LyXRC::RC_FULL_SCREEN_LIMIT:
2811         case LyXRC::RC_FULL_SCREEN_SCROLLBAR:
2812         case LyXRC::RC_FULL_SCREEN_MENUBAR:
2813         case LyXRC::RC_FULL_SCREEN_TABBAR:
2814         case LyXRC::RC_FULL_SCREEN_TOOLBARS:
2815         case LyXRC::RC_FULL_SCREEN_WIDTH:
2816         case LyXRC::RC_VISUAL_CURSOR:
2817         case LyXRC::RC_VIEWER:
2818         case LyXRC::RC_VIEWER_ALTERNATIVES:
2819         case LyXRC::RC_FORWARD_SEARCH:
2820         case LyXRC::RC_LAST:
2821                 break;
2822         }
2823 }
2824
2825
2826 #if 0
2827 string const LyXRC::getDescription(LyXRCTags tag)
2828 {
2829         docstring str;
2830
2831         switch (tag) {
2832         case RC_ACCEPT_COMPOUND:
2833                 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2834                 break;
2835
2836         case RC_ALT_LANG:
2837         case RC_USE_ALT_LANG:
2838                 str = _("Specify an alternate language. The default is to use the language of the document.");
2839                 break;
2840
2841         case RC_PLAINTEXT_ROFF_COMMAND:
2842                 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.");
2843                 break;
2844
2845         case RC_PLAINTEXT_LINELEN:
2846                 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.");
2847                 break;
2848
2849         case RC_AUTOREGIONDELETE:
2850                 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2851                 break;
2852
2853         case RC_AUTORESET_OPTIONS:
2854                 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2855                 break;
2856
2857         case RC_AUTOSAVE:
2858                 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2859                 break;
2860
2861         case RC_AUTO_NUMBER:
2862                 break;
2863
2864         case RC_BACKUPDIR_PATH:
2865                 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.");
2866                 break;
2867
2868         case RC_BIBTEX_COMMAND:
2869                 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2870                 break;
2871
2872         case RC_JBIBTEX_COMMAND:
2873                 str = _("Define the options of the bibtex program for PLaTeX (Japanese LaTeX).");
2874                 break;
2875
2876         case RC_BINDFILE:
2877                 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2878                 break;
2879
2880         case RC_CHECKLASTFILES:
2881                 str = _("Select to check whether the lastfiles still exist.");
2882                 break;
2883
2884         case RC_CHKTEX_COMMAND:
2885                 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2886                 break;
2887
2888         case RC_CONVERTER:
2889                 break;
2890
2891         case RC_COPIER:
2892                 break;
2893
2894         case RC_CURSOR_FOLLOWS_SCROLLBAR:
2895                 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.");
2896                 break;
2897
2898         case RC_SCROLL_BELOW_DOCUMENT:
2899                 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");
2900                 break;
2901
2902         case RC_MAC_LIKE_WORD_MOVEMENT:
2903                 str = _("Use the Mac OS X conventions for the word-level cursor movement");
2904                 break;
2905
2906         case RC_SHOW_MACRO_LABEL:
2907                 str = _("Show a small box around a Math Macro with the macro name when the cursor is inside.");
2908                 break;
2909
2910         case RC_DATE_INSERT_FORMAT:
2911                 //xgettext:no-c-format
2912                 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2913                 break;
2914
2915         case RC_DEFFILE:
2916                 str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories.");
2917                 break;
2918
2919         case RC_DEFAULT_VIEW_FORMAT:
2920                 str = _("The default format used with LFUN_BUFFER_[VIEW|UPDATE].");
2921                 break;
2922
2923         case RC_DEFAULT_LANGUAGE:
2924                 str = _("New documents will be assigned this language.");
2925                 break;
2926
2927         case RC_DEFAULT_PAPERSIZE:
2928                 str = _("Specify the default paper size.");
2929                 break;
2930
2931         case RC_DIALOGS_ICONIFY_WITH_MAIN:
2932                 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2933                 break;
2934
2935         case RC_DISPLAY_GRAPHICS:
2936                 str = _("Select how LyX will display any graphics.");
2937                 break;
2938
2939         case RC_DOCUMENTPATH:
2940                 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2941                 break;
2942
2943         case RC_ESC_CHARS:
2944         case RC_USE_ESC_CHARS:
2945                 str = _("Specify additional chars that can be part of a word.");
2946                 break;
2947
2948         case RC_EXAMPLEPATH:
2949                 str = _("The path that LyX will set when offering to choose an example. An empty value selects the directory LyX was started from.");
2950                 break;
2951
2952         case RC_FONT_ENCODING:
2953                 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2954                 break;
2955
2956         case RC_FORMAT:
2957                 break;
2958
2959         case RC_INDEX_COMMAND:
2960                 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\".");
2961                 break;
2962
2963         case RC_JINDEX_COMMAND:
2964                 str = _("Define the options of the index program for PLaTeX (Japanese LaTeX).");
2965                 break;
2966
2967         case RC_NOMENCL_COMMAND:
2968                 str = _("Define the options of makeindex (cf. man makeindex) to be used for nomenclatures. This might differ from the index processing options.");
2969                 break;
2970
2971         case RC_INPUT:
2972                 break;
2973
2974         case RC_KBMAP:
2975         case RC_KBMAP_PRIMARY:
2976         case RC_KBMAP_SECONDARY:
2977                 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.");
2978                 break;
2979
2980         case RC_LANGUAGE_AUTO_BEGIN:
2981                 str = _("Select if a language switching command is needed at the beginning of the document.");
2982                 break;
2983
2984         case RC_LANGUAGE_AUTO_END:
2985                 str = _("Select if a language switching command is needed at the end of the document.");
2986                 break;
2987
2988         case RC_LANGUAGE_COMMAND_BEGIN:
2989                 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.");
2990                 break;
2991
2992         case RC_LANGUAGE_COMMAND_END:
2993                 str = _("The LaTeX command for changing back to the language of the document.");
2994                 break;
2995
2996         case RC_LANGUAGE_COMMAND_LOCAL:
2997                 str = _("The LaTeX command for local changing of the language.");
2998                 break;
2999
3000         case RC_LANGUAGE_GLOBAL_OPTIONS:
3001                 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
3002                 break;
3003
3004         case RC_LANGUAGE_PACKAGE:
3005                 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
3006                 break;
3007
3008         case RC_LANGUAGE_USE_BABEL:
3009                 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
3010                 break;
3011
3012         case RC_USELASTFILEPOS:
3013                 str = _("De-select if you do not want LyX to scroll to saved position.");
3014                 break;
3015
3016         case RC_LOADSESSION:
3017                 str = _("De-select to prevent loading files opened from the last LyX session.");
3018                 break;
3019
3020         case RC_MAKE_BACKUP:
3021                 str = _("De-select if you don't want LyX to create backup files.");
3022                 break;
3023
3024         case RC_MARK_FOREIGN_LANGUAGE:
3025                 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
3026                 break;
3027
3028         case RC_MOUSE_WHEEL_SPEED:
3029                 str = bformat(_("The scrolling speed of the mouse wheel."),
3030                       maxlastfiles);
3031                 break;
3032
3033         case RC_COMPLETION_POPUP_DELAY:
3034                 str = _("The completion popup delay.");
3035                 break;
3036
3037         case RC_COMPLETION_POPUP_MATH:
3038                 str = _("Select to display the completion popup in math mode.");
3039                 break;
3040
3041         case RC_COMPLETION_POPUP_TEXT:
3042                 str = _("Select to display the completion popup in text mode.");
3043                 break;
3044
3045         case RC_COMPLETION_POPUP_AFTER_COMPLETE:
3046                 str = _("Show the completion popup without delay after non-unique completion attempt.");
3047                 break;
3048
3049         case RC_COMPLETION_POPUP_TEXT:
3050                 str = _("Show a small triangle on the cursor to indicate that a completion is available.");
3051                 break;
3052
3053         case RC_COMPLETION_POPUP_DELAY:
3054                 str = _("The inline completion delay.");
3055                 break;
3056
3057         case RC_COMPLETION_INLINE_MATH:
3058                 str = _("Select to display the inline completion in math mode.");
3059                 break;
3060
3061         case RC_COMPLETION_INLINE_TEXT:
3062                 str = _("Select to display the inline completion in text mode.");
3063                 break;
3064
3065         case RC_COMPLETION_INLINE_DOTS:
3066                 str = _("Use \"...\" to shorten long completions.");
3067                 break;
3068
3069         case RC_AUTOCORRECTION_MATH:
3070                 str = _("Allow TeXMacs shorthand, like => converting to \Rightarrow.");
3071                 break;
3072
3073         case RC_NUMLASTFILES:
3074                 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."),
3075                         maxlastfiles);
3076                 break;
3077
3078         case RC_PATH_PREFIX:
3079                 str = _("Specify those directories which should be "
3080                          "prepended to the PATH environment variable. "
3081                          "Use the OS native format.");
3082                 break;
3083
3084         case RC_PREVIEW:
3085                 str = _("Shows a typeset preview of things such as math");
3086                 break;
3087
3088         case RC_PREVIEW_HASHED_LABELS:
3089                 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
3090                 break;
3091
3092         case RC_PREVIEW_SCALE_FACTOR:
3093                 str = _("Scale the preview size to suit.");
3094                 break;
3095
3096         case RC_PRINTCOLLCOPIESFLAG:
3097                 str = _("The option for specifying whether the copies should be collated.");
3098                 break;
3099
3100         case RC_PRINTCOPIESFLAG:
3101                 str = _("The option for specifying the number of copies to print.");
3102                 break;
3103
3104         case RC_PRINTER:
3105                 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
3106                 break;
3107
3108         case RC_PRINTEVENPAGEFLAG:
3109                 str = _("The option to print only even pages.");
3110                 break;
3111
3112         case RC_PRINTEXSTRAOPTIONS:
3113                 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
3114                 break;
3115
3116         case RC_PRINTFILEEXTENSION:
3117                 str = _("Extension of printer program output file. Usually \".ps\".");
3118                 break;
3119
3120         case RC_PRINTLANDSCAPEFLAG:
3121                 str = _("The option to print out in landscape.");
3122                 break;
3123
3124         case RC_PRINTODDPAGEFLAG:
3125                 str = _("The option to print only odd pages.");
3126                 break;
3127
3128         case RC_PRINTPAGERANGEFLAG:
3129                 str = _("The option for specifying a comma-separated list of pages to print.");
3130                 break;
3131
3132         case RC_PRINTPAPERDIMENSIONFLAG:
3133                                    str = _("Option to specify the dimensions of the print paper.");
3134                 break;
3135
3136         case RC_PRINTPAPERFLAG:
3137                 str = _("The option to specify paper type.");
3138                 break;
3139
3140         case RC_PRINTREVERSEFLAG:
3141                 str = _("The option to reverse the order of the pages printed.");
3142                 break;
3143
3144         case RC_PRINTSPOOL_COMMAND:
3145                 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.");
3146                 break;
3147
3148         case RC_PRINTSPOOL_PRINTERPREFIX:
3149                 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.");
3150                 break;
3151
3152         case RC_PRINTTOFILE:
3153                 str = _("Option to pass to the print program to print to a file.");
3154                 break;
3155
3156         case RC_PRINTTOPRINTER:
3157                 str = _("Option to pass to the print program to print on a specific printer.");
3158                 break;
3159
3160         case RC_PRINT_ADAPTOUTPUT:
3161                 str = _("Select for LyX to pass the name of the destination printer to your print command.");
3162                 break;
3163
3164         case RC_PRINT_COMMAND:
3165                 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
3166                 break;
3167
3168         case RC_RTL_SUPPORT:
3169                 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
3170                 break;
3171
3172         case RC_VISUAL_CURSOR:
3173                 str = _("Select to have visual bidi cursor movement, unselect for logical movement.");
3174                 break;
3175
3176         case RC_SCREEN_DPI:
3177                 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
3178                 break;
3179
3180         case RC_SCREEN_FONT_ROMAN:
3181         case RC_SCREEN_FONT_SANS:
3182         case RC_SCREEN_FONT_TYPEWRITER:
3183                 str = _("The screen fonts used to display the text while editing.");
3184                 break;
3185
3186         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
3187         case RC_SCREEN_FONT_SANS_FOUNDRY:
3188         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
3189                 break;
3190
3191         case RC_SCREEN_FONT_SCALABLE:
3192                 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.");
3193                 break;
3194
3195         case RC_SCREEN_FONT_SIZES:
3196                 str = _("The font sizes used for calculating the scaling of the screen fonts.");
3197                 break;
3198
3199         case RC_SCREEN_ZOOM:
3200                 //xgettext:no-c-format
3201                 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
3202                 break;
3203
3204         case RC_GEOMETRY_SESSION:
3205                 str = _("Allow session manager to save and restore windows geometry.");
3206                 break;
3207
3208         case RC_SERVERPIPE:
3209                 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
3210                 break;
3211
3212         case RC_SET_COLOR:
3213                 break;
3214
3215         case RC_SHOW_BANNER:
3216                 str = _("De-select if you don't want the startup banner.");
3217                 break;
3218
3219         case RC_TEMPDIRPATH:
3220                 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
3221                 break;
3222
3223         case RC_THESAURUSDIRPATH:
3224                 str = _("This is the place where the files of the thesaurus library reside.");
3225                 break;
3226
3227         case RC_TEMPLATEPATH:
3228                 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
3229                 break;
3230
3231         case RC_TEX_ALLOWS_SPACES:
3232                 break;
3233
3234         case RC_TEX_EXPECTS_WINDOWS_PATHS:
3235                 break;
3236
3237         case RC_UIFILE:
3238                 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
3239                 break;
3240
3241         case RC_USER_EMAIL:
3242                 break;
3243
3244         case RC_USER_NAME:
3245                 break;
3246
3247         case RC_USETEMPDIR:
3248                 break;
3249
3250         case RC_USE_TOOLTIP:
3251                 str = _("Enable the automatic appearance of tool tips in the work area.");
3252                 break;
3253
3254         case RC_USE_PIXMAP_CACHE:
3255                 str = _("Enable the pixmap cache that might improve performance on Mac and Windows.");
3256                 break;
3257
3258         case RC_USE_SPELL_LIB:
3259                 break;
3260
3261         case RC_VIEWDVI_PAPEROPTION:
3262                 _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
3263                 break;
3264
3265         case RC_VIEWER:
3266                 break;
3267
3268         case RC_LAST:
3269                 break;
3270         }
3271
3272         return str;
3273 }
3274 #endif
3275
3276
3277 // The global instance
3278 LyXRC lyxrc;
3279
3280 // The global copy of the system lyxrc entries (everything except preferences)
3281 LyXRC system_lyxrc;
3282
3283
3284 } // namespace lyx