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