]> git.lyx.org Git - lyx.git/blob - src/LyXRC.cpp
* temporary fix for the crash of the pixmap cache on Mac with Qt 4.4.
[lyx.git] / src / LyXRC.cpp
1 /**
2  * \file LyXRC.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author Jean-Marc Lasgouttes
8  * \author Angus Leeming
9  * \author John Levon
10  * \author André Pönitz
11  * \author Allan Rae
12  * \author Dekel Tsur
13  *
14  * Full author contact details are available in file CREDITS.
15  */
16
17 #include <config.h>
18
19 #include <fstream>
20 #include <iostream>
21
22 #include "LyXRC.h"
23
24 #include "Color.h"
25 #include "Converter.h"
26 #include "Format.h"
27 #include "Session.h"
28 #include "Lexer.h"
29 #include "FontEnums.h"
30 #include "Mover.h"
31
32 #include "graphics/GraphicsTypes.h"
33
34 #include "support/convert.h"
35 #include "support/debug.h"
36 #include "support/environment.h"
37 #include "support/filetools.h"
38 #include "support/gettext.h"
39 #include "support/lstrings.h"
40 #include "support/os.h"
41 #include "support/userinfo.h"
42
43 using namespace std;
44 using namespace lyx::support;
45
46 namespace lyx {
47
48 namespace os = support::os;
49
50 namespace {
51
52 // when adding something to this array keep it sorted!
53 LexerKeyword lyxrcTags[] = {
54         { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
55         { "\\allow_geometry_session", LyXRC::RC_GEOMETRY_SESSION },
56         { "\\alternate_language", LyXRC::RC_ALT_LANG },
57         { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
58         { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
59         { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
60         { "\\autosave", LyXRC::RC_AUTOSAVE },
61         { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
62         { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
63         { "\\bind_file", LyXRC::RC_BINDFILE },
64         { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
65         { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
66         { "\\completion_cursor_text", LyXRC::RC_COMPLETION_CURSOR_TEXT },
67         { "\\completion_inline_delay", LyXRC::RC_COMPLETION_INLINE_DELAY },
68         { "\\completion_inline_dots", LyXRC::RC_COMPLETION_INLINE_DOTS },
69         { "\\completion_inline_math", LyXRC::RC_COMPLETION_INLINE_MATH },
70         { "\\completion_inline_text", LyXRC::RC_COMPLETION_INLINE_TEXT },
71         { "\\completion_popup_after_complete", LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE },
72         { "\\completion_popup_delay", LyXRC::RC_COMPLETION_POPUP_DELAY },
73         { "\\completion_popup_math", LyXRC::RC_COMPLETION_POPUP_MATH },
74         { "\\completion_popup_text", LyXRC::RC_COMPLETION_POPUP_TEXT },
75         { "\\converter", LyXRC::RC_CONVERTER },
76         { "\\converter_cache_maxage", LyXRC::RC_CONVERTER_CACHE_MAXAGE },
77         { "\\copier", LyXRC::RC_COPIER },
78         { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
79         { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
80         { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
81         { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
82         { "\\def_file", LyXRC::RC_DEFFILE },
83         { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
84         { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
85         { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
86         { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
87         { "\\document_path", LyXRC::RC_DOCUMENTPATH },
88         { "\\escape_chars", LyXRC::RC_ESC_CHARS },
89         { "\\example_path", LyXRC::RC_EXAMPLEPATH },
90         { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
91         { "\\format", LyXRC::RC_FORMAT },
92         { "\\fullscreen_limit", LyXRC::RC_FULL_SCREEN_LIMIT },
93         { "\\fullscreen_scrollbar", LyXRC::RC_FULL_SCREEN_SCROLLBAR },
94         { "\\fullscreen_tabbar", LyXRC::RC_FULL_SCREEN_TABBAR },
95         { "\\fullscreen_toolbars", LyXRC::RC_FULL_SCREEN_TOOLBARS },
96         { "\\fullscreen_width", LyXRC::RC_FULL_SCREEN_WIDTH },
97         { "\\group_layouts", LyXRC::RC_GROUP_LAYOUTS },
98         { "\\gui_language", LyXRC::RC_GUI_LANGUAGE },
99         { "\\index_command", LyXRC::RC_INDEX_COMMAND },
100         { "\\input", LyXRC::RC_INPUT },
101         { "\\kbmap", LyXRC::RC_KBMAP },
102         { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
103         { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
104         { "\\label_init_length", LyXRC::RC_LABEL_INIT_LENGTH },
105         { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
106         { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
107         { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
108         { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
109         { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
110         { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
111         { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
112         { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
113         { "\\load_session", LyXRC::RC_LOADSESSION },
114         { "\\mac_like_word_movement", LyXRC::RC_MAC_LIKE_WORD_MOVEMENT },
115         { "\\macro_edit_style", LyXRC::RC_MACRO_EDIT_STYLE },
116         { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
117         { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
118         { "\\mouse_wheel_speed", LyXRC::RC_MOUSE_WHEEL_SPEED },
119         { "\\nomencl_command", LyXRC::RC_NOMENCL_COMMAND },
120         { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
121         { "\\open_buffers_in_tabs", LyXRC::RC_OPEN_BUFFERS_IN_TABS },
122         { "\\path_prefix", LyXRC::RC_PATH_PREFIX },
123         { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
124         { "\\plaintext_linelen", LyXRC::RC_PLAINTEXT_LINELEN },
125         { "\\plaintext_roff_command", LyXRC::RC_PLAINTEXT_ROFF_COMMAND },
126         { "\\preview", LyXRC::RC_PREVIEW },
127         { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
128         { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
129         { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
130         { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
131         { "\\print_command", LyXRC::RC_PRINT_COMMAND },
132         { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
133         { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
134         { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
135         { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
136         { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
137         { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
138         { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
139         { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
140         { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
141         { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
142         { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
143         { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
144         { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
145         { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
146         { "\\printer", LyXRC::RC_PRINTER },
147         { "\\rtl", LyXRC::RC_RTL_SUPPORT },
148         { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
149         { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
150         { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
151         { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
152         { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
153         { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
154         { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
155         { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
156         { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
157         { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
158         { "\\serverpipe", LyXRC::RC_SERVERPIPE },
159         { "\\set_color", LyXRC::RC_SET_COLOR },
160         { "\\show_banner", LyXRC::RC_SHOW_BANNER },
161         { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
162         { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
163         { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
164         { "\\template_path", LyXRC::RC_TEMPLATEPATH },
165         { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
166         { "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS },
167         { "\\ui_file", LyXRC::RC_UIFILE },
168         { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
169         { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
170         { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
171         { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
172         { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
173         { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
174         { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE },
175         // compatibility with versions older than 1.4.0 only
176         { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
177         { "\\use_spell_lib", 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         use_spell_lib = true;
264         isp_command = "ispell";
265         isp_accept_compound = false;
266         isp_use_input_encoding = false;
267         isp_use_alt_lang = false;
268         isp_use_pers_dict = false;
269         isp_use_esc_chars = false;
270         use_kbmap = false;
271         rtl_support = true;
272         visual_cursor = false;
273         auto_number = true;
274         mark_foreign_language = true;
275         language_auto_begin = true;
276         language_auto_end = true;
277         language_global_options = true;
278         language_use_babel = true;
279         language_package = "\\usepackage{babel}";
280         language_command_begin = "\\selectlanguage{$$lang}";
281         language_command_local = "\\foreignlanguage{$$lang}{";
282         sort_layouts = false;
283         group_layouts = true;
284         default_language = "english";
285         gui_language = "auto";
286         show_banner = true;
287         windows_style_tex_paths = false;
288         tex_allows_spaces = false;
289         date_insert_format = "%x";
290         cursor_follows_scrollbar = false;
291         mac_like_word_movement = false;
292         macro_edit_style = MACRO_EDIT_INLINE_BOX;
293         dialogs_iconify_with_main = false;
294         label_init_length = 3;
295         preview = PREVIEW_OFF;
296         preview_hashed_labels  = false;
297         preview_scale_factor = "0.9";
298         use_converter_cache = true;
299         use_tooltip = true;
300         use_pixmap_cache = false;
301         converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
302         user_name = to_utf8(support::user_name());
303         user_email = to_utf8(support::user_email());
304         open_buffers_in_tabs = true;
305
306         // Fullscreen settings
307         full_screen_limit = false;
308         full_screen_toolbars = true;
309         full_screen_tabbar = true;
310         full_screen_scrollbar = true;
311         full_screen_width = 700;
312
313         completion_cursor_text = true;
314         completion_popup_math = true;
315         completion_popup_text = false;
316         completion_popup_delay = 2.0;
317         completion_popup_after_complete = true;
318         completion_inline_math = true;
319         completion_inline_text = false;
320         completion_inline_dots = -1;
321         completion_inline_delay = 0.2;
322 }
323
324
325 namespace {
326
327 void oldFontFormat(string & family, string & foundry)
328 {
329         if (family.empty() || family[0] != '-')
330                 return;
331         foundry = token(family, '-', 1);
332         family = token(family, '-', 2);
333         if (foundry == "*")
334                 foundry.erase();
335 }
336
337 } // namespace anon
338
339
340 int LyXRC::read(FileName const & filename)
341 {
342         Lexer lexrc(lyxrcTags);
343         if (lyxerr.debugging(Debug::PARSER))
344                 lexrc.printTable(lyxerr);
345
346         lexrc.setFile(filename);
347         if (!lexrc.isOK())
348                 return -2;
349
350         LYXERR(Debug::LYXRC, "Reading '" << filename << "'...");
351
352         return read(lexrc);
353 }
354
355
356 int LyXRC::read(istream & is)
357 {
358         Lexer lexrc(lyxrcTags);
359         if (lyxerr.debugging(Debug::PARSER))
360                 lexrc.printTable(lyxerr);
361
362         lexrc.setStream(is);
363         if (!lexrc.isOK())
364                 return -2;
365
366         LYXERR(Debug::LYXRC, "Reading istream...");
367
368         return read(lexrc);
369 }
370
371
372 int LyXRC::read(Lexer & lexrc)
373 {
374         if (!lexrc.isOK()) return -2;
375
376         while (lexrc.isOK()) {
377                 // By using two switches we take advantage of the compiler
378                 // telling us if we have missed a LyXRCTags element in
379                 // the second switch.
380                 // Note that this also shows a problem with Lexer since it
381                 // helps us avoid taking advantage of the strictness of the
382                 // compiler.
383
384                 int le = lexrc.lex();
385                 switch (le) {
386                 case Lexer::LEX_UNDEF:
387                         lexrc.printError("Unknown tag `$$Token'");
388                         continue;
389                 case Lexer::LEX_FEOF:
390                         continue;
391                 default: break;
392                 }
393                 switch (static_cast<LyXRCTags>(le)) {
394                 case RC_INPUT: // Include file
395                         if (lexrc.next()) {
396                                 FileName const tmp =
397                                         libFileSearch(string(),
398                                                       lexrc.getString());
399                                 if (read(tmp)) {
400                                         lexrc.printError("Error reading "
401                                                          "included file: " + tmp.absFilename());
402                                 }
403                         }
404                         break;
405                 case RC_BINDFILE:
406                         if (lexrc.next()) {
407                                 bind_file = os::internal_path(lexrc.getString());
408                         }
409                         break;
410
411                 case RC_DEFFILE:
412                         if (lexrc.next()) {
413                                 def_file = os::internal_path(lexrc.getString());
414                         }
415                         break;
416
417                 case RC_UIFILE:
418                         if (lexrc.next()) {
419                                 ui_file = os::internal_path(lexrc.getString());
420                         }
421                         break;
422
423                 case RC_AUTORESET_OPTIONS:
424                         lexrc >> auto_reset_options;
425                         break;
426
427                 case RC_DISPLAY_GRAPHICS:
428                         if (lexrc.next())
429                                 display_graphics = lexrc.getString() == "true";
430                         break;
431
432                 case RC_TEX_EXPECTS_WINDOWS_PATHS:
433                         lexrc >> windows_style_tex_paths;
434                         break;
435
436                 case RC_TEX_ALLOWS_SPACES:
437                         lexrc >> tex_allows_spaces;
438                         break;
439
440                 case RC_KBMAP:
441                         lexrc >> use_kbmap;
442                         break;
443
444                 case RC_KBMAP_PRIMARY:
445                         if (lexrc.next()) {
446                                 string const kmap(os::internal_path(lexrc.getString()));
447                                 if (kmap.empty()) {
448                                         // nothing
449                                 } else if (!libFileSearch("kbd", kmap,
450                                                           "kmap").empty()) {
451                                         primary_kbmap = kmap;
452                                 } else {
453                                         lexrc.printError("LyX: Keymap `$$Token' not found");
454                                 }
455                         }
456                         break;
457
458                 case RC_KBMAP_SECONDARY:
459                         if (lexrc.next()) {
460                                 string const kmap(os::internal_path(lexrc.getString()));
461                                 if (kmap.empty()) {
462                                         // nothing
463                                 } else if (!libFileSearch("kbd", kmap,
464                                                           "kmap").empty()) {
465                                         secondary_kbmap = kmap;
466                                 } else {
467                                         lexrc.printError("LyX: Keymap `$$Token' not found");
468                                 }
469                         }
470                         break;
471
472                 case RC_FONT_ENCODING:
473                         lexrc >> fontenc;
474                         break;
475
476                 case RC_PRINTER:
477                         lexrc >> printer;
478                         break;
479
480                 case RC_PRINT_COMMAND:
481                         if (lexrc.next(true)) {
482                                 print_command = lexrc.getString();
483                         }
484                         break;
485
486                 case RC_PRINTEVENPAGEFLAG:
487                         lexrc >> print_evenpage_flag;
488                         break;
489
490                 case RC_PRINTODDPAGEFLAG:
491                         lexrc >> print_oddpage_flag;
492                         break;
493
494                 case RC_PRINTPAGERANGEFLAG:
495                         lexrc >> print_pagerange_flag;
496                         break;
497
498                 case RC_PRINTCOPIESFLAG:
499                         lexrc >> print_copies_flag;
500                         break;
501
502                 case RC_PRINTCOLLCOPIESFLAG:
503                         lexrc >> print_collcopies_flag;
504                         break;
505
506                 case RC_PRINTREVERSEFLAG:
507                         lexrc >> print_reverse_flag;
508                         break;
509
510                 case RC_PRINTLANDSCAPEFLAG:
511                         lexrc >> print_landscape_flag;
512                         break;
513
514                 case RC_PRINTTOPRINTER:
515                         lexrc >> print_to_printer;
516                         break;
517
518                 case RC_PRINT_ADAPTOUTPUT:
519                         lexrc >> print_adapt_output;
520                         break;
521
522                 case RC_PRINTTOFILE:
523                         if (lexrc.next()) {
524                                 print_to_file = os::internal_path(lexrc.getString());
525                         }
526                         break;
527
528                 case RC_PRINTFILEEXTENSION:
529                         lexrc >> print_file_extension;
530                         break;
531
532                 case RC_PRINTEXSTRAOPTIONS:
533                         lexrc >> print_extra_options;
534                         break;
535
536                 case RC_PRINTSPOOL_COMMAND:
537                         if (lexrc.next(true)) {
538                                 print_spool_command = lexrc.getString();
539                         }
540                         break;
541
542                 case RC_PRINTSPOOL_PRINTERPREFIX:
543                         lexrc >> print_spool_printerprefix;
544                         break;
545
546                 case RC_PRINTPAPERDIMENSIONFLAG:
547                         lexrc >> print_paper_dimension_flag;
548                         break;
549
550                 case RC_PRINTPAPERFLAG:
551                         lexrc >> print_paper_flag;
552                         break;
553
554                 case RC_CUSTOM_EXPORT_COMMAND:
555                         lexrc >> custom_export_command;
556                         break;
557
558                 case RC_CUSTOM_EXPORT_FORMAT:
559                         lexrc >> custom_export_format;
560                         break;
561
562                 case RC_DEFAULT_PAPERSIZE:
563                         if (lexrc.next()) {
564                                 string const size = ascii_lowercase(lexrc.getString());
565                                 if (size == "usletter")
566                                         default_papersize = PAPER_USLETTER;
567                                 else if (size == "legal")
568                                         default_papersize = PAPER_USLEGAL;
569                                 else if (size == "executive")
570                                         default_papersize = PAPER_USEXECUTIVE;
571                                 else if (size == "a3")
572                                         default_papersize = PAPER_A3;
573                                 else if (size == "a4")
574                                         default_papersize = PAPER_A4;
575                                 else if (size == "a5")
576                                         default_papersize = PAPER_A5;
577                                 else if (size == "b5")
578                                         default_papersize = PAPER_B5;
579                                 else if (size == "default")
580                                         default_papersize = PAPER_DEFAULT;
581                         }
582                         break;
583
584                 case RC_VIEWDVI_PAPEROPTION:
585                         if (lexrc.next())
586                                 view_dvi_paper_option = lexrc.getString();
587                         else
588                                 view_dvi_paper_option.erase();
589                         break;
590
591                 case RC_CHKTEX_COMMAND:
592                         if (lexrc.next(true)) {
593                                 chktex_command = lexrc.getString();
594                         }
595                         break;
596
597                 case RC_BIBTEX_COMMAND:
598                         if (lexrc.next(true)) {
599                                 bibtex_command = lexrc.getString();
600                         }
601                         break;
602
603                 case RC_INDEX_COMMAND:
604                         if (lexrc.next(true)) {
605                                 index_command = lexrc.getString();
606                         }
607                         break;
608
609                 case RC_NOMENCL_COMMAND:
610                         if (lexrc.next(true)) {
611                                 nomencl_command = lexrc.getString();
612                         }
613                         break;
614
615                 case RC_SCREEN_DPI:
616                         lexrc >> dpi;
617                         break;
618
619                 case RC_SCREEN_ZOOM:
620                         lexrc >> zoom;
621                         break;
622
623                 case RC_GEOMETRY_SESSION:
624                         lexrc >> allow_geometry_session;
625                         break;
626
627                 case RC_SCREEN_FONT_SIZES:
628                         lexrc >> font_sizes[FONT_SIZE_TINY];
629                         lexrc >> font_sizes[FONT_SIZE_SCRIPT];
630                         lexrc >> font_sizes[FONT_SIZE_FOOTNOTE];
631                         lexrc >> font_sizes[FONT_SIZE_SMALL];
632                         lexrc >> font_sizes[FONT_SIZE_NORMAL];
633                         lexrc >> font_sizes[FONT_SIZE_LARGE];
634                         lexrc >> font_sizes[FONT_SIZE_LARGER];
635                         lexrc >> font_sizes[FONT_SIZE_LARGEST];
636                         lexrc >> font_sizes[FONT_SIZE_HUGE];
637                         lexrc >> font_sizes[FONT_SIZE_HUGER];
638                         break;
639
640                 case RC_SCREEN_FONT_SCALABLE:
641                         lexrc >> use_scalable_fonts;
642                         break;
643
644                 case RC_AUTOSAVE:
645                         lexrc >> autosave;
646                         break;
647
648                 case RC_DOCUMENTPATH:
649                         if (lexrc.next()) {
650                                 document_path = os::internal_path(lexrc.getString());
651                                 document_path = expandPath(document_path);
652                         }
653                         break;
654
655                 case RC_EXAMPLEPATH:
656                         if (lexrc.next()) {
657                                 example_path = os::internal_path(lexrc.getString());
658                                 example_path = expandPath(example_path);
659                         }
660                         break;
661
662                 case RC_TEMPLATEPATH:
663                         if (lexrc.next()) {
664                                 template_path = os::internal_path(lexrc.getString());
665                                 template_path = expandPath(template_path);
666                         }
667                         break;
668
669                 case RC_TEMPDIRPATH:
670                         if (lexrc.next()) {
671                                 tempdir_path = os::internal_path(lexrc.getString());
672                                 tempdir_path = expandPath(tempdir_path);
673                         }
674                         break;
675
676                 case RC_USETEMPDIR:
677                         if (lexrc.next())
678                                 LYXERR0("Ignoring obsolete use_tempdir flag.");
679                         break;
680
681                 case RC_USELASTFILEPOS:
682                         lexrc >> use_lastfilepos;
683                         break;
684
685                 case RC_LOADSESSION:
686                         lexrc >> load_session;
687                         break;
688
689                 case RC_MOUSE_WHEEL_SPEED:
690                         lexrc >> mouse_wheel_speed;
691                         break;
692
693                 case RC_COMPLETION_INLINE_DELAY:
694                         lexrc >> completion_inline_delay;
695                         break;
696
697                 case RC_COMPLETION_INLINE_MATH:
698                         lexrc >> completion_inline_math;
699                         break;
700
701                 case RC_COMPLETION_INLINE_TEXT:
702                         lexrc >> completion_inline_text;
703                         break;
704
705                 case RC_COMPLETION_INLINE_DOTS:
706                         lexrc >> completion_inline_dots;
707                         break;
708
709                 case RC_COMPLETION_POPUP_DELAY:
710                         lexrc >> completion_popup_delay;
711                         break;
712
713                 case RC_COMPLETION_POPUP_MATH:
714                         lexrc >> completion_popup_math;
715                         break;
716
717                 case RC_COMPLETION_POPUP_TEXT:
718                         lexrc >> completion_popup_text;
719                         break;
720
721                 case RC_COMPLETION_CURSOR_TEXT:
722                         lexrc >> completion_cursor_text;
723                         break;
724
725                 case RC_COMPLETION_POPUP_AFTER_COMPLETE:
726                         lexrc >> completion_popup_after_complete;
727                         break;
728
729                 case RC_NUMLASTFILES:
730                         lexrc >> num_lastfiles;
731                         break;
732
733                 case RC_CHECKLASTFILES:
734                         lexrc >> check_lastfiles;
735                         break;
736
737                 case RC_SCREEN_FONT_ROMAN:
738                         if (lexrc.next()) {
739                                 roman_font_name = lexrc.getString();
740                                 oldFontFormat(roman_font_name,
741                                               roman_font_foundry);
742                         }
743                         break;
744
745                 case RC_SCREEN_FONT_SANS:
746                         if (lexrc.next()) {
747                                 sans_font_name = lexrc.getString();
748                                 oldFontFormat(sans_font_name, sans_font_foundry);
749                         }
750                         break;
751
752                 case RC_SCREEN_FONT_TYPEWRITER:
753                         if (lexrc.next()) {
754                                 typewriter_font_name = lexrc.getString();
755                                 oldFontFormat(typewriter_font_name,
756                                               typewriter_font_foundry);
757                         }
758                         break;
759
760                 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
761                         lexrc >> roman_font_foundry;
762                         break;
763
764                 case RC_SCREEN_FONT_SANS_FOUNDRY:
765                         lexrc >> sans_font_foundry;
766                         break;
767
768                 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
769                         lexrc >> typewriter_font_foundry;
770                         break;
771
772                 case RC_SET_COLOR: {
773                         if (!lexrc.next()) {
774                                 lexrc.printError("Missing color tag.");
775                                 break;
776                         }
777                         string lyx_name = lexrc.getString();
778
779                         if (!lexrc.next()) {
780                                 lexrc.printError("Missing color name for color: `$$Token'");
781                                 break;
782                         }
783                         string x11_name = lexrc.getString();
784
785                         ColorCode const col =
786                                 lcolor.getFromLyXName(lyx_name);
787                         if (col == Color_none ||
788                             col == Color_inherit ||
789                             col == Color_ignore)
790                                 break;
791
792                         if (!lcolor.setColor(col, x11_name))
793                                 LYXERR0("Bad lyxrc set_color for " << lyx_name);
794                         break;
795                 }
796
797                 case RC_AUTOREGIONDELETE:
798                         // Auto region delete defaults to true
799                         lexrc >> auto_region_delete;
800                         break;
801
802                 case RC_SERVERPIPE:
803                         if (lexrc.next()) {
804                                 lyxpipes = os::internal_path(lexrc.getString());
805                                 lyxpipes = expandPath(lyxpipes);
806                         }
807                         break;
808
809                 case RC_CURSOR_FOLLOWS_SCROLLBAR:
810                         lexrc >> cursor_follows_scrollbar;
811                         break;
812
813                 case RC_MAC_LIKE_WORD_MOVEMENT:
814                         lexrc >> mac_like_word_movement;
815                         break;
816
817                 case RC_MACRO_EDIT_STYLE:
818                         if (lexrc.next()) {
819                                 switch (lexrc.getInteger()) {
820                                 case 0: macro_edit_style = MACRO_EDIT_INLINE_BOX; break;
821                                 case 1: macro_edit_style = MACRO_EDIT_INLINE; break;
822                                 case 2: macro_edit_style = MACRO_EDIT_LIST; break;
823                                 }
824                         }
825                         break;
826
827                 case RC_DIALOGS_ICONIFY_WITH_MAIN:
828                         lexrc >> dialogs_iconify_with_main;
829                         break;
830
831                 case RC_PLAINTEXT_ROFF_COMMAND:
832                         if (lexrc.next(true)) {
833                                 plaintext_roff_command = lexrc.getString();
834                         }
835                         break;
836                 case RC_PLAINTEXT_LINELEN:
837                         lexrc >> plaintext_linelen;
838                         break;
839                         // Spellchecker settings:
840                 case RC_USE_SPELL_LIB:
841                         lexrc >> use_spell_lib;
842                         break;
843                 case RC_SPELL_COMMAND:
844                         if (lexrc.next(true))
845                                 isp_command = lexrc.getString();
846                         break;
847                 case RC_ACCEPT_COMPOUND:
848                         lexrc >> isp_accept_compound;
849                         break;
850                 case RC_USE_INP_ENC:
851                         lexrc >> isp_use_input_encoding;
852                         break;
853                 case RC_USE_ALT_LANG:
854                         lexrc >> isp_use_alt_lang;
855                         break;
856                 case RC_USE_PERS_DICT:
857                         lexrc >> isp_use_pers_dict;
858                         break;
859                 case RC_USE_TOOLTIP:
860                         lexrc >> use_tooltip;
861                         break;
862                 case RC_USE_PIXMAP_CACHE:
863                         lexrc >> use_pixmap_cache;
864                         break;
865                 case RC_USE_ESC_CHARS:
866                         lexrc >> isp_use_esc_chars;
867                         break;
868                 case RC_ALT_LANG:
869                         lexrc >> isp_alt_lang;
870                         break;
871                 case RC_PERS_DICT:
872                         if (lexrc.next())
873                                 isp_pers_dict = os::internal_path(lexrc.getString());
874                         break;
875                 case RC_ESC_CHARS:
876                         lexrc >> isp_esc_chars;
877                         break;
878                 case RC_MAKE_BACKUP:
879                         lexrc >> make_backup;
880                         break;
881                 case RC_BACKUPDIR_PATH:
882                         if (lexrc.next()) {
883                                 backupdir_path = os::internal_path(lexrc.getString());
884                                 backupdir_path = expandPath(backupdir_path);
885                         }
886                         break;
887                 case RC_DATE_INSERT_FORMAT:
888                         lexrc >> date_insert_format;
889                         break;
890                 case RC_LANGUAGE_PACKAGE:
891                         lexrc >> language_package;
892                         break;
893                 case RC_LANGUAGE_AUTO_BEGIN:
894                         lexrc >> language_auto_begin;
895                         break;
896                 case RC_LANGUAGE_AUTO_END:
897                         lexrc >> language_auto_end;
898                         break;
899                 case RC_LANGUAGE_GLOBAL_OPTIONS:
900                         lexrc >> language_global_options;
901                         break;
902                 case RC_LANGUAGE_USE_BABEL:
903                         lexrc >> language_use_babel;
904                         break;
905                 case RC_LANGUAGE_COMMAND_BEGIN:
906                         lexrc >> language_command_begin;
907                         break;
908                 case RC_LANGUAGE_COMMAND_END:
909                         lexrc >> language_command_end;
910                         break;
911                 case RC_LANGUAGE_COMMAND_LOCAL:
912                         lexrc >> language_command_local;
913                         break;
914                 case RC_RTL_SUPPORT:
915                         lexrc >> rtl_support;
916                         break;
917                 case RC_VISUAL_CURSOR:
918                         lexrc >> visual_cursor;
919                         break;
920                 case RC_AUTO_NUMBER:
921                         lexrc >> auto_number;
922                         break;
923                 case RC_MARK_FOREIGN_LANGUAGE:
924                         lexrc >> mark_foreign_language;
925                         break;
926
927                 case RC_COPIER: {
928                         string fmt, command;
929                         if (lexrc.next())
930                                 fmt = lexrc.getString();
931                         if (lexrc.next(true))
932                                 command = lexrc.getString();
933                         setMover(fmt, command);
934                         break;
935                 }
936
937                 case RC_CONVERTER: {
938                         string from, to, command, flags;
939                         if (lexrc.next())
940                                 from = lexrc.getString();
941                         if (lexrc.next())
942                                 to = lexrc.getString();
943                         if (lexrc.next(true))
944                                 command = lexrc.getString();
945                         if (lexrc.next())
946                                 flags = lexrc.getString();
947                         if (command.empty())
948                                 theConverters().erase(from, to);
949                         else
950                                 theConverters().add(from, to, command, flags);
951                         break;
952                 }
953                 // compatibility with versions older than 1.4.0 only
954                 case RC_VIEWER: {
955                         string format, command;
956                         lexrc >> format >> command;
957                         formats.setViewer(format, command);
958                         break;
959                 }
960                 case RC_FORMAT: {
961                         string format, extension, prettyname, shortcut;
962                         lexrc >> format >> extension >> prettyname >> shortcut;
963                         string viewer, editor;
964                         if (lexrc.next(true))
965                                 viewer = lexrc.getString();
966                         if (lexrc.next(true))
967                                 editor = lexrc.getString();
968                         string flags;
969                         // Hack to ensure compatibility with versions older
970                         // than 1.5.0
971                         int le = lexrc.lex();
972                         if (le != Lexer::LEX_FEOF && le != Lexer::LEX_UNDEF) {
973                                 flags = lexrc.getString();
974                                 if (le != Lexer::LEX_DATA) {
975                                         // We have got a known token.
976                                         // Therefore this is an old style
977                                         // format definition without
978                                         // flags.
979                                         lexrc.pushToken(flags);
980                                         flags.erase();
981                                 }
982                         }
983                         int flgs = Format::none;
984                         while (!flags.empty()) {
985                                 string flag;
986                                 flags = split(flags, flag, ',');
987                                 if (flag == "document")
988                                         flgs |= Format::document;
989                                 else if (flag == "vector")
990                                         flgs |= Format::vector;
991                                 else
992                                         LYXERR0("Ignoring unknown flag `"
993                                                << flag << "' for format `"
994                                                << format << "'.");
995                         }
996                         if (prettyname.empty()) {
997                                 if (theConverters().formatIsUsed(format))
998                                         LYXERR0("Can't delete format " << format);
999                                 else
1000                                         formats.erase(format);
1001                         } else {
1002                                 formats.add(format, extension, prettyname,
1003                                             shortcut, viewer, editor, flgs);
1004                         }
1005                         break;
1006                 }
1007                 case RC_DEFAULT_LANGUAGE:
1008                         lexrc >> default_language;
1009                         break;
1010
1011                 case RC_GUI_LANGUAGE:
1012                         lexrc >> gui_language;
1013                         break;
1014
1015                 case RC_LABEL_INIT_LENGTH:
1016                         lexrc >> label_init_length;
1017                         break;
1018
1019                 case RC_SHOW_BANNER:
1020                         lexrc >> show_banner;
1021                         break;
1022
1023                 case RC_PREVIEW:
1024                         if (lexrc.next()) {
1025                                 string const tmp = lexrc.getString();
1026                                 if (tmp == "true" || tmp == "on")
1027                                         preview = PREVIEW_ON;
1028                                 else if (tmp == "no_math")
1029                                         preview = PREVIEW_NO_MATH;
1030                                 else {
1031                                         preview = PREVIEW_OFF;
1032                                         if (tmp != "false" && tmp != "off")
1033                                                 LYXERR0("Unrecognized preview status \""
1034                                                        << tmp << '\n');
1035                                 }
1036                         }
1037                         break;
1038
1039                 case RC_PREVIEW_HASHED_LABELS:
1040                         lexrc >> preview_hashed_labels;
1041                         break;
1042
1043                 case RC_PREVIEW_SCALE_FACTOR:
1044                         lexrc >> preview_scale_factor;
1045                         break;
1046
1047                 case RC_USER_NAME:
1048                         lexrc >> user_name;
1049                         break;
1050                 case RC_USER_EMAIL:
1051                         lexrc >> user_email;
1052                         break;
1053
1054                 case RC_PATH_PREFIX:
1055                         lexrc >> path_prefix;
1056                         break;
1057
1058                 case RC_USE_CONVERTER_CACHE:
1059                         lexrc >> use_converter_cache;
1060                         break;
1061                 case RC_CONVERTER_CACHE_MAXAGE:
1062                         lexrc >> converter_cache_maxage;
1063                         break;
1064
1065                 case RC_SORT_LAYOUTS:
1066                         lexrc >> sort_layouts;
1067                         break;
1068                 case RC_GROUP_LAYOUTS:
1069                         lexrc >> group_layouts;
1070                         break;
1071                 case RC_FULL_SCREEN_LIMIT:
1072                         lexrc >> full_screen_limit;
1073                         break;
1074                 case RC_FULL_SCREEN_TOOLBARS:
1075                         lexrc >> full_screen_toolbars;
1076                         break;
1077                 case RC_FULL_SCREEN_SCROLLBAR:
1078                         lexrc >> full_screen_scrollbar;
1079                         break;
1080                 case RC_FULL_SCREEN_TABBAR:
1081                         lexrc >> full_screen_tabbar;
1082                         break;
1083                 case RC_FULL_SCREEN_WIDTH:
1084                         lexrc >> full_screen_width;
1085                         break;
1086                 case RC_OPEN_BUFFERS_IN_TABS:
1087                         lexrc >> open_buffers_in_tabs;
1088                         break;
1089
1090                 case RC_LAST:
1091                         break; // this is just a dummy
1092                 }
1093         }
1094
1095         /// Update converters data-structures
1096         theConverters().update(formats);
1097         theConverters().buildGraph();
1098
1099         return 0;
1100 }
1101
1102
1103 void LyXRC::write(FileName const & filename, bool ignore_system_lyxrc) const
1104 {
1105         ofstream ofs(filename.toFilesystemEncoding().c_str());
1106         if (ofs)
1107                 write(ofs, ignore_system_lyxrc);
1108 }
1109
1110
1111 void LyXRC::print() const
1112 {
1113         if (lyxerr.debugging())
1114                 write(lyxerr, false);
1115         else
1116                 write(cout, false);
1117 }
1118
1119
1120 class SameMover {
1121 public:
1122         typedef pair<string, SpecialisedMover> Data;
1123
1124         SameMover(Data const & comparison)
1125                 : comparison_(comparison) {}
1126
1127         bool operator()(Data const & data) const
1128         {
1129                 return data.first == comparison_.first &&
1130                         data.second.command() == comparison_.second.command();
1131         }
1132
1133 private:
1134         Data comparison_;
1135 };
1136
1137
1138 namespace {
1139
1140         // Escape \ and " so that LyXLex can read the string later
1141         string escapeCommand(string const & str) {
1142                 return subst(subst(str , "\\", "\\\\"), 
1143                              "\"", "\\\"");
1144         }
1145
1146 }
1147
1148
1149 void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) const
1150 {
1151         LyXRCTags tag = RC_LAST;
1152         
1153         if (!name.empty()) {
1154                 for (int i = 0; i != lyxrcCount; ++i)
1155                         if ("\\" + name == lyxrcTags[i].tag)
1156                                 tag = static_cast<LyXRCTags>(lyxrcTags[i].code);
1157         }
1158
1159         if (tag == RC_LAST)
1160                 os << "# This file is written by LyX, 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_LINELEN:
2052                 if (ignore_system_lyxrc ||
2053                     plaintext_linelen != system_lyxrc.plaintext_linelen) {
2054                         os << "\\plaintext_linelen " << plaintext_linelen << '\n';
2055                 }
2056                 if (tag != RC_LAST)
2057                         break;
2058         case RC_MAKE_BACKUP:
2059                 if (ignore_system_lyxrc ||
2060                     make_backup != system_lyxrc.make_backup) {
2061                         os << "\\make_backup " << convert<string>(make_backup) << '\n';
2062                 }
2063                 if (tag != RC_LAST)
2064                         break;
2065         case RC_BACKUPDIR_PATH:
2066                 if (ignore_system_lyxrc ||
2067                     backupdir_path != system_lyxrc.backupdir_path) {
2068                         string const path = os::external_path(backupdir_path);
2069                         os << "\\backupdir_path \"" << path << "\"\n";
2070                 }
2071                 if (tag != RC_LAST)
2072                         break;
2073
2074                 os << "\n#\n"
2075                    << "# PLAIN TEXT EXPORT SECTION ##############################\n"
2076                    << "#\n\n";
2077
2078         case RC_PLAINTEXT_ROFF_COMMAND:
2079                 if (ignore_system_lyxrc ||
2080                     plaintext_roff_command != system_lyxrc.plaintext_roff_command) {
2081                         os << "\\plaintext_roff_command \"" << escapeCommand(plaintext_roff_command)
2082                            << "\"\n";
2083                 }
2084                 if (tag != RC_LAST)
2085                         break;
2086
2087                 os << "\n#\n"
2088                    << "# SPELLCHECKER SECTION ##############################\n"
2089                    << "#\n\n";
2090         case RC_USE_SPELL_LIB:
2091                 if (ignore_system_lyxrc ||
2092                     use_spell_lib != system_lyxrc.use_spell_lib) {
2093                         os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
2094                 }
2095                 if (tag != RC_LAST)
2096                         break;
2097         case RC_SPELL_COMMAND:
2098                 if (ignore_system_lyxrc ||
2099                     isp_command != system_lyxrc.isp_command) {
2100                         os << "\\spell_command \"" << escapeCommand(isp_command) << "\"\n";
2101                 }
2102                 if (tag != RC_LAST)
2103                         break;
2104         case RC_ACCEPT_COMPOUND:
2105                 if (ignore_system_lyxrc ||
2106                     isp_accept_compound != system_lyxrc.isp_accept_compound) {
2107                         os << "\\accept_compound " << convert<string>(isp_accept_compound)
2108                            << '\n';
2109                 }
2110                 if (tag != RC_LAST)
2111                         break;
2112         case RC_USE_ALT_LANG:
2113                 if (ignore_system_lyxrc ||
2114                     isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
2115                         os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
2116                            << '\n';
2117                 }
2118                 if (tag != RC_LAST)
2119                         break;
2120         case RC_ALT_LANG:
2121                 if (ignore_system_lyxrc ||
2122                     isp_alt_lang != system_lyxrc.isp_alt_lang) {
2123                         os << "\\alternate_language \"" << isp_alt_lang
2124                            << "\"\n";
2125                 }
2126                 if (tag != RC_LAST)
2127                         break;
2128         case RC_USE_ESC_CHARS:
2129                 if (ignore_system_lyxrc ||
2130                     isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
2131                         os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
2132                            << '\n';
2133                 }
2134                 if (tag != RC_LAST)
2135                         break;
2136         case RC_ESC_CHARS:
2137                 if (ignore_system_lyxrc ||
2138                     isp_esc_chars != system_lyxrc.isp_esc_chars) {
2139                         os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
2140                 }
2141                 if (tag != RC_LAST)
2142                         break;
2143         case RC_USE_PERS_DICT:
2144                 if (ignore_system_lyxrc ||
2145                     isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
2146                         os << "\\use_personal_dictionary "
2147                            << convert<string>(isp_use_pers_dict)
2148                            << '\n';
2149                 }
2150                 if (tag != RC_LAST)
2151                         break;
2152         case RC_USE_TOOLTIP:
2153                 if (ignore_system_lyxrc ||
2154                     use_tooltip != system_lyxrc.use_tooltip) {
2155                         os << "\\use_tooltip "
2156                            << convert<string>(use_tooltip)
2157                            << '\n';
2158                 }
2159         case RC_USE_PIXMAP_CACHE:
2160                 if (ignore_system_lyxrc ||
2161                     use_pixmap_cache != system_lyxrc.use_pixmap_cache) {
2162                         os << "\\use_pixmap_cache "
2163                            << convert<string>(use_pixmap_cache)
2164                            << '\n';
2165                 }
2166         case RC_PERS_DICT:
2167                 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
2168                         string const path = os::external_path(isp_pers_dict);
2169                         os << "\\personal_dictionary \"" << path << "\"\n";
2170                 }
2171                 if (tag != RC_LAST)
2172                         break;
2173         case RC_USE_INP_ENC:
2174                 if (ignore_system_lyxrc ||
2175                     isp_use_input_encoding
2176                     != system_lyxrc.isp_use_input_encoding) {
2177                         os << "\\use_input_encoding "
2178                            << convert<string>(isp_use_input_encoding)
2179                            << '\n';
2180                 }
2181                 if (tag != RC_LAST)
2182                         break;
2183
2184                 os << "\n#\n"
2185                    << "# LANGUAGE SUPPORT SECTION ##########################\n"
2186                    << "#\n\n";
2187
2188         case RC_RTL_SUPPORT:
2189                 if (ignore_system_lyxrc ||
2190                     rtl_support != system_lyxrc.rtl_support) {
2191                         os << "\\rtl " << convert<string>(rtl_support) << '\n';
2192                 }
2193                 if (tag != RC_LAST)
2194                         break;
2195         case RC_VISUAL_CURSOR:
2196                 if (ignore_system_lyxrc ||
2197                         visual_cursor != system_lyxrc.visual_cursor) {
2198                         os << "\\visual_cursor " << convert<string>(visual_cursor) << '\n';
2199                 }
2200                 if (tag != RC_LAST)
2201                         break;
2202         case RC_LANGUAGE_PACKAGE:
2203                 if (ignore_system_lyxrc ||
2204                     language_package != system_lyxrc.language_package) {
2205                         os << "\\language_package \"" << language_package
2206                            << "\"\n";
2207                 }
2208                 if (tag != RC_LAST)
2209                         break;
2210         case RC_LANGUAGE_GLOBAL_OPTIONS:
2211                 if (ignore_system_lyxrc ||
2212                     language_global_options
2213                     != system_lyxrc.language_global_options) {
2214                         os << "\\language_global_options \""
2215                            << convert<string>(language_global_options)
2216                            << "\"\n";
2217                 }
2218                 if (tag != RC_LAST)
2219                         break;
2220         case RC_LANGUAGE_USE_BABEL:
2221                 if (ignore_system_lyxrc ||
2222                     language_use_babel != system_lyxrc.language_use_babel) {
2223                         os << "\\language_use_babel \""
2224                            << convert<string>(language_use_babel)
2225                            << "\"\n";
2226                 }
2227                 if (tag != RC_LAST)
2228                         break;
2229         case RC_LANGUAGE_COMMAND_BEGIN:
2230                 if (ignore_system_lyxrc ||
2231                     language_command_begin
2232                     != system_lyxrc.language_command_begin) {
2233                         os << "\\language_command_begin \""
2234                            << language_command_begin
2235                            << "\"\n";
2236                 }
2237                 if (tag != RC_LAST)
2238                         break;
2239         case RC_LANGUAGE_COMMAND_END:
2240                 if (ignore_system_lyxrc ||
2241                     language_command_end
2242                     != system_lyxrc.language_command_end) {
2243                         os << "\\language_command_end \"" << language_command_end
2244                            << "\"\n";
2245                 }
2246                 if (tag != RC_LAST)
2247                         break;
2248         case RC_LANGUAGE_COMMAND_LOCAL:
2249                 if (ignore_system_lyxrc ||
2250                     language_command_local
2251                     != system_lyxrc.language_command_local) {
2252                         os << "\\language_command_local \""
2253                            << language_command_local
2254                            << "\"\n";
2255                 }
2256                 if (tag != RC_LAST)
2257                         break;
2258         case RC_LANGUAGE_AUTO_BEGIN:
2259                 if (ignore_system_lyxrc ||
2260                     language_auto_begin != system_lyxrc.language_auto_begin) {
2261                         os << "\\language_auto_begin "
2262                            << convert<string>(language_auto_begin) << '\n';
2263                 }
2264                 if (tag != RC_LAST)
2265                         break;
2266         case RC_LANGUAGE_AUTO_END:
2267                 if (ignore_system_lyxrc ||
2268                     language_auto_end != system_lyxrc.language_auto_end) {
2269                         os << "\\language_auto_end "
2270                            << convert<string>(language_auto_end) << '\n';
2271                 }
2272                 if (tag != RC_LAST)
2273                         break;
2274         case RC_MARK_FOREIGN_LANGUAGE:
2275                 if (ignore_system_lyxrc ||
2276                     mark_foreign_language
2277                     != system_lyxrc.mark_foreign_language) {
2278                         os << "\\mark_foreign_language " <<
2279                                 convert<string>(mark_foreign_language) << '\n';
2280                 }
2281                 if (tag != RC_LAST)
2282                         break;
2283
2284                 os << "\n#\n"
2285                    << "# 2nd MISC SUPPORT SECTION ##########################\n"
2286                    << "#\n\n";
2287
2288         case RC_AUTO_NUMBER:
2289                 if (ignore_system_lyxrc ||
2290                     auto_number != system_lyxrc.auto_number) {
2291                         os << "\\auto_number " << convert<string>(auto_number) << '\n';
2292                 }
2293                 if (tag != RC_LAST)
2294                         break;
2295         case RC_DEFAULT_LANGUAGE:
2296                 if (ignore_system_lyxrc ||
2297                     default_language != system_lyxrc.default_language) {
2298                         os << "\\default_language " << default_language << '\n';
2299                 }
2300                 if (tag != RC_LAST)
2301                         break;
2302         case RC_GUI_LANGUAGE:
2303                 if (ignore_system_lyxrc ||
2304                     gui_language != system_lyxrc.gui_language) {
2305                         os << "\\gui_language " << gui_language << '\n';
2306                 }
2307                 if (tag != RC_LAST)
2308                         break;
2309
2310                 os << "\n#\n"
2311                    << "# FORMATS SECTION ##########################\n"
2312                    << "#\n\n";
2313
2314         case RC_FORMAT:
2315                 // New/modified formats
2316                 for (Formats::const_iterator cit = formats.begin();
2317                      cit != formats.end(); ++cit) {
2318                         Format const * format =
2319                                 system_formats.getFormat(cit->name());
2320                         if (!format ||
2321                             format->extension() != cit->extension() ||
2322                             format->prettyname() != cit->prettyname() ||
2323                             format->shortcut() != cit->shortcut() ||
2324                             format->viewer() != cit->viewer() ||
2325                             format->editor() != cit->editor() ||
2326                             format->documentFormat() != cit->documentFormat() ||
2327                             format->vectorFormat() != cit->vectorFormat()) {
2328                                 os << "\\format \"" << cit->name() << "\" \""
2329                                    << cit->extension() << "\" \""
2330                                    << cit->prettyname() << "\" \""
2331                                    << cit->shortcut() << "\" \""
2332                                    << escapeCommand(cit->viewer()) << "\" \""
2333                                    << escapeCommand(cit->editor()) << "\" \"";
2334                                 vector<string> flags;
2335                                 if (cit->documentFormat())
2336                                         flags.push_back("document");
2337                                 if (cit->vectorFormat())
2338                                         flags.push_back("vector");
2339                                 os << getStringFromVector(flags);
2340                                 os << "\"\n";
2341                         }
2342                 }
2343
2344                 // Look for deleted formats
2345                 for (Formats::const_iterator cit = system_formats.begin();
2346                      cit != system_formats.end(); ++cit)
2347                         if (!formats.getFormat(cit->name()))
2348                                 os << "\\format \"" << cit->name()
2349                                    << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
2350                 if (tag != RC_LAST)
2351                         break;
2352         case RC_VIEWER:
2353                 // Ignore it
2354                 if (tag != RC_LAST)
2355                         break;
2356
2357                 os << "\n#\n"
2358                    << "# CONVERTERS SECTION ##########################\n"
2359                    << "#\n\n";
2360
2361         case RC_CONVERTER:
2362                 // Look for new converters
2363                 for (Converters::const_iterator cit = theConverters().begin();
2364                      cit != theConverters().end(); ++cit) {
2365                         Converter const * converter =
2366                                 theSystemConverters().getConverter(cit->from,
2367                                                                cit->to);
2368                         if (!converter ||
2369                             converter->command != cit->command ||
2370                             converter->flags != cit->flags)
2371                                 os << "\\converter \"" << cit->from << "\" \""
2372                                    << cit->to << "\" \""
2373                                    << escapeCommand(cit->command) << "\" \""
2374                                    << cit->flags << "\"\n";
2375                 }
2376
2377                 // New/modifed converters
2378                 for (Converters::const_iterator cit = theSystemConverters().begin();
2379                      cit != theSystemConverters().end(); ++cit)
2380                         if (!theConverters().getConverter(cit->from, cit->to))
2381                                 os << "\\converter \"" << cit->from
2382                                    << "\" \"" << cit->to << "\" \"\" \"\"\n";
2383                 if (tag != RC_LAST)
2384                         break;
2385
2386         case RC_COPIER:
2387                 if (tag == RC_LAST)
2388                         os << "\n#\n"
2389                            << "# COPIERS SECTION ##########################\n"
2390                            << "#\n\n";
2391
2392                 // Look for new movers
2393                 Movers::const_iterator const sysbegin = theSystemMovers().begin();
2394                 Movers::const_iterator const sysend = theSystemMovers().end();
2395                 Movers::const_iterator it = theMovers().begin();
2396                 Movers::const_iterator end = theMovers().end();
2397
2398                 for (; it != end; ++it) {
2399                         Movers::const_iterator const sysit =
2400                                 find_if(sysbegin, sysend, SameMover(*it));
2401                         if (sysit == sysend) {
2402                                 string const & fmt = it->first;
2403                                 string const & command =
2404                                         it->second.command();
2405
2406                                 os << "\\copier " << fmt
2407                                    << " \"" << escapeCommand(command) << "\"\n";
2408                         }
2409                 }
2410                 if (tag != RC_LAST)
2411                         break;
2412
2413                 // We don't actually delete SpecialisedMover(s) from the
2414                 // map, just clear their 'command', so there's no need
2415                 // to test for anything else.
2416         }
2417
2418         os.flush();
2419 }
2420
2421
2422 #if 0
2423 string const LyXRC::getDescription(LyXRCTags tag)
2424 {
2425         docstring str;
2426
2427         switch (tag) {
2428         case RC_ACCEPT_COMPOUND:
2429                 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2430                 break;
2431
2432         case RC_ALT_LANG:
2433         case RC_USE_ALT_LANG:
2434                 str = _("Specify an alternate language. The default is to use the language of the document.");
2435                 break;
2436
2437         case RC_PLAINTEXT_ROFF_COMMAND:
2438                 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.");
2439                 break;
2440
2441         case RC_PLAINTEXT_LINELEN:
2442                 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.");
2443                 break;
2444
2445         case RC_AUTOREGIONDELETE:
2446                 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2447                 break;
2448
2449         case RC_AUTORESET_OPTIONS:
2450                 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2451                 break;
2452
2453         case RC_AUTOSAVE:
2454                 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2455                 break;
2456
2457         case RC_AUTO_NUMBER:
2458                 break;
2459
2460         case RC_BACKUPDIR_PATH:
2461                 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.");
2462                 break;
2463
2464         case RC_BIBTEX_COMMAND:
2465                 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2466                 break;
2467
2468         case RC_BINDFILE:
2469                 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2470                 break;
2471
2472         case RC_CHECKLASTFILES:
2473                 str = _("Select to check whether the lastfiles still exist.");
2474                 break;
2475
2476         case RC_CHKTEX_COMMAND:
2477                 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2478                 break;
2479
2480         case RC_CONVERTER:
2481                 break;
2482
2483         case RC_COPIER:
2484                 break;
2485
2486         case RC_CURSOR_FOLLOWS_SCROLLBAR:
2487                 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.");
2488                 break;
2489
2490         case RC_MAC_LIKE_WORD_MOVEMENT:
2491                 str = _("Use the Mac OS X conventions for the word-level cursor movement");
2492                 break;
2493
2494         case RC_SHOW_MACRO_LABEL:
2495                 str = _("Show a small box around a Math Macro with the macro name when the cursor is inside.");
2496                 break;
2497
2498         case RC_CUSTOM_EXPORT_COMMAND:
2499                 break;
2500
2501         case RC_CUSTOM_EXPORT_FORMAT:
2502                 break;
2503
2504         case RC_DATE_INSERT_FORMAT:
2505                 //xgettext:no-c-format
2506                 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2507                 break;
2508
2509         case RC_DEFFILE:
2510                 str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories.");
2511                 break;
2512
2513         case RC_DEFAULT_LANGUAGE:
2514                 str = _("New documents will be assigned this language.");
2515                 break;
2516
2517         case RC_DEFAULT_PAPERSIZE:
2518                 str = _("Specify the default paper size.");
2519                 break;
2520
2521         case RC_DIALOGS_ICONIFY_WITH_MAIN:
2522                 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2523                 break;
2524
2525         case RC_DISPLAY_GRAPHICS:
2526                 str = _("Select how LyX will display any graphics.");
2527                 break;
2528
2529         case RC_DOCUMENTPATH:
2530                 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2531                 break;
2532
2533         case RC_ESC_CHARS:
2534         case RC_USE_ESC_CHARS:
2535                 str = _("Specify additional chars that can be part of a word.");
2536                 break;
2537
2538         case RC_EXAMPLEPATH:
2539                 str = _("The path that LyX will set when offering to choose an example. An empty value selects the directory LyX was started from.");
2540                 break;
2541
2542         case RC_FONT_ENCODING:
2543                 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2544                 break;
2545
2546         case RC_FORMAT:
2547                 break;
2548
2549         case RC_INDEX_COMMAND:
2550                 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\".");
2551                 break;
2552
2553         case RC_NOMENCL_COMMAND:
2554                 str = _("Define the options of makeindex (cf. man makeindex) to be used for nomenclatures. This might differ from the index processing options.");
2555                 break;
2556
2557         case RC_INPUT:
2558                 break;
2559
2560         case RC_KBMAP:
2561         case RC_KBMAP_PRIMARY:
2562         case RC_KBMAP_SECONDARY:
2563                 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.");
2564                 break;
2565
2566         case RC_LABEL_INIT_LENGTH:
2567                 str = _("Maximum number of words in the initialization string for a new label");
2568                 break;
2569
2570         case RC_LANGUAGE_AUTO_BEGIN:
2571                 str = _("Select if a language switching command is needed at the beginning of the document.");
2572                 break;
2573
2574         case RC_LANGUAGE_AUTO_END:
2575                 str = _("Select if a language switching command is needed at the end of the document.");
2576                 break;
2577
2578         case RC_LANGUAGE_COMMAND_BEGIN:
2579                 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.");
2580                 break;
2581
2582         case RC_LANGUAGE_COMMAND_END:
2583                 str = _("The LaTeX command for changing back to the language of the document.");
2584                 break;
2585
2586         case RC_LANGUAGE_COMMAND_LOCAL:
2587                 str = _("The LaTeX command for local changing of the language.");
2588                 break;
2589
2590         case RC_LANGUAGE_GLOBAL_OPTIONS:
2591                 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2592                 break;
2593
2594         case RC_LANGUAGE_PACKAGE:
2595                 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2596                 break;
2597
2598         case RC_LANGUAGE_USE_BABEL:
2599                 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2600                 break;
2601
2602         case RC_USELASTFILEPOS:
2603                 str = _("De-select if you do not want LyX to scroll to saved position.");
2604                 break;
2605
2606         case RC_LOADSESSION:
2607                 str = _("De-select to prevent loading files opened from the last LyX session.");
2608                 break;
2609
2610         case RC_MAKE_BACKUP:
2611                 str = _("De-select if you don't want LyX to create backup files.");
2612                 break;
2613
2614         case RC_MARK_FOREIGN_LANGUAGE:
2615                 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2616                 break;
2617
2618         case RC_MOUSE_WHEEL_SPEED:
2619                 str = bformat(_("The scrolling speed of the mouse wheel."),
2620                       maxlastfiles);
2621                 break;
2622
2623         case RC_COMPLETION_POPUP_DELAY:
2624                 str = _("The completion popup delay.");
2625                 break;
2626
2627         case RC_COMPLETION_POPUP_MATH:
2628                 str = _("Select to display the completion popup in math mode.");
2629                 break;
2630
2631         case RC_COMPLETION_POPUP_TEXT:
2632                 str = _("Select to display the completion popup in text mode.");
2633                 break;
2634
2635         case RC_COMPLETION_POPUP_AFTER_COMPLETE:
2636                 str = _("Show the completion popup without delay after non-unique completion attempt.");
2637                 break;
2638
2639         case RC_COMPLETION_POPUP_TEXT:
2640                 str = _("Show a small triangle on the cursor to indicate that a completion is available.");
2641                 break;
2642
2643         case RC_COMPLETION_POPUP_DELAY:
2644                 str = _("The inline completion delay.");
2645                 break;
2646
2647         case RC_COMPLETION_INLINE_MATH:
2648                 str = _("Select to display the inline completion in math mode.");
2649                 break;
2650
2651         case RC_COMPLETION_INLINE_TEXT:
2652                 str = _("Select to display the inline completion in text mode.");
2653                 break;
2654
2655         case RC_COMPLETION_INLINE_DOTS:
2656                 str = _("Use \"...\" to shorten long completions.");
2657                 break;
2658
2659         case RC_NUMLASTFILES:
2660                 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."),
2661                         maxlastfiles);
2662                 break;
2663
2664         case RC_PATH_PREFIX:
2665                 str = _("Specify those directories which should be "
2666                          "prepended to the PATH environment variable. "
2667                          "Use the OS native format.");
2668                 break;
2669
2670         case RC_PERS_DICT:
2671         case RC_USE_PERS_DICT:
2672                 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2673                 break;
2674
2675         case RC_PREVIEW:
2676                 str = _("Shows a typeset preview of things such as math");
2677                 break;
2678
2679         case RC_PREVIEW_HASHED_LABELS:
2680                 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2681                 break;
2682
2683         case RC_PREVIEW_SCALE_FACTOR:
2684                 str = _("Scale the preview size to suit.");
2685                 break;
2686
2687         case RC_PRINTCOLLCOPIESFLAG:
2688                 str = _("The option for specifying whether the copies should be collated.");
2689                 break;
2690
2691         case RC_PRINTCOPIESFLAG:
2692                 str = _("The option for specifying the number of copies to print.");
2693                 break;
2694
2695         case RC_PRINTER:
2696                 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2697                 break;
2698
2699         case RC_PRINTEVENPAGEFLAG:
2700                 str = _("The option to print only even pages.");
2701                 break;
2702
2703         case RC_PRINTEXSTRAOPTIONS:
2704                 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2705                 break;
2706
2707         case RC_PRINTFILEEXTENSION:
2708                 str = _("Extension of printer program output file. Usually \".ps\".");
2709                 break;
2710
2711         case RC_PRINTLANDSCAPEFLAG:
2712                 str = _("The option to print out in landscape.");
2713                 break;
2714
2715         case RC_PRINTODDPAGEFLAG:
2716                 str = _("The option to print only odd pages.");
2717                 break;
2718
2719         case RC_PRINTPAGERANGEFLAG:
2720                 str = _("The option for specifying a comma-separated list of pages to print.");
2721                 break;
2722
2723         case RC_PRINTPAPERDIMENSIONFLAG:
2724                                    str = _("Option to specify the dimensions of the print paper.");
2725                 break;
2726
2727         case RC_PRINTPAPERFLAG:
2728                 str = _("The option to specify paper type.");
2729                 break;
2730
2731         case RC_PRINTREVERSEFLAG:
2732                 str = _("The option to reverse the order of the pages printed.");
2733                 break;
2734
2735         case RC_PRINTSPOOL_COMMAND:
2736                 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.");
2737                 break;
2738
2739         case RC_PRINTSPOOL_PRINTERPREFIX:
2740                 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.");
2741                 break;
2742
2743         case RC_PRINTTOFILE:
2744                 str = _("Option to pass to the print program to print to a file.");
2745                 break;
2746
2747         case RC_PRINTTOPRINTER:
2748                 str = _("Option to pass to the print program to print on a specific printer.");
2749                 break;
2750
2751         case RC_PRINT_ADAPTOUTPUT:
2752                 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2753                 break;
2754
2755         case RC_PRINT_COMMAND:
2756                 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2757                 break;
2758
2759         case RC_RTL_SUPPORT:
2760                 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2761                 break;
2762
2763         case RC_VISUAL_CURSOR:
2764                 str = _("Select to have visual bidi cursor movement, unselect for logical movement.");
2765                 break;
2766
2767         case RC_SCREEN_DPI:
2768                 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2769                 break;
2770
2771         case RC_SCREEN_FONT_ROMAN:
2772         case RC_SCREEN_FONT_SANS:
2773         case RC_SCREEN_FONT_TYPEWRITER:
2774                 str = _("The screen fonts used to display the text while editing.");
2775                 break;
2776
2777         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
2778         case RC_SCREEN_FONT_SANS_FOUNDRY:
2779         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2780                 break;
2781
2782         case RC_SCREEN_FONT_SCALABLE:
2783                 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.");
2784                 break;
2785
2786         case RC_SCREEN_FONT_SIZES:
2787                 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2788                 break;
2789
2790         case RC_SCREEN_ZOOM:
2791                 //xgettext:no-c-format
2792                 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2793                 break;
2794
2795         case RC_GEOMETRY_SESSION:
2796                 str = _("Allow session manager to save and restore windows geometry.");
2797                 break;
2798
2799         case RC_SERVERPIPE:
2800                 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2801                 break;
2802
2803         case RC_SET_COLOR:
2804                 break;
2805
2806         case RC_SHOW_BANNER:
2807                 str = _("De-select if you don't want the startup banner.");
2808                 break;
2809
2810         case RC_SPELL_COMMAND:
2811                 str = _("What command runs the spellchecker?");
2812                 break;
2813
2814         case RC_TEMPDIRPATH:
2815                 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2816                 break;
2817
2818         case RC_TEMPLATEPATH:
2819                 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2820                 break;
2821
2822         case RC_TEX_ALLOWS_SPACES:
2823                 break;
2824
2825         case RC_TEX_EXPECTS_WINDOWS_PATHS:
2826                 break;
2827
2828         case RC_UIFILE:
2829                 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2830                 break;
2831
2832         case RC_USER_EMAIL:
2833                 break;
2834
2835         case RC_USER_NAME:
2836                 break;
2837
2838         case RC_USETEMPDIR:
2839                 break;
2840
2841         case RC_USE_INP_ENC:
2842                 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.");
2843                 break;
2844
2845         case RC_USE_TOOLTIP:
2846                 str = _("Enable the automatic appearance of tool tips in the work area.");
2847                 break;
2848
2849         case RC_USE_PIXMAP_CACHE:
2850                 str = _("Enable the pixmap cache that might improve performance on Mac and Windows.");
2851                 break;
2852
2853         case RC_USE_SPELL_LIB:
2854                 break;
2855
2856         case RC_VIEWDVI_PAPEROPTION:
2857                 _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2858                 break;
2859
2860         case RC_VIEWER:
2861                 break;
2862
2863         case RC_LAST:
2864                 break;
2865         }
2866
2867         return str;
2868 }
2869 #endif
2870
2871
2872 // The global instance
2873 LyXRC lyxrc;
2874
2875 // The global copy of the system lyxrc entries (everything except preferences)
2876 LyXRC system_lyxrc;
2877
2878
2879 } // namespace lyx