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