]> git.lyx.org Git - lyx.git/blob - src/lyxrc.C
The LyXRC::prepend_path patch as tested on the Mac by Andreas.
[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 struct SameMover {
1166         typedef std::pair<std::string, SpecialisedMover> Data;
1167
1168         SameMover(Data const & comparison)
1169                 : comparison_(comparison) {}
1170
1171         bool operator()(Data const & data) const
1172         {
1173                 return data.first == comparison_.first &&
1174                         data.second.command() == comparison_.second.command();
1175         }
1176
1177 private:
1178         Data comparison_;
1179 };
1180
1181
1182 void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
1183 {
1184         os << "### This file is part of\n"
1185            << "### ========================================================\n"
1186            << "###          LyX, The Document Processor\n"
1187            << "###\n"
1188            << "###          Copyright 1995 Matthias Ettrich\n"
1189            << "###          Copyright 1995-2001 The LyX Team.\n"
1190            << "###\n"
1191            << "### ========================================================\n"
1192            << "\n"
1193            << "# This file is written by LyX, if you want to make your own\n"
1194            << "# modifications you should do them from inside LyX and save\n"
1195            << "\n";
1196
1197         // Why the switch you might ask. It is a trick to ensure that all
1198         // the elements in the LyXRCTags enum is handled. As you can see
1199         // there are no breaks at all. So it is just a huge fall-through.
1200         // The nice thing is that we will get a warning from the compiler
1201         // if we forget an element.
1202         LyXRCTags tag = RC_LAST;
1203         switch (tag) {
1204         case RC_LAST:
1205         case RC_INPUT:
1206                 // input/include files are not done here
1207         case RC_BINDFILE:
1208                 if (ignore_system_lyxrc ||
1209                     bind_file != system_lyxrc.bind_file) {
1210                         os << "\\bind_file " << bind_file << "\n";
1211                 }
1212                 //
1213                 // Misc Section
1214                 //
1215                 os << "\n#\n"
1216                    << "# MISC SECTION ######################################\n"
1217                    << "#\n\n";
1218
1219                 // bind files are not done here.
1220
1221         case RC_PATH_PREFIX:
1222                 if (ignore_system_lyxrc ||
1223                     path_prefix != system_lyxrc.path_prefix) {
1224                         os << "\\path_prefix \"" << path_prefix << "\"\n";
1225                 }
1226
1227         case RC_UIFILE:
1228                 if (ignore_system_lyxrc ||
1229                     ui_file != system_lyxrc.ui_file) {
1230                         os << "\\ui_file \"" << ui_file << "\"\n";
1231                 }
1232         case RC_AUTOREGIONDELETE:
1233                 if (ignore_system_lyxrc ||
1234                     auto_region_delete != system_lyxrc.auto_region_delete) {
1235                         os << "# Set to false to inhibit automatic replacement of\n"
1236                            << "# the current selection.\n"
1237                            << "\\auto_region_delete " << convert<string>(auto_region_delete)
1238                            << '\n';
1239                 }
1240         case RC_AUTORESET_OPTIONS:
1241                 if (ignore_system_lyxrc ||
1242                     auto_reset_options != system_lyxrc.auto_reset_options) {
1243                         os << "# Set to false to inhibit automatic reset of\n"
1244                            << "# the class options to defaults on class change.\n"
1245                            << "\\auto_reset_options "
1246                            << convert<string>(auto_reset_options)
1247                            << '\n';
1248                 }
1249         case RC_AUTOSAVE:
1250                 if (ignore_system_lyxrc ||
1251                     autosave != system_lyxrc.autosave) {
1252                         os << "# The time interval between auto-saves in seconds.\n"
1253                            << "\\autosave " << autosave << '\n';
1254                 }
1255         case RC_DISPLAY_GRAPHICS:
1256                 if (ignore_system_lyxrc ||
1257                     display_graphics != system_lyxrc.display_graphics) {
1258                         os << "# Display graphics within LyX\n"
1259                            << "# monochrome|grayscale|color|none\n"
1260                            << "\\display_graphics "
1261                            << lyx::graphics::displayTranslator().find(display_graphics)
1262                            << '\n';
1263                 }
1264
1265         case RC_VIEWDVI_PAPEROPTION:
1266                 if (ignore_system_lyxrc ||
1267                     view_dvi_paper_option
1268                     != system_lyxrc.view_dvi_paper_option) {
1269                         os << "# Options used to specify paper size to the\n"
1270                            << "# view_dvi_command (e.g. -paper)\n"
1271                            << "\\view_dvi_paper_option \""
1272                            << view_dvi_paper_option << "\"\n";
1273                 }
1274         case RC_DEFAULT_PAPERSIZE:
1275                 if (ignore_system_lyxrc ||
1276                     default_papersize != system_lyxrc.default_papersize) {
1277                         os << "# The default papersize to use.\n"
1278                            << "\\default_papersize \"";
1279                         switch (default_papersize) {
1280                         case PAPER_USLETTER:
1281                                 os << "usletter"; break;
1282                         case PAPER_LEGALPAPER:
1283                                 os << "legal"; break;
1284                         case PAPER_EXECUTIVEPAPER:
1285                                 os << "executive"; break;
1286                         case PAPER_A3PAPER:
1287                                 os << "a3"; break;
1288                         case PAPER_A4PAPER:
1289                                 os << "a4"; break;
1290                         case PAPER_A5PAPER:
1291                                 os << "a5"; break;
1292                         case PAPER_B5PAPER:
1293                                 os << "b5"; break;
1294                         case PAPER_DEFAULT: break;
1295                         }
1296                         os << "\"\n";
1297                 }
1298         case RC_CHKTEX_COMMAND:
1299                 if (ignore_system_lyxrc ||
1300                     chktex_command != system_lyxrc.chktex_command) {
1301                         os << "\\chktex_command \"" << chktex_command << "\"\n";
1302                 }
1303         case RC_BIBTEX_COMMAND:
1304                 if (ignore_system_lyxrc ||
1305                     bibtex_command != system_lyxrc.bibtex_command) {
1306                         os << "\\bibtex_command \"" << bibtex_command << "\"\n";
1307                 }
1308         case RC_INDEX_COMMAND:
1309                 if (ignore_system_lyxrc ||
1310                     index_command != system_lyxrc.index_command) {
1311                         os << "\\index_command \"" << index_command << "\"\n";
1312                 }
1313         case RC_KBMAP:
1314                 if (ignore_system_lyxrc ||
1315                     use_kbmap != system_lyxrc.use_kbmap) {
1316                         os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1317                 }
1318
1319         case RC_CYGWIN_PATH_FIX:
1320                 if (ignore_system_lyxrc ||
1321                     cygwin_path_fix != system_lyxrc.cygwin_path_fix) {
1322                         os << "\\cygwin_path_fix_needed "
1323                            << convert<string>(cygwin_path_fix) << '\n';
1324                 }
1325         case RC_KBMAP_PRIMARY:
1326                 if (ignore_system_lyxrc ||
1327                     primary_kbmap != system_lyxrc.primary_kbmap) {
1328                         os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1329                 }
1330         case RC_KBMAP_SECONDARY:
1331                 if (ignore_system_lyxrc ||
1332                     secondary_kbmap != system_lyxrc.secondary_kbmap) {
1333                         os << "\\kbmap_secondary \"" << secondary_kbmap
1334                            << "\"\n";
1335                 }
1336         case RC_SERVERPIPE:
1337                 if (ignore_system_lyxrc ||
1338                     lyxpipes != system_lyxrc.lyxpipes) {
1339                         os << "\\serverpipe \"" << lyxpipes << "\"\n";
1340                 }
1341         case RC_DATE_INSERT_FORMAT:
1342                 if (ignore_system_lyxrc ||
1343                     date_insert_format != system_lyxrc.date_insert_format) {
1344                         os << "\\date_insert_format \"" << date_insert_format
1345                            << "\"\n";
1346                 }
1347         case RC_LABEL_INIT_LENGTH:
1348                 if (ignore_system_lyxrc ||
1349                     label_init_length != system_lyxrc.label_init_length) {
1350                         os << "\\label_init_length " << label_init_length
1351                            << '\n';
1352                 }
1353
1354         case RC_USER_NAME:
1355                 os << "\\user_name \"" << user_name << "\"\n";
1356
1357         case RC_USER_EMAIL:
1358                 os << "\\user_email \"" << user_email << "\"\n";
1359
1360         case RC_SHOW_BANNER:
1361                 if (ignore_system_lyxrc ||
1362                     show_banner != system_lyxrc.show_banner) {
1363                         os << "\\show_banner " << convert<string>(show_banner) << '\n';
1364                 }
1365
1366         case RC_PREVIEW:
1367                 if (ignore_system_lyxrc ||
1368                     preview != system_lyxrc.preview) {
1369                         string status;
1370                         switch (preview) {
1371                         case PREVIEW_ON:
1372                                 status = "on";
1373                                 break;
1374                         case PREVIEW_NO_MATH:
1375                                 status = "no_math";
1376                                 break;
1377                         case PREVIEW_OFF:
1378                                 status = "off";
1379                                 break;
1380                         }
1381                         os << "\\preview " << status << '\n';
1382                 }
1383
1384         case RC_PREVIEW_HASHED_LABELS:
1385                 if (ignore_system_lyxrc ||
1386                     preview_hashed_labels !=
1387                     system_lyxrc.preview_hashed_labels) {
1388                         os << "\\preview_hashed_labels "
1389                            << convert<string>(preview_hashed_labels) << '\n';
1390                 }
1391
1392         case RC_PREVIEW_SCALE_FACTOR:
1393                 if (ignore_system_lyxrc ||
1394                     preview_scale_factor != system_lyxrc.preview_scale_factor) {
1395                         os << "\\preview_scale_factor "
1396                            << preview_scale_factor << '\n';
1397                 }
1398
1399                 os << "\n#\n"
1400                    << "# SCREEN & FONTS SECTION ############################\n"
1401                    << "#\n\n";
1402
1403         case RC_POPUP_NORMAL_FONT:
1404                 if (ignore_system_lyxrc ||
1405                     popup_normal_font != system_lyxrc.popup_normal_font) {
1406                         os << "\\popup_normal_font \"" << popup_normal_font
1407                            << "\"\n";
1408                 }
1409         case RC_POPUP_BOLD_FONT:
1410                 if (ignore_system_lyxrc ||
1411                     popup_bold_font != system_lyxrc.popup_bold_font) {
1412                         os << "\\popup_bold_font \"" << popup_bold_font
1413                            << "\"\n";
1414                 }
1415         case RC_POPUP_FONT_ENCODING:
1416                 if (ignore_system_lyxrc ||
1417                     popup_font_encoding != system_lyxrc.popup_font_encoding) {
1418                         os << "\\popup_font_encoding \"" << popup_font_encoding
1419                            << "\"\n";
1420                 }
1421         case RC_SCREEN_DPI:
1422                 if (ignore_system_lyxrc ||
1423                     dpi != system_lyxrc.dpi) {
1424                         os << "\\screen_dpi " << dpi << '\n';
1425                 }
1426         case RC_SCREEN_ZOOM:
1427                 if (ignore_system_lyxrc ||
1428                     zoom != system_lyxrc.zoom) {
1429                         os << "\\screen_zoom " << zoom << '\n';
1430                 }
1431         case RC_WHEEL_JUMP:
1432                 if (ignore_system_lyxrc ||
1433                     wheel_jump != system_lyxrc.wheel_jump) {
1434                         os << "\\wheel_jump " << wheel_jump << '\n';
1435                 }
1436         case RC_CURSOR_FOLLOWS_SCROLLBAR:
1437                 if (ignore_system_lyxrc ||
1438                     cursor_follows_scrollbar
1439                     != system_lyxrc.cursor_follows_scrollbar) {
1440                         os << "\\cursor_follows_scrollbar "
1441                            << convert<string>(cursor_follows_scrollbar) << '\n';
1442                 }
1443         case RC_DIALOGS_ICONIFY_WITH_MAIN:
1444                 if (ignore_system_lyxrc ||
1445                     dialogs_iconify_with_main
1446                    != system_lyxrc.dialogs_iconify_with_main) {
1447                         os << "\\dialogs_iconify_with_main "
1448                           <<  convert<string>(dialogs_iconify_with_main) << '\n';
1449                 }
1450         case RC_SCREEN_FONT_ROMAN:
1451                 if (ignore_system_lyxrc ||
1452                     roman_font_name != system_lyxrc.roman_font_name) {
1453                         os << "\\screen_font_roman \"" << roman_font_name
1454                            << "\"\n";
1455                 }
1456         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1457                 if (ignore_system_lyxrc ||
1458                     roman_font_foundry != system_lyxrc.roman_font_foundry) {
1459                         os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1460                            << "\"\n";
1461                 }
1462         case RC_SCREEN_FONT_SANS:
1463                 if (ignore_system_lyxrc ||
1464                     sans_font_name != system_lyxrc.sans_font_name) {
1465                         os << "\\screen_font_sans \"" << sans_font_name
1466                            << "\"\n";
1467                 }
1468         case RC_SCREEN_FONT_SANS_FOUNDRY:
1469                 if (ignore_system_lyxrc ||
1470                     sans_font_foundry != system_lyxrc.sans_font_foundry) {
1471                         os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1472                            << "\"\n";
1473                 }
1474         case RC_SCREEN_FONT_TYPEWRITER:
1475                 if (ignore_system_lyxrc ||
1476                     typewriter_font_name != system_lyxrc.typewriter_font_name) {
1477                         os << "\\screen_font_typewriter \""
1478                            << typewriter_font_name << "\"\n";
1479                 }
1480         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1481                 if (ignore_system_lyxrc ||
1482                     typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1483                         os << "\\screen_font_typewriter_foundry \""
1484                            << typewriter_font_foundry << "\"\n";
1485                 }
1486
1487         case RC_SCREEN_FONT_SCALABLE:
1488                 if (ignore_system_lyxrc ||
1489                     use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1490                         os << "\\screen_font_scalable "
1491                            << convert<string>(use_scalable_fonts)
1492                            << '\n';
1493                 }
1494         case RC_SCREEN_FONT_ENCODING:
1495                 if (ignore_system_lyxrc ||
1496                     font_norm != system_lyxrc.font_norm) {
1497                         os << "\\screen_font_encoding \"" << font_norm
1498                            << "\"\n";
1499                 }
1500         case RC_SCREEN_FONT_SIZES:
1501                 if (ignore_system_lyxrc ||
1502                     font_sizes[LyXFont::SIZE_TINY]
1503                     != system_lyxrc.font_sizes[LyXFont::SIZE_TINY] ||
1504                     font_sizes[LyXFont::SIZE_SCRIPT]
1505                     != system_lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] ||
1506                     font_sizes[LyXFont::SIZE_FOOTNOTE]
1507                     != system_lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] ||
1508                     font_sizes[LyXFont::SIZE_SMALL]
1509                     != system_lyxrc.font_sizes[LyXFont::SIZE_SMALL] ||
1510                     font_sizes[LyXFont::SIZE_NORMAL]
1511                     != system_lyxrc.font_sizes[LyXFont::SIZE_NORMAL] ||
1512                     font_sizes[LyXFont::SIZE_LARGE]
1513                     != system_lyxrc.font_sizes[LyXFont::SIZE_LARGE] ||
1514                     font_sizes[LyXFont::SIZE_LARGER]
1515                     != system_lyxrc.font_sizes[LyXFont::SIZE_LARGER] ||
1516                     font_sizes[LyXFont::SIZE_LARGEST]
1517                     != system_lyxrc.font_sizes[LyXFont::SIZE_LARGEST] ||
1518                     font_sizes[LyXFont::SIZE_HUGE]
1519                     != system_lyxrc.font_sizes[LyXFont::SIZE_HUGE] ||
1520                     font_sizes[LyXFont::SIZE_HUGER]
1521                     != system_lyxrc.font_sizes[LyXFont::SIZE_HUGER]) {
1522                         os.setf(ios::fixed);
1523                         os.precision(2);
1524                         os << "\\screen_font_sizes"
1525                            << ' ' << font_sizes[LyXFont::SIZE_TINY]
1526                            << ' ' << font_sizes[LyXFont::SIZE_SCRIPT]
1527                            << ' ' << font_sizes[LyXFont::SIZE_FOOTNOTE]
1528                            << ' ' << font_sizes[LyXFont::SIZE_SMALL]
1529                            << ' ' << font_sizes[LyXFont::SIZE_NORMAL]
1530                            << ' ' << font_sizes[LyXFont::SIZE_LARGE]
1531                            << ' ' << font_sizes[LyXFont::SIZE_LARGER]
1532                            << ' ' << font_sizes[LyXFont::SIZE_LARGEST]
1533                            << ' ' << font_sizes[LyXFont::SIZE_HUGE]
1534                            << ' ' << font_sizes[LyXFont::SIZE_HUGER]
1535                            << '\n';
1536                 }
1537
1538                 os << "\n#\n"
1539                    << "# COLOR SECTION ###################################\n"
1540                    << "#\n\n";
1541
1542         case RC_SET_COLOR:
1543                 for (int i = 0; i < LColor::ignore; ++i) {
1544                         LColor::color lc = static_cast<LColor::color>(i);
1545
1546                         string const col(lcolor.getX11Name(lc));
1547                         if (ignore_system_lyxrc ||
1548                             col != system_lcolor.getX11Name(lc)) {
1549                                 os << "\\set_color \""
1550                                    << lcolor.getLyXName(lc) << "\" \""
1551                                    << col << "\"\n";
1552                         }
1553                 }
1554
1555                 os << "\n#\n"
1556                    << "# PRINTER SECTION ###################################\n"
1557                    << "#\n\n";
1558
1559         case RC_PRINTER:
1560                 if (ignore_system_lyxrc ||
1561                     printer != system_lyxrc.printer) {
1562                         os << "\\printer \"" << printer << "\"\n";
1563                 }
1564         case RC_PRINT_ADAPTOUTPUT:
1565                 if (ignore_system_lyxrc ||
1566                     print_adapt_output != system_lyxrc.print_adapt_output) {
1567                         os << "\\print_adapt_output "
1568                            << convert<string>(print_adapt_output)
1569                            << '\n';
1570                 }
1571         case RC_PRINT_COMMAND:
1572                 if (ignore_system_lyxrc ||
1573                     print_command != system_lyxrc.print_command) {
1574                         os << "\\print_command \"" << print_command << "\"\n";
1575                 }
1576         case RC_PRINTEXSTRAOPTIONS:
1577                 if (ignore_system_lyxrc ||
1578                     print_extra_options != system_lyxrc.print_extra_options) {
1579                         os << "\\print_extra_options \"" << print_extra_options
1580                            << "\"\n";
1581                 }
1582         case RC_PRINTSPOOL_COMMAND:
1583                 if (ignore_system_lyxrc ||
1584                     print_spool_command != system_lyxrc.print_spool_command) {
1585                         os << "\\print_spool_command \"" << print_spool_command
1586                            << "\"\n";
1587                 }
1588         case RC_PRINTSPOOL_PRINTERPREFIX:
1589                 if (ignore_system_lyxrc ||
1590                     print_spool_printerprefix
1591                     != system_lyxrc.print_spool_printerprefix) {
1592                         os << "\\print_spool_printerprefix \""
1593                            << print_spool_printerprefix << "\"\n";
1594                 }
1595         case RC_PRINTEVENPAGEFLAG:
1596                 if (ignore_system_lyxrc ||
1597                     print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1598                         os << "\\print_evenpage_flag \"" << print_evenpage_flag
1599                            << "\"\n";
1600                 }
1601         case RC_PRINTODDPAGEFLAG:
1602                 if (ignore_system_lyxrc ||
1603                     print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1604                         os << "\\print_oddpage_flag \"" << print_oddpage_flag
1605                            << "\"\n";
1606                 }
1607         case RC_PRINTREVERSEFLAG:
1608                 if (ignore_system_lyxrc ||
1609                     print_reverse_flag != system_lyxrc.print_reverse_flag) {
1610                         os << "\\print_reverse_flag \"" << print_reverse_flag
1611                            << "\"\n";
1612                 }
1613         case RC_PRINTLANDSCAPEFLAG:
1614                 if (ignore_system_lyxrc ||
1615                     print_landscape_flag != system_lyxrc.print_landscape_flag) {
1616                         os << "\\print_landscape_flag \"" << print_landscape_flag
1617                            << "\"\n";
1618                 }
1619         case RC_PRINTPAGERANGEFLAG:
1620                 if (ignore_system_lyxrc ||
1621                     print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1622                         os << "\\print_pagerange_flag \"" << print_pagerange_flag
1623                            << "\"\n";
1624                 }
1625         case RC_PRINTCOPIESFLAG:
1626                 if (ignore_system_lyxrc ||
1627                     print_copies_flag != system_lyxrc.print_copies_flag) {
1628                         os << "\\print_copies_flag \"" << print_copies_flag
1629                            << "\"\n";
1630                 }
1631         case RC_PRINTCOLLCOPIESFLAG:
1632                 if (ignore_system_lyxrc ||
1633                     print_collcopies_flag
1634                     != system_lyxrc.print_collcopies_flag) {
1635                         os << "\\print_collcopies_flag \""
1636                            << print_collcopies_flag
1637                            << "\"\n";
1638                 }
1639         case RC_PRINTPAPERFLAG:
1640                 if (ignore_system_lyxrc ||
1641                     print_paper_flag != system_lyxrc.print_paper_flag) {
1642                         os << "\\print_paper_flag \"" << print_paper_flag
1643                            << "\"\n";
1644                 }
1645         case RC_PRINTPAPERDIMENSIONFLAG:
1646                 if (ignore_system_lyxrc ||
1647                     print_paper_dimension_flag
1648                     != system_lyxrc.print_paper_dimension_flag) {
1649                         os << "\\print_paper_dimension_flag \""
1650                            << print_paper_dimension_flag << "\"\n";
1651                 }
1652         case RC_PRINTTOPRINTER:
1653                 if (ignore_system_lyxrc ||
1654                     print_to_printer != system_lyxrc.print_to_printer) {
1655                         os << "\\print_to_printer \"" << print_to_printer
1656                            << "\"\n";
1657                 }
1658         case RC_PRINTTOFILE:
1659                 if (ignore_system_lyxrc ||
1660                     print_to_file != system_lyxrc.print_to_file) {
1661                         os << "\\print_to_file \"" << print_to_file << "\"\n";
1662                 }
1663         case RC_PRINTFILEEXTENSION:
1664                 if (ignore_system_lyxrc ||
1665                     print_file_extension != system_lyxrc.print_file_extension) {
1666                         os << "\\print_file_extension \""
1667                            << print_file_extension
1668                            << "\"\n";
1669                 }
1670
1671                 os << "\n#\n"
1672                    << "# EXPORT SECTION ####################################\n"
1673                    << "#\n\n";
1674
1675         case RC_CUSTOM_EXPORT_COMMAND:
1676                 if (ignore_system_lyxrc ||
1677                     custom_export_command
1678                     != system_lyxrc.custom_export_command) {
1679                         os << "\\custom_export_command \""
1680                            << custom_export_command
1681                            << "\"\n";
1682                 }
1683         case RC_CUSTOM_EXPORT_FORMAT:
1684                 if (ignore_system_lyxrc ||
1685                     custom_export_format
1686                     != system_lyxrc.custom_export_format) {
1687                         os << "\\custom_export_format \"" << custom_export_format
1688                            << "\"\n";
1689                 }
1690
1691                 os << "\n#\n"
1692                    << "# TEX SECTION #######################################\n"
1693                    << "#\n\n";
1694
1695         case RC_FONT_ENCODING:
1696                 if (ignore_system_lyxrc ||
1697                     fontenc != system_lyxrc.fontenc) {
1698                         os << "\\font_encoding \"" << fontenc << "\"\n";
1699                 }
1700
1701                 os << "\n#\n"
1702                    << "# FILE SECTION ######################################\n"
1703                    << "#\n\n";
1704
1705         case RC_DOCUMENTPATH:
1706                 if (ignore_system_lyxrc ||
1707                     document_path != system_lyxrc.document_path) {
1708                         os << "\\document_path \"" << document_path << "\"\n";
1709                 }
1710         case RC_LASTFILES:
1711                 if (ignore_system_lyxrc ||
1712                     lastfiles != system_lyxrc.lastfiles) {
1713                         os << "\\lastfiles \"" << lastfiles << "\"\n";
1714                 }
1715         case RC_NUMLASTFILES:
1716                 if (ignore_system_lyxrc ||
1717                     num_lastfiles != system_lyxrc.num_lastfiles) {
1718                         os << "\\num_lastfiles " << num_lastfiles << '\n';
1719                 }
1720         case RC_CHECKLASTFILES:
1721                 if (ignore_system_lyxrc ||
1722                     check_lastfiles != system_lyxrc.check_lastfiles) {
1723                         os << "\\check_lastfiles " << convert<string>(check_lastfiles)
1724                            << '\n';
1725                 }
1726         case RC_TEMPLATEPATH:
1727                 if (ignore_system_lyxrc ||
1728                     template_path != system_lyxrc.template_path) {
1729                         os << "\\template_path \"" << template_path << "\"\n";
1730                 }
1731         case RC_TEMPDIRPATH:
1732                 if (ignore_system_lyxrc ||
1733                     tempdir_path != system_lyxrc.tempdir_path) {
1734                         os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1735                 }
1736         case RC_USETEMPDIR:
1737                 // Ignore it
1738         case RC_ASCII_LINELEN:
1739                 if (ignore_system_lyxrc ||
1740                     ascii_linelen != system_lyxrc.ascii_linelen) {
1741                         os << "\\ascii_linelen " << ascii_linelen << '\n';
1742                 }
1743         case RC_MAKE_BACKUP:
1744                 if (ignore_system_lyxrc ||
1745                     make_backup != system_lyxrc.make_backup) {
1746                         os << "\\make_backup " << convert<string>(make_backup) << '\n';
1747                 }
1748         case RC_BACKUPDIR_PATH:
1749                 if (ignore_system_lyxrc ||
1750                     backupdir_path != system_lyxrc.backupdir_path) {
1751                         os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1752                 }
1753
1754                 os << "\n#\n"
1755                    << "# ASCII EXPORT SECTION ##############################\n"
1756                    << "#\n\n";
1757
1758         case RC_ASCIIROFF_COMMAND:
1759                 if (ignore_system_lyxrc ||
1760                     ascii_roff_command != system_lyxrc.ascii_roff_command) {
1761                         os << "\\ascii_roff_command \"" << ascii_roff_command
1762                            << "\"\n";
1763                 }
1764
1765                 os << "\n#\n"
1766                    << "# SPELLCHECKER SECTION ##############################\n"
1767                    << "#\n\n";
1768         case RC_USE_SPELL_LIB:
1769                 if (ignore_system_lyxrc ||
1770                     use_spell_lib != system_lyxrc.use_spell_lib) {
1771                         os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
1772                 }
1773         case RC_SPELL_COMMAND:
1774                 if (ignore_system_lyxrc ||
1775                     isp_command != system_lyxrc.isp_command) {
1776                         os << "\\spell_command \"" << isp_command << "\"\n";
1777                 }
1778         case RC_ACCEPT_COMPOUND:
1779                 if (ignore_system_lyxrc ||
1780                     isp_accept_compound != system_lyxrc.isp_accept_compound) {
1781                         os << "\\accept_compound " << convert<string>(isp_accept_compound)
1782                            << '\n';
1783                 }
1784         case RC_USE_ALT_LANG:
1785                 if (ignore_system_lyxrc ||
1786                     isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
1787                         os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
1788                            << '\n';
1789                 }
1790         case RC_ALT_LANG:
1791                 if (ignore_system_lyxrc ||
1792                     isp_alt_lang != system_lyxrc.isp_alt_lang) {
1793                         os << "\\alternate_language \"" << isp_alt_lang
1794                            << "\"\n";
1795                 }
1796         case RC_USE_ESC_CHARS:
1797                 if (ignore_system_lyxrc ||
1798                     isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
1799                         os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
1800                            << '\n';
1801                 }
1802         case RC_ESC_CHARS:
1803                 if (ignore_system_lyxrc ||
1804                     isp_esc_chars != system_lyxrc.isp_esc_chars) {
1805                         os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1806                 }
1807         case RC_USE_PERS_DICT:
1808                 if (ignore_system_lyxrc ||
1809                     isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
1810                         os << "\\use_personal_dictionary "
1811                            << convert<string>(isp_use_pers_dict)
1812                            << '\n';
1813                 }
1814         case RC_PERS_DICT:
1815                 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
1816                         os << "\\personal_dictionary \"" << isp_pers_dict
1817                            << "\"\n";
1818                 }
1819         case RC_USE_INP_ENC:
1820                 if (ignore_system_lyxrc ||
1821                     isp_use_input_encoding
1822                     != system_lyxrc.isp_use_input_encoding) {
1823                         os << "\\use_input_encoding "
1824                            << convert<string>(isp_use_input_encoding)
1825                            << '\n';
1826                 }
1827
1828                 os << "\n#\n"
1829                    << "# LANGUAGE SUPPORT SECTION ##########################\n"
1830                    << "#\n\n";
1831
1832         case RC_RTL_SUPPORT:
1833                 if (ignore_system_lyxrc ||
1834                     rtl_support != system_lyxrc.rtl_support) {
1835                         os << "\\rtl " << convert<string>(rtl_support) << '\n';
1836                 }
1837         case RC_LANGUAGE_PACKAGE:
1838                 if (ignore_system_lyxrc ||
1839                     language_package != system_lyxrc.language_package) {
1840                         os << "\\language_package \"" << language_package
1841                            << "\"\n";
1842                 }
1843         case RC_LANGUAGE_GLOBAL_OPTIONS:
1844                 if (ignore_system_lyxrc ||
1845                     language_global_options
1846                     != system_lyxrc.language_global_options) {
1847                         os << "\\language_global_options \""
1848                            << convert<string>(language_global_options)
1849                            << "\"\n";
1850                 }
1851         case RC_LANGUAGE_USE_BABEL:
1852                 if (ignore_system_lyxrc ||
1853                     language_use_babel != system_lyxrc.language_use_babel) {
1854                         os << "\\language_use_babel \""
1855                            << convert<string>(language_use_babel)
1856                            << "\"\n";
1857                 }
1858         case RC_LANGUAGE_COMMAND_BEGIN:
1859                 if (ignore_system_lyxrc ||
1860                     language_command_begin
1861                     != system_lyxrc.language_command_begin) {
1862                         os << "\\language_command_begin \""
1863                            << language_command_begin
1864                            << "\"\n";
1865                 }
1866         case RC_LANGUAGE_COMMAND_END:
1867                 if (ignore_system_lyxrc ||
1868                     language_command_end
1869                     != system_lyxrc.language_command_end) {
1870                         os << "\\language_command_end \"" << language_command_end
1871                            << "\"\n";
1872                 }
1873         case RC_LANGUAGE_COMMAND_LOCAL:
1874                 if (ignore_system_lyxrc ||
1875                     language_command_local
1876                     != system_lyxrc.language_command_local) {
1877                         os << "\\language_command_local \""
1878                            << language_command_local
1879                            << "\"\n";
1880                 }
1881         case RC_LANGUAGE_AUTO_BEGIN:
1882                 if (ignore_system_lyxrc ||
1883                     language_auto_begin != system_lyxrc.language_auto_begin) {
1884                         os << "\\language_auto_begin "
1885                            << convert<string>(language_auto_begin) << '\n';
1886                 }
1887         case RC_LANGUAGE_AUTO_END:
1888                 if (ignore_system_lyxrc ||
1889                     language_auto_end != system_lyxrc.language_auto_end) {
1890                         os << "\\language_auto_end "
1891                            << convert<string>(language_auto_end) << '\n';
1892                 }
1893         case RC_MARK_FOREIGN_LANGUAGE:
1894                 if (ignore_system_lyxrc ||
1895                     mark_foreign_language
1896                     != system_lyxrc.mark_foreign_language) {
1897                         os << "\\mark_foreign_language " <<
1898                                 convert<string>(mark_foreign_language) << '\n';
1899                 }
1900
1901                 os << "\n#\n"
1902                    << "# 2nd MISC SUPPORT SECTION ##########################\n"
1903                    << "#\n\n";
1904
1905         case RC_AUTO_NUMBER:
1906                 if (ignore_system_lyxrc ||
1907                     auto_number != system_lyxrc.auto_number) {
1908                         os << "\\auto_number " << convert<string>(auto_number) << '\n';
1909                 }
1910         case RC_DEFAULT_LANGUAGE:
1911                 if (ignore_system_lyxrc ||
1912                     default_language != system_lyxrc.default_language) {
1913                         os << "\\default_language " << default_language << '\n';
1914                 }
1915
1916                 os << "\n#\n"
1917                    << "# FORMATS SECTION ##########################\n"
1918                    << "#\n\n";
1919
1920         case RC_FORMAT:
1921                 // New/modifed formats
1922                 for (Formats::const_iterator cit = formats.begin();
1923                      cit != formats.end(); ++cit) {
1924                         Format const * format =
1925                                 system_formats.getFormat(cit->name());
1926                         if (!format ||
1927                             format->extension() != cit->extension() ||
1928                             format->prettyname() != cit->prettyname() ||
1929                             format->shortcut() != cit->shortcut() ||
1930                             format->viewer() != cit->viewer() ||
1931                             format->editor() != cit->editor())
1932                                 os << "\\format \"" << cit->name() << "\" \""
1933                                    << cit->extension() << "\" \""
1934                                    << cit->prettyname() << "\" \""
1935                                    << cit->shortcut() << "\" \""
1936                                    << cit->viewer() << "\" \""
1937                                    << cit->editor() << "\"\n";
1938                 }
1939
1940                 // Look for deleted formats
1941                 for (Formats::const_iterator cit = system_formats.begin();
1942                      cit != system_formats.end(); ++cit)
1943                         if (!formats.getFormat(cit->name()))
1944                                 os << "\\format \"" << cit->name()
1945                                    << "\" \"\" \"\" \"\" \"\" \"\"\n";
1946         case RC_VIEWER:
1947                 // Ignore it
1948
1949                 os << "\n#\n"
1950                    << "# CONVERTERS SECTION ##########################\n"
1951                    << "#\n\n";
1952
1953         case RC_CONVERTER:
1954                 // Look for new converters
1955                 for (Converters::const_iterator cit = converters.begin();
1956                      cit != converters.end(); ++cit) {
1957                         Converter const * converter =
1958                                 system_converters.getConverter(cit->from,
1959                                                                cit->to);
1960                         if (!converter ||
1961                             converter->command != cit->command ||
1962                             converter->flags != cit->flags)
1963                                 os << "\\converter \"" << cit->from << "\" \""
1964                                    << cit->to << "\" \""
1965                                    << cit->command << "\" \""
1966                                    << cit->flags << "\"\n";
1967                 }
1968
1969                 // New/modifed converters
1970                 for (Converters::const_iterator cit = system_converters.begin();
1971                      cit != system_converters.end(); ++cit)
1972                         if (!converters.getConverter(cit->from, cit->to))
1973                                 os << "\\converter \"" << cit->from
1974                                    << "\" \"" << cit->to << "\" \"\" \"\"\n";
1975
1976         case RC_COPIER:
1977                 os << "\n#\n"
1978                    << "# COPIERS SECTION ##########################\n"
1979                    << "#\n\n";
1980
1981                 // Look for new movers
1982                 Movers::iterator const sysbegin = system_movers.begin();
1983                 Movers::iterator const sysend = system_movers.end();
1984
1985                 for (Movers::iterator it = movers.begin(), end = movers.end();
1986                      it != end; ++it) {
1987                         Movers::iterator const sysit =
1988                                 std::find_if(sysbegin, sysend, SameMover(*it));
1989                         if (sysit == sysend) {
1990                                 std::string const & fmt = it->first;
1991                                 std::string const & command =
1992                                         it->second.command();
1993
1994                                 os << "\\copier " << fmt
1995                                    << " \"" << command << "\"\n";
1996                         }
1997                 }
1998
1999                 // We don't actually delete SpecialisedMover(s) from the
2000                 // map, just clear their 'command', so there's no need
2001                 // to test for anything else.
2002         }
2003
2004         os.flush();
2005 }
2006
2007 void LyXRC::set_font_norm_type()
2008 {
2009         if (font_norm == "iso10646-1")
2010                 font_norm_type = ISO_10646_1;
2011         else if (font_norm == "iso8859-1")
2012                 font_norm_type = ISO_8859_1;
2013         else if (font_norm == "iso8859-3")
2014                 font_norm_type = ISO_8859_3;
2015         else if (font_norm == "iso8859-4")
2016                 font_norm_type = ISO_8859_4;
2017         else if (font_norm == "iso8859-6.8x")
2018                 font_norm_type = ISO_8859_6_8;
2019         else if (font_norm == "iso8859-9")
2020                 font_norm_type = ISO_8859_9;
2021         else if (font_norm == "iso8859-15")
2022                 font_norm_type = ISO_8859_15;
2023         else
2024                 font_norm_type = OTHER_ENCODING;
2025 }
2026
2027
2028 string const LyXRC::getDescription(LyXRCTags tag)
2029 {
2030         string str;
2031
2032         switch (tag) {
2033         case RC_ACCEPT_COMPOUND:
2034                 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2035                 break;
2036
2037         case RC_ALT_LANG:
2038         case RC_USE_ALT_LANG:
2039                 str = _("Specify an alternate language. The default is to use the language of the document.");
2040                 break;
2041
2042         case RC_ASCIIROFF_COMMAND:
2043                 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.");
2044                 break;
2045
2046         case RC_ASCII_LINELEN:
2047                 str = _("This is the maximum line length of an exported ASCII file (LaTeX, SGML or plain text).");
2048                 break;
2049
2050         case RC_AUTOREGIONDELETE:
2051                 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2052                 break;
2053
2054         case RC_AUTORESET_OPTIONS:
2055                 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2056                 break;
2057
2058         case RC_AUTOSAVE:
2059                 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2060                 break;
2061
2062         case RC_AUTO_NUMBER:
2063                 break;
2064
2065         case RC_BACKUPDIR_PATH:
2066                 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.");
2067                 break;
2068
2069         case RC_BIBTEX_COMMAND:
2070                 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2071                 break;
2072
2073         case RC_BINDFILE:
2074                 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2075                 break;
2076
2077         case RC_CHECKLASTFILES:
2078                 str = _("Select to check whether the lastfiles still exist.");
2079                 break;
2080
2081         case RC_CHKTEX_COMMAND:
2082                 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2083                 break;
2084
2085         case RC_CONVERTER:
2086                 break;
2087
2088         case RC_COPIER:
2089                 break;
2090
2091         case RC_CURSOR_FOLLOWS_SCROLLBAR:
2092                 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.");
2093                 break;
2094
2095         case RC_CUSTOM_EXPORT_COMMAND:
2096                 break;
2097
2098         case RC_CUSTOM_EXPORT_FORMAT:
2099                 break;
2100
2101         case RC_CYGWIN_PATH_FIX:
2102                 break;
2103
2104         case RC_DATE_INSERT_FORMAT:
2105                 //xgettext:no-c-format
2106                 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2107                 break;
2108
2109         case RC_DEFAULT_LANGUAGE:
2110                 str = _("New documents will be assigned this language.");
2111                 break;
2112
2113         case RC_DEFAULT_PAPERSIZE:
2114                 str = _("Specify the default paper size.");
2115                 break;
2116
2117         case RC_DIALOGS_ICONIFY_WITH_MAIN:
2118                 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2119                 break;
2120
2121         case RC_DISPLAY_GRAPHICS:
2122                 str = _("Select how LyX will display any graphics.");
2123                 break;
2124
2125         case RC_DOCUMENTPATH:
2126                 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2127                 break;
2128
2129         case RC_ESC_CHARS:
2130         case RC_USE_ESC_CHARS:
2131                 str = _("Specify additional chars that can be part of a word.");
2132                 break;
2133
2134         case RC_FONT_ENCODING:
2135                 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2136                 break;
2137
2138         case RC_FORMAT:
2139                 break;
2140
2141         case RC_INDEX_COMMAND:
2142                 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\".");
2143                 break;
2144
2145         case RC_INPUT:
2146                 break;
2147
2148         case RC_KBMAP:
2149         case RC_KBMAP_PRIMARY:
2150         case RC_KBMAP_SECONDARY:
2151                 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.");
2152                 break;
2153
2154         case RC_LABEL_INIT_LENGTH:
2155                 str = _("Maximum number of words in the initialization string for a new label");
2156                 break;
2157
2158         case RC_LANGUAGE_AUTO_BEGIN:
2159                 str = _("Select if a language switching command is needed at the beginning of the document.");
2160                 break;
2161
2162         case RC_LANGUAGE_AUTO_END:
2163                 str = _("Select if a language switching command is needed at the end of the document.");
2164                 break;
2165
2166         case RC_LANGUAGE_COMMAND_BEGIN:
2167                 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.");
2168                 break;
2169
2170         case RC_LANGUAGE_COMMAND_END:
2171                 str = _("The LaTeX command for changing back to the language of the document.");
2172                 break;
2173
2174         case RC_LANGUAGE_COMMAND_LOCAL:
2175                 str = _("The LaTeX command for local changing of the language.");
2176                 break;
2177
2178         case RC_LANGUAGE_GLOBAL_OPTIONS:
2179                 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2180                 break;
2181
2182         case RC_LANGUAGE_PACKAGE:
2183                 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2184                 break;
2185
2186         case RC_LANGUAGE_USE_BABEL:
2187                 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2188                 break;
2189
2190         case RC_LASTFILES:
2191                 str = _("The file where the last-files information should be stored.");
2192                 break;
2193
2194         case RC_MAKE_BACKUP:
2195                 str = _("De-select if you don't want LyX to create backup files.");
2196                 break;
2197
2198         case RC_MARK_FOREIGN_LANGUAGE:
2199                 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2200                 break;
2201
2202         case RC_NUMLASTFILES:
2203                 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."), maxlastfiles);
2204                 break;
2205
2206         case RC_PATH_PREFIX:
2207                 break;
2208
2209         case RC_PERS_DICT:
2210         case RC_USE_PERS_DICT:
2211                 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2212                 break;
2213
2214         case RC_POPUP_BOLD_FONT:
2215                 str = _("The bold font in the dialogs.");
2216                 break;
2217
2218         case RC_POPUP_FONT_ENCODING:
2219                 str = _("The encoding for the menu/popups fonts.");
2220                 break;
2221
2222         case RC_POPUP_NORMAL_FONT:
2223                 str = _("The normal font in the dialogs.");
2224                 break;
2225
2226         case RC_PREVIEW:
2227                 str = _("Shows a typeset preview of things such as math");
2228                 break;
2229
2230         case RC_PREVIEW_HASHED_LABELS:
2231                 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2232                 break;
2233
2234         case RC_PREVIEW_SCALE_FACTOR:
2235                 str = _("Scale the preview size to suit.");
2236                 break;
2237
2238         case RC_PRINTCOLLCOPIESFLAG:
2239                 str = _("The option for specifying whether the copies should be collated.");
2240                 break;
2241
2242         case RC_PRINTCOPIESFLAG:
2243                 str = _("The option for specifying the number of copies to print.");
2244                 break;
2245
2246         case RC_PRINTER:
2247                 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2248                 break;
2249
2250         case RC_PRINTEVENPAGEFLAG:
2251                 str = _("The option to print only even pages.");
2252                 break;
2253
2254         case RC_PRINTEXSTRAOPTIONS:
2255                 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2256                 break;
2257
2258         case RC_PRINTFILEEXTENSION:
2259                 str = _("Extension of printer program output file. Usually \".ps\".");
2260                 break;
2261
2262         case RC_PRINTLANDSCAPEFLAG:
2263                 str = _("The option to print out in landscape.");
2264                 break;
2265
2266         case RC_PRINTODDPAGEFLAG:
2267                 str = _("The option to print only odd pages.");
2268                 break;
2269
2270         case RC_PRINTPAGERANGEFLAG:
2271                 str = _("The option for specifying a comma-separated list of pages to print.");
2272                 break;
2273
2274         case RC_PRINTPAPERDIMENSIONFLAG:
2275                 str = _("Option to specify the dimensions of the print paper.");
2276                 break;
2277
2278         case RC_PRINTPAPERFLAG:
2279                 str = _("The option to specify paper type.");
2280                 break;
2281
2282         case RC_PRINTREVERSEFLAG:
2283                 str = _("The option to reverse the order of the pages printed.");
2284                 break;
2285
2286         case RC_PRINTSPOOL_COMMAND:
2287                 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.");
2288                 break;
2289
2290         case RC_PRINTSPOOL_PRINTERPREFIX:
2291                 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.");
2292                 break;
2293
2294         case RC_PRINTTOFILE:
2295                 str = _("Option to pass to the print program to print to a file.");
2296                 break;
2297
2298         case RC_PRINTTOPRINTER:
2299                 str = _("Option to pass to the print program to print on a specific printer.");
2300                 break;
2301
2302         case RC_PRINT_ADAPTOUTPUT:
2303                 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2304                 break;
2305
2306         case RC_PRINT_COMMAND:
2307                 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2308                 break;
2309
2310         case RC_RTL_SUPPORT:
2311                 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2312                 break;
2313
2314         case RC_SCREEN_DPI:
2315                 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2316                 break;
2317
2318         case RC_SCREEN_FONT_ENCODING:
2319                 str = _("The encoding for the screen fonts.");
2320                 break;
2321
2322         case RC_SCREEN_FONT_ROMAN:
2323         case RC_SCREEN_FONT_SANS:
2324         case RC_SCREEN_FONT_TYPEWRITER:
2325                 str = _("The screen fonts used to display the text while editing.");
2326                 break;
2327
2328         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
2329         case RC_SCREEN_FONT_SANS_FOUNDRY:
2330         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2331                 break;
2332
2333         case RC_SCREEN_FONT_SCALABLE:
2334                 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.");
2335                 break;
2336
2337         case RC_SCREEN_FONT_SIZES:
2338                 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2339                 break;
2340
2341         case RC_SCREEN_ZOOM:
2342                 //xgettext:no-c-format
2343                 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2344                 break;
2345
2346         case RC_SERVERPIPE:
2347                 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2348                 break;
2349
2350         case RC_SET_COLOR:
2351                 break;
2352
2353         case RC_SHOW_BANNER:
2354                 str = _("De-select if you don't want the startup banner.");
2355                 break;
2356
2357         case RC_SPELL_COMMAND:
2358                 str = _("What command runs the spell checker?");
2359                 break;
2360
2361         case RC_TEMPDIRPATH:
2362                 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2363                 break;
2364
2365         case RC_TEMPLATEPATH:
2366                 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2367                 break;
2368
2369         case RC_UIFILE:
2370                 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2371                 break;
2372
2373         case RC_USER_EMAIL:
2374                 break;
2375
2376         case RC_USER_NAME:
2377                 break;
2378
2379         case RC_USETEMPDIR:
2380                 break;
2381
2382         case RC_USE_INP_ENC:
2383                 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.");
2384                 break;
2385
2386         case RC_USE_SPELL_LIB:
2387                 break;
2388
2389         case RC_VIEWDVI_PAPEROPTION:
2390                 str = _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2391                 break;
2392
2393         case RC_VIEWER:
2394                 break;
2395
2396         case RC_WHEEL_JUMP:
2397                 str = _("The number of lines that are scrolled by mice with wheels or five button mice.");
2398                 break;
2399
2400         case RC_LAST:
2401                 break;
2402         }
2403
2404         return str;
2405 }
2406
2407 // The global instance
2408 LyXRC lyxrc;
2409
2410 // The global copy of the system lyxrc entries (everything except preferences)
2411 LyXRC system_lyxrc;