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