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