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