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