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