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