]> git.lyx.org Git - lyx.git/blob - src/lyxrc.C
114dfcfc7cf64e67c09d78339b0be99a4d157b6e
[lyx.git] / src / lyxrc.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1995 Matthias Ettrich
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation "lyxrc.h"
15 #endif
16
17 #include <fstream>
18 #include <iomanip>
19 #include <iostream>
20
21 #include "debug.h"
22
23 #include "lyxrc.h"
24 #include "kbmap.h"
25 #include "LyXAction.h"
26 #include "lyxserver.h"
27 #include "lyx_main.h"
28 #include "intl.h"
29 #include "tex-strings.h"
30 #include "support/path.h"
31 #include "support/filetools.h"
32 #include "lyxtext.h"
33
34 using std::ostream;
35 using std::ofstream;
36 using std::cout;
37 using std::ios;
38 using std::endl;
39
40 // this is crappy... why are those colors command line arguments and
41 // not in lyxrc?? (Matthias) 
42 // Because nobody put them there. (Asger)
43
44 extern bool cursor_follows_scrollbar;
45 extern LyXAction lyxaction;
46 extern kb_keymap * toplevel_keymap;
47
48
49 enum LyXRCTags {
50         RC_BEGINTOOLBAR = 1,
51         RC_FONT_ENCODING,
52         RC_PRINTER,
53         RC_PRINT_COMMAND,
54         RC_PRINTEVENPAGEFLAG,
55         RC_PRINTODDPAGEFLAG,
56         RC_PRINTPAGERANGEFLAG,
57         RC_PRINTCOPIESFLAG,
58         RC_PRINTCOLLCOPIESFLAG,
59         RC_PRINTREVERSEFLAG,
60         RC_PRINTLANDSCAPEFLAG,
61         RC_PRINTTOPRINTER,
62         RC_PRINT_ADAPTOUTPUT,
63         RC_PRINTTOFILE,
64         RC_PRINTFILEEXTENSION,
65         RC_PRINTEXSTRAOPTIONS,
66         RC_PRINTSPOOL_COMMAND,
67         RC_PRINTSPOOL_PRINTERPREFIX,
68         RC_PRINTPAPERFLAG,
69         RC_PRINTPAPERDIMENSIONFLAG,
70         RC_CUSTOM_EXPORT_COMMAND,
71         RC_CUSTOM_EXPORT_FORMAT,
72         RC_LATEX_COMMAND,
73         RC_LITERATE_COMMAND,
74         RC_LITERATE_EXTENSION,
75         RC_LITERATE_ERROR_FILTER,
76         RC_BUILD_COMMAND,
77         RC_BUILD_ERROR_FILTER,
78         RC_SCREEN_DPI,
79         RC_SCREEN_ZOOM,
80         RC_SCREEN_FONT_SIZES,
81         RC_SCREEN_FONT_ROMAN,
82         RC_SCREEN_FONT_SANS,
83         RC_SCREEN_FONT_TYPEWRITER,
84         RC_SCREEN_FONT_MENU,
85         RC_SCREEN_FONT_POPUP,
86         RC_SCREEN_FONT_ENCODING,
87         RC_SCREEN_FONT_ENCODING_MENU,
88         RC_SET_COLOR,
89         RC_AUTOSAVE,
90         RC_DOCUMENTPATH,
91         RC_TEMPLATEPATH,
92         RC_TEMPDIRPATH,
93         RC_USETEMPDIR,
94         RC_LASTFILES,
95         RC_AUTOREGIONDELETE,
96         RC_BIND,
97         RC_OVERRIDE_X_DEADKEYS,
98         RC_SERVERPIPE,
99         RC_INPUT,
100         RC_BINDFILE,
101         RC_KBMAP,
102         RC_KBMAP_PRIMARY,
103         RC_KBMAP_SECONDARY,
104         RC_FAX_COMMAND,
105         RC_PHONEBOOK,
106         RC_FAXPROGRAM,
107         RC_ASCIIROFF_COMMAND,
108         RC_ASCII_LINELEN,
109         RC_NUMLASTFILES,
110         RC_CHECKLASTFILES,
111         RC_VIEWDVI_COMMAND,
112         RC_VIEWDVI_PAPEROPTION,
113         RC_DEFAULT_PAPERSIZE,
114         RC_PS_COMMAND,
115         RC_VIEWPS_COMMAND,
116         RC_VIEWPSPIC_COMMAND,
117         RC_ACCEPT_COMPOUND,
118         RC_SPELL_COMMAND,
119         RC_USE_INP_ENC,
120         RC_USE_ALT_LANG,
121         RC_USE_PERS_DICT,
122         RC_USE_ESC_CHARS,
123         RC_SCREEN_FONT_SCALABLE,
124         RC_ALT_LANG,
125         RC_PERS_DICT,
126         RC_ESC_CHARS,
127         RC_CHKTEX_COMMAND,
128         RC_CURSOR_FOLLOWS_SCROLLBAR,
129         RC_EXIT_CONFIRMATION,
130         RC_DISPLAY_SHORTCUTS,
131         RC_RELYX_COMMAND,
132         RC_HTML_COMMAND,
133         RC_MAKE_BACKUP,
134         RC_BACKUPDIR_PATH,
135         RC_RTL_SUPPORT,
136         RC_AUTO_NUMBER,
137         RC_MARK_FOREIGN_LANGUAGE,
138         RC_LANGUAGE_PACKAGE,
139         RC_LANGUAGE_AUTO_BEGIN,
140         RC_LANGUAGE_AUTO_END,
141         RC_LANGUAGE_COMMAND_BEGIN,
142         RC_LANGUAGE_COMMAND_END,
143         RC_PDFLATEX_COMMAND,
144         RC_PDF_MODE,
145         RC_VIEWPDF_COMMAND,
146         RC_PDF_TO_PS_COMMAND,
147         RC_DVI_TO_PS_COMMAND,
148         RC_DATE_INSERT_FORMAT,
149         RC_SHOW_BANNER,
150         RC_USE_GUI,
151         RC_LINUXDOC_TO_LYX_COMMAND,
152         RC_LINUXDOC_TO_HTML_COMMAND,
153         RC_LINUXDOC_TO_LATEX_COMMAND,
154         RC_DOCBOOK_TO_DVI_COMMAND,
155         RC_DOCBOOK_TO_HTML_COMMAND,
156         RC_DOCBOOK_TO_PDF_COMMAND,
157         RC_WHEEL_JUMP,
158         RC_LAST
159 };
160
161
162 static
163 keyword_item lyxrcTags[] = {
164         { "\\accept_compound", RC_ACCEPT_COMPOUND },
165         { "\\alternate_language", RC_ALT_LANG },
166         { "\\ascii_linelen", RC_ASCII_LINELEN },
167         { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
168         { "\\auto_number", RC_AUTO_NUMBER },
169         { "\\auto_region_delete", RC_AUTOREGIONDELETE },
170         { "\\autosave", RC_AUTOSAVE },
171         { "\\backupdir_path", RC_BACKUPDIR_PATH },
172         { "\\begin_toolbar", RC_BEGINTOOLBAR },
173         { "\\bind", RC_BIND },
174         { "\\bind_file", RC_BINDFILE },
175         { "\\build_command", RC_BUILD_COMMAND },
176         { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
177         { "\\check_lastfiles", RC_CHECKLASTFILES },
178         { "\\chktex_command", RC_CHKTEX_COMMAND },
179         { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
180         { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
181         { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
182         { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
183         { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
184         { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
185         { "\\docbook_to_dvi_command", RC_DOCBOOK_TO_DVI_COMMAND },
186         { "\\docbook_to_html_command", RC_DOCBOOK_TO_HTML_COMMAND },
187         { "\\docbook_to_pdf_command", RC_DOCBOOK_TO_PDF_COMMAND },
188         { "\\document_path", RC_DOCUMENTPATH },
189         { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
190         { "\\escape_chars", RC_ESC_CHARS },
191         { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
192         { "\\fax_command", RC_FAX_COMMAND },
193         { "\\fax_program", RC_FAXPROGRAM },
194         { "\\font_encoding", RC_FONT_ENCODING },
195         { "\\html_command", RC_HTML_COMMAND },
196         { "\\input", RC_INPUT },
197         { "\\kbmap", RC_KBMAP },
198         { "\\kbmap_primary", RC_KBMAP_PRIMARY },
199         { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
200         { "\\language_auto_begin", RC_LANGUAGE_AUTO_BEGIN },
201         { "\\language_auto_end", RC_LANGUAGE_AUTO_END },
202         { "\\language_command_begin", RC_LANGUAGE_COMMAND_BEGIN },
203         { "\\language_command_end", RC_LANGUAGE_COMMAND_END },
204         { "\\language_package", RC_LANGUAGE_PACKAGE },
205         { "\\lastfiles", RC_LASTFILES },
206         { "\\latex_command", RC_LATEX_COMMAND },
207         { "\\linuxdoc_to_html_command", RC_LINUXDOC_TO_HTML_COMMAND },
208         { "\\linuxdoc_to_latex_command", RC_LINUXDOC_TO_LATEX_COMMAND },
209         { "\\linuxdoc_to_lyx_command", RC_LINUXDOC_TO_LYX_COMMAND },
210         { "\\literate_command", RC_LITERATE_COMMAND },
211         { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
212         { "\\literate_extension", RC_LITERATE_EXTENSION },
213         { "\\make_backup", RC_MAKE_BACKUP },
214         { "\\mark_foreign_language", RC_MARK_FOREIGN_LANGUAGE },
215         { "\\num_lastfiles", RC_NUMLASTFILES },
216         { "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
217         { "\\pdf_mode", RC_PDF_MODE },
218         { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
219         { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
220         { "\\personal_dictionary", RC_PERS_DICT },
221         { "\\phone_book", RC_PHONEBOOK },
222         { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
223         { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
224         { "\\print_command", RC_PRINT_COMMAND },
225         { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
226         { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
227         { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
228         { "\\print_file_extension", RC_PRINTFILEEXTENSION },
229         { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
230         { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
231         { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
232         { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
233         { "\\print_paper_flag", RC_PRINTPAPERFLAG },
234         { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
235         { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
236         { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
237         { "\\print_to_file", RC_PRINTTOFILE },
238         { "\\print_to_printer", RC_PRINTTOPRINTER },
239         { "\\printer", RC_PRINTER },
240         { "\\ps_command", RC_PS_COMMAND },
241         { "\\relyx_command", RC_RELYX_COMMAND },
242         { "\\rtl", RC_RTL_SUPPORT },
243         { "\\screen_dpi", RC_SCREEN_DPI },
244         { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
245         { "\\screen_font_encoding_menu", RC_SCREEN_FONT_ENCODING_MENU },
246         { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
247         { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
248         { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
249         { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
250         { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
251         { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
252         { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
253         { "\\screen_zoom", RC_SCREEN_ZOOM },
254         { "\\serverpipe", RC_SERVERPIPE },
255         { "\\set_color", RC_SET_COLOR },
256         { "\\show_banner", RC_SHOW_BANNER },
257         { "\\spell_command", RC_SPELL_COMMAND },
258         { "\\tempdir_path", RC_TEMPDIRPATH },
259         { "\\template_path", RC_TEMPLATEPATH },
260         { "\\use_alt_language", RC_USE_ALT_LANG },
261         { "\\use_escape_chars", RC_USE_ESC_CHARS },
262         { "\\use_gui", RC_USE_GUI },
263         { "\\use_input_encoding", RC_USE_INP_ENC },
264         { "\\use_personal_dictionary", RC_USE_PERS_DICT },
265         { "\\use_tempdir", RC_USETEMPDIR },
266         { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
267         { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
268         { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
269         { "\\view_ps_command", RC_VIEWPS_COMMAND },
270         { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND },
271         { "\\wheel_jump", RC_WHEEL_JUMP }
272 };
273
274 /* Let the range depend of the size of lyxrcTags.  Alejandro 240596 */
275 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
276
277
278 LyXRC::LyXRC() 
279 {
280         setDefaults();
281 }
282
283
284 void LyXRC::setDefaults() {
285         // Get printer from the environment. If fail, use default "",
286         // assuming that everything is set up correctly.
287         printer = GetEnv("PRINTER");
288         print_adapt_output = false;
289         print_command = "dvips";
290         print_evenpage_flag = "-B";
291         print_oddpage_flag = "-A";
292         print_pagerange_flag = "-pp";
293         print_copies_flag = "-c";
294         print_collcopies_flag = "-C";
295         print_reverse_flag = "-r";
296         print_landscape_flag = "-t landscape";
297         print_to_printer = "-P";
298         print_to_file = "-o ";
299         print_file_extension = ".ps";
300         print_paper_flag = "-t";
301         print_paper_dimension_flag = "-T";
302         document_path = GetEnvPath("HOME");
303         tempdir_path = "/tmp";
304         use_tempdir = true;
305         pdf_mode = false;
306         latex_command = "latex";
307         pdflatex_command = "pdflatex";
308         pdf_to_ps_command = "pdf2ps";
309         dvi_to_ps_command = "dvips";
310         literate_command = "none";
311         literate_extension = "none";
312         literate_error_filter = "cat";
313         build_command = "make";
314         build_error_filter = "cat";
315         relyx_command = "reLyX";
316         ps_command = "gs";
317         view_ps_command = "ghostview -swap";
318         view_pspic_command = "ghostview";
319         view_dvi_command = "xdvi";
320         view_dvi_paper_option = "-paper";
321         view_pdf_command = "xpdf";
322         default_papersize = BufferParams::PAPER_USLETTER;
323         custom_export_format = "ps";
324         chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
325         html_command = "tth -t";
326         fontenc = "default";
327         dpi = 75;
328         // Because a screen typically is wider than a piece of paper:
329         zoom = 150;
330         wheel_jump = 100;
331         // Default LaTeX font size:
332         font_sizes[LyXFont::SIZE_TINY] = 5.0;
333         font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
334         font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
335         font_sizes[LyXFont::SIZE_SMALL] = 9.0;
336         font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
337         font_sizes[LyXFont::SIZE_LARGE] = 12.0;
338         font_sizes[LyXFont::SIZE_LARGER] = 14.4;
339         font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
340         font_sizes[LyXFont::SIZE_HUGE] = 20.74;
341         font_sizes[LyXFont::SIZE_HUGER] = 24.88;
342         use_scalable_fonts = true;
343         roman_font_name = "-*-times";
344         sans_font_name = "-*-helvetica";
345         typewriter_font_name = "-*-courier";
346         menu_font_name = "-*-helvetica-bold-r";
347         popup_font_name = "-*-helvetica-medium-r";
348         font_norm = "iso8859-1";
349         font_norm_type = OTHER_ENCODING;
350         font_norm_menu = "";
351         override_x_deadkeys = true;
352         autosave = 300;
353         auto_region_delete = true;
354         ascii_linelen = 65;
355         num_lastfiles = 4;
356         check_lastfiles = true;
357         make_backup = true;
358         backupdir_path = "";
359         exit_confirmation = true;
360         display_shortcuts = true;
361         // Spellchecker settings:
362         isp_command = "ispell";
363         isp_accept_compound = false;
364         isp_use_input_encoding = false;
365         isp_use_alt_lang = false;
366         isp_use_pers_dict = false;
367         isp_use_esc_chars = false;
368         use_kbmap = false;
369         hasBindFile = false;
370         rtl_support = false;
371         auto_number = true;
372         mark_foreign_language = true;
373         language_package = "\\usepackage{babel}";
374         language_auto_begin = true;
375         language_auto_end = true;
376         language_command_begin = "\\selectlanguage{$$lang}";
377         language_command_end = "\\selectlanguage{$$lang}";
378
379         ///
380         date_insert_format = "%A, %e %B %Y";
381         show_banner = true;
382         use_gui = true;
383
384         ///
385         linuxdoc_to_latex_command="none";
386         linuxdoc_to_lyx_command="none";
387         linuxdoc_to_html_command="none";
388
389         docbook_to_dvi_command="none";
390         docbook_to_html_command="none";
391         docbook_to_pdf_command="none";
392 }
393
394
395 int LyXRC::ReadBindFile(string const & name)
396 {
397         hasBindFile = true;
398         string tmp = i18nLibFileSearch("bind", name, "bind");
399         lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
400         int result = read(tmp);
401         if (result) {
402                 lyxerr << "Error reading bind file: " << tmp << endl;
403         }
404         return result;
405 }
406
407
408 int LyXRC::read(string const & filename)
409 {
410         // Default bindfile.
411         string bindFile = "cua";
412         
413         LyXLex lexrc(lyxrcTags, lyxrcCount);
414         if (lyxerr.debugging(Debug::PARSER))
415                 lexrc.printTable(lyxerr);
416         
417         lexrc.setFile(filename);
418         if (!lexrc.IsOK()) return -2;
419         
420         lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
421         
422         while (lexrc.IsOK()) {
423                 // By using two switches we take advantage of the compiler
424                 // telling us if we have missed a LyXRCTags element in
425                 // the second switch.
426                 // Note that this also shows a problem with LyXLex since it
427                 // helps us avoid taking advantage of the strictness of the
428                 // compiler.
429
430                 int le = lexrc.lex();
431                 switch(le) {
432                 case LyXLex::LEX_UNDEF:
433                         lexrc.printError("Unknown tag `$$Token'");
434                         continue; 
435                 case LyXLex::LEX_FEOF:
436                         continue; 
437                 default: break;
438                 }
439                 switch (static_cast<LyXRCTags>(le)) {
440                 case RC_INPUT: // Include file
441                         if (lexrc.next()) {
442                                 string tmp = LibFileSearch(string(),
443                                                            lexrc.GetString()); 
444                                 if (read(tmp)) {
445                                         lexrc.printError("Error reading "
446                                                          "included file: "+tmp);
447                                 }
448                         }
449                         break;
450                 case RC_BINDFILE:                     // RVDK_PATCH_5
451                         if (lexrc.next()) {
452                                 string tmp(lexrc.GetString());
453                                 if (bind_file.empty()) {
454                                         // we only need the name of the first
455                                         // bind file since that (usually)
456                                         // includes several others.
457                                         bind_file = tmp;
458                                 }
459                                 ReadBindFile(tmp);
460                         }
461                         break;
462                         
463                 case RC_BEGINTOOLBAR:
464                         // this toolbar should be changed to be a completely
465                         // non gui toolbar. (Lgb)
466                         toolbardefaults.read(lexrc);
467                         break;
468                         
469                 case RC_KBMAP:
470                         if (lexrc.next())
471                                 use_kbmap = lexrc.GetBool();
472                         break;
473                         
474                 case RC_EXIT_CONFIRMATION:
475                         if (lexrc.next())
476                                 exit_confirmation = lexrc.GetBool();
477                         break;
478                         
479                 case RC_DISPLAY_SHORTCUTS:
480                         if (lexrc.next())
481                                 display_shortcuts = lexrc.GetBool();
482                         break;
483                         
484                 case RC_KBMAP_PRIMARY:
485                         if (lexrc.next()) 
486                                 if (!LibFileSearch("kbd", lexrc.GetString(), 
487                                                    "kmap").empty()) 
488                                         primary_kbmap = lexrc.GetString();
489                                 else 
490                                         lexrc.printError("LyX: Keymap `$$Token' not found");
491                         break;
492                         
493                 case RC_KBMAP_SECONDARY:
494                         if (lexrc.next()) 
495                                 if (!LibFileSearch("kbd", lexrc.GetString(), 
496                                                    "kmap").empty()) 
497                                         secondary_kbmap = lexrc.GetString();
498                                 else 
499                                         lexrc.printError("LyX: Keymap `$$Token' not found");
500                         break;
501                         
502                 case RC_FONT_ENCODING:
503                         if (lexrc.next())
504                                 fontenc = lexrc.GetString();
505                         break;
506                         
507                 case RC_PRINTER:
508                         if (lexrc.next())
509                                 printer = lexrc.GetString();
510                         break;
511                         
512                 case RC_PRINT_COMMAND:
513                         if (lexrc.next())
514                                 print_command = lexrc.GetString();
515                         break;
516                         
517                 case RC_PRINTEVENPAGEFLAG:
518                         if (lexrc.next())
519                                 print_evenpage_flag = lexrc.GetString();
520                         break;
521                         
522                 case RC_PRINTODDPAGEFLAG:
523                         if (lexrc.next())
524                                 print_oddpage_flag = lexrc.GetString();
525                         break;
526                         
527                 case RC_PRINTPAGERANGEFLAG:
528                         if (lexrc.next())
529                                 print_pagerange_flag = lexrc.GetString();
530                         break;
531                         
532                 case RC_PRINTCOPIESFLAG:
533                         if (lexrc.next())
534                                 print_copies_flag = lexrc.GetString();
535                         break;
536                         
537                 case RC_PRINTCOLLCOPIESFLAG:
538                         if (lexrc.next())
539                                 print_collcopies_flag = lexrc.GetString();
540                         break;
541                         
542                 case RC_PRINTREVERSEFLAG:
543                         if (lexrc.next())
544                                 print_reverse_flag = lexrc.GetString();
545                         break;
546                         
547                 case RC_PRINTLANDSCAPEFLAG:
548                         if (lexrc.next())
549                                 print_landscape_flag = lexrc.GetString();
550                         break;
551                         
552                 case RC_PRINTTOPRINTER:
553                         if (lexrc.next())
554                                 print_to_printer = lexrc.GetString();
555                         break;
556                         
557                 case RC_PRINT_ADAPTOUTPUT:
558                         if (lexrc.next())
559                                 print_adapt_output = lexrc.GetBool();
560                         break;
561                         
562                 case RC_PRINTTOFILE:
563                         if (lexrc.next())
564                                 print_to_file = lexrc.GetString();
565                         break;
566                         
567                 case RC_PRINTFILEEXTENSION:
568                         if (lexrc.next())
569                                 print_file_extension = lexrc.GetString();
570                         break;
571                         
572                 case RC_PRINTEXSTRAOPTIONS:
573                         if (lexrc.next())
574                                 print_extra_options = lexrc.GetString();
575                         break;
576                         
577                 case RC_PRINTSPOOL_COMMAND:
578                         if (lexrc.next())
579                                 print_spool_command = lexrc.GetString();
580                         break;
581                         
582                 case RC_PRINTSPOOL_PRINTERPREFIX:
583                         if (lexrc.next())
584                                 print_spool_printerprefix = lexrc.GetString();
585                         break;
586                         
587                 case RC_PRINTPAPERDIMENSIONFLAG:
588                         if (lexrc.next())
589                                 print_paper_dimension_flag = lexrc.GetString();
590                         break;
591                         
592                 case RC_PRINTPAPERFLAG:
593                         if (lexrc.next())
594                                 print_paper_flag = lexrc.GetString();
595                         break;
596                         
597                 case RC_CUSTOM_EXPORT_COMMAND:
598                         if (lexrc.next())
599                                 custom_export_command = lexrc.GetString();
600                         break;
601                         
602                 case RC_CUSTOM_EXPORT_FORMAT:
603                         if (lexrc.next())
604                                 custom_export_format = lexrc.GetString();
605                         break;
606
607                 case RC_PDF_MODE:
608                         if (lexrc.next())
609                                 pdf_mode = lexrc.GetBool();
610                         break;
611                         
612                 case RC_LATEX_COMMAND:
613                         if (lexrc.next())
614                                 latex_command = lexrc.GetString();
615                         break;
616
617                 case RC_PDFLATEX_COMMAND:
618                         if (lexrc.next())
619                                 pdflatex_command = lexrc.GetString();
620                         break;
621
622                 case RC_PDF_TO_PS_COMMAND:
623                         if (lexrc.next())
624                                 pdf_to_ps_command = lexrc.GetString();
625                         break;
626
627                 case RC_DVI_TO_PS_COMMAND:
628                         if (lexrc.next())
629                                 dvi_to_ps_command = lexrc.GetString();
630                         break;
631                         
632                 case RC_LITERATE_COMMAND:
633                         if (lexrc.next())
634                                 literate_command = lexrc.GetString();
635                         break;
636                         
637                 case RC_LITERATE_EXTENSION:
638                         if (lexrc.next())
639                                 literate_extension = lexrc.GetString();
640                         break;
641                         
642                 case RC_LITERATE_ERROR_FILTER:
643                         if (lexrc.next())
644                                 literate_error_filter = lexrc.GetString();
645                         break;
646                         
647                 case RC_BUILD_COMMAND:
648                         if (lexrc.next())
649                                 build_command = lexrc.GetString();
650                         break;
651                         
652                 case RC_BUILD_ERROR_FILTER:
653                         if (lexrc.next())
654                                 build_error_filter = lexrc.GetString();
655                         break;
656                         
657                 case RC_RELYX_COMMAND:
658                         if (lexrc.next())
659                                 relyx_command = lexrc.GetString();
660                         break;
661                         
662                 case RC_DEFAULT_PAPERSIZE:
663                         if (lexrc.next()) {
664                                 string size = lowercase(lexrc.GetString());
665                                 if (size == "usletter")
666                                         default_papersize =
667                                                 BufferParams::PAPER_USLETTER;
668                                 else if (size == "legal")
669                                         default_papersize =
670                                                 BufferParams::PAPER_LEGALPAPER;
671                                 else if (size == "executive")
672                                         default_papersize =
673                                                 BufferParams::PAPER_EXECUTIVEPAPER;
674                                 else if (size == "a3")
675                                         default_papersize =
676                                                 BufferParams::PAPER_A3PAPER;
677                                 else if (size == "a4")
678                                         default_papersize =
679                                                 BufferParams::PAPER_A4PAPER;
680                                 else if (size == "a5")
681                                         default_papersize =
682                                                 BufferParams::PAPER_A5PAPER;
683                                 else if (size == "b5")
684                                         default_papersize =
685                                                 BufferParams::PAPER_B5PAPER;
686                         }
687                         break;
688                 case RC_VIEWDVI_COMMAND:
689                         if (lexrc.next())
690                                 view_dvi_command = lexrc.GetString();
691                         break;
692
693                 case RC_VIEWDVI_PAPEROPTION:
694                         if (lexrc.next())
695                                 view_dvi_paper_option = lexrc.GetString();
696                         else 
697                                 view_dvi_paper_option = "";
698                         break;
699
700                 case RC_VIEWPDF_COMMAND:
701                         if (lexrc.next())
702                                 view_pdf_command = lexrc.GetString();
703                         break;
704                         
705                 case RC_PS_COMMAND:
706                         if (lexrc.next())
707                                 ps_command = lexrc.GetString();
708                         break;
709                         
710                 case RC_VIEWPS_COMMAND:
711                         if (lexrc.next())
712                                 view_ps_command = lexrc.GetString();
713                         break;
714                         
715                 case RC_VIEWPSPIC_COMMAND:
716                         if (lexrc.next())
717                                 view_pspic_command = lexrc.GetString();
718                         break;
719                         
720                 case RC_CHKTEX_COMMAND:
721                         if (lexrc.next())
722                                 chktex_command = lexrc.GetString();
723                         break;
724                         
725                 case RC_HTML_COMMAND:
726                         if (lexrc.next())
727                                 html_command = lexrc.GetString();
728                         break;
729                         
730                 case RC_SCREEN_DPI:
731                         if (lexrc.next())
732                                 dpi = lexrc.GetInteger();
733                         break;
734                         
735                 case RC_SCREEN_ZOOM:
736                         if (lexrc.next())
737                                 zoom = lexrc.GetInteger();
738                         break;
739
740                 case RC_WHEEL_JUMP:
741                         if (lexrc.next())
742                                 wheel_jump = lexrc.GetInteger();
743                         break;
744                         
745                 case RC_SCREEN_FONT_SIZES:
746                         if (lexrc.next())
747                                 font_sizes[LyXFont::SIZE_TINY] =
748                                         lexrc.GetFloat();
749                         if (lexrc.next())
750                                 font_sizes[LyXFont::SIZE_SCRIPT] =
751                                         lexrc.GetFloat();
752                         if (lexrc.next())
753                                 font_sizes[LyXFont::SIZE_FOOTNOTE] =
754                                         lexrc.GetFloat();
755                         if (lexrc.next())
756                                 font_sizes[LyXFont::SIZE_SMALL] =
757                                         lexrc.GetFloat();
758                         if (lexrc.next())
759                                 font_sizes[LyXFont::SIZE_NORMAL] =
760                                         lexrc.GetFloat();
761                         if (lexrc.next())
762                                 font_sizes[LyXFont::SIZE_LARGE] =
763                                         lexrc.GetFloat();
764                         if (lexrc.next())
765                                 font_sizes[LyXFont::SIZE_LARGER] =
766                                         lexrc.GetFloat();
767                         if (lexrc.next())
768                                 font_sizes[LyXFont::SIZE_LARGEST] =
769                                         lexrc.GetFloat();
770                         if (lexrc.next())
771                                 font_sizes[LyXFont::SIZE_HUGE] =
772                                         lexrc.GetFloat();
773                         if (lexrc.next())
774                                 font_sizes[LyXFont::SIZE_HUGER] =
775                                         lexrc.GetFloat();
776                         break;
777                         
778                 case RC_SCREEN_FONT_SCALABLE:
779                         if (lexrc.next())
780                                 use_scalable_fonts = lexrc.GetBool();
781                         break;
782                         
783                 case RC_AUTOSAVE:
784                         if (lexrc.next())
785                                 autosave = lexrc.GetInteger();
786                         break;
787                         
788                 case RC_DOCUMENTPATH:
789                         if (lexrc.next()) {
790                                 document_path = ExpandPath(lexrc.GetString());
791                         }
792                         break;
793                         
794                 case RC_TEMPLATEPATH:
795                         if (lexrc.next())
796                                 template_path = ExpandPath(lexrc.GetString());
797                         break;
798                         
799                 case RC_TEMPDIRPATH:
800                         if (lexrc.next())
801                                 tempdir_path = ExpandPath(lexrc.GetString());
802                         break;
803                         
804                 case RC_USETEMPDIR:
805                         if (lexrc.next())
806                                 use_tempdir = lexrc.GetBool();
807                         break;
808                         
809                 case RC_LASTFILES:
810                         if (lexrc.next())
811                                 lastfiles = ExpandPath(lexrc.GetString());
812                         break;
813                         
814                 case RC_NUMLASTFILES:
815                         if (lexrc.next())
816                                 num_lastfiles = lexrc.GetInteger();
817                         break;
818                         
819                 case RC_CHECKLASTFILES:
820                         if (lexrc.next())
821                                 check_lastfiles = lexrc.GetBool();
822                         break;
823                         
824                 case RC_SCREEN_FONT_ROMAN:
825                         if (lexrc.next())
826                                 roman_font_name = lexrc.GetString();
827                         break;
828                         
829                 case RC_SCREEN_FONT_SANS:
830                         if (lexrc.next())
831                                 sans_font_name = lexrc.GetString();
832                         break;
833                         
834                 case RC_SCREEN_FONT_TYPEWRITER:
835                         if (lexrc.next())
836                                 typewriter_font_name = lexrc.GetString();
837                         break;
838                         
839                 case RC_SCREEN_FONT_MENU:
840                         if (lexrc.next())
841                                 menu_font_name = lexrc.GetString();
842                         break;
843                         
844                 case RC_SCREEN_FONT_POPUP:
845                         if (lexrc.next())
846                                 popup_font_name = lexrc.GetString();
847                         break;
848                         
849                 case RC_SCREEN_FONT_ENCODING:
850                         if (lexrc.next()) {
851                                 font_norm = lexrc.GetString();
852                                 set_font_norm_type();
853                         }
854                         break;
855
856                 case RC_SCREEN_FONT_ENCODING_MENU:
857                         if (lexrc.next())
858                                 font_norm_menu = lexrc.GetString();
859                         break;
860
861                 case RC_SET_COLOR:
862                 {
863                         string lyx_name, x11_name;
864
865                         if (lexrc.lex() == LyXLex::LEX_DATA)  {
866                                 lyx_name = lexrc.GetString();
867                         } else {
868                                 lexrc.printError("Bad color tag: `$$Token'");
869                                 break;
870                         }
871                         
872                         if (lexrc.lex() == LyXLex::LEX_DATA) {
873                                 x11_name = lexrc.GetString();
874                         } else {
875                                 lexrc.printError("Bad color name: `$$Token'");
876                                 break;
877                         }
878
879                         if (!lcolor.setColor(lyx_name, x11_name))
880                                 lyxerr << "Bad lyxrc set_color for "
881                                         << lyx_name << endl;
882
883                         break;
884                 }
885                 case RC_AUTOREGIONDELETE:
886                         // Auto region delete defaults to true
887                         if (lexrc.next())
888                                 auto_region_delete = lexrc.GetBool();
889                         break;
890                         
891                 case RC_BIND:
892                 {
893                         // we should not do an explicit binding before
894                         // loading a bind file. So, in this case, load
895                         // the default bind file.
896                         if (!hasBindFile) {
897                                 ReadBindFile();
898                                 bind_file = bindFile;
899                         }
900                         // !!!chb, dynamic key binding...
901                         int action, res = 0;
902                         string seq, cmd;
903                         
904                         if (lexrc.lex() == LyXLex::LEX_DATA)  {
905                                 seq = lexrc.GetString();
906                         } else {
907                                 lexrc.printError("Bad key sequence: `$$Token'");
908                                 break;
909                         }
910                         
911                         if (lexrc.lex() == LyXLex::LEX_DATA) {
912                                 cmd = lexrc.GetString();
913                         } else {
914                                 lexrc.printError("Bad command: `$$Token'");
915                                 break;
916                         }
917                         
918                         if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
919                                 if (lyxerr.debugging(Debug::KEY)) {
920                                         lyxerr << "RC_BIND: Sequence `"
921                                                << seq << "' Command `"
922                                                << cmd << "' Action `"
923                                                << action << '\'' << endl;
924                                 }
925                                 res = toplevel_keymap->bind(seq.c_str(),
926                                                             action);
927                                 if (res != 0) {
928                                         lexrc.printError(
929                                                 "Invalid key sequence `"
930                                                 + seq + '\''); 
931                                 }
932                         } else {// cmd is the last token read.
933                                 lexrc.printError(
934                                         "Unknown LyX function `$$Token'");
935                         }
936                         break;
937                 }
938                 case RC_OVERRIDE_X_DEADKEYS:
939                         if (lexrc.next())
940                                 override_x_deadkeys = lexrc.GetBool();
941                         break;
942
943                 case RC_SERVERPIPE:
944                         if (lexrc.next())
945                                 lyxpipes = ExpandPath(lexrc.GetString());
946                         break;
947                         
948                 case RC_CURSOR_FOLLOWS_SCROLLBAR:
949                         if (lexrc.next())
950                                 cursor_follows_scrollbar = lexrc.GetBool();
951                         break;
952
953                 case RC_FAX_COMMAND:
954                         if (lexrc.next())
955                                 fax_command = lexrc.GetString();
956                         break;
957                 case RC_FAXPROGRAM:
958                         if (lexrc.next())
959                                 fax_program = lexrc.GetString();
960                         break;
961                 case RC_PHONEBOOK:
962                         if (lexrc.next()) {
963                                 string s = lexrc.GetString();
964                                 if (AbsolutePath(s))
965                                         phone_book = s;
966                                 else
967                                         phone_book = user_lyxdir + s;
968                         }
969                         break;
970                 case RC_ASCIIROFF_COMMAND:
971                         if (lexrc.next())
972                                 ascii_roff_command = lexrc.GetString();
973                         break;
974                 case RC_ASCII_LINELEN:
975                         if (lexrc.next())
976                                 ascii_linelen = lexrc.GetInteger();
977                         break;
978                         // Spellchecker settings:
979                 case RC_SPELL_COMMAND:
980                         if (lexrc.next())
981                                 isp_command = lexrc.GetString();
982                         break;
983                 case RC_ACCEPT_COMPOUND:
984                         if (lexrc.next())
985                                 isp_accept_compound = lexrc.GetBool();
986                         break;
987                 case RC_USE_INP_ENC:
988                         if (lexrc.next())
989                                 isp_use_input_encoding = lexrc.GetBool();
990                         break;
991                 case RC_USE_ALT_LANG:
992                         if (lexrc.next())
993                                 isp_use_alt_lang = lexrc.GetBool();
994                         break;
995                 case RC_USE_PERS_DICT:
996                         if (lexrc.next())
997                                 isp_use_pers_dict = lexrc.GetBool();
998                         break;
999                 case RC_USE_ESC_CHARS:
1000                         if (lexrc.next())
1001                                 isp_use_esc_chars = lexrc.GetBool();
1002                         break;
1003                 case RC_ALT_LANG:
1004                         if (lexrc.next())
1005                                 isp_alt_lang = lexrc.GetString();
1006                         break;
1007                 case RC_PERS_DICT:
1008                         if (lexrc.next())
1009                                 isp_pers_dict = lexrc.GetString();
1010                         break;
1011                 case RC_ESC_CHARS:
1012                         if (lexrc.next())
1013                                 isp_esc_chars = lexrc.GetString();
1014                         break;
1015                 case RC_MAKE_BACKUP:
1016                         if (lexrc.next())
1017                                 make_backup = lexrc.GetBool();
1018                         break;
1019                 case RC_BACKUPDIR_PATH:
1020                         if (lexrc.next())
1021                                 backupdir_path = ExpandPath(lexrc.GetString());
1022                         break;
1023                 case RC_DATE_INSERT_FORMAT:
1024                         if (lexrc.next())
1025                                 date_insert_format = lexrc.GetString();
1026                         break;
1027                 case RC_LANGUAGE_PACKAGE:
1028                         if (lexrc.next())
1029                                 language_package = lexrc.GetString();
1030                         break;
1031                 case RC_LANGUAGE_AUTO_BEGIN:
1032                         if (lexrc.next())
1033                                 language_auto_begin = lexrc.GetBool();
1034                         break;
1035                 case RC_LANGUAGE_AUTO_END:
1036                         if (lexrc.next())
1037                                 language_auto_end = lexrc.GetBool();
1038                         break;
1039                 case RC_LANGUAGE_COMMAND_BEGIN:
1040                         if (lexrc.next())
1041                                 language_command_begin = lexrc.GetString();
1042                         break;
1043                 case RC_LANGUAGE_COMMAND_END:
1044                         if (lexrc.next())
1045                                 language_command_end = lexrc.GetString();
1046                         break;
1047                 case RC_RTL_SUPPORT:
1048                         if (lexrc.next())
1049                                 rtl_support = lexrc.GetBool();
1050                         break;
1051                 case RC_AUTO_NUMBER:
1052                         if (lexrc.next())
1053                                 auto_number = lexrc.GetBool();
1054                         break;
1055                 case RC_MARK_FOREIGN_LANGUAGE:
1056                         if (lexrc.next())
1057                                 mark_foreign_language = lexrc.GetBool();
1058                         break;
1059                 case RC_SHOW_BANNER:
1060                         if (lexrc.next())
1061                                 show_banner = lexrc.GetBool();
1062                         break;
1063                 case RC_USE_GUI:
1064                         if (lexrc.next())
1065                                 use_gui = lexrc.GetBool();
1066                         break;
1067                 case RC_LINUXDOC_TO_LYX_COMMAND:
1068                         if ( lexrc.next())
1069                                 linuxdoc_to_lyx_command = lexrc.GetString();
1070                         break;
1071                 case RC_LINUXDOC_TO_HTML_COMMAND:
1072                         if ( lexrc.next())
1073                                 linuxdoc_to_html_command = lexrc.GetString();
1074                         break;
1075                 case RC_LINUXDOC_TO_LATEX_COMMAND:
1076                         if ( lexrc.next())
1077                                 linuxdoc_to_latex_command = lexrc.GetString();
1078                         break;
1079                 case RC_DOCBOOK_TO_DVI_COMMAND:
1080                         if ( lexrc.next())
1081                                 docbook_to_dvi_command = lexrc.GetString();
1082                         break;
1083                 case RC_DOCBOOK_TO_HTML_COMMAND:
1084                         if ( lexrc.next())
1085                                 docbook_to_html_command = lexrc.GetString();
1086                         break;
1087                 case RC_DOCBOOK_TO_PDF_COMMAND:
1088                         if ( lexrc.next())
1089                                 docbook_to_pdf_command = lexrc.GetString();
1090                         break;
1091
1092                 case RC_LAST: break; // this is just a dummy
1093                 }
1094         }
1095
1096         return 0;
1097 }
1098
1099
1100 void LyXRC::write(string const & filename) const
1101 {
1102         ofstream ofs(filename.c_str());
1103         if (ofs)
1104                 output(ofs);
1105 }
1106
1107
1108 void LyXRC::print() const
1109 {
1110         if (lyxerr.debugging())
1111                 output(lyxerr);
1112         else
1113                 output(cout);
1114 }
1115
1116
1117 void LyXRC::output(ostream & os) const
1118 {
1119         os << "### This file is part of\n"
1120            << "### ========================================================\n"
1121            << "###          LyX, The Document Processor\n"
1122            << "###\n"
1123            << "###          Copyright 1995 Matthias Ettrich\n"
1124            << "###          Copyright 1995-1998 The LyX Team.\n"
1125            << "###\n"
1126            << "### ========================================================\n"
1127            << "\n"
1128            << "# This file is written by LyX, if you want to make your own\n"
1129            << "# modifications you should do them from inside LyX and save\n"
1130            << "# your preferences, or you can also make your modifications\n"
1131            << "# to lyxrc by hand. It is not advisable to edit this file.\n"
1132            << "\n";
1133         
1134         // Why the switch you might ask. It is a trick to ensure that all
1135         // the elements in the LyXRCTags enum is handled. As you can see
1136         // there are no breaks at all. So it is just a huge fall-through.
1137         // The nice thing is that we will get a warning from the compiler
1138         // if we forget an element.
1139         LyXRCTags tag = RC_LAST;
1140         switch(tag) {
1141         case RC_LAST:
1142         case RC_INPUT:
1143                 // input/include files are not done here
1144         case RC_BIND:
1145                 // bindings is not written to the preferences file.
1146         case RC_BINDFILE:
1147                 // bind files are not done here.
1148         case RC_BEGINTOOLBAR:
1149                 // Toolbar is not written here (yet).
1150         //case RC_SET_COLOR:
1151                 // color bindings not written to preference file.
1152                 // And we want to be warned about that. (Lgb)
1153         case RC_FONT_ENCODING:
1154                 os << "\\font_encoding \"" << fontenc << "\"\n";
1155         case RC_PRINTER:
1156                 os << "\\printer \"" << printer << "\"\n";
1157         case RC_PRINT_COMMAND:
1158                 os << "\\print_command \"" << print_command << "\"\n";
1159         case RC_PRINTEVENPAGEFLAG:
1160                 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1161                    << "\"\n";
1162         case RC_PRINTODDPAGEFLAG:
1163                 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1164                    << "\"\n";
1165         case RC_PRINTPAGERANGEFLAG:
1166                 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1167                    << "\"\n";
1168         case RC_PRINTCOPIESFLAG:
1169                 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1170         case RC_PRINTCOLLCOPIESFLAG:
1171                 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1172                    << "\"\n";
1173         case RC_PRINTREVERSEFLAG:
1174                 os << "\\print_reverse_flag \"" << print_reverse_flag
1175                    << "\"\n";
1176         case RC_PRINTLANDSCAPEFLAG:
1177                 os << "\\print_landscape_flag \"" << print_landscape_flag
1178                    << "\"\n";
1179         case RC_PRINTTOPRINTER:
1180                 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1181         case RC_PRINT_ADAPTOUTPUT:
1182                 os << "\\print_adapt_output " << tostr(print_adapt_output)
1183                    << "\n";
1184         case RC_PRINTTOFILE:
1185                 os << "\\print_to_file \"" << print_to_file << "\"\n";
1186         case RC_PRINTFILEEXTENSION:
1187                 os << "\\print_file_extension \"" << print_file_extension
1188                    << "\"\n";
1189         case RC_PRINTEXSTRAOPTIONS:
1190                 os << "\\print_extra_options \"" << print_extra_options
1191                    << "\"\n";
1192         case RC_PRINTSPOOL_COMMAND:
1193                 os << "\\print_spool_command \"" << print_spool_command
1194                    << "\"\n";
1195         case RC_PRINTSPOOL_PRINTERPREFIX:
1196                 os << "\\print_spool_printerprefix \""
1197                    << print_spool_printerprefix << "\"\n";
1198         case RC_PRINTPAPERDIMENSIONFLAG:
1199                 os << "\\print_paper_dimension_flag \""
1200                    << print_paper_dimension_flag << "\"\n";
1201         case RC_PRINTPAPERFLAG:
1202                 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1203         case RC_CUSTOM_EXPORT_COMMAND:
1204                 os << "\\custom_export_command \"" << custom_export_command
1205                    << "\"\n";
1206         case RC_CUSTOM_EXPORT_FORMAT:
1207                 os << "\\custom_export_format \"" << custom_export_format
1208                    << "\"\n";
1209         case RC_PDF_MODE:
1210                 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1211         case RC_LATEX_COMMAND:
1212                 os << "\\latex_command \"" << latex_command << "\"\n";
1213         case RC_PDFLATEX_COMMAND:
1214                 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1215         case RC_PDF_TO_PS_COMMAND:
1216                 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1217         case RC_DVI_TO_PS_COMMAND:
1218                 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1219         case RC_LITERATE_COMMAND:
1220                 os << "\\literate_command \"" << literate_command << "\"\n";
1221         case RC_LITERATE_EXTENSION:
1222                 os << "\\literate_extension \"" << literate_extension
1223                    << "\"\n";
1224         case RC_LITERATE_ERROR_FILTER:
1225                 os << "\\literate_error_filter \"" << literate_error_filter
1226                    << "\"\n";
1227         case RC_BUILD_COMMAND:
1228                 os << "\\build_command \"" << build_command << "\"\n";
1229         case RC_BUILD_ERROR_FILTER:
1230                 os << "\\build_error_filter \"" << build_error_filter
1231                    << "\"\n";
1232         case RC_SCREEN_DPI:
1233                 os << "\\screen_dpi " << dpi << "\n";
1234         case RC_SCREEN_ZOOM:
1235                 os << "\\screen_zoom " << zoom << "\n";
1236         case RC_WHEEL_JUMP:
1237                 os << "\\wheel_jump " << wheel_jump << "\n";
1238         case RC_SCREEN_FONT_SIZES:
1239                 os.setf(ios::fixed);
1240                 os.precision(2);
1241                 os << "\\screen_font_sizes";
1242                 os << " " << font_sizes[LyXFont::SIZE_TINY];
1243                 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1244                 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1245                 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1246                 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1247                 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1248                 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1249                 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1250                 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1251                 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1252                 os << "\n";
1253         case RC_OVERRIDE_X_DEADKEYS:
1254                 os << "\\override_x_deadkeys " 
1255                    << override_x_deadkeys << "\n";
1256         case RC_AUTOREGIONDELETE:
1257                 os << "\\auto_region_delete " << tostr(auto_region_delete)
1258                    << "\n";
1259         case RC_AUTOSAVE:
1260                 os << "\\autosave " << autosave << "\n";
1261         case RC_EXIT_CONFIRMATION:
1262                 os << "\\exit_confirmation " << tostr(exit_confirmation)
1263                    << "\n";
1264         case RC_DISPLAY_SHORTCUTS:
1265                 os << "\\display_shortcuts " << tostr(display_shortcuts)
1266                    << "\n";
1267         case RC_VIEWDVI_COMMAND:
1268                 os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1269         case RC_VIEWDVI_PAPEROPTION:
1270                 os << "\\view_dvi_paper_option \"" << view_dvi_paper_option << "\"\n";
1271         case RC_VIEWPDF_COMMAND:
1272                 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1273         case RC_DEFAULT_PAPERSIZE:
1274                 os << "\\default_papersize \"";
1275                 switch (default_papersize) {
1276                 case BufferParams::PAPER_USLETTER:
1277                         os << "usletter"; break;
1278                 case BufferParams::PAPER_LEGALPAPER:
1279                         os << "legal"; break;
1280                 case BufferParams::PAPER_EXECUTIVEPAPER:
1281                         os << "executive"; break;
1282                 case BufferParams::PAPER_A3PAPER:
1283                         os << "a3"; break;
1284                 case BufferParams::PAPER_A4PAPER:
1285                         os << "a4"; break;
1286                 case BufferParams::PAPER_A5PAPER:
1287                         os << "a5"; break;
1288                 case BufferParams::PAPER_B5PAPER:
1289                         os << "b5"; break;
1290                 case BufferParams::PAPER_DEFAULT: break;
1291                 }
1292                 os << "\"\n";
1293         case RC_VIEWPS_COMMAND:
1294                 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1295         case RC_VIEWPSPIC_COMMAND:
1296                 os << "\\view_pspic_command \"" << view_pspic_command
1297                    << "\"\n";
1298         case RC_PS_COMMAND:
1299                 os << "\\ps_command \"" << ps_command << "\"\n";
1300         case RC_CHKTEX_COMMAND:
1301                 os << "\\chktex_command \"" << chktex_command << "\"\n";
1302         case RC_HTML_COMMAND:
1303                 os << "\\html_command \"" << html_command << "\"\n";
1304         case RC_KBMAP:
1305                 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1306         case RC_KBMAP_PRIMARY:
1307                 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1308         case RC_KBMAP_SECONDARY:
1309                 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1310         case RC_SERVERPIPE:
1311                 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1312         case RC_RELYX_COMMAND:
1313                 os << "\\relyx_command \"" << relyx_command << "\"\n";
1314         case RC_DOCUMENTPATH:
1315                 os << "\\document_path \"" << document_path << "\"\n";
1316         case RC_TEMPLATEPATH:
1317                 os << "\\template_path \"" << template_path << "\"\n";
1318         case RC_TEMPDIRPATH:
1319                 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1320         case RC_USETEMPDIR:
1321                 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1322         case RC_LASTFILES:
1323                 os << "\\lastfiles \"" << lastfiles << "\"\n";
1324         case RC_NUMLASTFILES:
1325                 os << "\\num_lastfiles " << num_lastfiles << "\n";
1326         case RC_CHECKLASTFILES:
1327                 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1328         case RC_SCREEN_FONT_ROMAN:
1329                 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1330         case RC_SCREEN_FONT_SANS:
1331                 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1332         case RC_SCREEN_FONT_TYPEWRITER:
1333                 os << "\\screen_font_typewriter \""
1334                    << typewriter_font_name << "\"\n";
1335         case RC_SCREEN_FONT_MENU:
1336                 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1337         case RC_SCREEN_FONT_POPUP:
1338                 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1339         case RC_SCREEN_FONT_ENCODING:
1340                 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1341         case RC_SCREEN_FONT_ENCODING_MENU:
1342                 os << "\\screen_font_encoding_menu \"" << font_norm_menu
1343                    << "\"\n";
1344         case RC_SCREEN_FONT_SCALABLE:
1345                 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1346                    << "\n";
1347         case RC_CURSOR_FOLLOWS_SCROLLBAR:
1348                 os << "\\cursor_follows_scrollbar "
1349                    << tostr(cursor_follows_scrollbar) << "\n";
1350         case RC_FAX_COMMAND:
1351                 os << "\\fax_command \"" << fax_command << "\"\n";
1352         case RC_FAXPROGRAM:
1353                 os << "\\fax_program \"" << fax_program << "\"\n";
1354         case RC_PHONEBOOK:
1355                 os << "\\phone_book \"" << phone_book << "\"\n";
1356         case RC_ASCIIROFF_COMMAND:
1357                 os << "\\ascii_roff_command \"" << ascii_roff_command
1358                    << "\"\n";
1359         case RC_ASCII_LINELEN:
1360                 os << "\\ascii_linelen " << ascii_linelen << "\n";
1361         case RC_SPELL_COMMAND:
1362                 os << "\\spell_command \"" << isp_command << "\"\n";
1363         case RC_ACCEPT_COMPOUND:
1364                 os << "\\accept_compound " << tostr(isp_accept_compound)
1365                    << "\n";
1366         case RC_USE_INP_ENC:
1367                 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1368                    << "\n";
1369         case RC_USE_ALT_LANG:
1370                 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1371         case RC_USE_PERS_DICT:
1372                 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1373                    << "\n";
1374         case RC_USE_ESC_CHARS:
1375                 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1376                    << "\n";
1377         case RC_ALT_LANG:
1378                 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1379         case RC_PERS_DICT:
1380                 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1381         case RC_ESC_CHARS:
1382                 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1383         case RC_RTL_SUPPORT:
1384                 os << "\\rtl " << tostr(rtl_support) << "\n";
1385         case RC_AUTO_NUMBER:
1386                 os << "\\auto_number " << tostr(auto_number) << "\n";
1387         case RC_MARK_FOREIGN_LANGUAGE:
1388                 os << "\\mark_foreign_language " << 
1389                         tostr(mark_foreign_language) << "\n";
1390         case RC_LANGUAGE_AUTO_BEGIN:
1391                 os << "\\language_auto_begin " 
1392                    << tostr(language_auto_begin) << "\n";
1393         case RC_LANGUAGE_AUTO_END:
1394                 os << "\\language_auto_end " 
1395                    << tostr(language_auto_end) << "\n";
1396         case RC_LANGUAGE_PACKAGE:
1397                 os << "\\language_package \"" << language_package << "\"\n";
1398         case RC_LANGUAGE_COMMAND_BEGIN:
1399                 os << "\\language_command_begin \"" << language_command_begin
1400                    << "\"\n";
1401         case RC_LANGUAGE_COMMAND_END:
1402                 os << "\\language_command_end \"" << language_command_end
1403                    << "\"\n";
1404         case RC_MAKE_BACKUP:
1405                 os << "\\make_backup " << tostr(make_backup) << "\n";
1406         case RC_BACKUPDIR_PATH:
1407                 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1408         case RC_DATE_INSERT_FORMAT:
1409                 os << "\\date_insert_format \"" << date_insert_format
1410                    << "\"\n";
1411         case RC_SHOW_BANNER:
1412                 os << "\\show_banner " << tostr(show_banner) << "\n";
1413         case RC_USE_GUI:
1414                 os << "\\use_gui " << tostr(show_banner) << "\n";
1415         case RC_LINUXDOC_TO_LYX_COMMAND:
1416                 os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command
1417                    << "\"\n";
1418         case RC_LINUXDOC_TO_HTML_COMMAND:
1419                 os << "\\linuxdoc_to_html_command \"" << linuxdoc_to_html_command
1420                    << "\"\n";
1421         case RC_LINUXDOC_TO_LATEX_COMMAND:
1422                 os << "\\linuxdoc_to_latex_command \"" << linuxdoc_to_latex_command
1423                    << "\"\n";
1424         case RC_DOCBOOK_TO_DVI_COMMAND:
1425                 os << "\\docbook_to_dvi_command \"" << docbook_to_dvi_command
1426                    << "\"\n";
1427         case RC_DOCBOOK_TO_HTML_COMMAND:
1428                 os << "\\docbook_to_html_command \"" << docbook_to_html_command
1429                    << "\"\n";
1430         case RC_DOCBOOK_TO_PDF_COMMAND:
1431                 os << "\\docbook_to_pdf_command \"" << docbook_to_pdf_command
1432                    << "\"\n";
1433         }
1434         os.flush();
1435 }
1436
1437 void LyXRC::set_font_norm_type()
1438 {
1439         if (font_norm == "iso10646-1")
1440                 font_norm_type = ISO_10646_1;
1441         else if (font_norm == "iso8859-6.8x")
1442                 font_norm_type = ISO_8859_6_8;
1443         else
1444                 font_norm_type = OTHER_ENCODING;
1445 }
1446
1447 // The global instance
1448 LyXRC lyxrc;