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