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