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