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