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