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