]> git.lyx.org Git - lyx.git/blob - src/lyxrc.C
New citation popup from Angus
[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                                 ReadBindFile(lexrc.GetString());
447                         }
448                         break;
449                         
450                 case RC_BEGINTOOLBAR:
451                         // this toolbar should be changed to be a completely
452                         // non gui toolbar. (Lgb)
453                         toolbardefaults.read(lexrc);
454                         break;
455                         
456                 case RC_KBMAP:
457                         if (lexrc.next())
458                                 use_kbmap = lexrc.GetBool();
459                         break;
460                         
461                 case RC_EXIT_CONFIRMATION:
462                         if (lexrc.next())
463                                 exit_confirmation = lexrc.GetBool();
464                         break;
465                         
466                 case RC_DISPLAY_SHORTCUTS:
467                         if (lexrc.next())
468                                 display_shortcuts = lexrc.GetBool();
469                         break;
470                         
471                 case RC_KBMAP_PRIMARY:
472                         if (lexrc.next())
473                                 primary_kbmap = lexrc.GetString();
474                         break;
475                         
476                 case RC_KBMAP_SECONDARY:
477                         if (lexrc.next())
478                                 secondary_kbmap = lexrc.GetString();
479                         break;
480                         
481                 case RC_FONT_ENCODING:
482                         if (lexrc.next())
483                                 fontenc = lexrc.GetString();
484                         break;
485                         
486                 case RC_PRINTER:
487                         if (lexrc.next())
488                                 printer = lexrc.GetString();
489                         break;
490                         
491                 case RC_PRINT_COMMAND:
492                         if (lexrc.next())
493                                 print_command = lexrc.GetString();
494                         break;
495                         
496                 case RC_PRINTEVENPAGEFLAG:
497                         if (lexrc.next())
498                                 print_evenpage_flag = lexrc.GetString();
499                         break;
500                         
501                 case RC_PRINTODDPAGEFLAG:
502                         if (lexrc.next())
503                                 print_oddpage_flag = lexrc.GetString();
504                         break;
505                         
506                 case RC_PRINTPAGERANGEFLAG:
507                         if (lexrc.next())
508                                 print_pagerange_flag = lexrc.GetString();
509                         break;
510                         
511                 case RC_PRINTCOPIESFLAG:
512                         if (lexrc.next())
513                                 print_copies_flag = lexrc.GetString();
514                         break;
515                         
516                 case RC_PRINTCOLLCOPIESFLAG:
517                         if (lexrc.next())
518                                 print_collcopies_flag = lexrc.GetString();
519                         break;
520                         
521                 case RC_PRINTREVERSEFLAG:
522                         if (lexrc.next())
523                                 print_reverse_flag = lexrc.GetString();
524                         break;
525                         
526                 case RC_PRINTLANDSCAPEFLAG:
527                         if (lexrc.next())
528                                 print_landscape_flag = lexrc.GetString();
529                         break;
530                         
531                 case RC_PRINTTOPRINTER:
532                         if (lexrc.next())
533                                 print_to_printer = lexrc.GetString();
534                         break;
535                         
536                 case RC_PRINT_ADAPTOUTPUT:
537                         if (lexrc.next())
538                                 print_adapt_output = lexrc.GetBool();
539                         break;
540                         
541                 case RC_PRINTTOFILE:
542                         if (lexrc.next())
543                                 print_to_file = lexrc.GetString();
544                         break;
545                         
546                 case RC_PRINTFILEEXTENSION:
547                         if (lexrc.next())
548                                 print_file_extension = lexrc.GetString();
549                         break;
550                         
551                 case RC_PRINTEXSTRAOPTIONS:
552                         if (lexrc.next())
553                                 print_extra_options = lexrc.GetString();
554                         break;
555                         
556                 case RC_PRINTSPOOL_COMMAND:
557                         if (lexrc.next())
558                                 print_spool_command = lexrc.GetString();
559                         break;
560                         
561                 case RC_PRINTSPOOL_PRINTERPREFIX:
562                         if (lexrc.next())
563                                 print_spool_printerprefix = lexrc.GetString();
564                         break;
565                         
566                 case RC_PRINTPAPERDIMENSIONFLAG:
567                         if (lexrc.next())
568                                 print_paper_dimension_flag = lexrc.GetString();
569                         break;
570                         
571                 case RC_PRINTPAPERFLAG:
572                         if (lexrc.next())
573                                 print_paper_flag = lexrc.GetString();
574                         break;
575                         
576                 case RC_CUSTOM_EXPORT_COMMAND:
577                         if (lexrc.next())
578                                 custom_export_command = lexrc.GetString();
579                         break;
580                         
581                 case RC_CUSTOM_EXPORT_FORMAT:
582                         if (lexrc.next())
583                                 custom_export_format = lexrc.GetString();
584                         break;
585
586                 case RC_PDF_MODE:
587                         if (lexrc.next())
588                                 pdf_mode = lexrc.GetBool();
589                         break;
590                         
591                 case RC_LATEX_COMMAND:
592                         if (lexrc.next())
593                                 latex_command = lexrc.GetString();
594                         break;
595
596                 case RC_PDFLATEX_COMMAND:
597                         if (lexrc.next())
598                                 pdflatex_command = lexrc.GetString();
599                         break;
600
601                 case RC_PDF_TO_PS_COMMAND:
602                         if (lexrc.next())
603                                 pdf_to_ps_command = lexrc.GetString();
604                         break;
605
606                 case RC_DVI_TO_PS_COMMAND:
607                         if (lexrc.next())
608                                 dvi_to_ps_command = lexrc.GetString();
609                         break;
610                         
611                 case RC_LITERATE_COMMAND:
612                         if (lexrc.next())
613                                 literate_command = lexrc.GetString();
614                         break;
615                         
616                 case RC_LITERATE_EXTENSION:
617                         if (lexrc.next())
618                                 literate_extension = lexrc.GetString();
619                         break;
620                         
621                 case RC_LITERATE_ERROR_FILTER:
622                         if (lexrc.next())
623                                 literate_error_filter = lexrc.GetString();
624                         break;
625                         
626                 case RC_BUILD_COMMAND:
627                         if (lexrc.next())
628                                 build_command = lexrc.GetString();
629                         break;
630                         
631                 case RC_BUILD_ERROR_FILTER:
632                         if (lexrc.next())
633                                 build_error_filter = lexrc.GetString();
634                         break;
635                         
636                 case RC_RELYX_COMMAND:
637                         if (lexrc.next())
638                                 relyx_command = lexrc.GetString();
639                         break;
640                         
641                 case RC_DEFAULT_PAPERSIZE:
642                         if (lexrc.next()) {
643                                 string size = lowercase(lexrc.GetString());
644                                 if (size == "usletter")
645                                         default_papersize =
646                                                 BufferParams::PAPER_USLETTER;
647                                 else if (size == "legal")
648                                         default_papersize =
649                                                 BufferParams::PAPER_LEGALPAPER;
650                                 else if (size == "executive")
651                                         default_papersize =
652                                                 BufferParams::PAPER_EXECUTIVEPAPER;
653                                 else if (size == "a3")
654                                         default_papersize =
655                                                 BufferParams::PAPER_A3PAPER;
656                                 else if (size == "a4")
657                                         default_papersize =
658                                                 BufferParams::PAPER_A4PAPER;
659                                 else if (size == "a5")
660                                         default_papersize =
661                                                 BufferParams::PAPER_A5PAPER;
662                                 else if (size == "b5")
663                                         default_papersize =
664                                                 BufferParams::PAPER_B5PAPER;
665                         }
666                         break;
667                 case RC_VIEWDVI_COMMAND:
668                         if (lexrc.next())
669                                 view_dvi_command = lexrc.GetString();
670                         break;
671
672                 case RC_VIEWDVI_PAPEROPTION:
673                         if (lexrc.next())
674                                 view_dvi_paper_option = lexrc.GetString();
675                         else 
676                                 view_dvi_paper_option = "";
677                         break;
678
679                 case RC_VIEWPDF_COMMAND:
680                         if (lexrc.next())
681                                 view_pdf_command = lexrc.GetString();
682                         break;
683                         
684                 case RC_PS_COMMAND:
685                         if (lexrc.next())
686                                 ps_command = lexrc.GetString();
687                         break;
688                         
689                 case RC_VIEWPS_COMMAND:
690                         if (lexrc.next())
691                                 view_ps_command = lexrc.GetString();
692                         break;
693                         
694                 case RC_VIEWPSPIC_COMMAND:
695                         if (lexrc.next())
696                                 view_pspic_command = lexrc.GetString();
697                         break;
698                         
699                 case RC_CHKTEX_COMMAND:
700                         if (lexrc.next())
701                                 chktex_command = lexrc.GetString();
702                         break;
703                         
704                 case RC_HTML_COMMAND:
705                         if (lexrc.next())
706                                 html_command = lexrc.GetString();
707                         break;
708                         
709                 case RC_SCREEN_DPI:
710                         if (lexrc.next())
711                                 dpi = lexrc.GetInteger();
712                         break;
713                         
714                 case RC_SCREEN_ZOOM:
715                         if (lexrc.next())
716                                 zoom = lexrc.GetInteger();
717                         break;
718                         
719                 case RC_SCREEN_FONT_SIZES:
720                         if (lexrc.next())
721                                 font_sizes[LyXFont::SIZE_TINY] =
722                                         lexrc.GetFloat();
723                         if (lexrc.next())
724                                 font_sizes[LyXFont::SIZE_SCRIPT] =
725                                         lexrc.GetFloat();
726                         if (lexrc.next())
727                                 font_sizes[LyXFont::SIZE_FOOTNOTE] =
728                                         lexrc.GetFloat();
729                         if (lexrc.next())
730                                 font_sizes[LyXFont::SIZE_SMALL] =
731                                         lexrc.GetFloat();
732                         if (lexrc.next())
733                                 font_sizes[LyXFont::SIZE_NORMAL] =
734                                         lexrc.GetFloat();
735                         if (lexrc.next())
736                                 font_sizes[LyXFont::SIZE_LARGE] =
737                                         lexrc.GetFloat();
738                         if (lexrc.next())
739                                 font_sizes[LyXFont::SIZE_LARGER] =
740                                         lexrc.GetFloat();
741                         if (lexrc.next())
742                                 font_sizes[LyXFont::SIZE_LARGEST] =
743                                         lexrc.GetFloat();
744                         if (lexrc.next())
745                                 font_sizes[LyXFont::SIZE_HUGE] =
746                                         lexrc.GetFloat();
747                         if (lexrc.next())
748                                 font_sizes[LyXFont::SIZE_HUGER] =
749                                         lexrc.GetFloat();
750                         break;
751                         
752                 case RC_SCREEN_FONT_SCALABLE:
753                         if (lexrc.next())
754                                 use_scalable_fonts = lexrc.GetBool();
755                         break;
756                         
757                 case RC_AUTOSAVE:
758                         if (lexrc.next())
759                                 autosave = lexrc.GetInteger();
760                         break;
761                         
762                 case RC_DOCUMENTPATH:
763                         if (lexrc.next()) {
764                                 document_path = ExpandPath(lexrc.GetString());
765                         }
766                         break;
767                         
768                 case RC_TEMPLATEPATH:
769                         if (lexrc.next())
770                                 template_path = ExpandPath(lexrc.GetString());
771                         break;
772                         
773                 case RC_TEMPDIRPATH:
774                         if (lexrc.next())
775                                 tempdir_path = ExpandPath(lexrc.GetString());
776                         break;
777                         
778                 case RC_USETEMPDIR:
779                         if (lexrc.next())
780                                 use_tempdir = lexrc.GetBool();
781                         break;
782                         
783                 case RC_LASTFILES:
784                         if (lexrc.next())
785                                 lastfiles = ExpandPath(lexrc.GetString());
786                         break;
787                         
788                 case RC_NUMLASTFILES:
789                         if (lexrc.next())
790                                 num_lastfiles = lexrc.GetInteger();
791                         break;
792                         
793                 case RC_CHECKLASTFILES:
794                         if (lexrc.next())
795                                 check_lastfiles = lexrc.GetBool();
796                         break;
797                         
798                 case RC_SCREEN_FONT_ROMAN:
799                         if (lexrc.next())
800                                 roman_font_name = lexrc.GetString();
801                         break;
802                         
803                 case RC_SCREEN_FONT_SANS:
804                         if (lexrc.next())
805                                 sans_font_name = lexrc.GetString();
806                         break;
807                         
808                 case RC_SCREEN_FONT_TYPEWRITER:
809                         if (lexrc.next())
810                                 typewriter_font_name = lexrc.GetString();
811                         break;
812                         
813                 case RC_SCREEN_FONT_MENU:
814                         if (lexrc.next())
815                                 menu_font_name = lexrc.GetString();
816                         break;
817                         
818                 case RC_SCREEN_FONT_POPUP:
819                         if (lexrc.next())
820                                 popup_font_name = lexrc.GetString();
821                         break;
822                         
823                 case RC_SCREEN_FONT_ENCODING:
824                         if (lexrc.next())
825                                 font_norm = lexrc.GetString();
826                         break;
827
828                 case RC_SCREEN_FONT_ENCODING_MENU:
829                         if (lexrc.next())
830                                 font_norm_menu = lexrc.GetString();
831                         break;
832
833                 case RC_AUTOREGIONDELETE:
834                         // Auto region delete defaults to true
835                         if (lexrc.next())
836                                 auto_region_delete = lexrc.GetBool();
837                         break;
838                         
839                 case RC_BIND:
840                 {
841                         // we should not do an explicit binding before
842                         // loading a bind file. So, in this case, load
843                         // the default bind file.
844                         if (!hasBindFile)
845                                 ReadBindFile();
846                         
847                         // !!!chb, dynamic key binding...
848                         int action, res = 0;
849                         string seq, cmd;
850                         
851                         if (lexrc.lex() == LyXLex::LEX_DATA)  {
852                                 seq = lexrc.GetString();
853                         } else {
854                                 lexrc.printError("Bad key sequence: `$$Token'");
855                                 break;
856                         }
857                         
858                         if (lexrc.lex() == LyXLex::LEX_DATA) {
859                                 cmd = lexrc.GetString();
860                         } else {
861                                 lexrc.printError("Bad command: `$$Token'");
862                                 break;
863                         }
864                         
865                         if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
866                                 if (lyxerr.debugging(Debug::KEY)) {
867                                         lyxerr << "RC_BIND: Sequence `"
868                                                << seq << "' Command `"
869                                                << cmd << "' Action `"
870                                                << action << '\'' << endl;
871                                 }
872                                 res = toplevel_keymap->bind(seq.c_str(),
873                                                             action);
874                                 if (res != 0) {
875                                         lexrc.printError(
876                                                 "Invalid key sequence `"
877                                                 + seq + '\''); 
878                                 }
879                         } else {// cmd is the last token read.
880                                 lexrc.printError(
881                                         "Unknown LyX function `$$Token'");
882                         }
883                         break;
884                 }
885                 case RC_OVERRIDE_X_DEADKEYS:
886                         if (lexrc.next())
887                                 override_x_deadkeys = lexrc.GetBool();
888                         break;
889
890                 case RC_SERVERPIPE:
891                         if (lexrc.next())
892                                 lyxpipes = ExpandPath(lexrc.GetString());
893                         break;
894                         
895                 case RC_CURSOR_FOLLOWS_SCROLLBAR:
896                         if (lexrc.next())
897                                 cursor_follows_scrollbar = lexrc.GetBool();
898                         break;
899
900                 case RC_FAX_COMMAND:
901                         if (lexrc.next())
902                                 fax_command = lexrc.GetString();
903                         break;
904                 case RC_FAXPROGRAM:
905                         if (lexrc.next())
906                                 fax_program = lexrc.GetString();
907                         break;
908                 case RC_PHONEBOOK:
909                         if (lexrc.next()) {
910                                 string s = lexrc.GetString();
911                                 if (AbsolutePath(s))
912                                         phone_book = s;
913                                 else
914                                         phone_book = user_lyxdir + s;
915                         }
916                         break;
917                 case RC_ASCIIROFF_COMMAND:
918                         if (lexrc.next())
919                                 ascii_roff_command = lexrc.GetString();
920                         break;
921                 case RC_ASCII_LINELEN:
922                         if (lexrc.next())
923                                 ascii_linelen = lexrc.GetInteger();
924                         break;
925                         // Spellchecker settings:
926                 case RC_SPELL_COMMAND:
927                         if (lexrc.next())
928                                 isp_command = lexrc.GetString();
929                         break;
930                 case RC_ACCEPT_COMPOUND:
931                         if (lexrc.next())
932                                 isp_accept_compound = lexrc.GetBool();
933                         break;
934                 case RC_USE_INP_ENC:
935                         if (lexrc.next())
936                                 isp_use_input_encoding = lexrc.GetBool();
937                         break;
938                 case RC_USE_ALT_LANG:
939                         if (lexrc.next())
940                                 isp_use_alt_lang = lexrc.GetBool();
941                         break;
942                 case RC_USE_PERS_DICT:
943                         if (lexrc.next())
944                                 isp_use_pers_dict = lexrc.GetBool();
945                         break;
946                 case RC_USE_ESC_CHARS:
947                         if (lexrc.next())
948                                 isp_use_esc_chars = lexrc.GetBool();
949                         break;
950                 case RC_ALT_LANG:
951                         if (lexrc.next())
952                                 isp_alt_lang = lexrc.GetString();
953                         break;
954                 case RC_PERS_DICT:
955                         if (lexrc.next())
956                                 isp_pers_dict = lexrc.GetString();
957                         break;
958                 case RC_ESC_CHARS:
959                         if (lexrc.next())
960                                 isp_esc_chars = lexrc.GetString();
961                         break;
962                 case RC_MAKE_BACKUP:
963                         if (lexrc.next())
964                                 make_backup = lexrc.GetBool();
965                         break;
966                 case RC_BACKUPDIR_PATH:
967                         if (lexrc.next())
968                                 backupdir_path = ExpandPath(lexrc.GetString());
969                         break;
970                 case RC_DATE_INSERT_FORMAT:
971                         if (lexrc.next())
972                                 date_insert_format = lexrc.GetString();
973                         break;
974                 case RC_LANGUAGE_PACKAGE:
975                         if (lexrc.next())
976                                 language_package = lexrc.GetString();
977                         break;
978                 case RC_LANGUAGE_AUTO_BEGIN:
979                         if (lexrc.next())
980                                 language_auto_begin = lexrc.GetBool();
981                         break;
982                 case RC_LANGUAGE_AUTO_END:
983                         if (lexrc.next())
984                                 language_auto_end = lexrc.GetBool();
985                         break;
986                 case RC_LANGUAGE_COMMAND_BEGIN:
987                         if (lexrc.next())
988                                 language_command_begin = lexrc.GetString();
989                         break;
990                 case RC_LANGUAGE_COMMAND_END:
991                         if (lexrc.next())
992                                 language_command_end = lexrc.GetString();
993                         break;
994                 case RC_RTL_SUPPORT:
995                         if (lexrc.next())
996                                 rtl_support = lexrc.GetBool();
997                         break;
998                 case RC_AUTO_NUMBER:
999                         if (lexrc.next())
1000                                 auto_number = lexrc.GetBool();
1001                         break;
1002                 case RC_MARK_FOREIGN_LANGUAGE:
1003                         if (lexrc.next())
1004                                 mark_foreign_language = lexrc.GetBool();
1005                         break;
1006                 case RC_SHOW_BANNER:
1007                         if (lexrc.next())
1008                                 show_banner = lexrc.GetBool();
1009                         break;
1010                 case RC_USE_GUI:
1011                         if (lexrc.next())
1012                                 use_gui = lexrc.GetBool();
1013                         break;
1014                 case RC_LINUXDOC_TO_LYX_COMMAND:
1015                         if ( lexrc.next())
1016                                 linuxdoc_to_lyx_command = lexrc.GetString();
1017                         break;
1018                 case RC_LINUXDOC_TO_HTML_COMMAND:
1019                         if ( lexrc.next())
1020                                 linuxdoc_to_html_command = lexrc.GetString();
1021                         break;
1022                 case RC_LINUXDOC_TO_LATEX_COMMAND:
1023                         if ( lexrc.next())
1024                                 linuxdoc_to_latex_command = lexrc.GetString();
1025                         break;
1026                 case RC_DOCBOOK_TO_DVI_COMMAND:
1027                         if ( lexrc.next())
1028                                 docbook_to_dvi_command = lexrc.GetString();
1029                         break;
1030                 case RC_DOCBOOK_TO_HTML_COMMAND:
1031                         if ( lexrc.next())
1032                                 docbook_to_html_command = lexrc.GetString();
1033                         break;
1034                 case RC_DOCBOOK_TO_PDF_COMMAND:
1035                         if ( lexrc.next())
1036                                 docbook_to_pdf_command = lexrc.GetString();
1037                         break;
1038                 case RC_LAST: break; // this is just a dummy
1039                 }
1040         }
1041
1042         return 0;
1043 }
1044
1045
1046 void LyXRC::write(string const & filename) const
1047 {
1048         ofstream ofs(filename.c_str());
1049         if (ofs)
1050                 output(ofs);
1051 }
1052
1053
1054 void LyXRC::print() const
1055 {
1056         if (lyxerr.debugging())
1057                 output(lyxerr);
1058         else
1059                 output(cout);
1060 }
1061
1062
1063 void LyXRC::output(ostream & os) const
1064 {
1065         os << "### This file is part of\n"
1066            << "### ========================================================\n"
1067            << "###          LyX, The Document Processor\n"
1068            << "###\n"
1069            << "###          Copyright 1995 Matthias Ettrich\n"
1070            << "###          Copyright 1995-1998 The LyX Team.\n"
1071            << "###\n"
1072            << "### ========================================================\n"
1073            << "\n"
1074            << "# This file is written by LyX, if you want to make your own\n"
1075            << "# modifications you should do them from inside LyX and save\n"
1076            << "# your preferences, or you can also make your modifications\n"
1077            << "# to lyxrc by hand. It is not advisable to edit this file.\n"
1078            << "\n";
1079         
1080         // Why the switch you might ask. It is a trick to ensure that all
1081         // the elements in the LyXRCTags enum is handled. As you can see
1082         // there are no breaks at all. So it is just a huge fall-through.
1083         // The nice thing is that we will get a warning from the compiler
1084         // if we forget an element.
1085         LyXRCTags tag = RC_LAST;
1086         switch(tag) {
1087         case RC_LAST:
1088         case RC_INPUT:
1089                 // input/include files are not done here
1090         case RC_BIND:
1091                 // bindings is not written to the preferences file.
1092         case RC_BINDFILE:
1093                 // bind files are not done here.
1094         case RC_BEGINTOOLBAR:
1095                 // Toolbar is not written here (yet).
1096         case RC_FONT_ENCODING:
1097                 os << "\\font_encoding \"" << fontenc << "\"\n";
1098         case RC_PRINTER:
1099                 os << "\\printer \"" << printer << "\"\n";
1100         case RC_PRINT_COMMAND:
1101                 os << "\\print_command \"" << print_command << "\"\n";
1102         case RC_PRINTEVENPAGEFLAG:
1103                 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1104                    << "\"\n";
1105         case RC_PRINTODDPAGEFLAG:
1106                 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1107                    << "\"\n";
1108         case RC_PRINTPAGERANGEFLAG:
1109                 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1110                    << "\"\n";
1111         case RC_PRINTCOPIESFLAG:
1112                 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1113         case RC_PRINTCOLLCOPIESFLAG:
1114                 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1115                    << "\"\n";
1116         case RC_PRINTREVERSEFLAG:
1117                 os << "\\print_reverse_flag \"" << print_reverse_flag
1118                    << "\"\n";
1119         case RC_PRINTLANDSCAPEFLAG:
1120                 os << "\\print_landscape_flag \"" << print_landscape_flag
1121                    << "\"\n";
1122         case RC_PRINTTOPRINTER:
1123                 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1124         case RC_PRINT_ADAPTOUTPUT:
1125                 os << "\\print_adapt_output " << tostr(print_adapt_output)
1126                    << "\n";
1127         case RC_PRINTTOFILE:
1128                 os << "\\print_to_file \"" << print_to_file << "\"\n";
1129         case RC_PRINTFILEEXTENSION:
1130                 os << "\\print_file_extension \"" << print_file_extension
1131                    << "\"\n";
1132         case RC_PRINTEXSTRAOPTIONS:
1133                 os << "\\print_extra_options \"" << print_extra_options
1134                    << "\"\n";
1135         case RC_PRINTSPOOL_COMMAND:
1136                 os << "\\print_spool_command \"" << print_spool_command
1137                    << "\"\n";
1138         case RC_PRINTSPOOL_PRINTERPREFIX:
1139                 os << "\\print_spool_printerprefix \""
1140                    << print_spool_printerprefix << "\"\n";
1141         case RC_PRINTPAPERDIMENSIONFLAG:
1142                 os << "\\print_paper_dimension_flag \""
1143                    << print_paper_dimension_flag << "\"\n";
1144         case RC_PRINTPAPERFLAG:
1145                 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1146         case RC_CUSTOM_EXPORT_COMMAND:
1147                 os << "\\custom_export_command \"" << custom_export_command
1148                    << "\"\n";
1149         case RC_CUSTOM_EXPORT_FORMAT:
1150                 os << "\\custom_export_format \"" << custom_export_format
1151                    << "\"\n";
1152         case RC_PDF_MODE:
1153                 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1154         case RC_LATEX_COMMAND:
1155                 os << "\\latex_command \"" << latex_command << "\"\n";
1156         case RC_PDFLATEX_COMMAND:
1157                 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1158         case RC_PDF_TO_PS_COMMAND:
1159                 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1160         case RC_DVI_TO_PS_COMMAND:
1161                 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1162         case RC_LITERATE_COMMAND:
1163                 os << "\\literate_command \"" << literate_command << "\"\n";
1164         case RC_LITERATE_EXTENSION:
1165                 os << "\\literate_extension \"" << literate_extension
1166                    << "\"\n";
1167         case RC_LITERATE_ERROR_FILTER:
1168                 os << "\\literate_error_filter \"" << literate_error_filter
1169                    << "\"\n";
1170         case RC_BUILD_COMMAND:
1171                 os << "\\build_command \"" << build_command << "\"\n";
1172         case RC_BUILD_ERROR_FILTER:
1173                 os << "\\build_error_filter \"" << build_error_filter
1174                    << "\"\n";
1175         case RC_SCREEN_DPI:
1176                 os << "\\screen_dpi " << dpi << "\n";
1177         case RC_SCREEN_ZOOM:
1178                 os << "\\screen_zoom " << zoom << "\n";
1179         case RC_SCREEN_FONT_SIZES:
1180                 os.setf(ios::fixed);
1181                 os.precision(2);
1182                 os << "\\screen_font_sizes";
1183                 os << " " << font_sizes[LyXFont::SIZE_TINY];
1184                 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1185                 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1186                 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1187                 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1188                 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1189                 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1190                 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1191                 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1192                 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1193                 os << "\n";
1194         case RC_OVERRIDE_X_DEADKEYS:
1195                 os << "\\override_x_deadkeys " 
1196                    << override_x_deadkeys << "\n";
1197         case RC_AUTOREGIONDELETE:
1198                 os << "\\auto_region_delete " << tostr(auto_region_delete)
1199                    << "\n";
1200         case RC_AUTOSAVE:
1201                 os << "\\autosave " << autosave << "\n";
1202         case RC_EXIT_CONFIRMATION:
1203                 os << "\\exit_confirmation " << tostr(exit_confirmation)
1204                    << "\n";
1205         case RC_DISPLAY_SHORTCUTS:
1206                 os << "\\display_shortcuts " << tostr(display_shortcuts)
1207                    << "\n";
1208         case RC_VIEWDVI_COMMAND:
1209                 os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1210         case RC_VIEWDVI_PAPEROPTION:
1211                 os << "\\view_dvi_paper_option \"" << view_dvi_paper_option << "\"\n";
1212         case RC_VIEWPDF_COMMAND:
1213                 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1214         case RC_DEFAULT_PAPERSIZE:
1215                 os << "\\default_papersize \"";
1216                 switch (default_papersize) {
1217                 case BufferParams::PAPER_USLETTER:
1218                         os << "usletter"; break;
1219                 case BufferParams::PAPER_LEGALPAPER:
1220                         os << "legal"; break;
1221                 case BufferParams::PAPER_EXECUTIVEPAPER:
1222                         os << "executive"; break;
1223                 case BufferParams::PAPER_A3PAPER:
1224                         os << "a3"; break;
1225                 case BufferParams::PAPER_A4PAPER:
1226                         os << "a4"; break;
1227                 case BufferParams::PAPER_A5PAPER:
1228                         os << "a5"; break;
1229                 case BufferParams::PAPER_B5PAPER:
1230                         os << "b5"; break;
1231                 case BufferParams::PAPER_DEFAULT: break;
1232                 }
1233                 os << "\"\n";
1234         case RC_VIEWPS_COMMAND:
1235                 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1236         case RC_VIEWPSPIC_COMMAND:
1237                 os << "\\view_pspic_command \"" << view_pspic_command
1238                    << "\"\n";
1239         case RC_PS_COMMAND:
1240                 os << "\\ps_command \"" << ps_command << "\"\n";
1241         case RC_CHKTEX_COMMAND:
1242                 os << "\\chktex_command \"" << chktex_command << "\"\n";
1243         case RC_HTML_COMMAND:
1244                 os << "\\html_command \"" << html_command << "\"\n";
1245         case RC_KBMAP:
1246                 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1247         case RC_KBMAP_PRIMARY:
1248                 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1249         case RC_KBMAP_SECONDARY:
1250                 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1251         case RC_SERVERPIPE:
1252                 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1253         case RC_RELYX_COMMAND:
1254                 os << "\\relyx_command \"" << relyx_command << "\"\n";
1255         case RC_DOCUMENTPATH:
1256                 os << "\\document_path \"" << document_path << "\"\n";
1257         case RC_TEMPLATEPATH:
1258                 os << "\\template_path \"" << template_path << "\"\n";
1259         case RC_TEMPDIRPATH:
1260                 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1261         case RC_USETEMPDIR:
1262                 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1263         case RC_LASTFILES:
1264                 os << "\\lastfiles \"" << lastfiles << "\"\n";
1265         case RC_NUMLASTFILES:
1266                 os << "\\num_lastfiles " << num_lastfiles << "\n";
1267         case RC_CHECKLASTFILES:
1268                 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1269         case RC_SCREEN_FONT_ROMAN:
1270                 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1271         case RC_SCREEN_FONT_SANS:
1272                 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1273         case RC_SCREEN_FONT_TYPEWRITER:
1274                 os << "\\screen_font_typewriter \""
1275                    << typewriter_font_name << "\"\n";
1276         case RC_SCREEN_FONT_MENU:
1277                 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1278         case RC_SCREEN_FONT_POPUP:
1279                 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1280         case RC_SCREEN_FONT_ENCODING:
1281                 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1282         case RC_SCREEN_FONT_ENCODING_MENU:
1283                 os << "\\screen_font_encoding_menu \"" << font_norm_menu
1284                    << "\"\n";
1285         case RC_SCREEN_FONT_SCALABLE:
1286                 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1287                    << "\n";
1288         case RC_CURSOR_FOLLOWS_SCROLLBAR:
1289                 os << "\\cursor_follows_scrollbar "
1290                    << tostr(cursor_follows_scrollbar) << "\n";
1291         case RC_FAX_COMMAND:
1292                 os << "\\fax_command \"" << fax_command << "\"\n";
1293         case RC_FAXPROGRAM:
1294                 os << "\\fax_program \"" << fax_program << "\"\n";
1295         case RC_PHONEBOOK:
1296                 os << "\\phone_book \"" << phone_book << "\"\n";
1297         case RC_ASCIIROFF_COMMAND:
1298                 os << "\\ascii_roff_command \"" << ascii_roff_command
1299                    << "\"\n";
1300         case RC_ASCII_LINELEN:
1301                 os << "\\ascii_linelen " << ascii_linelen << "\n";
1302         case RC_SPELL_COMMAND:
1303                 os << "\\spell_command \"" << isp_command << "\"\n";
1304         case RC_ACCEPT_COMPOUND:
1305                 os << "\\accept_compound " << tostr(isp_accept_compound)
1306                    << "\n";
1307         case RC_USE_INP_ENC:
1308                 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1309                    << "\n";
1310         case RC_USE_ALT_LANG:
1311                 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1312         case RC_USE_PERS_DICT:
1313                 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1314                    << "\n";
1315         case RC_USE_ESC_CHARS:
1316                 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1317                    << "\n";
1318         case RC_ALT_LANG:
1319                 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1320         case RC_PERS_DICT:
1321                 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1322         case RC_ESC_CHARS:
1323                 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1324         case RC_RTL_SUPPORT:
1325                 os << "\\rtl " << tostr(rtl_support) << "\n";
1326         case RC_AUTO_NUMBER:
1327                 os << "\\auto_number" << tostr(auto_number) << "\n";
1328         case RC_MARK_FOREIGN_LANGUAGE:
1329                 os << "\\mark_foreign_language " << 
1330                         tostr(mark_foreign_language) << "\n";
1331         case RC_LANGUAGE_AUTO_BEGIN:
1332                 os << "\\language_auto_begin " 
1333                    << tostr(language_auto_begin) << "\n";
1334         case RC_LANGUAGE_AUTO_END:
1335                 os << "\\language_auto_end " 
1336                    << tostr(language_auto_end) << "\n";
1337         case RC_LANGUAGE_PACKAGE:
1338                 os << "\\language_package \"" << language_package << "\"\n";
1339         case RC_LANGUAGE_COMMAND_BEGIN:
1340                 os << "\\language_command_begin \"" << language_command_begin
1341                    << "\"\n";
1342         case RC_LANGUAGE_COMMAND_END:
1343                 os << "\\language_command_end \"" << language_command_end
1344                    << "\"\n";
1345         case RC_MAKE_BACKUP:
1346                 os << "\\make_backup " << tostr(make_backup) << "\n";
1347         case RC_BACKUPDIR_PATH:
1348                 os << "\\backupdir_path" << backupdir_path << "\n";
1349         case RC_DATE_INSERT_FORMAT:
1350                 os << "\\date_insert_format \"" << date_insert_format
1351                    << "\"\n";
1352         case RC_SHOW_BANNER:
1353                 os << "\\show_banner " << tostr(show_banner) << "\n";
1354         case RC_USE_GUI:
1355                 os << "\\use_gui " << tostr(show_banner) << "\n";
1356         case RC_LINUXDOC_TO_LYX_COMMAND:
1357                 os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command
1358                    << "\"\n";
1359         case RC_LINUXDOC_TO_HTML_COMMAND:
1360                 os << "\\linuxdoc_to_html_command \"" << linuxdoc_to_html_command
1361                    << "\"\n";
1362         case RC_LINUXDOC_TO_LATEX_COMMAND:
1363                 os << "\\linuxdoc_to_latex_command \"" << linuxdoc_to_latex_command
1364                    << "\"\n";
1365         case RC_DOCBOOK_TO_DVI_COMMAND:
1366                 os << "\\docbook_to_dvi_command \"" << docbook_to_dvi_command
1367                    << "\"\n";
1368         case RC_DOCBOOK_TO_HTML_COMMAND:
1369                 os << "\\docbook_to_html_command \"" << docbook_to_html_command
1370                    << "\"\n";
1371         case RC_DOCBOOK_TO_PDF_COMMAND:
1372                 os << "\\docbook_to_pdf_command \"" << docbook_to_pdf_command
1373                    << "\"\n";
1374         }
1375         os.flush();
1376 }
1377
1378
1379 // The global instance
1380 LyXRC lyxrc;