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