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