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