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