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