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