]> git.lyx.org Git - lyx.git/blob - src/lyxrc.C
f7359f6e5acf58bae776f9c1f6303552637db5c3
[lyx.git] / src / lyxrc.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1995 Matthias Ettrich
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation "lyxrc.h"
15 #endif
16
17 #include <fstream>
18 #include <iomanip>
19 #include <iostream>
20
21 #include "debug.h"
22
23 #include "lyxrc.h"
24 #include "kbmap.h"
25 #include "LyXAction.h"
26 #include "lyxserver.h"
27 #include "lyx_main.h"
28 #include "intl.h"
29 #include "tex-strings.h"
30 #include "support/path.h"
31 #include "support/filetools.h"
32 #include "lyxtext.h"
33
34 using std::ostream;
35 using std::ofstream;
36 using std::cout;
37 using std::ios;
38 using std::endl;
39
40 // this is crappy... why are those colors command line arguments and
41 // not in lyxrc?? (Matthias) 
42 // Because nobody put them there. (Asger)
43
44 extern bool cursor_follows_scrollbar;
45 extern LyXAction lyxaction;
46 extern kb_keymap * toplevel_keymap;
47
48
49 enum LyXRCTags {
50         RC_BEGINTOOLBAR = 1,
51         RC_FONT_ENCODING,
52         RC_PRINTER,
53         RC_PRINT_COMMAND,
54         RC_PRINTEVENPAGEFLAG,
55         RC_PRINTODDPAGEFLAG,
56         RC_PRINTPAGERANGEFLAG,
57         RC_PRINTCOPIESFLAG,
58         RC_PRINTCOLLCOPIESFLAG,
59         RC_PRINTREVERSEFLAG,
60         RC_PRINTLANDSCAPEFLAG,
61         RC_PRINTTOPRINTER,
62         RC_PRINT_ADAPTOUTPUT,
63         RC_PRINTTOFILE,
64         RC_PRINTFILEEXTENSION,
65         RC_PRINTEXSTRAOPTIONS,
66         RC_PRINTSPOOL_COMMAND,
67         RC_PRINTSPOOL_PRINTERPREFIX,
68         RC_PRINTPAPERFLAG,
69         RC_PRINTPAPERDIMENSIONFLAG,
70         RC_CUSTOM_EXPORT_COMMAND,
71         RC_CUSTOM_EXPORT_FORMAT,
72         RC_LATEX_COMMAND,
73         RC_LITERATE_COMMAND,
74         RC_LITERATE_EXTENSION,
75         RC_LITERATE_ERROR_FILTER,
76         RC_BUILD_COMMAND,
77         RC_BUILD_ERROR_FILTER,
78         RC_SCREEN_DPI,
79         RC_SCREEN_ZOOM,
80         RC_SCREEN_FONT_SIZES,
81         RC_SCREEN_FONT_ROMAN,
82         RC_SCREEN_FONT_SANS,
83         RC_SCREEN_FONT_TYPEWRITER,
84         RC_SCREEN_FONT_MENU,
85         RC_SCREEN_FONT_POPUP,
86         RC_SCREEN_FONT_ENCODING,
87         RC_SCREEN_FONT_ENCODING_MENU,
88         RC_AUTOSAVE,
89         RC_DOCUMENTPATH,
90         RC_TEMPLATEPATH,
91         RC_TEMPDIRPATH,
92         RC_USETEMPDIR,
93         RC_LASTFILES,
94         RC_AUTOREGIONDELETE,
95         RC_BIND,
96         RC_OVERRIDE_X_DEADKEYS,
97         RC_SERVERPIPE,
98         RC_INPUT,
99         RC_BINDFILE,
100         RC_KBMAP,
101         RC_KBMAP_PRIMARY,
102         RC_KBMAP_SECONDARY,
103         RC_FAX_COMMAND,
104         RC_PHONEBOOK,
105         RC_FAXPROGRAM,
106         RC_ASCIIROFF_COMMAND,
107         RC_ASCII_LINELEN,
108         RC_NUMLASTFILES,
109         RC_CHECKLASTFILES,
110         RC_VIEWDVI_COMMAND,
111         RC_VIEWDVI_PAPEROPTION,
112         RC_DEFAULT_PAPERSIZE,
113         RC_PS_COMMAND,
114         RC_VIEWPS_COMMAND,
115         RC_VIEWPSPIC_COMMAND,
116         RC_ACCEPT_COMPOUND,
117         RC_SPELL_COMMAND,
118         RC_USE_INP_ENC,
119         RC_USE_ALT_LANG,
120         RC_USE_PERS_DICT,
121         RC_USE_ESC_CHARS,
122         RC_SCREEN_FONT_SCALABLE,
123         RC_ALT_LANG,
124         RC_PERS_DICT,
125         RC_ESC_CHARS,
126         RC_CHKTEX_COMMAND,
127         RC_CURSOR_FOLLOWS_SCROLLBAR,
128         RC_EXIT_CONFIRMATION,
129         RC_DISPLAY_SHORTCUTS,
130         RC_RELYX_COMMAND,
131         RC_HTML_COMMAND,
132         RC_MAKE_BACKUP,
133         RC_BACKUPDIR_PATH,
134         RC_RTL_SUPPORT,
135         RC_AUTO_NUMBER,
136         RC_MARK_FOREIGN_LANGUAGE,
137         RC_LANGUAGE_PACKAGE,
138         RC_LANGUAGE_AUTO_BEGIN,
139         RC_LANGUAGE_AUTO_END,
140         RC_LANGUAGE_COMMAND_BEGIN,
141         RC_LANGUAGE_COMMAND_END,
142         RC_PDFLATEX_COMMAND,
143         RC_PDF_MODE,
144         RC_VIEWPDF_COMMAND,
145         RC_PDF_TO_PS_COMMAND,
146         RC_DVI_TO_PS_COMMAND,
147         RC_DATE_INSERT_FORMAT,
148         RC_SHOW_BANNER,
149         RC_USE_GUI,
150         RC_LINUXDOC_TO_LYX_COMMAND,
151         RC_LINUXDOC_TO_HTML_COMMAND,
152         RC_LINUXDOC_TO_LATEX_COMMAND,
153         RC_DOCBOOK_TO_DVI_COMMAND,
154         RC_DOCBOOK_TO_HTML_COMMAND,
155         RC_DOCBOOK_TO_PDF_COMMAND,
156         RC_LAST
157 };
158
159
160 static
161 keyword_item lyxrcTags[] = {
162         { "\\accept_compound", RC_ACCEPT_COMPOUND },
163         { "\\alternate_language", RC_ALT_LANG },
164         { "\\ascii_linelen", RC_ASCII_LINELEN },
165         { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
166         { "\\auto_number", RC_AUTO_NUMBER },
167         { "\\auto_region_delete", RC_AUTOREGIONDELETE },
168         { "\\autosave", RC_AUTOSAVE },
169         { "\\backupdir_path", RC_BACKUPDIR_PATH },
170         { "\\begin_toolbar", RC_BEGINTOOLBAR },
171         { "\\bind", RC_BIND },
172         { "\\bind_file", RC_BINDFILE },
173         { "\\build_command", RC_BUILD_COMMAND },
174         { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
175         { "\\check_lastfiles", RC_CHECKLASTFILES },
176         { "\\chktex_command", RC_CHKTEX_COMMAND },
177         { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
178         { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
179         { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
180         { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
181         { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
182         { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
183         { "\\docbook_to_dvi_command", RC_DOCBOOK_TO_DVI_COMMAND },
184         { "\\docbook_to_html_command", RC_DOCBOOK_TO_HTML_COMMAND },
185         { "\\docbook_to_pdf_command", RC_DOCBOOK_TO_PDF_COMMAND },
186         { "\\document_path", RC_DOCUMENTPATH },
187         { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
188         { "\\escape_chars", RC_ESC_CHARS },
189         { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
190         { "\\fax_command", RC_FAX_COMMAND },
191         { "\\fax_program", RC_FAXPROGRAM },
192         { "\\font_encoding", RC_FONT_ENCODING },
193         { "\\html_command", RC_HTML_COMMAND },
194         { "\\input", RC_INPUT },
195         { "\\kbmap", RC_KBMAP },
196         { "\\kbmap_primary", RC_KBMAP_PRIMARY },
197         { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
198         { "\\language_auto_begin", RC_LANGUAGE_AUTO_BEGIN },
199         { "\\language_auto_end", RC_LANGUAGE_AUTO_END },
200         { "\\language_command_begin", RC_LANGUAGE_COMMAND_BEGIN },
201         { "\\language_command_end", RC_LANGUAGE_COMMAND_END },
202         { "\\language_package", RC_LANGUAGE_PACKAGE },
203         { "\\lastfiles", RC_LASTFILES },
204         { "\\latex_command", RC_LATEX_COMMAND },
205         { "\\linuxdoc_to_html_command", RC_LINUXDOC_TO_HTML_COMMAND },
206         { "\\linuxdoc_to_latex_command", RC_LINUXDOC_TO_LATEX_COMMAND },
207         { "\\linuxdoc_to_lyx_command", RC_LINUXDOC_TO_LYX_COMMAND },
208         { "\\literate_command", RC_LITERATE_COMMAND },
209         { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
210         { "\\literate_extension", RC_LITERATE_EXTENSION },
211         { "\\make_backup", RC_MAKE_BACKUP },
212         { "\\mark_foreign_language", RC_MARK_FOREIGN_LANGUAGE },
213         { "\\num_lastfiles", RC_NUMLASTFILES },
214         { "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
215         { "\\pdf_mode", RC_PDF_MODE },
216         { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
217         { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
218         { "\\personal_dictionary", RC_PERS_DICT },
219         { "\\phone_book", RC_PHONEBOOK },
220         { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
221         { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
222         { "\\print_command", RC_PRINT_COMMAND },
223         { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
224         { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
225         { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
226         { "\\print_file_extension", RC_PRINTFILEEXTENSION },
227         { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
228         { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
229         { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
230         { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
231         { "\\print_paper_flag", RC_PRINTPAPERFLAG },
232         { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
233         { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
234         { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
235         { "\\print_to_file", RC_PRINTTOFILE },
236         { "\\print_to_printer", RC_PRINTTOPRINTER },
237         { "\\printer", RC_PRINTER },
238         { "\\ps_command", RC_PS_COMMAND },
239         { "\\relyx_command", RC_RELYX_COMMAND },
240         { "\\rtl", RC_RTL_SUPPORT },
241         { "\\screen_dpi", RC_SCREEN_DPI },
242         { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
243         { "\\screen_font_encoding_menu", RC_SCREEN_FONT_ENCODING_MENU },
244         { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
245         { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
246         { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
247         { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
248         { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
249         { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
250         { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
251         { "\\screen_zoom", RC_SCREEN_ZOOM },
252         { "\\serverpipe", RC_SERVERPIPE },
253         { "\\show_banner", RC_SHOW_BANNER },
254         { "\\spell_command", RC_SPELL_COMMAND },
255         { "\\tempdir_path", RC_TEMPDIRPATH },
256         { "\\template_path", RC_TEMPLATEPATH },
257         { "\\use_alt_language", RC_USE_ALT_LANG },
258         { "\\use_escape_chars", RC_USE_ESC_CHARS },
259         { "\\use_gui", RC_USE_GUI },
260         { "\\use_input_encoding", RC_USE_INP_ENC },
261         { "\\use_personal_dictionary", RC_USE_PERS_DICT },
262         { "\\use_tempdir", RC_USETEMPDIR },
263         { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
264         { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
265         { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
266         { "\\view_ps_command", RC_VIEWPS_COMMAND },
267         { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
268 };
269
270 /* Let the range depend of the size of lyxrcTags.  Alejandro 240596 */
271 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
272
273
274 LyXRC::LyXRC() 
275 {
276         setDefaults();
277 }
278
279
280 void LyXRC::setDefaults() {
281         // Get printer from the environment. If fail, use default "",
282         // assuming that everything is set up correctly.
283         printer = GetEnv("PRINTER");
284         print_adapt_output = false;
285         print_command = "dvips";
286         print_evenpage_flag = "-B";
287         print_oddpage_flag = "-A";
288         print_pagerange_flag = "-pp";
289         print_copies_flag = "-c";
290         print_collcopies_flag = "-C";
291         print_reverse_flag = "-r";
292         print_landscape_flag = "-t landscape";
293         print_to_printer = "-P";
294         print_to_file = "-o ";
295         print_file_extension = ".ps";
296         print_paper_flag = "-t";
297         print_paper_dimension_flag = "-T";
298         document_path = GetEnvPath("HOME");
299         tempdir_path = "/tmp";
300         use_tempdir = true;
301         pdf_mode = false;
302         latex_command = "latex";
303         pdflatex_command = "pdflatex";
304         pdf_to_ps_command = "pdf2ps";
305         dvi_to_ps_command = "dvips";
306         literate_command = "none";
307         literate_extension = "none";
308         literate_error_filter = "cat";
309         build_command = "make";
310         build_error_filter = "cat";
311         relyx_command = "reLyX";
312         ps_command = "gs";
313         view_ps_command = "ghostview -swap";
314         view_pspic_command = "ghostview";
315         view_dvi_command = "xdvi";
316         view_dvi_paper_option = "-paper";
317         view_pdf_command = "xpdf";
318         default_papersize = BufferParams::PAPER_USLETTER;
319         custom_export_format = "ps";
320         chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
321         html_command = "tth -t";
322         fontenc = "default";
323         dpi = 75;
324         // Because a screen typically is wider than a piece of paper:
325         zoom = 150;
326         // Default LaTeX font size:
327         font_sizes[LyXFont::SIZE_TINY] = 5.0;
328         font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
329         font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
330         font_sizes[LyXFont::SIZE_SMALL] = 9.0;
331         font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
332         font_sizes[LyXFont::SIZE_LARGE] = 12.0;
333         font_sizes[LyXFont::SIZE_LARGER] = 14.4;
334         font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
335         font_sizes[LyXFont::SIZE_HUGE] = 20.74;
336         font_sizes[LyXFont::SIZE_HUGER] = 24.88;
337         use_scalable_fonts = true;
338         roman_font_name = "-*-times";
339         sans_font_name = "-*-helvetica";
340         typewriter_font_name = "-*-courier";
341         menu_font_name = "-*-helvetica-bold-r";
342         popup_font_name = "-*-helvetica-medium-r";
343         font_norm = "iso8859-1";
344         font_norm_menu = "";
345         override_x_deadkeys = true;
346         autosave = 300;
347         auto_region_delete = true;
348         ascii_linelen = 75;
349         num_lastfiles = 4;
350         check_lastfiles = true;
351         make_backup = true;
352         backupdir_path = "";
353         exit_confirmation = true;
354         display_shortcuts = true;
355         // Spellchecker settings:
356         isp_command = "ispell";
357         isp_accept_compound = false;
358         isp_use_input_encoding = false;
359         isp_use_alt_lang = false;
360         isp_use_pers_dict = false;
361         isp_use_esc_chars = false;
362         use_kbmap = false;
363         hasBindFile = false;
364         rtl_support = false;
365         auto_number = true;
366         mark_foreign_language = true;
367         language_package = "\\usepackage{babel}";
368         language_auto_begin = true;
369         language_auto_end = true;
370         language_command_begin = "\\selectlanguage{$$lang}";
371         language_command_end = "\\selectlanguage{$$lang}";
372
373         ///
374         date_insert_format = "%A, %e %B %Y";
375         show_banner = true;
376         use_gui = true;
377
378         ///
379         linuxdoc_to_latex_command="none";
380         linuxdoc_to_lyx_command="none";
381         linuxdoc_to_html_command="none";
382
383         docbook_to_dvi_command="none";
384         docbook_to_html_command="none";
385         docbook_to_pdf_command="none";
386 }
387
388
389 int LyXRC::ReadBindFile(string const & name)
390 {
391         hasBindFile = true;
392         string tmp = i18nLibFileSearch("bind", name, "bind");
393         lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
394         int result = read(tmp);
395         if (result) {
396                 lyxerr << "Error reading bind file: " << tmp << endl;
397         }
398         return result;
399 }
400
401
402 int LyXRC::read(string const & filename)
403 {
404         // Default bindfile.
405         string bindFile = "cua";
406         
407         LyXLex lexrc(lyxrcTags, lyxrcCount);
408         if (lyxerr.debugging(Debug::PARSER))
409                 lexrc.printTable(lyxerr);
410         
411         lexrc.setFile(filename);
412         if (!lexrc.IsOK()) return -2;
413         
414         lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
415         
416         while (lexrc.IsOK()) {
417                 // By using two switches we take advantage of the compiler
418                 // telling us if we have missed a LyXRCTags element in
419                 // the second switch.
420                 // Note that this also shows a problem with LyXLex since it
421                 // helps us avoid taking advantage of the strictness of the
422                 // compiler.
423
424                 int le = lexrc.lex();
425                 switch(le) {
426                 case LyXLex::LEX_UNDEF:
427                         lexrc.printError("Unknown tag `$$Token'");
428                         continue; 
429                 case LyXLex::LEX_FEOF:
430                         continue; 
431                 default: break;
432                 }
433                 switch (static_cast<LyXRCTags>(le)) {
434                 case RC_INPUT: // Include file
435                         if (lexrc.next()) {
436                                 string tmp = LibFileSearch(string(),
437                                                            lexrc.GetString()); 
438                                 if (read(tmp)) {
439                                         lexrc.printError("Error reading "
440                                                          "included file: "+tmp);
441                                 }
442                         }
443                         break;
444                 case RC_BINDFILE:                     // RVDK_PATCH_5
445                         if (lexrc.next()) {
446                                 string tmp(lexrc.GetString());
447                                 if (bind_file.empty()) {
448                                         // we only need the name of the first
449                                         // bind file since that (usually)
450                                         // includes several others.
451                                         bind_file = tmp;
452                                 }
453                                 ReadBindFile(tmp);
454                         }
455                         break;
456                         
457                 case RC_BEGINTOOLBAR:
458                         // this toolbar should be changed to be a completely
459                         // non gui toolbar. (Lgb)
460                         toolbardefaults.read(lexrc);
461                         break;
462                         
463                 case RC_KBMAP:
464                         if (lexrc.next())
465                                 use_kbmap = lexrc.GetBool();
466                         break;
467                         
468                 case RC_EXIT_CONFIRMATION:
469                         if (lexrc.next())
470                                 exit_confirmation = lexrc.GetBool();
471                         break;
472                         
473                 case RC_DISPLAY_SHORTCUTS:
474                         if (lexrc.next())
475                                 display_shortcuts = lexrc.GetBool();
476                         break;
477                         
478                 case RC_KBMAP_PRIMARY:
479                         if (lexrc.next())
480                                 primary_kbmap = lexrc.GetString();
481                         break;
482                         
483                 case RC_KBMAP_SECONDARY:
484                         if (lexrc.next())
485                                 secondary_kbmap = lexrc.GetString();
486                         break;
487                         
488                 case RC_FONT_ENCODING:
489                         if (lexrc.next())
490                                 fontenc = lexrc.GetString();
491                         break;
492                         
493                 case RC_PRINTER:
494                         if (lexrc.next())
495                                 printer = lexrc.GetString();
496                         break;
497                         
498                 case RC_PRINT_COMMAND:
499                         if (lexrc.next())
500                                 print_command = lexrc.GetString();
501                         break;
502                         
503                 case RC_PRINTEVENPAGEFLAG:
504                         if (lexrc.next())
505                                 print_evenpage_flag = lexrc.GetString();
506                         break;
507                         
508                 case RC_PRINTODDPAGEFLAG:
509                         if (lexrc.next())
510                                 print_oddpage_flag = lexrc.GetString();
511                         break;
512                         
513                 case RC_PRINTPAGERANGEFLAG:
514                         if (lexrc.next())
515                                 print_pagerange_flag = lexrc.GetString();
516                         break;
517                         
518                 case RC_PRINTCOPIESFLAG:
519                         if (lexrc.next())
520                                 print_copies_flag = lexrc.GetString();
521                         break;
522                         
523                 case RC_PRINTCOLLCOPIESFLAG:
524                         if (lexrc.next())
525                                 print_collcopies_flag = lexrc.GetString();
526                         break;
527                         
528                 case RC_PRINTREVERSEFLAG:
529                         if (lexrc.next())
530                                 print_reverse_flag = lexrc.GetString();
531                         break;
532                         
533                 case RC_PRINTLANDSCAPEFLAG:
534                         if (lexrc.next())
535                                 print_landscape_flag = lexrc.GetString();
536                         break;
537                         
538                 case RC_PRINTTOPRINTER:
539                         if (lexrc.next())
540                                 print_to_printer = lexrc.GetString();
541                         break;
542                         
543                 case RC_PRINT_ADAPTOUTPUT:
544                         if (lexrc.next())
545                                 print_adapt_output = lexrc.GetBool();
546                         break;
547                         
548                 case RC_PRINTTOFILE:
549                         if (lexrc.next())
550                                 print_to_file = lexrc.GetString();
551                         break;
552                         
553                 case RC_PRINTFILEEXTENSION:
554                         if (lexrc.next())
555                                 print_file_extension = lexrc.GetString();
556                         break;
557                         
558                 case RC_PRINTEXSTRAOPTIONS:
559                         if (lexrc.next())
560                                 print_extra_options = lexrc.GetString();
561                         break;
562                         
563                 case RC_PRINTSPOOL_COMMAND:
564                         if (lexrc.next())
565                                 print_spool_command = lexrc.GetString();
566                         break;
567                         
568                 case RC_PRINTSPOOL_PRINTERPREFIX:
569                         if (lexrc.next())
570                                 print_spool_printerprefix = lexrc.GetString();
571                         break;
572                         
573                 case RC_PRINTPAPERDIMENSIONFLAG:
574                         if (lexrc.next())
575                                 print_paper_dimension_flag = lexrc.GetString();
576                         break;
577                         
578                 case RC_PRINTPAPERFLAG:
579                         if (lexrc.next())
580                                 print_paper_flag = lexrc.GetString();
581                         break;
582                         
583                 case RC_CUSTOM_EXPORT_COMMAND:
584                         if (lexrc.next())
585                                 custom_export_command = lexrc.GetString();
586                         break;
587                         
588                 case RC_CUSTOM_EXPORT_FORMAT:
589                         if (lexrc.next())
590                                 custom_export_format = lexrc.GetString();
591                         break;
592
593                 case RC_PDF_MODE:
594                         if (lexrc.next())
595                                 pdf_mode = lexrc.GetBool();
596                         break;
597                         
598                 case RC_LATEX_COMMAND:
599                         if (lexrc.next())
600                                 latex_command = lexrc.GetString();
601                         break;
602
603                 case RC_PDFLATEX_COMMAND:
604                         if (lexrc.next())
605                                 pdflatex_command = lexrc.GetString();
606                         break;
607
608                 case RC_PDF_TO_PS_COMMAND:
609                         if (lexrc.next())
610                                 pdf_to_ps_command = lexrc.GetString();
611                         break;
612
613                 case RC_DVI_TO_PS_COMMAND:
614                         if (lexrc.next())
615                                 dvi_to_ps_command = lexrc.GetString();
616                         break;
617                         
618                 case RC_LITERATE_COMMAND:
619                         if (lexrc.next())
620                                 literate_command = lexrc.GetString();
621                         break;
622                         
623                 case RC_LITERATE_EXTENSION:
624                         if (lexrc.next())
625                                 literate_extension = lexrc.GetString();
626                         break;
627                         
628                 case RC_LITERATE_ERROR_FILTER:
629                         if (lexrc.next())
630                                 literate_error_filter = lexrc.GetString();
631                         break;
632                         
633                 case RC_BUILD_COMMAND:
634                         if (lexrc.next())
635                                 build_command = lexrc.GetString();
636                         break;
637                         
638                 case RC_BUILD_ERROR_FILTER:
639                         if (lexrc.next())
640                                 build_error_filter = lexrc.GetString();
641                         break;
642                         
643                 case RC_RELYX_COMMAND:
644                         if (lexrc.next())
645                                 relyx_command = lexrc.GetString();
646                         break;
647                         
648                 case RC_DEFAULT_PAPERSIZE:
649                         if (lexrc.next()) {
650                                 string size = lowercase(lexrc.GetString());
651                                 if (size == "usletter")
652                                         default_papersize =
653                                                 BufferParams::PAPER_USLETTER;
654                                 else if (size == "legal")
655                                         default_papersize =
656                                                 BufferParams::PAPER_LEGALPAPER;
657                                 else if (size == "executive")
658                                         default_papersize =
659                                                 BufferParams::PAPER_EXECUTIVEPAPER;
660                                 else if (size == "a3")
661                                         default_papersize =
662                                                 BufferParams::PAPER_A3PAPER;
663                                 else if (size == "a4")
664                                         default_papersize =
665                                                 BufferParams::PAPER_A4PAPER;
666                                 else if (size == "a5")
667                                         default_papersize =
668                                                 BufferParams::PAPER_A5PAPER;
669                                 else if (size == "b5")
670                                         default_papersize =
671                                                 BufferParams::PAPER_B5PAPER;
672                         }
673                         break;
674                 case RC_VIEWDVI_COMMAND:
675                         if (lexrc.next())
676                                 view_dvi_command = lexrc.GetString();
677                         break;
678
679                 case RC_VIEWDVI_PAPEROPTION:
680                         if (lexrc.next())
681                                 view_dvi_paper_option = lexrc.GetString();
682                         else 
683                                 view_dvi_paper_option = "";
684                         break;
685
686                 case RC_VIEWPDF_COMMAND:
687                         if (lexrc.next())
688                                 view_pdf_command = lexrc.GetString();
689                         break;
690                         
691                 case RC_PS_COMMAND:
692                         if (lexrc.next())
693                                 ps_command = lexrc.GetString();
694                         break;
695                         
696                 case RC_VIEWPS_COMMAND:
697                         if (lexrc.next())
698                                 view_ps_command = lexrc.GetString();
699                         break;
700                         
701                 case RC_VIEWPSPIC_COMMAND:
702                         if (lexrc.next())
703                                 view_pspic_command = lexrc.GetString();
704                         break;
705                         
706                 case RC_CHKTEX_COMMAND:
707                         if (lexrc.next())
708                                 chktex_command = lexrc.GetString();
709                         break;
710                         
711                 case RC_HTML_COMMAND:
712                         if (lexrc.next())
713                                 html_command = lexrc.GetString();
714                         break;
715                         
716                 case RC_SCREEN_DPI:
717                         if (lexrc.next())
718                                 dpi = lexrc.GetInteger();
719                         break;
720                         
721                 case RC_SCREEN_ZOOM:
722                         if (lexrc.next())
723                                 zoom = lexrc.GetInteger();
724                         break;
725                         
726                 case RC_SCREEN_FONT_SIZES:
727                         if (lexrc.next())
728                                 font_sizes[LyXFont::SIZE_TINY] =
729                                         lexrc.GetFloat();
730                         if (lexrc.next())
731                                 font_sizes[LyXFont::SIZE_SCRIPT] =
732                                         lexrc.GetFloat();
733                         if (lexrc.next())
734                                 font_sizes[LyXFont::SIZE_FOOTNOTE] =
735                                         lexrc.GetFloat();
736                         if (lexrc.next())
737                                 font_sizes[LyXFont::SIZE_SMALL] =
738                                         lexrc.GetFloat();
739                         if (lexrc.next())
740                                 font_sizes[LyXFont::SIZE_NORMAL] =
741                                         lexrc.GetFloat();
742                         if (lexrc.next())
743                                 font_sizes[LyXFont::SIZE_LARGE] =
744                                         lexrc.GetFloat();
745                         if (lexrc.next())
746                                 font_sizes[LyXFont::SIZE_LARGER] =
747                                         lexrc.GetFloat();
748                         if (lexrc.next())
749                                 font_sizes[LyXFont::SIZE_LARGEST] =
750                                         lexrc.GetFloat();
751                         if (lexrc.next())
752                                 font_sizes[LyXFont::SIZE_HUGE] =
753                                         lexrc.GetFloat();
754                         if (lexrc.next())
755                                 font_sizes[LyXFont::SIZE_HUGER] =
756                                         lexrc.GetFloat();
757                         break;
758                         
759                 case RC_SCREEN_FONT_SCALABLE:
760                         if (lexrc.next())
761                                 use_scalable_fonts = lexrc.GetBool();
762                         break;
763                         
764                 case RC_AUTOSAVE:
765                         if (lexrc.next())
766                                 autosave = lexrc.GetInteger();
767                         break;
768                         
769                 case RC_DOCUMENTPATH:
770                         if (lexrc.next()) {
771                                 document_path = ExpandPath(lexrc.GetString());
772                         }
773                         break;
774                         
775                 case RC_TEMPLATEPATH:
776                         if (lexrc.next())
777                                 template_path = ExpandPath(lexrc.GetString());
778                         break;
779                         
780                 case RC_TEMPDIRPATH:
781                         if (lexrc.next())
782                                 tempdir_path = ExpandPath(lexrc.GetString());
783                         break;
784                         
785                 case RC_USETEMPDIR:
786                         if (lexrc.next())
787                                 use_tempdir = lexrc.GetBool();
788                         break;
789                         
790                 case RC_LASTFILES:
791                         if (lexrc.next())
792                                 lastfiles = ExpandPath(lexrc.GetString());
793                         break;
794                         
795                 case RC_NUMLASTFILES:
796                         if (lexrc.next())
797                                 num_lastfiles = lexrc.GetInteger();
798                         break;
799                         
800                 case RC_CHECKLASTFILES:
801                         if (lexrc.next())
802                                 check_lastfiles = lexrc.GetBool();
803                         break;
804                         
805                 case RC_SCREEN_FONT_ROMAN:
806                         if (lexrc.next())
807                                 roman_font_name = lexrc.GetString();
808                         break;
809                         
810                 case RC_SCREEN_FONT_SANS:
811                         if (lexrc.next())
812                                 sans_font_name = lexrc.GetString();
813                         break;
814                         
815                 case RC_SCREEN_FONT_TYPEWRITER:
816                         if (lexrc.next())
817                                 typewriter_font_name = lexrc.GetString();
818                         break;
819                         
820                 case RC_SCREEN_FONT_MENU:
821                         if (lexrc.next())
822                                 menu_font_name = lexrc.GetString();
823                         break;
824                         
825                 case RC_SCREEN_FONT_POPUP:
826                         if (lexrc.next())
827                                 popup_font_name = lexrc.GetString();
828                         break;
829                         
830                 case RC_SCREEN_FONT_ENCODING:
831                         if (lexrc.next())
832                                 font_norm = lexrc.GetString();
833                         break;
834
835                 case RC_SCREEN_FONT_ENCODING_MENU:
836                         if (lexrc.next())
837                                 font_norm_menu = lexrc.GetString();
838                         break;
839
840                 case RC_AUTOREGIONDELETE:
841                         // Auto region delete defaults to true
842                         if (lexrc.next())
843                                 auto_region_delete = lexrc.GetBool();
844                         break;
845                         
846                 case RC_BIND:
847                 {
848                         // we should not do an explicit binding before
849                         // loading a bind file. So, in this case, load
850                         // the default bind file.
851                         if (!hasBindFile) {
852                                 ReadBindFile();
853                                 bind_file = bindFile;
854                         }
855                         // !!!chb, dynamic key binding...
856                         int action, res = 0;
857                         string seq, cmd;
858                         
859                         if (lexrc.lex() == LyXLex::LEX_DATA)  {
860                                 seq = lexrc.GetString();
861                         } else {
862                                 lexrc.printError("Bad key sequence: `$$Token'");
863                                 break;
864                         }
865                         
866                         if (lexrc.lex() == LyXLex::LEX_DATA) {
867                                 cmd = lexrc.GetString();
868                         } else {
869                                 lexrc.printError("Bad command: `$$Token'");
870                                 break;
871                         }
872                         
873                         if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
874                                 if (lyxerr.debugging(Debug::KEY)) {
875                                         lyxerr << "RC_BIND: Sequence `"
876                                                << seq << "' Command `"
877                                                << cmd << "' Action `"
878                                                << action << '\'' << endl;
879                                 }
880                                 res = toplevel_keymap->bind(seq.c_str(),
881                                                             action);
882                                 if (res != 0) {
883                                         lexrc.printError(
884                                                 "Invalid key sequence `"
885                                                 + seq + '\''); 
886                                 }
887                         } else {// cmd is the last token read.
888                                 lexrc.printError(
889                                         "Unknown LyX function `$$Token'");
890                         }
891                         break;
892                 }
893                 case RC_OVERRIDE_X_DEADKEYS:
894                         if (lexrc.next())
895                                 override_x_deadkeys = lexrc.GetBool();
896                         break;
897
898                 case RC_SERVERPIPE:
899                         if (lexrc.next())
900                                 lyxpipes = ExpandPath(lexrc.GetString());
901                         break;
902                         
903                 case RC_CURSOR_FOLLOWS_SCROLLBAR:
904                         if (lexrc.next())
905                                 cursor_follows_scrollbar = lexrc.GetBool();
906                         break;
907
908                 case RC_FAX_COMMAND:
909                         if (lexrc.next())
910                                 fax_command = lexrc.GetString();
911                         break;
912                 case RC_FAXPROGRAM:
913                         if (lexrc.next())
914                                 fax_program = lexrc.GetString();
915                         break;
916                 case RC_PHONEBOOK:
917                         if (lexrc.next()) {
918                                 string s = lexrc.GetString();
919                                 if (AbsolutePath(s))
920                                         phone_book = s;
921                                 else
922                                         phone_book = user_lyxdir + s;
923                         }
924                         break;
925                 case RC_ASCIIROFF_COMMAND:
926                         if (lexrc.next())
927                                 ascii_roff_command = lexrc.GetString();
928                         break;
929                 case RC_ASCII_LINELEN:
930                         if (lexrc.next())
931                                 ascii_linelen = lexrc.GetInteger();
932                         break;
933                         // Spellchecker settings:
934                 case RC_SPELL_COMMAND:
935                         if (lexrc.next())
936                                 isp_command = lexrc.GetString();
937                         break;
938                 case RC_ACCEPT_COMPOUND:
939                         if (lexrc.next())
940                                 isp_accept_compound = lexrc.GetBool();
941                         break;
942                 case RC_USE_INP_ENC:
943                         if (lexrc.next())
944                                 isp_use_input_encoding = lexrc.GetBool();
945                         break;
946                 case RC_USE_ALT_LANG:
947                         if (lexrc.next())
948                                 isp_use_alt_lang = lexrc.GetBool();
949                         break;
950                 case RC_USE_PERS_DICT:
951                         if (lexrc.next())
952                                 isp_use_pers_dict = lexrc.GetBool();
953                         break;
954                 case RC_USE_ESC_CHARS:
955                         if (lexrc.next())
956                                 isp_use_esc_chars = lexrc.GetBool();
957                         break;
958                 case RC_ALT_LANG:
959                         if (lexrc.next())
960                                 isp_alt_lang = lexrc.GetString();
961                         break;
962                 case RC_PERS_DICT:
963                         if (lexrc.next())
964                                 isp_pers_dict = lexrc.GetString();
965                         break;
966                 case RC_ESC_CHARS:
967                         if (lexrc.next())
968                                 isp_esc_chars = lexrc.GetString();
969                         break;
970                 case RC_MAKE_BACKUP:
971                         if (lexrc.next())
972                                 make_backup = lexrc.GetBool();
973                         break;
974                 case RC_BACKUPDIR_PATH:
975                         if (lexrc.next())
976                                 backupdir_path = ExpandPath(lexrc.GetString());
977                         break;
978                 case RC_DATE_INSERT_FORMAT:
979                         if (lexrc.next())
980                                 date_insert_format = lexrc.GetString();
981                         break;
982                 case RC_LANGUAGE_PACKAGE:
983                         if (lexrc.next())
984                                 language_package = lexrc.GetString();
985                         break;
986                 case RC_LANGUAGE_AUTO_BEGIN:
987                         if (lexrc.next())
988                                 language_auto_begin = lexrc.GetBool();
989                         break;
990                 case RC_LANGUAGE_AUTO_END:
991                         if (lexrc.next())
992                                 language_auto_end = lexrc.GetBool();
993                         break;
994                 case RC_LANGUAGE_COMMAND_BEGIN:
995                         if (lexrc.next())
996                                 language_command_begin = lexrc.GetString();
997                         break;
998                 case RC_LANGUAGE_COMMAND_END:
999                         if (lexrc.next())
1000                                 language_command_end = lexrc.GetString();
1001                         break;
1002                 case RC_RTL_SUPPORT:
1003                         if (lexrc.next())
1004                                 rtl_support = lexrc.GetBool();
1005                         break;
1006                 case RC_AUTO_NUMBER:
1007                         if (lexrc.next())
1008                                 auto_number = lexrc.GetBool();
1009                         break;
1010                 case RC_MARK_FOREIGN_LANGUAGE:
1011                         if (lexrc.next())
1012                                 mark_foreign_language = 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_FAX_COMMAND:
1300                 os << "\\fax_command \"" << fax_command << "\"\n";
1301         case RC_FAXPROGRAM:
1302                 os << "\\fax_program \"" << fax_program << "\"\n";
1303         case RC_PHONEBOOK:
1304                 os << "\\phone_book \"" << phone_book << "\"\n";
1305         case RC_ASCIIROFF_COMMAND:
1306                 os << "\\ascii_roff_command \"" << ascii_roff_command
1307                    << "\"\n";
1308         case RC_ASCII_LINELEN:
1309                 os << "\\ascii_linelen " << ascii_linelen << "\n";
1310         case RC_SPELL_COMMAND:
1311                 os << "\\spell_command \"" << isp_command << "\"\n";
1312         case RC_ACCEPT_COMPOUND:
1313                 os << "\\accept_compound " << tostr(isp_accept_compound)
1314                    << "\n";
1315         case RC_USE_INP_ENC:
1316                 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1317                    << "\n";
1318         case RC_USE_ALT_LANG:
1319                 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1320         case RC_USE_PERS_DICT:
1321                 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1322                    << "\n";
1323         case RC_USE_ESC_CHARS:
1324                 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1325                    << "\n";
1326         case RC_ALT_LANG:
1327                 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1328         case RC_PERS_DICT:
1329                 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1330         case RC_ESC_CHARS:
1331                 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1332         case RC_RTL_SUPPORT:
1333                 os << "\\rtl " << tostr(rtl_support) << "\n";
1334         case RC_AUTO_NUMBER:
1335                 os << "\\auto_number " << tostr(auto_number) << "\n";
1336         case RC_MARK_FOREIGN_LANGUAGE:
1337                 os << "\\mark_foreign_language " << 
1338                         tostr(mark_foreign_language) << "\n";
1339         case RC_LANGUAGE_AUTO_BEGIN:
1340                 os << "\\language_auto_begin " 
1341                    << tostr(language_auto_begin) << "\n";
1342         case RC_LANGUAGE_AUTO_END:
1343                 os << "\\language_auto_end " 
1344                    << tostr(language_auto_end) << "\n";
1345         case RC_LANGUAGE_PACKAGE:
1346                 os << "\\language_package \"" << language_package << "\"\n";
1347         case RC_LANGUAGE_COMMAND_BEGIN:
1348                 os << "\\language_command_begin \"" << language_command_begin
1349                    << "\"\n";
1350         case RC_LANGUAGE_COMMAND_END:
1351                 os << "\\language_command_end \"" << language_command_end
1352                    << "\"\n";
1353         case RC_MAKE_BACKUP:
1354                 os << "\\make_backup " << tostr(make_backup) << "\n";
1355         case RC_BACKUPDIR_PATH:
1356                 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1357         case RC_DATE_INSERT_FORMAT:
1358                 os << "\\date_insert_format \"" << date_insert_format
1359                    << "\"\n";
1360         case RC_SHOW_BANNER:
1361                 os << "\\show_banner " << tostr(show_banner) << "\n";
1362         case RC_USE_GUI:
1363                 os << "\\use_gui " << tostr(show_banner) << "\n";
1364         case RC_LINUXDOC_TO_LYX_COMMAND:
1365                 os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command
1366                    << "\"\n";
1367         case RC_LINUXDOC_TO_HTML_COMMAND:
1368                 os << "\\linuxdoc_to_html_command \"" << linuxdoc_to_html_command
1369                    << "\"\n";
1370         case RC_LINUXDOC_TO_LATEX_COMMAND:
1371                 os << "\\linuxdoc_to_latex_command \"" << linuxdoc_to_latex_command
1372                    << "\"\n";
1373         case RC_DOCBOOK_TO_DVI_COMMAND:
1374                 os << "\\docbook_to_dvi_command \"" << docbook_to_dvi_command
1375                    << "\"\n";
1376         case RC_DOCBOOK_TO_HTML_COMMAND:
1377                 os << "\\docbook_to_html_command \"" << docbook_to_html_command
1378                    << "\"\n";
1379         case RC_DOCBOOK_TO_PDF_COMMAND:
1380                 os << "\\docbook_to_pdf_command \"" << docbook_to_pdf_command
1381                    << "\"\n";
1382         }
1383         os.flush();
1384 }
1385
1386
1387 // The global instance
1388 LyXRC lyxrc;