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