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