]> git.lyx.org Git - lyx.git/blob - src/lyxrc.C
Enable Qt's uic to process the .ui files when using srcdir != buildir and
[lyx.git] / src / lyxrc.C
1 /**
2  * \file lyxrc.C
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 "debug.h"
25 #include "converter.h"
26 #include "format.h"
27 #include "gettext.h"
28 #include "lastfiles.h"
29 #include "LColor.h"
30 #include "lyxlex.h"
31 #include "lyxfont.h"
32 #include "mover.h"
33
34 #include "graphics/GraphicsTypes.h"
35
36 #include "support/convert.h"
37 #include "support/filetools.h"
38 #include "support/lstrings.h"
39 #include "support/os.h"
40 #include "support/userinfo.h"
41
42 using lyx::support::ascii_lowercase;
43 using lyx::support::bformat;
44 using lyx::support::ExpandPath;
45 using lyx::support::GetEnv;
46 using lyx::support::LibFileSearch;
47 using lyx::support::token;
48
49 namespace os = lyx::support::os;
50
51 using std::cout;
52 using std::endl;
53
54 using std::ios;
55 using std::ofstream;
56 using std::ostream;
57 using std::string;
58
59
60 namespace {
61
62 // when adding something to this array keep it sorted!
63 keyword_item lyxrcTags[] = {
64         { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
65         { "\\alternate_language", LyXRC::RC_ALT_LANG },
66         { "\\ascii_linelen", LyXRC::RC_ASCII_LINELEN },
67         { "\\ascii_roff_command", LyXRC::RC_ASCIIROFF_COMMAND },
68         { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
69         { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
70         { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
71         { "\\autosave", LyXRC::RC_AUTOSAVE },
72         { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
73         { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
74         { "\\bind_file", LyXRC::RC_BINDFILE },
75         { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
76         { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
77         { "\\converter", LyXRC::RC_CONVERTER },
78         { "\\copier", LyXRC::RC_COPIER },
79         { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
80         { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
81         { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
82         { "\\cygwin_path_fix_needed", LyXRC::RC_CYGWIN_PATH_FIX },
83         { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
84         { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
85         { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
86         { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
87         { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
88         { "\\document_path", LyXRC::RC_DOCUMENTPATH },
89         { "\\escape_chars", LyXRC::RC_ESC_CHARS },
90         { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
91         { "\\format", LyXRC::RC_FORMAT },
92         { "\\index_command", LyXRC::RC_INDEX_COMMAND },
93         { "\\input", LyXRC::RC_INPUT },
94         { "\\kbmap", LyXRC::RC_KBMAP },
95         { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
96         { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
97         { "\\label_init_length", LyXRC::RC_LABEL_INIT_LENGTH },
98         { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
99         { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
100         { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
101         { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
102         { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
103         { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
104         { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
105         { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
106         { "\\lastfiles", LyXRC::RC_LASTFILES },
107         { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
108         { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
109         { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
110         { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
111         { "\\popup_bold_font", LyXRC::RC_POPUP_BOLD_FONT },
112         { "\\popup_font_encoding", LyXRC::RC_POPUP_FONT_ENCODING },
113         { "\\popup_normal_font", LyXRC::RC_POPUP_NORMAL_FONT },
114         { "\\preview", LyXRC::RC_PREVIEW },
115         { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
116         { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
117         { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
118         { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
119         { "\\print_command", LyXRC::RC_PRINT_COMMAND },
120         { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
121         { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
122         { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
123         { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
124         { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
125         { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
126         { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
127         { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
128         { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
129         { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
130         { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
131         { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
132         { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
133         { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
134         { "\\printer", LyXRC::RC_PRINTER },
135         { "\\rtl", LyXRC::RC_RTL_SUPPORT },
136         { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
137         { "\\screen_font_encoding", LyXRC::RC_SCREEN_FONT_ENCODING },
138         // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
139         { "\\screen_font_encoding_menu", LyXRC::RC_POPUP_FONT_ENCODING },
140         // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
141         { "\\screen_font_menu", LyXRC::RC_POPUP_BOLD_FONT },
142         // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
143         { "\\screen_font_popup", LyXRC::RC_POPUP_NORMAL_FONT },
144         { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
145         { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
146         { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
147         { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
148         { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
149         { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
150         { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
151         { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
152         { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
153         { "\\serverpipe", LyXRC::RC_SERVERPIPE },
154         { "\\set_color", LyXRC::RC_SET_COLOR },
155         { "\\show_banner", LyXRC::RC_SHOW_BANNER },
156         { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
157         { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
158         { "\\template_path", LyXRC::RC_TEMPLATEPATH },
159         { "\\ui_file", LyXRC::RC_UIFILE },
160         { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
161         { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
162         { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
163         { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
164         // compatibility with versions older than 1.4.0 only
165         { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
166         { "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB },
167         // compatibility with versions older than 1.4.0 only
168         { "\\use_tempdir", LyXRC::RC_USETEMPDIR },
169         { "\\user_email", LyXRC::RC_USER_EMAIL },
170         { "\\user_name", LyXRC::RC_USER_NAME },
171         { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
172         // compatibility with versions older than 1.4.0 only
173         { "\\viewer" ,LyXRC::RC_VIEWER},
174         { "\\wheel_jump", LyXRC::RC_WHEEL_JUMP }
175 };
176
177 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
178
179 } // namespace anon
180
181
182 LyXRC::LyXRC()
183 {
184         setDefaults();
185 }
186
187
188 void LyXRC::setDefaults() {
189         bind_file = "cua";
190         ui_file = "default";
191         // Get printer from the environment. If fail, use default "",
192         // assuming that everything is set up correctly.
193         printer = GetEnv("PRINTER");
194         print_adapt_output = false;
195         print_command = "dvips";
196         print_evenpage_flag = "-B";
197         print_oddpage_flag = "-A";
198         print_pagerange_flag = "-pp";
199         print_copies_flag = "-c";
200         print_collcopies_flag = "-C";
201         print_reverse_flag = "-r";
202         print_landscape_flag = "-t landscape";
203         print_to_printer = "-P";
204         print_to_file = "-o ";
205         print_file_extension = ".ps";
206         print_paper_flag = "-t";
207         print_paper_dimension_flag = "-T";
208         document_path.erase();
209         tempdir_path = "/tmp";
210         view_dvi_paper_option.erase();
211         default_papersize = PAPER_USLETTER;
212         custom_export_format = "ps";
213         chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
214         bibtex_command = "bibtex";
215         fontenc = "default";
216         index_command = "makeindex -c -q";
217         dpi = 75;
218         // Because a screen typically is wider than a piece of paper:
219         zoom = 150;
220         wheel_jump = 5;
221         // Default LaTeX font size:
222         font_sizes[LyXFont::SIZE_TINY] = "5.0";
223         font_sizes[LyXFont::SIZE_SCRIPT] = "7.0";
224         font_sizes[LyXFont::SIZE_FOOTNOTE] = "8.0";
225         font_sizes[LyXFont::SIZE_SMALL] = "9.0";
226         font_sizes[LyXFont::SIZE_NORMAL] = "10.0";
227         font_sizes[LyXFont::SIZE_LARGE] = "12.0";
228         font_sizes[LyXFont::SIZE_LARGER] = "14.4";
229         font_sizes[LyXFont::SIZE_LARGEST] = "17.26";
230         font_sizes[LyXFont::SIZE_HUGE] = "20.74";
231         font_sizes[LyXFont::SIZE_HUGER] = "24.88";
232         use_scalable_fonts = true;
233         roman_font_name = "";
234         sans_font_name = "";
235         typewriter_font_name = "";
236         popup_bold_font = "-*-helvetica-bold-r";
237         popup_normal_font = "-*-helvetica-medium-r";
238         font_norm = "iso8859-1";
239         font_norm_type = ISO_8859_1;
240         popup_font_encoding.erase();
241         autosave = 300;
242         auto_region_delete = true;
243         auto_reset_options = false;
244         ascii_linelen = 65;
245         num_lastfiles = maxlastfiles;
246         check_lastfiles = true;
247         make_backup = true;
248         backupdir_path.erase();
249         display_graphics = lyx::graphics::ColorDisplay;
250         // Spellchecker settings:
251         use_spell_lib = true;
252         isp_command = "ispell";
253         isp_accept_compound = false;
254         isp_use_input_encoding = false;
255         isp_use_alt_lang = false;
256         isp_use_pers_dict = false;
257         isp_use_esc_chars = false;
258         use_kbmap = false;
259         rtl_support = false;
260         auto_number = true;
261         mark_foreign_language = true;
262         language_auto_begin = true;
263         language_auto_end = true;
264         language_global_options = true;
265         language_use_babel = true;
266         language_package = "\\usepackage{babel}";
267         language_command_begin = "\\selectlanguage{$$lang}";
268         language_command_local = "\\foreignlanguage{$$lang}{";
269         default_language = "english";
270         show_banner = true;
271         cygwin_path_fix = false;
272         date_insert_format = "%A, %e %B %Y";
273         cursor_follows_scrollbar = false;
274         dialogs_iconify_with_main = false;
275         label_init_length = 3;
276         preview = PREVIEW_OFF;
277         preview_hashed_labels  = false;
278         preview_scale_factor = "0.9";
279
280         user_name = lyx::support::user_name();
281
282         user_email = lyx::support::user_email();
283 }
284
285
286 namespace {
287
288 void oldFontFormat(string & family, string & foundry)
289 {
290         if (family.empty() || family[0] != '-')
291                 return;
292         foundry = token(family, '-', 1);
293         family = token(family, '-', 2);
294         if (foundry == "*")
295                 foundry.erase();
296 }
297
298 } // namespace anon
299
300
301 int LyXRC::read(string const & filename)
302 {
303         LyXLex lexrc(lyxrcTags, lyxrcCount);
304         if (lyxerr.debugging(Debug::PARSER))
305                 lexrc.printTable(lyxerr);
306
307         lexrc.setFile(filename);
308         if (!lexrc.isOK()) return -2;
309
310         lyxerr[Debug::LYXRC] << "Reading '" << filename << "'..." << endl;
311
312         return read(lexrc);
313 }
314
315
316 int LyXRC::read(std::istream & is)
317 {
318         LyXLex lexrc(lyxrcTags, lyxrcCount);
319         if (lyxerr.debugging(Debug::PARSER))
320                 lexrc.printTable(lyxerr);
321
322         lexrc.setStream(is);
323         if (!lexrc.isOK()) return -2;
324
325         lyxerr[Debug::LYXRC] << "Reading istream..." << endl;
326
327         return read(lexrc);
328 }
329
330
331 int LyXRC::read(LyXLex & lexrc)
332 {
333         if (!lexrc.isOK()) return -2;
334
335         while (lexrc.isOK()) {
336                 // By using two switches we take advantage of the compiler
337                 // telling us if we have missed a LyXRCTags element in
338                 // the second switch.
339                 // Note that this also shows a problem with LyXLex since it
340                 // helps us avoid taking advantage of the strictness of the
341                 // compiler.
342
343                 int le = lexrc.lex();
344                 switch (le) {
345                 case LyXLex::LEX_UNDEF:
346                         lexrc.printError("Unknown tag `$$Token'");
347                         continue;
348                 case LyXLex::LEX_FEOF:
349                         continue;
350                 default: break;
351                 }
352                 switch (static_cast<LyXRCTags>(le)) {
353                 case RC_INPUT: // Include file
354                         if (lexrc.next()) {
355                                 string const tmp =
356                                         LibFileSearch(string(),
357                                                       lexrc.getString());
358                                 if (read(tmp)) {
359                                         lexrc.printError("Error reading "
360                                                          "included file: "+tmp);
361                                 }
362                         }
363                         break;
364                 case RC_BINDFILE:                     // RVDK_PATCH_5
365                         if (lexrc.next()) {
366                                 bind_file = lexrc.getString();
367                         }
368                         break;
369
370                 case RC_UIFILE:
371                         if (lexrc.next()) {
372                                 ui_file = lexrc.getString();
373                         }
374                         break;
375
376                 case RC_AUTORESET_OPTIONS:
377                         if (lexrc.next()) {
378                                 auto_reset_options = lexrc.getBool();
379                         }
380                         break;
381
382                 case RC_DISPLAY_GRAPHICS:
383                         if (lexrc.next()) {
384                                 display_graphics = lyx::graphics::displayTranslator().find(lexrc.getString());
385                         }
386                         break;
387
388                 case RC_KBMAP:
389                         if (lexrc.next()) {
390                                 use_kbmap = lexrc.getBool();
391                         }
392                         break;
393
394                 case RC_CYGWIN_PATH_FIX:
395                         if (lexrc.next()) {
396                                 cygwin_path_fix = lexrc.getBool();
397                                 os::cygwin_path_fix(cygwin_path_fix);
398                         }
399                         break;
400  
401                 case RC_KBMAP_PRIMARY:
402                         if (lexrc.next()) {
403                                 string const kmap(lexrc.getString());
404                                 if (kmap.empty()) {
405                                         // nothing
406                                 } else if (!LibFileSearch("kbd", kmap,
407                                                           "kmap").empty()) {
408                                         primary_kbmap = kmap;
409                                 } else {
410                                         lexrc.printError("LyX: Keymap `$$Token' not found");
411                                 }
412                         }
413                         break;
414
415                 case RC_KBMAP_SECONDARY:
416                         if (lexrc.next()) {
417                                 string const kmap(lexrc.getString());
418                                 if (kmap.empty()) {
419                                         // nothing
420                                 } else if (!LibFileSearch("kbd", kmap,
421                                                           "kmap").empty()) {
422                                         secondary_kbmap = kmap;
423                                 } else {
424                                         lexrc.printError("LyX: Keymap `$$Token' not found");
425                                 }
426                         }
427                         break;
428
429                 case RC_FONT_ENCODING:
430                         if (lexrc.next()) {
431                                 fontenc = lexrc.getString();
432                         }
433                         break;
434
435                 case RC_PRINTER:
436                         if (lexrc.next()) {
437                                 printer = lexrc.getString();
438                         }
439                         break;
440
441                 case RC_PRINT_COMMAND:
442                         if (lexrc.next()) {
443                                 print_command = lexrc.getString();
444                         }
445                         break;
446
447                 case RC_PRINTEVENPAGEFLAG:
448                         if (lexrc.next()) {
449                                 print_evenpage_flag = lexrc.getString();
450                         }
451                         break;
452
453                 case RC_PRINTODDPAGEFLAG:
454                         if (lexrc.next()) {
455                                 print_oddpage_flag = lexrc.getString();
456                         }
457                         break;
458
459                 case RC_PRINTPAGERANGEFLAG:
460                         if (lexrc.next()) {
461                                 print_pagerange_flag = lexrc.getString();
462                         }
463                         break;
464
465                 case RC_PRINTCOPIESFLAG:
466                         if (lexrc.next()) {
467                                 print_copies_flag = lexrc.getString();
468                         }
469                         break;
470
471                 case RC_PRINTCOLLCOPIESFLAG:
472                         if (lexrc.next()) {
473                                 print_collcopies_flag = lexrc.getString();
474                         }
475                         break;
476
477                 case RC_PRINTREVERSEFLAG:
478                         if (lexrc.next()) {
479                                 print_reverse_flag = lexrc.getString();
480                         }
481                         break;
482
483                 case RC_PRINTLANDSCAPEFLAG:
484                         if (lexrc.next()) {
485                                 print_landscape_flag = lexrc.getString();
486                         }
487                         break;
488
489                 case RC_PRINTTOPRINTER:
490                         if (lexrc.next()) {
491                                 print_to_printer = lexrc.getString();
492                         }
493                         break;
494
495                 case RC_PRINT_ADAPTOUTPUT:
496                         if (lexrc.next()) {
497                                 print_adapt_output = lexrc.getBool();
498                         }
499                         break;
500
501                 case RC_PRINTTOFILE:
502                         if (lexrc.next()) {
503                                 print_to_file = lexrc.getString();
504                         }
505                         break;
506
507                 case RC_PRINTFILEEXTENSION:
508                         if (lexrc.next()) {
509                                 print_file_extension = lexrc.getString();
510                         }
511                         break;
512
513                 case RC_PRINTEXSTRAOPTIONS:
514                         if (lexrc.next()) {
515                                 print_extra_options = lexrc.getString();
516                         }
517                         break;
518
519                 case RC_PRINTSPOOL_COMMAND:
520                         if (lexrc.next()) {
521                                 print_spool_command = lexrc.getString();
522                         }
523                         break;
524
525                 case RC_PRINTSPOOL_PRINTERPREFIX:
526                         if (lexrc.next()) {
527                                 print_spool_printerprefix = lexrc.getString();
528                         }
529                         break;
530
531                 case RC_PRINTPAPERDIMENSIONFLAG:
532                         if (lexrc.next()) {
533                                 print_paper_dimension_flag = lexrc.getString();
534                         }
535                         break;
536
537                 case RC_PRINTPAPERFLAG:
538                         if (lexrc.next()) {
539                                 print_paper_flag = lexrc.getString();
540                         }
541                         break;
542
543                 case RC_CUSTOM_EXPORT_COMMAND:
544                         if (lexrc.next()) {
545                                 custom_export_command = lexrc.getString();
546                         }
547                         break;
548
549                 case RC_CUSTOM_EXPORT_FORMAT:
550                         if (lexrc.next()) {
551                                 custom_export_format = lexrc.getString();
552                         }
553                         break;
554
555                 case RC_DEFAULT_PAPERSIZE:
556                         if (lexrc.next()) {
557                                 string const size =
558                                         ascii_lowercase(lexrc.getString());
559                                 if (size == "usletter")
560                                         default_papersize =
561                                                 PAPER_USLETTER;
562                                 else if (size == "legal")
563                                         default_papersize =
564                                                 PAPER_LEGALPAPER;
565                                 else if (size == "executive")
566                                         default_papersize =
567                                                 PAPER_EXECUTIVEPAPER;
568                                 else if (size == "a3")
569                                         default_papersize =
570                                                 PAPER_A3PAPER;
571                                 else if (size == "a4")
572                                         default_papersize =
573                                                 PAPER_A4PAPER;
574                                 else if (size == "a5")
575                                         default_papersize =
576                                                 PAPER_A5PAPER;
577                                 else if (size == "b5")
578                                         default_papersize =
579                                                 PAPER_B5PAPER;
580                         }
581                         break;
582
583                 case RC_VIEWDVI_PAPEROPTION:
584                         if (lexrc.next()) {
585                                 view_dvi_paper_option = lexrc.getString();
586                         } else {
587                                 view_dvi_paper_option.erase();
588                         }
589                         break;
590
591                 case RC_CHKTEX_COMMAND:
592                         if (lexrc.next()) {
593                                 chktex_command = lexrc.getString();
594                         }
595                         break;
596
597                 case RC_BIBTEX_COMMAND:
598                         if (lexrc.next()) {
599                                 bibtex_command = lexrc.getString();
600                         }
601                         break;
602
603                 case RC_INDEX_COMMAND:
604                         if (lexrc.next()) {
605                                 index_command = lexrc.getString();
606                         }
607                         break;
608
609                 case RC_SCREEN_DPI:
610                         if (lexrc.next()) {
611                                 dpi = lexrc.getInteger();
612                         }
613                         break;
614
615                 case RC_SCREEN_ZOOM:
616                         if (lexrc.next()) {
617                                 zoom = lexrc.getInteger();
618                         }
619                         break;
620
621                 case RC_WHEEL_JUMP:
622                         if (lexrc.next()) {
623                                 wheel_jump = lexrc.getInteger();
624                         }
625                         break;
626
627                 case RC_SCREEN_FONT_SIZES:
628                         if (lexrc.next()) {
629                                 font_sizes[LyXFont::SIZE_TINY] =
630                                         lexrc.getString();
631                         }
632                         if (lexrc.next()) {
633                                 font_sizes[LyXFont::SIZE_SCRIPT] =
634                                         lexrc.getString();
635                         }
636                         if (lexrc.next()) {
637                                 font_sizes[LyXFont::SIZE_FOOTNOTE] =
638                                         lexrc.getString();
639                         }
640                         if (lexrc.next()) {
641                                 font_sizes[LyXFont::SIZE_SMALL] =
642                                         lexrc.getString();
643                         }
644                         if (lexrc.next()) {
645                                 font_sizes[LyXFont::SIZE_NORMAL] =
646                                         lexrc.getString();
647                         }
648                         if (lexrc.next()) {
649                                 font_sizes[LyXFont::SIZE_LARGE] =
650                                         lexrc.getString();
651                         }
652                         if (lexrc.next()) {
653                                 font_sizes[LyXFont::SIZE_LARGER] =
654                                         lexrc.getString();
655                         }
656                         if (lexrc.next()) {
657                                 font_sizes[LyXFont::SIZE_LARGEST] =
658                                         lexrc.getString();
659                         }
660                         if (lexrc.next()) {
661                                 font_sizes[LyXFont::SIZE_HUGE] =
662                                         lexrc.getString();
663                         }
664                         if (lexrc.next()) {
665                                 font_sizes[LyXFont::SIZE_HUGER] =
666                                         lexrc.getString();
667                         }
668                         break;
669
670                 case RC_SCREEN_FONT_SCALABLE:
671                         if (lexrc.next()) {
672                                 use_scalable_fonts = lexrc.getBool();
673                         }
674                         break;
675
676                 case RC_AUTOSAVE:
677                         if (lexrc.next()) {
678                                 autosave = lexrc.getInteger();
679                         }
680                         break;
681
682                 case RC_DOCUMENTPATH:
683                         if (lexrc.next()) {
684                                 document_path = ExpandPath(lexrc.getString());
685                         }
686                         break;
687
688                 case RC_TEMPLATEPATH:
689                         if (lexrc.next()) {
690                                 template_path = ExpandPath(lexrc.getString());
691                         }
692                         break;
693
694                 case RC_TEMPDIRPATH:
695                         if (lexrc.next()) {
696                                 tempdir_path = ExpandPath(lexrc.getString());
697                         }
698                         break;
699
700                 case RC_USETEMPDIR:
701                         if (lexrc.next()) {
702                                 lyxerr << "Ignoring obsolete use_tempdir flag." << endl;
703                         }
704                         break;
705
706                 case RC_LASTFILES:
707                         if (lexrc.next()) {
708                                 lastfiles = ExpandPath(lexrc.getString());
709                         }
710                         break;
711
712                 case RC_NUMLASTFILES:
713                         if (lexrc.next()) {
714                                 num_lastfiles = lexrc.getInteger();
715                         }
716                         break;
717
718                 case RC_CHECKLASTFILES:
719                         if (lexrc.next()) {
720                                 check_lastfiles = lexrc.getBool();
721                         }
722                         break;
723
724                 case RC_SCREEN_FONT_ROMAN:
725                         if (lexrc.next()) {
726                                 roman_font_name = lexrc.getString();
727                                 oldFontFormat(roman_font_name,
728                                               roman_font_foundry);
729                         }
730                         break;
731
732                 case RC_SCREEN_FONT_SANS:
733                         if (lexrc.next()) {
734                                 sans_font_name = lexrc.getString();
735                                 oldFontFormat(sans_font_name, sans_font_foundry);
736                         }
737                         break;
738
739                 case RC_SCREEN_FONT_TYPEWRITER:
740                         if (lexrc.next()) {
741                                 typewriter_font_name = lexrc.getString();
742                                 oldFontFormat(typewriter_font_name,
743                                               typewriter_font_foundry);
744                         }
745                         break;
746
747                 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
748                         if (lexrc.next()) {
749                                 roman_font_foundry = lexrc.getString();
750                         }
751                         break;
752
753                 case RC_SCREEN_FONT_SANS_FOUNDRY:
754                         if (lexrc.next()) {
755                                 sans_font_foundry = lexrc.getString();
756                         }
757                         break;
758
759                 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
760                         if (lexrc.next()) {
761                                 typewriter_font_foundry = lexrc.getString();
762                         }
763                         break;
764
765                 case RC_SCREEN_FONT_ENCODING:
766                         if (lexrc.next()) {
767                                 font_norm = lexrc.getString();
768                                 set_font_norm_type();
769                         }
770                         break;
771
772                 case RC_POPUP_BOLD_FONT:
773                         if (lexrc.next()) {
774                                 popup_bold_font = lexrc.getString();
775                         }
776                         break;
777
778                 case RC_POPUP_NORMAL_FONT:
779                         if (lexrc.next()) {
780                                 popup_normal_font = lexrc.getString();
781                         }
782                         break;
783
784                 case RC_POPUP_FONT_ENCODING:
785                         if (lexrc.next()) {
786                                 popup_font_encoding = lexrc.getString();
787                         }
788                         break;
789
790                 case RC_SET_COLOR:
791                 {
792                         string lyx_name, x11_name;
793
794                         if (lexrc.next()) {
795                                 lyx_name = lexrc.getString();
796                         } else {
797                                 lexrc.printError("Missing color tag.");
798                                 break;
799                         }
800
801                         if (lexrc.next()) {
802                                 x11_name = lexrc.getString();
803                         } else {
804                                 lexrc.printError("Missing color name for color: `$$Token'");
805                                 break;
806                         }
807
808                         LColor::color const col =
809                                 lcolor.getFromLyXName(lyx_name);
810                         if (col == LColor::none ||
811                             col == LColor::inherit ||
812                             col == LColor::ignore)
813                                 break;
814
815                         if (!lcolor.setColor(col, x11_name)) {
816                                 lyxerr << "Bad lyxrc set_color for "
817                                         << lyx_name << endl;
818
819                         }
820                         break;
821                 }
822                 case RC_AUTOREGIONDELETE:
823                         // Auto region delete defaults to true
824                         if (lexrc.next()) {
825                                 auto_region_delete = lexrc.getBool();
826                         }
827                         break;
828
829                 case RC_SERVERPIPE:
830                         if (lexrc.next()) {
831                                 lyxpipes = ExpandPath(lexrc.getString());
832                         }
833                         break;
834
835                 case RC_CURSOR_FOLLOWS_SCROLLBAR:
836                         if (lexrc.next()) {
837                                 cursor_follows_scrollbar = lexrc.getBool();
838                         }
839                         break;
840
841                 case RC_DIALOGS_ICONIFY_WITH_MAIN:
842                         if (lexrc.next()) {
843                                 dialogs_iconify_with_main = lexrc.getBool();
844                         }
845                         break;
846
847                 case RC_ASCIIROFF_COMMAND:
848                         if (lexrc.next()) {
849                                 ascii_roff_command = lexrc.getString();
850                         }
851                         break;
852                 case RC_ASCII_LINELEN:
853                         if (lexrc.next()) {
854                                 ascii_linelen = lexrc.getInteger();
855                         }
856                         break;
857                         // Spellchecker settings:
858                 case RC_USE_SPELL_LIB:
859                         if (lexrc.next()) {
860                                 use_spell_lib = lexrc.getBool();
861                         }
862                         break;
863                 case RC_SPELL_COMMAND:
864                         if (lexrc.next()) {
865                                 isp_command = lexrc.getString();
866                         }
867                         break;
868                 case RC_ACCEPT_COMPOUND:
869                         if (lexrc.next()) {
870                                 isp_accept_compound = lexrc.getBool();
871                         }
872                         break;
873                 case RC_USE_INP_ENC:
874                         if (lexrc.next()) {
875                                 isp_use_input_encoding = lexrc.getBool();
876                         }
877                         break;
878                 case RC_USE_ALT_LANG:
879                         if (lexrc.next()) {
880                                 isp_use_alt_lang = lexrc.getBool();
881                         }
882                         break;
883                 case RC_USE_PERS_DICT:
884                         if (lexrc.next()) {
885                                 isp_use_pers_dict = lexrc.getBool();
886                         }
887                         break;
888                 case RC_USE_ESC_CHARS:
889                         if (lexrc.next()) {
890                                 isp_use_esc_chars = lexrc.getBool();
891                         }
892                         break;
893                 case RC_ALT_LANG:
894                         if (lexrc.next()) {
895                                 isp_alt_lang = lexrc.getString();
896                         }
897                         break;
898                 case RC_PERS_DICT:
899                         if (lexrc.next()) {
900                                 isp_pers_dict = lexrc.getString();
901                         }
902                         break;
903                 case RC_ESC_CHARS:
904                         if (lexrc.next()) {
905                                 isp_esc_chars = lexrc.getString();
906                         }
907                         break;
908                 case RC_MAKE_BACKUP:
909                         if (lexrc.next()) {
910                                 make_backup = lexrc.getBool();
911                         }
912                         break;
913                 case RC_BACKUPDIR_PATH:
914                         if (lexrc.next()) {
915                                 backupdir_path = ExpandPath(lexrc.getString());
916                         }
917                         break;
918                 case RC_DATE_INSERT_FORMAT:
919                         if (lexrc.next()) {
920                                 date_insert_format = lexrc.getString();
921                         }
922                         break;
923                 case RC_LANGUAGE_PACKAGE:
924                         if (lexrc.next()) {
925                                 language_package = lexrc.getString();
926                         }
927                         break;
928                 case RC_LANGUAGE_AUTO_BEGIN:
929                         if (lexrc.next()) {
930                                 language_auto_begin = lexrc.getBool();
931                         }
932                         break;
933                 case RC_LANGUAGE_AUTO_END:
934                         if (lexrc.next()) {
935                                 language_auto_end = lexrc.getBool();
936                         }
937                         break;
938                 case RC_LANGUAGE_GLOBAL_OPTIONS:
939                         if (lexrc.next()) {
940                                 language_global_options = lexrc.getBool();
941                         }
942                         break;
943                 case RC_LANGUAGE_USE_BABEL:
944                         if (lexrc.next()) {
945                                 language_use_babel = lexrc.getBool();
946                         }
947                         break;
948                 case RC_LANGUAGE_COMMAND_BEGIN:
949                         if (lexrc.next()) {
950                                 language_command_begin = lexrc.getString();
951                         }
952                         break;
953                 case RC_LANGUAGE_COMMAND_END:
954                         if (lexrc.next()) {
955                                 language_command_end = lexrc.getString();
956                         }
957                         break;
958                 case RC_LANGUAGE_COMMAND_LOCAL:
959                         if (lexrc.next()) {
960                                 language_command_local = lexrc.getString();
961                         }
962                         break;
963                 case RC_RTL_SUPPORT:
964                         if (lexrc.next()) {
965                                 rtl_support = lexrc.getBool();
966                         }
967                         break;
968                 case RC_AUTO_NUMBER:
969                         if (lexrc.next()) {
970                                 auto_number = lexrc.getBool();
971                         }
972                         break;
973                 case RC_MARK_FOREIGN_LANGUAGE:
974                         if (lexrc.next()) {
975                                 mark_foreign_language = lexrc.getBool();
976                         }
977                         break;
978
979                 case RC_COPIER: {
980                         string fmt, command;
981                         if (lexrc.next()) {
982                                 fmt = lexrc.getString();
983                         }
984                         if (lexrc.next()) {
985                                 command = lexrc.getString();
986                         }
987                         movers.set(fmt, command);
988                         break;
989                 }
990
991                 case RC_CONVERTER: {
992                         string from, to, command, flags;
993                         if (lexrc.next()) {
994                                 from = lexrc.getString();
995                         }
996                         if (lexrc.next()) {
997                                 to = lexrc.getString();
998                         }
999                         if (lexrc.next()) {
1000                                 command = lexrc.getString();
1001                         }
1002                         if (lexrc.next()) {
1003                                 flags = lexrc.getString();
1004                         }
1005                         if (command.empty()
1006                             || token(command, ' ', 0) == "none") {
1007                                 converters.erase(from, to);
1008                         } else {
1009                                 converters.add(from, to, command, flags);
1010                         }
1011                         break;
1012                 }
1013                 // compatibility with versions older than 1.4.0 only
1014                 case RC_VIEWER: {
1015                         string format, command;
1016                         if (lexrc.next()) {
1017                                 format = lexrc.getString();
1018                         }
1019                         if (lexrc.next()) {
1020                                 command = lexrc.getString();
1021                                 if (token(command, ' ', 0) == "none")
1022                                         command.erase();
1023                         }
1024                         formats.setViewer(format, command);
1025                         break;
1026                 }
1027                 case RC_FORMAT: {
1028                         string format, extension, prettyname, shortcut;
1029                         if (lexrc.next()) {
1030                                 format = lexrc.getString();
1031                         }
1032                         if (lexrc.next()) {
1033                                 extension = lexrc.getString();
1034                         }
1035                         if (lexrc.next()) {
1036                                 prettyname = lexrc.getString();
1037                         }
1038                         if (lexrc.next()) {
1039                                 shortcut = lexrc.getString();
1040                         }
1041                         string viewer, editor;
1042                         // Hack to ensure compatibility with versions older
1043                         // than 1.4.0
1044                         int le = lexrc.lex();
1045                         if (le != LyXLex::LEX_FEOF && le != LyXLex::LEX_UNDEF) {
1046                                 viewer = lexrc.getString();
1047                                 if (le == LyXLex::LEX_DATA) {
1048                                         if (token(viewer, ' ', 0) == "none")
1049                                                 viewer.erase();
1050                                         if (lexrc.next()) {
1051                                                 editor = lexrc.getString();
1052                                                 if (token(editor, ' ', 0) == "none")
1053                                                         editor.erase();
1054                                         }
1055                                 } else {
1056                                         // We have got a known token.
1057                                         // Therefore this is an old style
1058                                         // format definition without
1059                                         // viewer and editor.
1060                                         lexrc.pushToken(viewer);
1061                                         viewer.erase();
1062                                 }
1063                         }
1064                         if (prettyname.empty()) {
1065                                 if (converters.formatIsUsed(format)) {
1066                                         lyxerr << "Can't delete format "
1067                                                << format << endl;
1068                                 } else {
1069                                         formats.erase(format);
1070                                 }
1071                         } else {
1072                                 formats.add(format, extension, prettyname,
1073                                             shortcut, viewer, editor);
1074                         }
1075                         break;
1076                 }
1077                 case RC_DEFAULT_LANGUAGE:
1078                         if (lexrc.next()) {
1079                                 default_language = lexrc.getString();
1080                         }
1081                         break;
1082
1083                 case RC_LABEL_INIT_LENGTH:
1084                         if (lexrc.next()) {
1085                                 label_init_length = lexrc.getInteger();
1086                         }
1087                         break;
1088
1089                 case RC_SHOW_BANNER:
1090                         if (lexrc.next()) {
1091                                 show_banner = lexrc.getBool();
1092                         }
1093                         break;
1094
1095                 case RC_PREVIEW:
1096                         if (lexrc.next()) {
1097                                 string const tmp = lexrc.getString();
1098                                 if (tmp == "true" || tmp == "on")
1099                                         preview = PREVIEW_ON;
1100                                 else if (tmp == "no_math")
1101                                         preview = PREVIEW_NO_MATH;
1102                                 else {
1103                                         preview = PREVIEW_OFF;
1104                                         if (tmp != "false" && tmp != "off")
1105                                                 lyxerr << "Unrecognized "
1106                                                         "preview status \""
1107                                                        << tmp << '\n' << endl;
1108                                 }
1109                         }
1110                         break;
1111
1112                 case RC_PREVIEW_HASHED_LABELS:
1113                         if (lexrc.next()) {
1114                                 preview_hashed_labels = lexrc.getBool();
1115                         }
1116                         break;
1117
1118                 case RC_PREVIEW_SCALE_FACTOR:
1119                         if (lexrc.next()) {
1120                                 preview_scale_factor = lexrc.getString();
1121                         }
1122                         break;
1123
1124                 case RC_USER_NAME:
1125                         if (lexrc.next())
1126                                 user_name = lexrc.getString();
1127                         break;
1128
1129                 case RC_USER_EMAIL:
1130                         if (lexrc.next())
1131                                 user_email = lexrc.getString();
1132                         break;
1133
1134                 case RC_LAST: break; // this is just a dummy
1135                 }
1136         }
1137
1138         /// Update converters data-structures
1139         converters.update(formats);
1140         converters.buildGraph();
1141
1142         return 0;
1143 }
1144
1145
1146 void LyXRC::write(string const & filename, bool ignore_system_lyxrc) const
1147 {
1148         ofstream ofs(filename.c_str());
1149         if (ofs)
1150                 write(ofs, ignore_system_lyxrc);
1151 }
1152
1153
1154 void LyXRC::print() const
1155 {
1156         if (lyxerr.debugging())
1157                 write(lyxerr, false);
1158         else
1159                 write(cout, false);
1160 }
1161
1162
1163 struct SameMover {
1164         typedef std::pair<std::string, SpecialisedMover> Data;
1165
1166         SameMover(Data const & comparison)
1167                 : comparison_(comparison) {}
1168
1169         bool operator()(Data const & data) const
1170         {
1171                 return data.first == comparison_.first &&
1172                         data.second.command() == comparison_.second.command();
1173         }
1174
1175 private:
1176         Data comparison_;
1177 };
1178
1179
1180 void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
1181 {
1182         os << "### This file is part of\n"
1183            << "### ========================================================\n"
1184            << "###          LyX, The Document Processor\n"
1185            << "###\n"
1186            << "###          Copyright 1995 Matthias Ettrich\n"
1187            << "###          Copyright 1995-2001 The LyX Team.\n"
1188            << "###\n"
1189            << "### ========================================================\n"
1190            << "\n"
1191            << "# This file is written by LyX, if you want to make your own\n"
1192            << "# modifications you should do them from inside LyX and save\n"
1193            << "\n";
1194
1195         // Why the switch you might ask. It is a trick to ensure that all
1196         // the elements in the LyXRCTags enum is handled. As you can see
1197         // there are no breaks at all. So it is just a huge fall-through.
1198         // The nice thing is that we will get a warning from the compiler
1199         // if we forget an element.
1200         LyXRCTags tag = RC_LAST;
1201         switch (tag) {
1202         case RC_LAST:
1203         case RC_INPUT:
1204                 // input/include files are not done here
1205         case RC_BINDFILE:
1206                 if (ignore_system_lyxrc ||
1207                     bind_file != system_lyxrc.bind_file) {
1208                         os << "\\bind_file " << bind_file << "\n";
1209                 }
1210                 //
1211                 // Misc Section
1212                 //
1213                 os << "\n#\n"
1214                    << "# MISC SECTION ######################################\n"
1215                    << "#\n\n";
1216
1217                 // bind files are not done here.
1218         case RC_UIFILE:
1219                 if (ignore_system_lyxrc ||
1220                     ui_file != system_lyxrc.ui_file) {
1221                         os << "\\ui_file \"" << ui_file << "\"\n";
1222                 }
1223         case RC_AUTOREGIONDELETE:
1224                 if (ignore_system_lyxrc ||
1225                     auto_region_delete != system_lyxrc.auto_region_delete) {
1226                         os << "# Set to false to inhibit automatic replacement of\n"
1227                            << "# the current selection.\n"
1228                            << "\\auto_region_delete " << convert<string>(auto_region_delete)
1229                            << '\n';
1230                 }
1231         case RC_AUTORESET_OPTIONS:
1232                 if (ignore_system_lyxrc ||
1233                     auto_reset_options != system_lyxrc.auto_reset_options) {
1234                         os << "# Set to false to inhibit automatic reset of\n"
1235                            << "# the class options to defaults on class change.\n"
1236                            << "\\auto_reset_options "
1237                            << convert<string>(auto_reset_options)
1238                            << '\n';
1239                 }
1240         case RC_AUTOSAVE:
1241                 if (ignore_system_lyxrc ||
1242                     autosave != system_lyxrc.autosave) {
1243                         os << "# The time interval between auto-saves in seconds.\n"
1244                            << "\\autosave " << autosave << '\n';
1245                 }
1246         case RC_DISPLAY_GRAPHICS:
1247                 if (ignore_system_lyxrc ||
1248                     display_graphics != system_lyxrc.display_graphics) {
1249                         os << "# Display graphics within LyX\n"
1250                            << "# monochrome|grayscale|color|none\n"
1251                            << "\\display_graphics "
1252                            << lyx::graphics::displayTranslator().find(display_graphics)
1253                            << '\n';
1254                 }
1255
1256         case RC_VIEWDVI_PAPEROPTION:
1257                 if (ignore_system_lyxrc ||
1258                     view_dvi_paper_option
1259                     != system_lyxrc.view_dvi_paper_option) {
1260                         os << "# Options used to specify paper size to the\n"
1261                            << "# view_dvi_command (e.g. -paper)\n"
1262                            << "\\view_dvi_paper_option \""
1263                            << view_dvi_paper_option << "\"\n";
1264                 }
1265         case RC_DEFAULT_PAPERSIZE:
1266                 if (ignore_system_lyxrc ||
1267                     default_papersize != system_lyxrc.default_papersize) {
1268                         os << "# The default papersize to use.\n"
1269                            << "\\default_papersize \"";
1270                         switch (default_papersize) {
1271                         case PAPER_USLETTER:
1272                                 os << "usletter"; break;
1273                         case PAPER_LEGALPAPER:
1274                                 os << "legal"; break;
1275                         case PAPER_EXECUTIVEPAPER:
1276                                 os << "executive"; break;
1277                         case PAPER_A3PAPER:
1278                                 os << "a3"; break;
1279                         case PAPER_A4PAPER:
1280                                 os << "a4"; break;
1281                         case PAPER_A5PAPER:
1282                                 os << "a5"; break;
1283                         case PAPER_B5PAPER:
1284                                 os << "b5"; break;
1285                         case PAPER_DEFAULT: break;
1286                         }
1287                         os << "\"\n";
1288                 }
1289         case RC_CHKTEX_COMMAND:
1290                 if (ignore_system_lyxrc ||
1291                     chktex_command != system_lyxrc.chktex_command) {
1292                         os << "\\chktex_command \"" << chktex_command << "\"\n";
1293                 }
1294         case RC_BIBTEX_COMMAND:
1295                 if (ignore_system_lyxrc ||
1296                     bibtex_command != system_lyxrc.bibtex_command) {
1297                         os << "\\bibtex_command \"" << bibtex_command << "\"\n";
1298                 }
1299         case RC_INDEX_COMMAND:
1300                 if (ignore_system_lyxrc ||
1301                     index_command != system_lyxrc.index_command) {
1302                         os << "\\index_command \"" << index_command << "\"\n";
1303                 }
1304         case RC_KBMAP:
1305                 if (ignore_system_lyxrc ||
1306                     use_kbmap != system_lyxrc.use_kbmap) {
1307                         os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1308                 }
1309
1310         case RC_CYGWIN_PATH_FIX:
1311                 if (ignore_system_lyxrc ||
1312                     cygwin_path_fix != system_lyxrc.cygwin_path_fix) {
1313                         os << "\\cygwin_path_fix_needed "
1314                            << convert<string>(cygwin_path_fix) << '\n';
1315                 }
1316         case RC_KBMAP_PRIMARY:
1317                 if (ignore_system_lyxrc ||
1318                     primary_kbmap != system_lyxrc.primary_kbmap) {
1319                         os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1320                 }
1321         case RC_KBMAP_SECONDARY:
1322                 if (ignore_system_lyxrc ||
1323                     secondary_kbmap != system_lyxrc.secondary_kbmap) {
1324                         os << "\\kbmap_secondary \"" << secondary_kbmap
1325                            << "\"\n";
1326                 }
1327         case RC_SERVERPIPE:
1328                 if (ignore_system_lyxrc ||
1329                     lyxpipes != system_lyxrc.lyxpipes) {
1330                         os << "\\serverpipe \"" << lyxpipes << "\"\n";
1331                 }
1332         case RC_DATE_INSERT_FORMAT:
1333                 if (ignore_system_lyxrc ||
1334                     date_insert_format != system_lyxrc.date_insert_format) {
1335                         os << "\\date_insert_format \"" << date_insert_format
1336                            << "\"\n";
1337                 }
1338         case RC_LABEL_INIT_LENGTH:
1339                 if (ignore_system_lyxrc ||
1340                     label_init_length != system_lyxrc.label_init_length) {
1341                         os << "\\label_init_length " << label_init_length
1342                            << '\n';
1343                 }
1344
1345         case RC_USER_NAME:
1346                 os << "\\user_name \"" << user_name << "\"\n";
1347
1348         case RC_USER_EMAIL:
1349                 os << "\\user_email \"" << user_email << "\"\n";
1350
1351         case RC_SHOW_BANNER:
1352                 if (ignore_system_lyxrc ||
1353                     show_banner != system_lyxrc.show_banner) {
1354                         os << "\\show_banner " << convert<string>(show_banner) << '\n';
1355                 }
1356
1357         case RC_PREVIEW:
1358                 if (ignore_system_lyxrc ||
1359                     preview != system_lyxrc.preview) {
1360                         string status;
1361                         switch (preview) {
1362                         case PREVIEW_ON:
1363                                 status = "on";
1364                                 break;
1365                         case PREVIEW_NO_MATH:
1366                                 status = "no_math";
1367                                 break;
1368                         case PREVIEW_OFF:
1369                                 status = "off";
1370                                 break;
1371                         }
1372                         os << "\\preview " << status << '\n';
1373                 }
1374
1375         case RC_PREVIEW_HASHED_LABELS:
1376                 if (ignore_system_lyxrc ||
1377                     preview_hashed_labels !=
1378                     system_lyxrc.preview_hashed_labels) {
1379                         os << "\\preview_hashed_labels "
1380                            << convert<string>(preview_hashed_labels) << '\n';
1381                 }
1382
1383         case RC_PREVIEW_SCALE_FACTOR:
1384                 if (ignore_system_lyxrc ||
1385                     preview_scale_factor != system_lyxrc.preview_scale_factor) {
1386                         os << "\\preview_scale_factor "
1387                            << preview_scale_factor << '\n';
1388                 }
1389
1390                 os << "\n#\n"
1391                    << "# SCREEN & FONTS SECTION ############################\n"
1392                    << "#\n\n";
1393
1394         case RC_POPUP_NORMAL_FONT:
1395                 if (ignore_system_lyxrc ||
1396                     popup_normal_font != system_lyxrc.popup_normal_font) {
1397                         os << "\\popup_normal_font \"" << popup_normal_font
1398                            << "\"\n";
1399                 }
1400         case RC_POPUP_BOLD_FONT:
1401                 if (ignore_system_lyxrc ||
1402                     popup_bold_font != system_lyxrc.popup_bold_font) {
1403                         os << "\\popup_bold_font \"" << popup_bold_font
1404                            << "\"\n";
1405                 }
1406         case RC_POPUP_FONT_ENCODING:
1407                 if (ignore_system_lyxrc ||
1408                     popup_font_encoding != system_lyxrc.popup_font_encoding) {
1409                         os << "\\popup_font_encoding \"" << popup_font_encoding
1410                            << "\"\n";
1411                 }
1412         case RC_SCREEN_DPI:
1413                 if (ignore_system_lyxrc ||
1414                     dpi != system_lyxrc.dpi) {
1415                         os << "\\screen_dpi " << dpi << '\n';
1416                 }
1417         case RC_SCREEN_ZOOM:
1418                 if (ignore_system_lyxrc ||
1419                     zoom != system_lyxrc.zoom) {
1420                         os << "\\screen_zoom " << zoom << '\n';
1421                 }
1422         case RC_WHEEL_JUMP:
1423                 if (ignore_system_lyxrc ||
1424                     wheel_jump != system_lyxrc.wheel_jump) {
1425                         os << "\\wheel_jump " << wheel_jump << '\n';
1426                 }
1427         case RC_CURSOR_FOLLOWS_SCROLLBAR:
1428                 if (ignore_system_lyxrc ||
1429                     cursor_follows_scrollbar
1430                     != system_lyxrc.cursor_follows_scrollbar) {
1431                         os << "\\cursor_follows_scrollbar "
1432                            << convert<string>(cursor_follows_scrollbar) << '\n';
1433                 }
1434         case RC_DIALOGS_ICONIFY_WITH_MAIN:
1435                 if (ignore_system_lyxrc ||
1436                     dialogs_iconify_with_main
1437                    != system_lyxrc.dialogs_iconify_with_main) {
1438                         os << "\\dialogs_iconify_with_main "
1439                           <<  convert<string>(dialogs_iconify_with_main) << '\n';
1440                 }
1441         case RC_SCREEN_FONT_ROMAN:
1442                 if (ignore_system_lyxrc ||
1443                     roman_font_name != system_lyxrc.roman_font_name) {
1444                         os << "\\screen_font_roman \"" << roman_font_name
1445                            << "\"\n";
1446                 }
1447         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1448                 if (ignore_system_lyxrc ||
1449                     roman_font_foundry != system_lyxrc.roman_font_foundry) {
1450                         os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1451                            << "\"\n";
1452                 }
1453         case RC_SCREEN_FONT_SANS:
1454                 if (ignore_system_lyxrc ||
1455                     sans_font_name != system_lyxrc.sans_font_name) {
1456                         os << "\\screen_font_sans \"" << sans_font_name
1457                            << "\"\n";
1458                 }
1459         case RC_SCREEN_FONT_SANS_FOUNDRY:
1460                 if (ignore_system_lyxrc ||
1461                     sans_font_foundry != system_lyxrc.sans_font_foundry) {
1462                         os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1463                            << "\"\n";
1464                 }
1465         case RC_SCREEN_FONT_TYPEWRITER:
1466                 if (ignore_system_lyxrc ||
1467                     typewriter_font_name != system_lyxrc.typewriter_font_name) {
1468                         os << "\\screen_font_typewriter \""
1469                            << typewriter_font_name << "\"\n";
1470                 }
1471         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1472                 if (ignore_system_lyxrc ||
1473                     typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1474                         os << "\\screen_font_typewriter_foundry \""
1475                            << typewriter_font_foundry << "\"\n";
1476                 }
1477
1478         case RC_SCREEN_FONT_SCALABLE:
1479                 if (ignore_system_lyxrc ||
1480                     use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1481                         os << "\\screen_font_scalable "
1482                            << convert<string>(use_scalable_fonts)
1483                            << '\n';
1484                 }
1485         case RC_SCREEN_FONT_ENCODING:
1486                 if (ignore_system_lyxrc ||
1487                     font_norm != system_lyxrc.font_norm) {
1488                         os << "\\screen_font_encoding \"" << font_norm
1489                            << "\"\n";
1490                 }
1491         case RC_SCREEN_FONT_SIZES:
1492                 if (ignore_system_lyxrc ||
1493                     font_sizes[LyXFont::SIZE_TINY]
1494                     != system_lyxrc.font_sizes[LyXFont::SIZE_TINY] ||
1495                     font_sizes[LyXFont::SIZE_SCRIPT]
1496                     != system_lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] ||
1497                     font_sizes[LyXFont::SIZE_FOOTNOTE]
1498                     != system_lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] ||
1499                     font_sizes[LyXFont::SIZE_SMALL]
1500                     != system_lyxrc.font_sizes[LyXFont::SIZE_SMALL] ||
1501                     font_sizes[LyXFont::SIZE_NORMAL]
1502                     != system_lyxrc.font_sizes[LyXFont::SIZE_NORMAL] ||
1503                     font_sizes[LyXFont::SIZE_LARGE]
1504                     != system_lyxrc.font_sizes[LyXFont::SIZE_LARGE] ||
1505                     font_sizes[LyXFont::SIZE_LARGER]
1506                     != system_lyxrc.font_sizes[LyXFont::SIZE_LARGER] ||
1507                     font_sizes[LyXFont::SIZE_LARGEST]
1508                     != system_lyxrc.font_sizes[LyXFont::SIZE_LARGEST] ||
1509                     font_sizes[LyXFont::SIZE_HUGE]
1510                     != system_lyxrc.font_sizes[LyXFont::SIZE_HUGE] ||
1511                     font_sizes[LyXFont::SIZE_HUGER]
1512                     != system_lyxrc.font_sizes[LyXFont::SIZE_HUGER]) {
1513                         os.setf(ios::fixed);
1514                         os.precision(2);
1515                         os << "\\screen_font_sizes"
1516                            << ' ' << font_sizes[LyXFont::SIZE_TINY]
1517                            << ' ' << font_sizes[LyXFont::SIZE_SCRIPT]
1518                            << ' ' << font_sizes[LyXFont::SIZE_FOOTNOTE]
1519                            << ' ' << font_sizes[LyXFont::SIZE_SMALL]
1520                            << ' ' << font_sizes[LyXFont::SIZE_NORMAL]
1521                            << ' ' << font_sizes[LyXFont::SIZE_LARGE]
1522                            << ' ' << font_sizes[LyXFont::SIZE_LARGER]
1523                            << ' ' << font_sizes[LyXFont::SIZE_LARGEST]
1524                            << ' ' << font_sizes[LyXFont::SIZE_HUGE]
1525                            << ' ' << font_sizes[LyXFont::SIZE_HUGER]
1526                            << '\n';
1527                 }
1528
1529                 os << "\n#\n"
1530                    << "# COLOR SECTION ###################################\n"
1531                    << "#\n\n";
1532
1533         case RC_SET_COLOR:
1534                 for (int i = 0; i < LColor::ignore; ++i) {
1535                         LColor::color lc = static_cast<LColor::color>(i);
1536
1537                         string const col(lcolor.getX11Name(lc));
1538                         if (ignore_system_lyxrc ||
1539                             col != system_lcolor.getX11Name(lc)) {
1540                                 os << "\\set_color \""
1541                                    << lcolor.getLyXName(lc) << "\" \""
1542                                    << col << "\"\n";
1543                         }
1544                 }
1545
1546                 os << "\n#\n"
1547                    << "# PRINTER SECTION ###################################\n"
1548                    << "#\n\n";
1549
1550         case RC_PRINTER:
1551                 if (ignore_system_lyxrc ||
1552                     printer != system_lyxrc.printer) {
1553                         os << "\\printer \"" << printer << "\"\n";
1554                 }
1555         case RC_PRINT_ADAPTOUTPUT:
1556                 if (ignore_system_lyxrc ||
1557                     print_adapt_output != system_lyxrc.print_adapt_output) {
1558                         os << "\\print_adapt_output "
1559                            << convert<string>(print_adapt_output)
1560                            << '\n';
1561                 }
1562         case RC_PRINT_COMMAND:
1563                 if (ignore_system_lyxrc ||
1564                     print_command != system_lyxrc.print_command) {
1565                         os << "\\print_command \"" << print_command << "\"\n";
1566                 }
1567         case RC_PRINTEXSTRAOPTIONS:
1568                 if (ignore_system_lyxrc ||
1569                     print_extra_options != system_lyxrc.print_extra_options) {
1570                         os << "\\print_extra_options \"" << print_extra_options
1571                            << "\"\n";
1572                 }
1573         case RC_PRINTSPOOL_COMMAND:
1574                 if (ignore_system_lyxrc ||
1575                     print_spool_command != system_lyxrc.print_spool_command) {
1576                         os << "\\print_spool_command \"" << print_spool_command
1577                            << "\"\n";
1578                 }
1579         case RC_PRINTSPOOL_PRINTERPREFIX:
1580                 if (ignore_system_lyxrc ||
1581                     print_spool_printerprefix
1582                     != system_lyxrc.print_spool_printerprefix) {
1583                         os << "\\print_spool_printerprefix \""
1584                            << print_spool_printerprefix << "\"\n";
1585                 }
1586         case RC_PRINTEVENPAGEFLAG:
1587                 if (ignore_system_lyxrc ||
1588                     print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1589                         os << "\\print_evenpage_flag \"" << print_evenpage_flag
1590                            << "\"\n";
1591                 }
1592         case RC_PRINTODDPAGEFLAG:
1593                 if (ignore_system_lyxrc ||
1594                     print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1595                         os << "\\print_oddpage_flag \"" << print_oddpage_flag
1596                            << "\"\n";
1597                 }
1598         case RC_PRINTREVERSEFLAG:
1599                 if (ignore_system_lyxrc ||
1600                     print_reverse_flag != system_lyxrc.print_reverse_flag) {
1601                         os << "\\print_reverse_flag \"" << print_reverse_flag
1602                            << "\"\n";
1603                 }
1604         case RC_PRINTLANDSCAPEFLAG:
1605                 if (ignore_system_lyxrc ||
1606                     print_landscape_flag != system_lyxrc.print_landscape_flag) {
1607                         os << "\\print_landscape_flag \"" << print_landscape_flag
1608                            << "\"\n";
1609                 }
1610         case RC_PRINTPAGERANGEFLAG:
1611                 if (ignore_system_lyxrc ||
1612                     print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1613                         os << "\\print_pagerange_flag \"" << print_pagerange_flag
1614                            << "\"\n";
1615                 }
1616         case RC_PRINTCOPIESFLAG:
1617                 if (ignore_system_lyxrc ||
1618                     print_copies_flag != system_lyxrc.print_copies_flag) {
1619                         os << "\\print_copies_flag \"" << print_copies_flag
1620                            << "\"\n";
1621                 }
1622         case RC_PRINTCOLLCOPIESFLAG:
1623                 if (ignore_system_lyxrc ||
1624                     print_collcopies_flag
1625                     != system_lyxrc.print_collcopies_flag) {
1626                         os << "\\print_collcopies_flag \""
1627                            << print_collcopies_flag
1628                            << "\"\n";
1629                 }
1630         case RC_PRINTPAPERFLAG:
1631                 if (ignore_system_lyxrc ||
1632                     print_paper_flag != system_lyxrc.print_paper_flag) {
1633                         os << "\\print_paper_flag \"" << print_paper_flag
1634                            << "\"\n";
1635                 }
1636         case RC_PRINTPAPERDIMENSIONFLAG:
1637                 if (ignore_system_lyxrc ||
1638                     print_paper_dimension_flag
1639                     != system_lyxrc.print_paper_dimension_flag) {
1640                         os << "\\print_paper_dimension_flag \""
1641                            << print_paper_dimension_flag << "\"\n";
1642                 }
1643         case RC_PRINTTOPRINTER:
1644                 if (ignore_system_lyxrc ||
1645                     print_to_printer != system_lyxrc.print_to_printer) {
1646                         os << "\\print_to_printer \"" << print_to_printer
1647                            << "\"\n";
1648                 }
1649         case RC_PRINTTOFILE:
1650                 if (ignore_system_lyxrc ||
1651                     print_to_file != system_lyxrc.print_to_file) {
1652                         os << "\\print_to_file \"" << print_to_file << "\"\n";
1653                 }
1654         case RC_PRINTFILEEXTENSION:
1655                 if (ignore_system_lyxrc ||
1656                     print_file_extension != system_lyxrc.print_file_extension) {
1657                         os << "\\print_file_extension \""
1658                            << print_file_extension
1659                            << "\"\n";
1660                 }
1661
1662                 os << "\n#\n"
1663                    << "# EXPORT SECTION ####################################\n"
1664                    << "#\n\n";
1665
1666         case RC_CUSTOM_EXPORT_COMMAND:
1667                 if (ignore_system_lyxrc ||
1668                     custom_export_command
1669                     != system_lyxrc.custom_export_command) {
1670                         os << "\\custom_export_command \""
1671                            << custom_export_command
1672                            << "\"\n";
1673                 }
1674         case RC_CUSTOM_EXPORT_FORMAT:
1675                 if (ignore_system_lyxrc ||
1676                     custom_export_format
1677                     != system_lyxrc.custom_export_format) {
1678                         os << "\\custom_export_format \"" << custom_export_format
1679                            << "\"\n";
1680                 }
1681
1682                 os << "\n#\n"
1683                    << "# TEX SECTION #######################################\n"
1684                    << "#\n\n";
1685
1686         case RC_FONT_ENCODING:
1687                 if (ignore_system_lyxrc ||
1688                     fontenc != system_lyxrc.fontenc) {
1689                         os << "\\font_encoding \"" << fontenc << "\"\n";
1690                 }
1691
1692                 os << "\n#\n"
1693                    << "# FILE SECTION ######################################\n"
1694                    << "#\n\n";
1695
1696         case RC_DOCUMENTPATH:
1697                 if (ignore_system_lyxrc ||
1698                     document_path != system_lyxrc.document_path) {
1699                         os << "\\document_path \"" << document_path << "\"\n";
1700                 }
1701         case RC_LASTFILES:
1702                 if (ignore_system_lyxrc ||
1703                     lastfiles != system_lyxrc.lastfiles) {
1704                         os << "\\lastfiles \"" << lastfiles << "\"\n";
1705                 }
1706         case RC_NUMLASTFILES:
1707                 if (ignore_system_lyxrc ||
1708                     num_lastfiles != system_lyxrc.num_lastfiles) {
1709                         os << "\\num_lastfiles " << num_lastfiles << '\n';
1710                 }
1711         case RC_CHECKLASTFILES:
1712                 if (ignore_system_lyxrc ||
1713                     check_lastfiles != system_lyxrc.check_lastfiles) {
1714                         os << "\\check_lastfiles " << convert<string>(check_lastfiles)
1715                            << '\n';
1716                 }
1717         case RC_TEMPLATEPATH:
1718                 if (ignore_system_lyxrc ||
1719                     template_path != system_lyxrc.template_path) {
1720                         os << "\\template_path \"" << template_path << "\"\n";
1721                 }
1722         case RC_TEMPDIRPATH:
1723                 if (ignore_system_lyxrc ||
1724                     tempdir_path != system_lyxrc.tempdir_path) {
1725                         os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1726                 }
1727         case RC_USETEMPDIR:
1728                 // Ignore it
1729         case RC_ASCII_LINELEN:
1730                 if (ignore_system_lyxrc ||
1731                     ascii_linelen != system_lyxrc.ascii_linelen) {
1732                         os << "\\ascii_linelen " << ascii_linelen << '\n';
1733                 }
1734         case RC_MAKE_BACKUP:
1735                 if (ignore_system_lyxrc ||
1736                     make_backup != system_lyxrc.make_backup) {
1737                         os << "\\make_backup " << convert<string>(make_backup) << '\n';
1738                 }
1739         case RC_BACKUPDIR_PATH:
1740                 if (ignore_system_lyxrc ||
1741                     backupdir_path != system_lyxrc.backupdir_path) {
1742                         os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1743                 }
1744
1745                 os << "\n#\n"
1746                    << "# ASCII EXPORT SECTION ##############################\n"
1747                    << "#\n\n";
1748
1749         case RC_ASCIIROFF_COMMAND:
1750                 if (ignore_system_lyxrc ||
1751                     ascii_roff_command != system_lyxrc.ascii_roff_command) {
1752                         os << "\\ascii_roff_command \"" << ascii_roff_command
1753                            << "\"\n";
1754                 }
1755
1756                 os << "\n#\n"
1757                    << "# SPELLCHECKER SECTION ##############################\n"
1758                    << "#\n\n";
1759         case RC_USE_SPELL_LIB:
1760                 if (ignore_system_lyxrc ||
1761                     use_spell_lib != system_lyxrc.use_spell_lib) {
1762                         os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
1763                 }
1764         case RC_SPELL_COMMAND:
1765                 if (ignore_system_lyxrc ||
1766                     isp_command != system_lyxrc.isp_command) {
1767                         os << "\\spell_command \"" << isp_command << "\"\n";
1768                 }
1769         case RC_ACCEPT_COMPOUND:
1770                 if (ignore_system_lyxrc ||
1771                     isp_accept_compound != system_lyxrc.isp_accept_compound) {
1772                         os << "\\accept_compound " << convert<string>(isp_accept_compound)
1773                            << '\n';
1774                 }
1775         case RC_USE_ALT_LANG:
1776                 if (ignore_system_lyxrc ||
1777                     isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
1778                         os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
1779                            << '\n';
1780                 }
1781         case RC_ALT_LANG:
1782                 if (ignore_system_lyxrc ||
1783                     isp_alt_lang != system_lyxrc.isp_alt_lang) {
1784                         os << "\\alternate_language \"" << isp_alt_lang
1785                            << "\"\n";
1786                 }
1787         case RC_USE_ESC_CHARS:
1788                 if (ignore_system_lyxrc ||
1789                     isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
1790                         os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
1791                            << '\n';
1792                 }
1793         case RC_ESC_CHARS:
1794                 if (ignore_system_lyxrc ||
1795                     isp_esc_chars != system_lyxrc.isp_esc_chars) {
1796                         os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1797                 }
1798         case RC_USE_PERS_DICT:
1799                 if (ignore_system_lyxrc ||
1800                     isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
1801                         os << "\\use_personal_dictionary "
1802                            << convert<string>(isp_use_pers_dict)
1803                            << '\n';
1804                 }
1805         case RC_PERS_DICT:
1806                 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
1807                         os << "\\personal_dictionary \"" << isp_pers_dict
1808                            << "\"\n";
1809                 }
1810         case RC_USE_INP_ENC:
1811                 if (ignore_system_lyxrc ||
1812                     isp_use_input_encoding
1813                     != system_lyxrc.isp_use_input_encoding) {
1814                         os << "\\use_input_encoding "
1815                            << convert<string>(isp_use_input_encoding)
1816                            << '\n';
1817                 }
1818
1819                 os << "\n#\n"
1820                    << "# LANGUAGE SUPPORT SECTION ##########################\n"
1821                    << "#\n\n";
1822
1823         case RC_RTL_SUPPORT:
1824                 if (ignore_system_lyxrc ||
1825                     rtl_support != system_lyxrc.rtl_support) {
1826                         os << "\\rtl " << convert<string>(rtl_support) << '\n';
1827                 }
1828         case RC_LANGUAGE_PACKAGE:
1829                 if (ignore_system_lyxrc ||
1830                     language_package != system_lyxrc.language_package) {
1831                         os << "\\language_package \"" << language_package
1832                            << "\"\n";
1833                 }
1834         case RC_LANGUAGE_GLOBAL_OPTIONS:
1835                 if (ignore_system_lyxrc ||
1836                     language_global_options
1837                     != system_lyxrc.language_global_options) {
1838                         os << "\\language_global_options \""
1839                            << convert<string>(language_global_options)
1840                            << "\"\n";
1841                 }
1842         case RC_LANGUAGE_USE_BABEL:
1843                 if (ignore_system_lyxrc ||
1844                     language_use_babel != system_lyxrc.language_use_babel) {
1845                         os << "\\language_use_babel \""
1846                            << convert<string>(language_use_babel)
1847                            << "\"\n";
1848                 }
1849         case RC_LANGUAGE_COMMAND_BEGIN:
1850                 if (ignore_system_lyxrc ||
1851                     language_command_begin
1852                     != system_lyxrc.language_command_begin) {
1853                         os << "\\language_command_begin \""
1854                            << language_command_begin
1855                            << "\"\n";
1856                 }
1857         case RC_LANGUAGE_COMMAND_END:
1858                 if (ignore_system_lyxrc ||
1859                     language_command_end
1860                     != system_lyxrc.language_command_end) {
1861                         os << "\\language_command_end \"" << language_command_end
1862                            << "\"\n";
1863                 }
1864         case RC_LANGUAGE_COMMAND_LOCAL:
1865                 if (ignore_system_lyxrc ||
1866                     language_command_local
1867                     != system_lyxrc.language_command_local) {
1868                         os << "\\language_command_local \""
1869                            << language_command_local
1870                            << "\"\n";
1871                 }
1872         case RC_LANGUAGE_AUTO_BEGIN:
1873                 if (ignore_system_lyxrc ||
1874                     language_auto_begin != system_lyxrc.language_auto_begin) {
1875                         os << "\\language_auto_begin "
1876                            << convert<string>(language_auto_begin) << '\n';
1877                 }
1878         case RC_LANGUAGE_AUTO_END:
1879                 if (ignore_system_lyxrc ||
1880                     language_auto_end != system_lyxrc.language_auto_end) {
1881                         os << "\\language_auto_end "
1882                            << convert<string>(language_auto_end) << '\n';
1883                 }
1884         case RC_MARK_FOREIGN_LANGUAGE:
1885                 if (ignore_system_lyxrc ||
1886                     mark_foreign_language
1887                     != system_lyxrc.mark_foreign_language) {
1888                         os << "\\mark_foreign_language " <<
1889                                 convert<string>(mark_foreign_language) << '\n';
1890                 }
1891
1892                 os << "\n#\n"
1893                    << "# 2nd MISC SUPPORT SECTION ##########################\n"
1894                    << "#\n\n";
1895
1896         case RC_AUTO_NUMBER:
1897                 if (ignore_system_lyxrc ||
1898                     auto_number != system_lyxrc.auto_number) {
1899                         os << "\\auto_number " << convert<string>(auto_number) << '\n';
1900                 }
1901         case RC_DEFAULT_LANGUAGE:
1902                 if (ignore_system_lyxrc ||
1903                     default_language != system_lyxrc.default_language) {
1904                         os << "\\default_language " << default_language << '\n';
1905                 }
1906
1907                 os << "\n#\n"
1908                    << "# FORMATS SECTION ##########################\n"
1909                    << "#\n\n";
1910
1911         case RC_FORMAT:
1912                 // New/modifed formats
1913                 for (Formats::const_iterator cit = formats.begin();
1914                      cit != formats.end(); ++cit) {
1915                         Format const * format =
1916                                 system_formats.getFormat(cit->name());
1917                         if (!format ||
1918                             format->extension() != cit->extension() ||
1919                             format->prettyname() != cit->prettyname() ||
1920                             format->shortcut() != cit->shortcut() ||
1921                             format->viewer() != cit->viewer() ||
1922                             format->editor() != cit->editor())
1923                                 os << "\\format \"" << cit->name() << "\" \""
1924                                    << cit->extension() << "\" \""
1925                                    << cit->prettyname() << "\" \""
1926                                    << cit->shortcut() << "\" \""
1927                                    << cit->viewer() << "\" \""
1928                                    << cit->editor() << "\"\n";
1929                 }
1930
1931                 // Look for deleted formats
1932                 for (Formats::const_iterator cit = system_formats.begin();
1933                      cit != system_formats.end(); ++cit)
1934                         if (!formats.getFormat(cit->name()))
1935                                 os << "\\format \"" << cit->name()
1936                                    << "\" \"\" \"\" \"\" \"\" \"\"\n";
1937         case RC_VIEWER:
1938                 // Ignore it
1939
1940                 os << "\n#\n"
1941                    << "# CONVERTERS SECTION ##########################\n"
1942                    << "#\n\n";
1943
1944         case RC_CONVERTER:
1945                 // Look for new converters
1946                 for (Converters::const_iterator cit = converters.begin();
1947                      cit != converters.end(); ++cit) {
1948                         Converter const * converter =
1949                                 system_converters.getConverter(cit->from,
1950                                                                cit->to);
1951                         if (!converter ||
1952                             converter->command != cit->command ||
1953                             converter->flags != cit->flags)
1954                                 os << "\\converter \"" << cit->from << "\" \""
1955                                    << cit->to << "\" \""
1956                                    << cit->command << "\" \""
1957                                    << cit->flags << "\"\n";
1958                 }
1959
1960                 // New/modifed converters
1961                 for (Converters::const_iterator cit = system_converters.begin();
1962                      cit != system_converters.end(); ++cit)
1963                         if (!converters.getConverter(cit->from, cit->to))
1964                                 os << "\\converter \"" << cit->from
1965                                    << "\" \"" << cit->to << "\" \"\" \"\"\n";
1966
1967         case RC_COPIER:
1968                 os << "\n#\n"
1969                    << "# COPIERS SECTION ##########################\n"
1970                    << "#\n\n";
1971
1972                 // Look for new movers
1973                 Movers::iterator const sysbegin = system_movers.begin();
1974                 Movers::iterator const sysend = system_movers.end();
1975
1976                 for (Movers::iterator it = movers.begin(), end = movers.end();
1977                      it != end; ++it) {
1978                         Movers::iterator const sysit =
1979                                 std::find_if(sysbegin, sysend, SameMover(*it));
1980                         if (sysit == sysend) {
1981                                 std::string const & fmt = it->first;
1982                                 std::string const & command =
1983                                         it->second.command();
1984
1985                                 os << "\\copier " << fmt
1986                                    << " \"" << command << "\"\n";
1987                         }
1988                 }
1989
1990                 // We don't actually delete SpecialisedMover(s) from the
1991                 // map, just clear their 'command', so there's no need
1992                 // to test for anything else.
1993         }
1994
1995         os.flush();
1996 }
1997
1998 void LyXRC::set_font_norm_type()
1999 {
2000         if (font_norm == "iso10646-1")
2001                 font_norm_type = ISO_10646_1;
2002         else if (font_norm == "iso8859-1")
2003                 font_norm_type = ISO_8859_1;
2004         else if (font_norm == "iso8859-3")
2005                 font_norm_type = ISO_8859_3;
2006         else if (font_norm == "iso8859-4")
2007                 font_norm_type = ISO_8859_4;
2008         else if (font_norm == "iso8859-6.8x")
2009                 font_norm_type = ISO_8859_6_8;
2010         else if (font_norm == "iso8859-9")
2011                 font_norm_type = ISO_8859_9;
2012         else if (font_norm == "iso8859-15")
2013                 font_norm_type = ISO_8859_15;
2014         else
2015                 font_norm_type = OTHER_ENCODING;
2016 }
2017
2018
2019 string const LyXRC::getDescription(LyXRCTags tag)
2020 {
2021         string str;
2022
2023         switch (tag) {
2024         case RC_FONT_ENCODING:
2025                 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2026                 break;
2027
2028         case RC_PRINTER:
2029                 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2030                 break;
2031
2032         case RC_PRINT_COMMAND:
2033                 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2034                 break;
2035
2036         case RC_PRINTEVENPAGEFLAG:
2037                 str = _("The option to print only even pages.");
2038                 break;
2039
2040         case RC_PRINTODDPAGEFLAG:
2041                 str = _("The option to print only odd pages.");
2042                 break;
2043
2044         case RC_PRINTPAGERANGEFLAG:
2045                 str = _("The option for specifying a comma-separated list of pages to print.");
2046                 break;
2047
2048         case RC_PRINTCOPIESFLAG:
2049                 str = _("The option for specifying the number of copies to print.");
2050                 break;
2051
2052         case RC_PRINTCOLLCOPIESFLAG:
2053                 str = _("The option for specifying whether the copies should be collated.");
2054                 break;
2055
2056         case RC_PRINTREVERSEFLAG:
2057                 str = _("The option to reverse the order of the pages printed.");
2058                 break;
2059
2060         case RC_PRINTLANDSCAPEFLAG:
2061                 str = _("The option to print out in landscape.");
2062                 break;
2063
2064         case RC_PRINTPAPERFLAG:
2065                 str = _("The option to specify paper type.");
2066                 break;
2067
2068         case RC_PRINTPAPERDIMENSIONFLAG:
2069                 str = _("Option to specify the dimensions of the print paper.");
2070                 break;
2071
2072         case RC_PRINTTOPRINTER:
2073                 str = _("Option to pass to the print program to print on a specific printer.");
2074                 break;
2075
2076         case RC_PRINT_ADAPTOUTPUT:
2077                 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2078                 break;
2079
2080         case RC_PRINTTOFILE:
2081                 str = _("Option to pass to the print program to print to a file.");
2082                 break;
2083
2084         case RC_PRINTFILEEXTENSION:
2085                 str = _("Extension of printer program output file. Usually \".ps\".");
2086                 break;
2087
2088         case RC_PRINTEXSTRAOPTIONS:
2089                 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2090                 break;
2091
2092         case RC_PRINTSPOOL_COMMAND:
2093                 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.");
2094                 break;
2095
2096         case RC_PRINTSPOOL_PRINTERPREFIX:
2097                 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.");
2098                 break;
2099
2100         case RC_SCREEN_DPI:
2101                 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2102                 break;
2103
2104         case RC_SCREEN_ZOOM:
2105                 //xgettext:no-c-format
2106                 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2107                 break;
2108
2109         case RC_SCREEN_FONT_SIZES:
2110                 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2111                 break;
2112
2113         case RC_SCREEN_FONT_ROMAN:
2114         case RC_SCREEN_FONT_SANS:
2115         case RC_SCREEN_FONT_TYPEWRITER:
2116                 str = _("The screen fonts used to display the text while editing.");
2117                 break;
2118
2119         case RC_POPUP_BOLD_FONT:
2120                 str = _("The bold font in the dialogs.");
2121                 break;
2122
2123         case RC_POPUP_NORMAL_FONT:
2124                 str = _("The normal font in the dialogs.");
2125                 break;
2126
2127         case RC_SCREEN_FONT_ENCODING:
2128                 str = _("The encoding for the screen fonts.");
2129                 break;
2130
2131         case RC_POPUP_FONT_ENCODING:
2132                 str = _("The encoding for the menu/popups fonts.");
2133                 break;
2134
2135         case RC_SET_COLOR:
2136                 break;
2137
2138         case RC_AUTOSAVE:
2139                 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2140                 break;
2141
2142         case RC_DOCUMENTPATH:
2143                 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2144                 break;
2145
2146         case RC_TEMPLATEPATH:
2147                 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2148                 break;
2149
2150         case RC_TEMPDIRPATH:
2151                 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2152                 break;
2153
2154         case RC_LASTFILES:
2155                 str = _("The file where the last-files information should be stored.");
2156                 break;
2157
2158         case RC_AUTOREGIONDELETE:
2159                 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2160                 break;
2161
2162         case RC_AUTORESET_OPTIONS:
2163                 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2164                 break;
2165
2166         case RC_SERVERPIPE:
2167                 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2168                 break;
2169
2170         case RC_BINDFILE:
2171                 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2172                 break;
2173
2174         case RC_UIFILE:
2175                 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2176                 break;
2177
2178         case RC_KBMAP:
2179         case RC_KBMAP_PRIMARY:
2180         case RC_KBMAP_SECONDARY:
2181                 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.");
2182                 break;
2183
2184         case RC_ASCIIROFF_COMMAND:
2185                 str = _("Use to define an external program to render tables in the ASCII output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"none\" is specified, an internal routine is used.");
2186                 break;
2187
2188         case RC_ASCII_LINELEN:
2189                 str = _("This is the maximum line length of an exported ASCII file (LaTeX, SGML or plain text).");
2190                 break;
2191
2192         case RC_NUMLASTFILES:
2193                 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."), maxlastfiles);
2194                 break;
2195
2196         case RC_CHECKLASTFILES:
2197                 str = _("Select to check whether the lastfiles still exist.");
2198                 break;
2199
2200         case RC_VIEWDVI_PAPEROPTION:
2201                 str = _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2202                 break;
2203
2204         case RC_DEFAULT_PAPERSIZE:
2205                 str = _("Specify the default paper size.");
2206                 break;
2207
2208         case RC_ACCEPT_COMPOUND:
2209                 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2210                 break;
2211
2212         case RC_SPELL_COMMAND:
2213                 str = _("What command runs the spell checker?");
2214                 break;
2215
2216         case RC_USE_INP_ENC:
2217                 str = _("Specify whether to pass the -T input encoding option to ispell. Enable this if you can't spellcheck words with international letters in them. This may not work with all dictionaries.");
2218                 break;
2219
2220         case RC_USE_ALT_LANG:
2221         case RC_ALT_LANG:
2222                 str = _("Specify an alternate language. The default is to use the language of the document.");
2223                 break;
2224
2225         case RC_USE_PERS_DICT:
2226         case RC_PERS_DICT:
2227                 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2228                 break;
2229
2230         case RC_USE_ESC_CHARS:
2231         case RC_ESC_CHARS:
2232                 str = _("Specify additional chars that can be part of a word.");
2233                 break;
2234
2235         case RC_SCREEN_FONT_SCALABLE:
2236                 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.");
2237                 break;
2238
2239         case RC_CHKTEX_COMMAND:
2240                 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2241                 break;
2242
2243         case RC_BIBTEX_COMMAND:
2244                 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2245                 break;
2246
2247         case RC_INDEX_COMMAND:
2248                 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\".");
2249                 break;
2250
2251         case RC_CURSOR_FOLLOWS_SCROLLBAR:
2252                 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.");
2253                 break;
2254
2255         case RC_DIALOGS_ICONIFY_WITH_MAIN:
2256                 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2257                 break;
2258
2259         case RC_DISPLAY_GRAPHICS:
2260                 str = _("Select how LyX will display any graphics.");
2261                 break;
2262
2263         case RC_MAKE_BACKUP:
2264                 str = _("De-select if you don't want LyX to create backup files.");
2265                 break;
2266
2267         case RC_BACKUPDIR_PATH:
2268                 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.");
2269                 break;
2270
2271         case RC_RTL_SUPPORT:
2272                 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2273                 break;
2274
2275         case RC_MARK_FOREIGN_LANGUAGE:
2276                 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2277                 break;
2278
2279         case RC_LANGUAGE_PACKAGE:
2280                 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2281                 break;
2282
2283         case RC_LANGUAGE_GLOBAL_OPTIONS:
2284                 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2285                 break;
2286
2287         case RC_LANGUAGE_USE_BABEL:
2288                 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2289                 break;
2290
2291         case RC_LANGUAGE_AUTO_BEGIN:
2292                 str = _("Select if a language switching command is needed at the beginning of the document.");
2293                 break;
2294
2295         case RC_LANGUAGE_AUTO_END:
2296                 str = _("Select if a language switching command is needed at the end of the document.");
2297                 break;
2298
2299         case RC_LANGUAGE_COMMAND_BEGIN:
2300                 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.");
2301                 break;
2302
2303         case RC_LANGUAGE_COMMAND_END:
2304                 str = _("The LaTeX command for changing back to the language of the document.");
2305                 break;
2306
2307         case RC_LANGUAGE_COMMAND_LOCAL:
2308                 str = _("The LaTeX command for local changing of the language.");
2309                 break;
2310
2311         case RC_DATE_INSERT_FORMAT:
2312                 //xgettext:no-c-format
2313                 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2314                 break;
2315
2316         case RC_SHOW_BANNER:
2317                 str = _("De-select if you don't want the startup banner.");
2318                 break;
2319
2320         case RC_WHEEL_JUMP:
2321                 str = _("The number of lines that are scrolled by mice with wheels or five button mice.");
2322                 break;
2323
2324         case RC_CONVERTER:
2325                 break;
2326
2327         case RC_VIEWER:
2328                 break;
2329
2330         case RC_FORMAT:
2331                 break;
2332
2333         case RC_DEFAULT_LANGUAGE:
2334                 str = _("New documents will be assigned this language.");
2335                 break;
2336
2337         case RC_LABEL_INIT_LENGTH:
2338                 str = _("Maximum number of words in the initialization string for a new label");
2339                 break;
2340
2341         case RC_PREVIEW:
2342                 str = _("Shows a typeset preview of things such as math");
2343                 break;
2344
2345         case RC_PREVIEW_HASHED_LABELS:
2346                 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2347                 break;
2348
2349         case RC_PREVIEW_SCALE_FACTOR:
2350                 str = _("Scale the preview size to suit.");
2351                 break;
2352
2353         default:
2354                 break;
2355         }
2356
2357         return str;
2358 }
2359
2360 // The global instance
2361 LyXRC lyxrc;
2362
2363 // The global copy of the system lyxrc entries (everything except preferences)
2364 LyXRC system_lyxrc;