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