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