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