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