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