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