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