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