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