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