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