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