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