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