]> git.lyx.org Git - features.git/blob - src/lyxrc.C
6f97ee50f6e964639c1498f7ad5796d13f429339
[features.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 #ifdef MONO
40 extern int fast_selection;
41 #endif
42
43 extern string background_color;
44 extern char selection_color[];
45 extern bool cursor_follows_scrollbar;
46 extern kb_keymap * toplevel_keymap;
47 extern LyXAction lyxaction;
48
49 enum LyXRCTags {
50         RC_BEGINTOOLBAR = 1,
51         RC_FONT_ENCODING,
52         RC_PRINTER,
53         RC_PRINT_COMMAND,
54         RC_PRINTEVENPAGEFLAG,
55         RC_PRINTODDPAGEFLAG,
56         RC_PRINTPAGERANGEFLAG,
57         RC_PRINTCOPIESFLAG,
58         RC_PRINTCOLLCOPIESFLAG,
59         RC_PRINTREVERSEFLAG,
60         RC_PRINTLANDSCAPEFLAG,
61         RC_PRINTTOPRINTER,
62         RC_PRINT_ADAPTOUTPUT,
63         RC_PRINTTOFILE,
64         RC_PRINTFILEEXTENSION,
65         RC_PRINTEXSTRAOPTIONS,
66         RC_PRINTSPOOL_COMMAND,
67         RC_PRINTSPOOL_PRINTERPREFIX,
68         RC_PRINTPAPERFLAG,
69         RC_PRINTPAPERDIMENSIONFLAG,
70         RC_CUSTOM_EXPORT_COMMAND,
71         RC_CUSTOM_EXPORT_FORMAT,
72         RC_LATEX_COMMAND,
73         RC_LITERATE_COMMAND,
74         RC_LITERATE_EXTENSION,
75         RC_LITERATE_ERROR_FILTER,
76         RC_BUILD_COMMAND,
77         RC_BUILD_ERROR_FILTER,
78         RC_SCREEN_DPI,
79         RC_SCREEN_ZOOM,
80         RC_SCREEN_FONT_SIZES,
81         RC_SCREEN_FONT_ROMAN,
82         RC_SCREEN_FONT_SANS,
83         RC_SCREEN_FONT_TYPEWRITER,
84         RC_SCREEN_FONT_MENU,
85         RC_SCREEN_FONT_POPUP,
86         RC_SCREEN_FONT_ENCODING,
87         RC_AUTOSAVE,
88         RC_SGML_EXTRA_OPTIONS,
89         RC_DOCUMENTPATH,
90         RC_TEMPLATEPATH,
91         RC_TEMPDIRPATH,
92         RC_USETEMPDIR,
93         RC_LASTFILES,
94         RC_AUTOREGIONDELETE,
95         RC_BIND,
96         RC_SERVERPIPE,
97         RC_NOMENUACCELERATORS,
98         RC_INPUT,
99         RC_BINDFILE,
100         RC_KBMAP,
101         RC_KBMAP_PRIMARY,
102         RC_KBMAP_SECONDARY,
103 #ifdef MONO
104         RC_FAST_SELECTION,
105 #endif
106         RC_SELECTION_COLOR,
107         RC_BACKGROUND_COLOR,
108         RC_FAX_COMMAND,
109         RC_PHONEBOOK,
110         RC_FAXPROGRAM,
111         RC_ASCIIROFF_COMMAND,
112         RC_ASCII_LINELEN,
113         RC_NUMLASTFILES,
114         RC_CHECKLASTFILES,
115         RC_VIEWDVI_COMMAND,
116         RC_DEFAULT_PAPERSIZE,
117         RC_PS_COMMAND,
118         RC_VIEWPS_COMMAND,
119         RC_VIEWPSPIC_COMMAND,
120         RC_ACCEPT_COMPOUND,
121         RC_SPELL_COMMAND,
122         RC_USE_INP_ENC,
123         RC_USE_ALT_LANG,
124         RC_USE_PERS_DICT,
125         RC_USE_ESC_CHARS,
126         RC_SCREEN_FONT_SCALABLE,
127         RC_ALT_LANG,
128         RC_PERS_DICT,
129         RC_ESC_CHARS,
130         RC_CHKTEX_COMMAND,
131         RC_CURSOR_FOLLOWS_SCROLLBAR,
132         RC_EXIT_CONFIRMATION,
133         RC_DISPLAY_SHORTCUTS,
134         RC_RELYX_COMMAND,
135         RC_HTML_COMMAND,
136         RC_MAKE_BACKUP,
137         RC_RTL_SUPPORT,
138         RC_PDFLATEX_COMMAND,
139         RC_PDF_MODE,
140         RC_VIEWPDF_COMMAND,
141         RC_PDF_TO_PS_COMMAND,
142         RC_DVI_TO_PS_COMMAND,
143         RC_DATE_INSERT_FORMAT,
144         RC_LAST
145 };
146
147
148 static keyword_item lyxrcTags[] = {
149         { "\\accept_compound", RC_ACCEPT_COMPOUND },
150         { "\\alternate_language", RC_ALT_LANG },
151         { "\\ascii_linelen", RC_ASCII_LINELEN },
152         { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
153         { "\\auto_region_delete", RC_AUTOREGIONDELETE },
154         { "\\autosave", RC_AUTOSAVE },
155         { "\\background_color", RC_BACKGROUND_COLOR },
156         { "\\begin_toolbar", RC_BEGINTOOLBAR },
157         { "\\bind", RC_BIND },
158         { "\\bind_file", RC_BINDFILE },
159         { "\\build_command", RC_BUILD_COMMAND },
160         { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
161         { "\\check_lastfiles", RC_CHECKLASTFILES },
162         { "\\chktex_command", RC_CHKTEX_COMMAND },
163         { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
164         { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
165         { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
166         { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
167         { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
168         { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
169         { "\\document_path", RC_DOCUMENTPATH },
170         { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
171         { "\\escape_chars", RC_ESC_CHARS },
172         { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
173 #ifdef MONO
174         { "\\fast_selection", RC_FAST_SELECTION },
175 #endif  
176         { "\\fax_command", RC_FAX_COMMAND },
177         { "\\fax_program", RC_FAXPROGRAM },
178         { "\\font_encoding", RC_FONT_ENCODING },
179         { "\\html_command", RC_HTML_COMMAND },
180         { "\\input", RC_INPUT },
181         { "\\kbmap", RC_KBMAP },
182         { "\\kbmap_primary", RC_KBMAP_PRIMARY },
183         { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
184         { "\\lastfiles", RC_LASTFILES },
185         { "\\latex_command", RC_LATEX_COMMAND },
186         { "\\literate_command", RC_LITERATE_COMMAND },
187         { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
188         { "\\literate_extension", RC_LITERATE_EXTENSION },
189         { "\\make_backup", RC_MAKE_BACKUP },
190         { "\\num_lastfiles", RC_NUMLASTFILES },
191         { "\\pdf_mode", RC_PDF_MODE },
192         { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
193         { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
194         { "\\personal_dictionary", RC_PERS_DICT },
195         { "\\phone_book", RC_PHONEBOOK },
196         { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
197         { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
198         { "\\print_command", RC_PRINT_COMMAND },
199         { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
200         { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
201         { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
202         { "\\print_file_extension", RC_PRINTFILEEXTENSION },
203         { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
204         { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
205         { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
206         { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
207         { "\\print_paper_flag", RC_PRINTPAPERFLAG },
208         { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
209         { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
210         { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
211         { "\\print_to_file", RC_PRINTTOFILE },
212         { "\\print_to_printer", RC_PRINTTOPRINTER },
213         { "\\printer", RC_PRINTER },
214         { "\\ps_command", RC_PS_COMMAND },
215         { "\\relyx_command", RC_RELYX_COMMAND },
216         { "\\rtl", RC_RTL_SUPPORT },
217         { "\\screen_dpi", RC_SCREEN_DPI },
218         { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
219         { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
220         { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
221         { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
222         { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
223         { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
224         { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
225         { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
226         { "\\screen_zoom", RC_SCREEN_ZOOM },
227         { "\\selection_color", RC_SELECTION_COLOR },
228         { "\\serverpipe", RC_SERVERPIPE },
229         { "\\sgml_extra_options", RC_SGML_EXTRA_OPTIONS },
230         { "\\spell_command", RC_SPELL_COMMAND },
231         { "\\tempdir_path", RC_TEMPDIRPATH },
232         { "\\template_path", RC_TEMPLATEPATH },
233         { "\\use_alt_language", RC_USE_ALT_LANG },
234         { "\\use_escape_chars", RC_USE_ESC_CHARS },
235         { "\\use_input_encoding", RC_USE_INP_ENC },
236         { "\\use_personal_dictionary", RC_USE_PERS_DICT },
237         { "\\use_tempdir", RC_USETEMPDIR },
238         { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
239         { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
240         { "\\view_ps_command", RC_VIEWPS_COMMAND },
241         { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
242 };
243
244 /* Let the range depend of the size of lyxrcTags.  Alejandro 240596 */
245 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
246
247 // Should this be moved inside LyXAction? 
248 static inline
249 int bindKey(char const * seq, int action)
250
251         return toplevel_keymap->bind(seq, action); 
252 }
253
254
255 LyXRC::LyXRC()
256 {
257         // Get printer from the environment. If fail, use default "",
258         // assuming that everything is set up correctly.
259         printer = GetEnv("PRINTER");
260         print_adapt_output = false;
261         print_command = "dvips";
262         print_evenpage_flag = "-B";
263         print_oddpage_flag = "-A";
264         print_pagerange_flag = "-pp";
265         print_copies_flag = "-c";
266         print_collcopies_flag = "-C";
267         print_reverse_flag = "-r";
268         print_landscape_flag = "-t landscape";
269         print_to_printer = "-P";
270         print_to_file = "-o ";
271         print_file_extension = ".ps";
272         print_paper_flag = "-t";
273         print_paper_dimension_flag = "-T";
274         document_path = GetEnvPath("HOME");
275         tempdir_path = "/tmp";
276         use_tempdir = true;
277         pdf_mode = false;
278         latex_command = "latex";
279         pdflatex_command = "pdflatex";
280         pdf_to_ps_command = "pdf2ps";
281         dvi_to_ps_command = "dvips";
282         literate_command = "none";
283         literate_extension = "none";
284         literate_error_filter = "cat";
285         build_command = "make";
286         build_error_filter = "cat";
287         relyx_command = "reLyX";
288         ps_command = "gs";
289         view_ps_command = "ghostview -swap";
290         view_pspic_command = "ghostview";
291         view_dvi_command = "xdvi";
292         view_pdf_command = "xpdf";
293         default_papersize = BufferParams::PAPER_USLETTER;
294         custom_export_format = "ps";
295         chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
296         html_command = "tth -t";
297         fontenc = "default";
298         dpi = 75;
299         // Because a screen typically is wider than a piece of paper:
300         zoom = 150;
301         // Default LaTeX font size:
302         font_sizes[LyXFont::SIZE_TINY] = 5.0;
303         font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
304         font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
305         font_sizes[LyXFont::SIZE_SMALL] = 9.0;
306         font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
307         font_sizes[LyXFont::SIZE_LARGE] = 12.0;
308         font_sizes[LyXFont::SIZE_LARGER] = 14.4;
309         font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
310         font_sizes[LyXFont::SIZE_HUGE] = 20.74;
311         font_sizes[LyXFont::SIZE_HUGER] = 24.88;
312         use_scalable_fonts = true;
313         roman_font_name = "-*-times";
314         sans_font_name = "-*-helvetica";
315         typewriter_font_name = "-*-courier";
316         menu_font_name = "-*-helvetica-bold-r";
317         popup_font_name = "-*-helvetica-medium-r";
318         font_norm = "iso8859-1";
319         autosave = 300;
320         auto_region_delete = true;
321         ascii_linelen = 75;
322         num_lastfiles = 4;
323         check_lastfiles = true;
324         make_backup = true;
325         exit_confirmation = true;
326         display_shortcuts = true;
327         // Spellchecker settings:
328         isp_command = "ispell";
329         isp_accept_compound = false;
330         isp_use_input_encoding = false;
331         isp_use_alt_lang = false;
332         isp_use_pers_dict = false;
333         isp_use_esc_chars = false;
334         use_kbmap = false;
335         hasBindFile = false;
336         rtl_support = false;
337         defaultKeyBindings();
338         ///
339         date_insert_format = "%A, %e %B %Y";
340 }
341
342
343 int LyXRC::ReadBindFile(string const & name)
344 {
345         hasBindFile = true;
346         string tmp = i18nLibFileSearch("bind", name, "bind");
347         lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
348         int result = read(tmp);
349         if (result) {
350                 lyxerr << "Error reading bind file: " << tmp << endl;
351         }
352         return result;
353 }
354
355
356 int LyXRC::read(string const & filename)
357 {
358         // Default bindfile.
359         string bindFile = "cua";
360         
361         LyXLex lexrc(lyxrcTags, lyxrcCount);
362         if (lyxerr.debugging(Debug::PARSER))
363                 lexrc.printTable();
364         
365         lexrc.setFile(filename);
366         if (!lexrc.IsOK()) return -2;
367         
368         lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
369         
370         while (lexrc.IsOK()) {
371                 // By using two switches we take advantage of the compiler
372                 // telling us if we have missed a LyXRCTags element in
373                 // the second switch.
374                 // Note that this also shows a problem with LyXLex since it
375                 // helps us avoid taking advantage of the strictness of the
376                 // compiler.
377
378                 int le = lexrc.lex();
379                 switch(le) {
380                 case LyXLex::LEX_UNDEF:
381                         lexrc.printError("Unknown tag `$$Token'");
382                         continue; 
383                 case LyXLex::LEX_FEOF:
384                         continue; 
385                 default: break;
386                 }
387                 switch (static_cast<LyXRCTags>(le)) {
388                 case RC_INPUT: // Include file
389                         if (lexrc.next()) {
390                                 string tmp = LibFileSearch(string(),
391                                                            lexrc.GetString()); 
392                                 if (read(tmp)) {
393                                         lexrc.printError("Error reading "
394                                                          "included file: "+tmp);
395                                 }
396                         }
397                         break;
398                 case RC_BINDFILE:                     // RVDK_PATCH_5
399                         if (lexrc.next()) {
400                                 ReadBindFile(lexrc.GetString());
401                         }
402                         break;
403                         
404                 case RC_BEGINTOOLBAR:
405                         // this toolbar should be changed to be a completely
406                         // non gui toolbar. (Lgb)
407                         toolbar.read(lexrc);
408                         break;
409                         
410                 case RC_KBMAP:
411                         if (lexrc.next())
412                                 use_kbmap = lexrc.GetBool();
413                         break;
414                         
415                 case RC_EXIT_CONFIRMATION:
416                         if (lexrc.next())
417                                 exit_confirmation = lexrc.GetBool();
418                         break;
419                         
420                 case RC_DISPLAY_SHORTCUTS:
421                         if (lexrc.next())
422                                 display_shortcuts = lexrc.GetBool();
423                         break;
424                         
425                 case RC_KBMAP_PRIMARY:
426                         if (lexrc.next())
427                                 primary_kbmap = lexrc.GetString();
428                         break;
429                         
430                 case RC_KBMAP_SECONDARY:
431                         if (lexrc.next())
432                                 secondary_kbmap = lexrc.GetString();
433                         break;
434                         
435                 case RC_FONT_ENCODING:
436                         if (lexrc.next())
437                                 fontenc = lexrc.GetString();
438                         break;
439                         
440                 case RC_PRINTER:
441                         if (lexrc.next())
442                                 printer = lexrc.GetString();
443                         break;
444                         
445                 case RC_PRINT_COMMAND:
446                         if (lexrc.next())
447                                 print_command = lexrc.GetString();
448                         break;
449                         
450                 case RC_PRINTEVENPAGEFLAG:
451                         if (lexrc.next())
452                                 print_evenpage_flag = lexrc.GetString();
453                         break;
454                         
455                 case RC_PRINTODDPAGEFLAG:
456                         if (lexrc.next())
457                                 print_oddpage_flag = lexrc.GetString();
458                         break;
459                         
460                 case RC_PRINTPAGERANGEFLAG:
461                         if (lexrc.next())
462                                 print_pagerange_flag = lexrc.GetString();
463                         break;
464                         
465                 case RC_PRINTCOPIESFLAG:
466                         if (lexrc.next())
467                                 print_copies_flag = lexrc.GetString();
468                         break;
469                         
470                 case RC_PRINTCOLLCOPIESFLAG:
471                         if (lexrc.next())
472                                 print_collcopies_flag = lexrc.GetString();
473                         break;
474                         
475                 case RC_PRINTREVERSEFLAG:
476                         if (lexrc.next())
477                                 print_reverse_flag = lexrc.GetString();
478                         break;
479                         
480                 case RC_PRINTLANDSCAPEFLAG:
481                         if (lexrc.next())
482                                 print_landscape_flag = lexrc.GetString();
483                         break;
484                         
485                 case RC_PRINTTOPRINTER:
486                         if (lexrc.next())
487                                 print_to_printer = lexrc.GetString();
488                         break;
489                         
490                 case RC_PRINT_ADAPTOUTPUT:
491                         if (lexrc.next())
492                                 print_adapt_output = lexrc.GetBool();
493                         break;
494                         
495                 case RC_PRINTTOFILE:
496                         if (lexrc.next())
497                                 print_to_file = lexrc.GetString();
498                         break;
499                         
500                 case RC_PRINTFILEEXTENSION:
501                         if (lexrc.next())
502                                 print_file_extension = lexrc.GetString();
503                         break;
504                         
505                 case RC_PRINTEXSTRAOPTIONS:
506                         if (lexrc.next())
507                                 print_extra_options = lexrc.GetString();
508                         break;
509                         
510                 case RC_PRINTSPOOL_COMMAND:
511                         if (lexrc.next())
512                                 print_spool_command = lexrc.GetString();
513                         break;
514                         
515                 case RC_PRINTSPOOL_PRINTERPREFIX:
516                         if (lexrc.next())
517                                 print_spool_printerprefix = lexrc.GetString();
518                         break;
519                         
520                 case RC_PRINTPAPERDIMENSIONFLAG:
521                         if (lexrc.next())
522                                 print_paper_dimension_flag = lexrc.GetString();
523                         break;
524                         
525                 case RC_PRINTPAPERFLAG:
526                         if (lexrc.next())
527                                 print_paper_flag = lexrc.GetString();
528                         break;
529                         
530                 case RC_CUSTOM_EXPORT_COMMAND:
531                         if (lexrc.next())
532                                 custom_export_command = lexrc.GetString();
533                         break;
534                         
535                 case RC_CUSTOM_EXPORT_FORMAT:
536                         if (lexrc.next())
537                                 custom_export_format = lexrc.GetString();
538                         break;
539
540                 case RC_PDF_MODE:
541                         if (lexrc.next())
542                                 pdf_mode = lexrc.GetBool();
543                         break;
544                         
545                 case RC_LATEX_COMMAND:
546                         if (lexrc.next())
547                                 latex_command = lexrc.GetString();
548                         break;
549
550                 case RC_PDFLATEX_COMMAND:
551                         if (lexrc.next())
552                                 pdflatex_command = lexrc.GetString();
553                         break;
554
555                 case RC_PDF_TO_PS_COMMAND:
556                         if (lexrc.next())
557                                 pdf_to_ps_command = lexrc.GetString();
558                         break;
559
560                 case RC_DVI_TO_PS_COMMAND:
561                         if (lexrc.next())
562                                 dvi_to_ps_command = lexrc.GetString();
563                         break;
564                         
565                 case RC_LITERATE_COMMAND:
566                         if (lexrc.next())
567                                 literate_command = lexrc.GetString();
568                         break;
569                         
570                 case RC_LITERATE_EXTENSION:
571                         if (lexrc.next())
572                                 literate_extension = lexrc.GetString();
573                         break;
574                         
575                 case RC_LITERATE_ERROR_FILTER:
576                         if (lexrc.next())
577                                 literate_error_filter = lexrc.GetString();
578                         break;
579                         
580                 case RC_BUILD_COMMAND:
581                         if (lexrc.next())
582                                 build_command = lexrc.GetString();
583                         break;
584                         
585                 case RC_BUILD_ERROR_FILTER:
586                         if (lexrc.next())
587                                 build_error_filter = lexrc.GetString();
588                         break;
589                         
590                 case RC_RELYX_COMMAND:
591                         if (lexrc.next())
592                                 relyx_command = lexrc.GetString();
593                         break;
594                         
595                 case RC_DEFAULT_PAPERSIZE:
596                         if (lexrc.next()) {
597                                 string size = lowercase(lexrc.GetString());
598                                 if (size == "usletter")
599                                         default_papersize =
600                                                 BufferParams::PAPER_USLETTER;
601                                 else if (size == "legal")
602                                         default_papersize =
603                                                 BufferParams::PAPER_LEGALPAPER;
604                                 else if (size == "executive")
605                                         default_papersize =
606                                                 BufferParams::PAPER_EXECUTIVEPAPER;
607                                 else if (size == "a3")
608                                         default_papersize =
609                                                 BufferParams::PAPER_A3PAPER;
610                                 else if (size == "a4")
611                                         default_papersize =
612                                                 BufferParams::PAPER_A4PAPER;
613                                 else if (size == "a5")
614                                         default_papersize =
615                                                 BufferParams::PAPER_A5PAPER;
616                                 else if (size == "b5")
617                                         default_papersize =
618                                                 BufferParams::PAPER_B5PAPER;
619                         }
620                         break;
621                 case RC_VIEWDVI_COMMAND:
622                         if (lexrc.next())
623                                 view_dvi_command = lexrc.GetString();
624                         break;
625
626                 case RC_VIEWPDF_COMMAND:
627                         if (lexrc.next())
628                                 view_pdf_command = lexrc.GetString();
629                         break;
630                         
631                 case RC_PS_COMMAND:
632                         if (lexrc.next())
633                                 ps_command = lexrc.GetString();
634                         break;
635                         
636                 case RC_VIEWPS_COMMAND:
637                         if (lexrc.next())
638                                 view_ps_command = lexrc.GetString();
639                         break;
640                         
641                 case RC_VIEWPSPIC_COMMAND:
642                         if (lexrc.next())
643                                 view_pspic_command = lexrc.GetString();
644                         break;
645                         
646                 case RC_CHKTEX_COMMAND:
647                         if (lexrc.next())
648                                 chktex_command = lexrc.GetString();
649                         break;
650                         
651                 case RC_HTML_COMMAND:
652                         if (lexrc.next())
653                                 html_command = lexrc.GetString();
654                         break;
655                         
656                 case RC_SCREEN_DPI:
657                         if (lexrc.next())
658                                 dpi = lexrc.GetInteger();
659                         break;
660                         
661                 case RC_SCREEN_ZOOM:
662                         if (lexrc.next())
663                                 zoom = lexrc.GetInteger();
664                         break;
665                         
666                 case RC_SCREEN_FONT_SIZES:
667                         if (lexrc.next())
668                                 font_sizes[LyXFont::SIZE_TINY] =
669                                         lexrc.GetFloat();
670                         if (lexrc.next())
671                                 font_sizes[LyXFont::SIZE_SCRIPT] =
672                                         lexrc.GetFloat();
673                         if (lexrc.next())
674                                 font_sizes[LyXFont::SIZE_FOOTNOTE] =
675                                         lexrc.GetFloat();
676                         if (lexrc.next())
677                                 font_sizes[LyXFont::SIZE_SMALL] =
678                                         lexrc.GetFloat();
679                         if (lexrc.next())
680                                 font_sizes[LyXFont::SIZE_NORMAL] =
681                                         lexrc.GetFloat();
682                         if (lexrc.next())
683                                 font_sizes[LyXFont::SIZE_LARGE] =
684                                         lexrc.GetFloat();
685                         if (lexrc.next())
686                                 font_sizes[LyXFont::SIZE_LARGER] =
687                                         lexrc.GetFloat();
688                         if (lexrc.next())
689                                 font_sizes[LyXFont::SIZE_LARGEST] =
690                                         lexrc.GetFloat();
691                         if (lexrc.next())
692                                 font_sizes[LyXFont::SIZE_HUGE] =
693                                         lexrc.GetFloat();
694                         if (lexrc.next())
695                                 font_sizes[LyXFont::SIZE_HUGER] =
696                                         lexrc.GetFloat();
697                         break;
698                         
699                 case RC_SCREEN_FONT_SCALABLE:
700                         if (lexrc.next())
701                                 use_scalable_fonts = lexrc.GetBool();
702                         break;
703                         
704                 case RC_AUTOSAVE:
705                         if (lexrc.next())
706                                 autosave = lexrc.GetInteger();
707                         break;
708                         
709                 case RC_SGML_EXTRA_OPTIONS:
710                         if (lexrc.next())
711                                 sgml_extra_options = lexrc.GetString();
712                         break;
713                         
714                 case RC_DOCUMENTPATH:
715                         if (lexrc.next()) {
716                                 document_path = ExpandPath(lexrc.GetString());
717                         }
718                         break;
719                         
720                 case RC_TEMPLATEPATH:
721                         if (lexrc.next())
722                                 template_path = ExpandPath(lexrc.GetString());
723                         break;
724                         
725                 case RC_TEMPDIRPATH:
726                         if (lexrc.next())
727                                 tempdir_path = ExpandPath(lexrc.GetString());
728                         break;
729                         
730                 case RC_USETEMPDIR:
731                         if (lexrc.next())
732                                 use_tempdir = lexrc.GetBool();
733                         break;
734                         
735                 case RC_LASTFILES:
736                         if (lexrc.next())
737                                 lastfiles = ExpandPath(lexrc.GetString());
738                         break;
739                         
740                 case RC_NUMLASTFILES:
741                         if (lexrc.next())
742                                 num_lastfiles = lexrc.GetInteger();
743                         break;
744                         
745                 case RC_CHECKLASTFILES:
746                         if (lexrc.next())
747                                 check_lastfiles = lexrc.GetBool();
748                         break;
749                         
750                 case RC_SCREEN_FONT_ROMAN:
751                         if (lexrc.next())
752                                 roman_font_name = lexrc.GetString();
753                         break;
754                         
755                 case RC_SCREEN_FONT_SANS:
756                         if (lexrc.next())
757                                 sans_font_name = lexrc.GetString();
758                         break;
759                         
760                 case RC_SCREEN_FONT_TYPEWRITER:
761                         if (lexrc.next())
762                                 typewriter_font_name = lexrc.GetString();
763                         break;
764                         
765                 case RC_SCREEN_FONT_MENU:
766                         if (lexrc.next())
767                                 menu_font_name = lexrc.GetString();
768                         break;
769                         
770                 case RC_SCREEN_FONT_POPUP:
771                         if (lexrc.next())
772                                 popup_font_name = lexrc.GetString();
773                         break;
774                         
775                 case RC_SCREEN_FONT_ENCODING:
776                         if (lexrc.next())
777                                 font_norm = lexrc.GetString();
778                         break;
779                         
780                 case RC_AUTOREGIONDELETE:
781                         // Auto region delete defaults to true
782                         if (lexrc.next())
783                                 auto_region_delete = lexrc.GetBool();
784                         break;
785                         
786                 case RC_BIND:
787                 {
788                         // we should not do an explicit binding before
789                         // loading a bind file. So, in this case, load
790                         // the default bind file.
791                         if (!hasBindFile)
792                                 ReadBindFile();
793                         
794                         // !!!chb, dynamic key binding...
795                         int action, res = 0;
796                         string seq, cmd;
797                         
798                         if (lexrc.lex() == LyXLex::LEX_DATA)  {
799                                 seq = lexrc.GetString();
800                         } else {
801                                 lexrc.printError("Bad key sequence: `$$Token'");
802                                 break;
803                         }
804                         
805                         if (lexrc.lex() == LyXLex::LEX_DATA) {
806                                 cmd = lexrc.GetString();
807                         } else {
808                                 lexrc.printError("Bad command: `$$Token'");
809                                 break;
810                         }
811                         
812                         if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
813                                 if (lyxerr.debugging(Debug::KEY)) {
814                                         lyxerr << "RC_BIND: Sequence `"
815                                                << seq << "' Command `"
816                                                << cmd << "' Action `"
817                                                << action << '\'' << endl;
818                                 }
819                                 res = bindKey(seq.c_str(), action);
820                                 if (res != 0) {
821                                         lexrc.printError(
822                                                 "Invalid key sequence `"
823                                                 + seq + '\''); 
824                                 }
825                         } else {// cmd is the last token read.
826                                 lexrc.printError(
827                                         "Unknown LyX function `$$Token'");
828                         }
829                         break;
830                 }
831                 case RC_SERVERPIPE:
832                         if (lexrc.next())
833                                 lyxpipes = ExpandPath(lexrc.GetString());
834                         break;
835                         
836                 case RC_CURSOR_FOLLOWS_SCROLLBAR:
837                         if (lexrc.next())
838                                 cursor_follows_scrollbar = lexrc.GetBool();
839                         break;
840
841 #ifdef MONO
842                 case RC_FAST_SELECTION:
843                         if (lexrc.next())
844                                 fast_selection = lexrc.GetBool();
845                         break;
846 #endif
847
848                 case RC_BACKGROUND_COLOR:
849                         if (lexrc.next())
850                                 background_color = lexrc.GetString();
851                         break;
852                 case RC_SELECTION_COLOR:
853                         if (lexrc.next())
854                                 strncpy(selection_color,
855                                         lexrc.GetString().c_str(), 31);
856                         break;
857                 case RC_FAX_COMMAND:
858                         if (lexrc.next())
859                                 fax_command = lexrc.GetString();
860                         break;
861                 case RC_FAXPROGRAM:
862                         if (lexrc.next())
863                                 fax_program = lexrc.GetString();
864                         break;
865                 case RC_PHONEBOOK:
866                         if (lexrc.next()) {
867                                 string s = lexrc.GetString();
868                                 if (AbsolutePath(s))
869                                         phone_book = s;
870                                 else
871                                         phone_book = user_lyxdir + s;
872                         }
873                         break;
874                 case RC_ASCIIROFF_COMMAND:
875                         if (lexrc.next())
876                                 ascii_roff_command = lexrc.GetString();
877                         break;
878                 case RC_ASCII_LINELEN:
879                         if (lexrc.next())
880                                 ascii_linelen = lexrc.GetInteger();
881                         break;
882                         // Spellchecker settings:
883                 case RC_SPELL_COMMAND:
884                         if (lexrc.next())
885                                 isp_command = lexrc.GetString();
886                         break;
887                 case RC_ACCEPT_COMPOUND:
888                         if (lexrc.next())
889                                 isp_accept_compound = lexrc.GetBool();
890                         break;
891                 case RC_USE_INP_ENC:
892                         if (lexrc.next())
893                                 isp_use_input_encoding = lexrc.GetBool();
894                         break;
895                 case RC_USE_ALT_LANG:
896                         if (lexrc.next())
897                                 isp_use_alt_lang = lexrc.GetBool();
898                         break;
899                 case RC_USE_PERS_DICT:
900                         if (lexrc.next())
901                                 isp_use_pers_dict = lexrc.GetBool();
902                         break;
903                 case RC_USE_ESC_CHARS:
904                         if (lexrc.next())
905                                 isp_use_esc_chars = lexrc.GetBool();
906                         break;
907                 case RC_ALT_LANG:
908                         if (lexrc.next())
909                                 isp_alt_lang = lexrc.GetString();
910                         break;
911                 case RC_PERS_DICT:
912                         if (lexrc.next())
913                                 isp_pers_dict = lexrc.GetString();
914                         break;
915                 case RC_ESC_CHARS:
916                         if (lexrc.next())
917                                 isp_esc_chars = lexrc.GetString();
918                         break;
919                 case RC_MAKE_BACKUP:
920                         if (lexrc.next())
921                                 make_backup = lexrc.GetBool();
922                         break;
923                 case RC_DATE_INSERT_FORMAT:
924                         if (lexrc.next())
925                                 date_insert_format = lexrc.GetString();
926                         break;
927                 case RC_RTL_SUPPORT:
928                         if (lexrc.next())
929                                 rtl_support = 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_VIEWPDF_COMMAND:
1101                 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1102         case RC_DEFAULT_PAPERSIZE:
1103                 os << "\\default_papersize \"";
1104                 switch (default_papersize) {
1105                 case BufferParams::PAPER_USLETTER:
1106                         os << "usletter"; break;
1107                 case BufferParams::PAPER_LEGALPAPER:
1108                         os << "legal"; break;
1109                 case BufferParams::PAPER_EXECUTIVEPAPER:
1110                         os << "executive"; break;
1111                 case BufferParams::PAPER_A3PAPER:
1112                         os << "a3"; break;
1113                 case BufferParams::PAPER_A4PAPER:
1114                         os << "a4"; break;
1115                 case BufferParams::PAPER_A5PAPER:
1116                         os << "a5"; break;
1117                 case BufferParams::PAPER_B5PAPER:
1118                         os << "b5"; break;
1119                 case BufferParams::PAPER_DEFAULT: break;
1120                 }
1121                 os << "\"\n";
1122         case RC_VIEWPS_COMMAND:
1123                 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1124         case RC_VIEWPSPIC_COMMAND:
1125                 os << "\\view_pspic_command \"" << view_pspic_command
1126                    << "\"\n";
1127         case RC_PS_COMMAND:
1128                 os << "\\ps_command \"" << ps_command << "\"\n";
1129         case RC_CHKTEX_COMMAND:
1130                 os << "\\chktex_command \"" << chktex_command << "\"\n";
1131         case RC_HTML_COMMAND:
1132                 os << "\\html_command \"" << html_command << "\"\n";
1133         case RC_SGML_EXTRA_OPTIONS:
1134                 os << "\\sgml_extra_options \"" << sgml_extra_options
1135                    << "\"\n";
1136         case RC_KBMAP:
1137                 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1138         case RC_KBMAP_PRIMARY:
1139                 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1140         case RC_KBMAP_SECONDARY:
1141                 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1142         case RC_SERVERPIPE:
1143                 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1144         case RC_RELYX_COMMAND:
1145                 os << "\\relyx_command \"" << relyx_command << "\"\n";
1146         case RC_DOCUMENTPATH:
1147                 os << "\\document_path \"" << document_path << "\"\n";
1148         case RC_TEMPLATEPATH:
1149                 os << "\\template_path \"" << template_path << "\"\n";
1150         case RC_TEMPDIRPATH:
1151                 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1152         case RC_USETEMPDIR:
1153                 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1154         case RC_LASTFILES:
1155                 os << "\\lastfiles \"" << lastfiles << "\"\n";
1156         case RC_NUMLASTFILES:
1157                 os << "\\num_lastfiles " << num_lastfiles << "\n";
1158         case RC_CHECKLASTFILES:
1159                 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1160         case RC_SCREEN_FONT_ROMAN:
1161                 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1162         case RC_SCREEN_FONT_SANS:
1163                 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1164         case RC_SCREEN_FONT_TYPEWRITER:
1165                 os << "\\screen_font_typewriter \""
1166                    << typewriter_font_name << "\"\n";
1167         case RC_SCREEN_FONT_MENU:
1168                 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1169         case RC_SCREEN_FONT_POPUP:
1170                 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1171         case RC_SCREEN_FONT_ENCODING:
1172                 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1173         case RC_SCREEN_FONT_SCALABLE:
1174                 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1175                    << "\n";
1176         case RC_CURSOR_FOLLOWS_SCROLLBAR:
1177                 os << "\\cursor_follows_scrollbar "
1178                    << tostr(cursor_follows_scrollbar) << "\n";
1179 #ifdef MONO
1180         case RC_FAST_SELECTION:
1181                 os << "\\fast_selection "
1182                    << tostr(static_cast<bool>(fast_selection)) << "\n";
1183 #endif
1184         case RC_BACKGROUND_COLOR:
1185                 os << "\\background_color \"" << background_color << "\"\n";
1186         case RC_SELECTION_COLOR:
1187                 os << "\\selection_color \"" << selection_color << "\"\n";
1188         case RC_FAX_COMMAND:
1189                 os << "\\fax_command \"" << fax_command << "\"\n";
1190         case RC_FAXPROGRAM:
1191                 os << "\\fax_program \"" << fax_program << "\"\n";
1192         case RC_PHONEBOOK:
1193                 os << "\\phone_book \"" << phone_book << "\"\n";
1194         case RC_ASCIIROFF_COMMAND:
1195                 os << "\\ascii_roff_command \"" << ascii_roff_command
1196                    << "\"\n";
1197         case RC_ASCII_LINELEN:
1198                 os << "\\ascii_linelen " << ascii_linelen << "\n";
1199         case RC_SPELL_COMMAND:
1200                 os << "\\spell_command \"" << isp_command << "\"\n";
1201         case RC_ACCEPT_COMPOUND:
1202                 os << "\\accept_compound " << tostr(isp_accept_compound)
1203                    << "\n";
1204         case RC_USE_INP_ENC:
1205                 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1206                    << "\n";
1207         case RC_USE_ALT_LANG:
1208                 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1209         case RC_USE_PERS_DICT:
1210                 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1211                    << "\n";
1212         case RC_USE_ESC_CHARS:
1213                 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1214                    << "\n";
1215         case RC_ALT_LANG:
1216                 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1217         case RC_PERS_DICT:
1218                 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1219         case RC_ESC_CHARS:
1220                 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1221         case RC_RTL_SUPPORT:
1222                 os << "\\rtl " << tostr(rtl_support) << "\n";
1223         case RC_MAKE_BACKUP:
1224                 os << "\\make_backup " << tostr(make_backup) << "\n";
1225         case RC_DATE_INSERT_FORMAT:
1226                 os << "\\date_insert_format \"" << date_insert_format
1227                    << "\"\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 }