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