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