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