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