]> git.lyx.org Git - lyx.git/blob - src/lyxrc.C
5761c35fc94ab9617d5addeb879261b1d76b8677
[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 "debug.h"
18
19 #include "lyxrc.h"
20 #include "LyXAction.h"
21 #include "lyxserver.h"
22 #include "lyx_main.h"
23 #include "intl.h"
24 #include "tex-strings.h"
25 #include "support/path.h"
26 #include "support/filetools.h"
27 #include "lyxtext.h"
28
29 // this is crappy... why are those colors command line arguments and
30 // not in lyxrc?? (Matthias) 
31 // Because nobody put them there. (Asger)
32 extern int fast_selection;
33 extern string background_color;
34 extern char selection_color[];
35 extern bool cursor_follows_scrollbar;
36 extern kb_keymap *toplevel_keymap;
37 extern LyXAction lyxaction;
38
39 enum _LyXRCTags {
40         RC_BEGINTOOLBAR=1,
41         RC_FONT_ENCODING,
42         RC_PRINTER,
43         RC_PRINT_COMMAND,
44         RC_PRINTEVENPAGEFLAG,
45         RC_PRINTODDPAGEFLAG,
46         RC_PRINTPAGERANGEFLAG,
47         RC_PRINTCOPIESFLAG,
48         RC_PRINTCOLLCOPIESFLAG,
49         RC_PRINTREVERSEFLAG,
50         RC_PRINTLANDSCAPEFLAG,
51         RC_PRINTTOPRINTER,
52         RC_PRINT_ADAPTOUTPUT,
53         RC_PRINTTOFILE,
54         RC_PRINTFILEEXTENSION,
55         RC_PRINTEXSTRAOPTIONS,
56         RC_PRINTSPOOL_COMMAND,
57         RC_PRINTSPOOL_PRINTERPREFIX,
58         RC_PRINTPAPERFLAG,
59         RC_PRINTPAPERDIMENSIONFLAG,
60         RC_CUSTOM_EXPORT_COMMAND,
61         RC_CUSTOM_EXPORT_FORMAT,
62         RC_LATEX_COMMAND,
63         RC_LITERATE_COMMAND,
64         RC_LITERATE_EXTENSION,
65         RC_LITERATE_ERROR_FILTER,
66         RC_BUILD_COMMAND,
67         RC_BUILD_ERROR_FILTER,
68         RC_SCREEN_DPI,
69         RC_SCREEN_ZOOM,
70         RC_SCREEN_FONT_SIZES,
71         RC_SCREEN_FONT_ROMAN,
72         RC_SCREEN_FONT_SANS,
73         RC_SCREEN_FONT_TYPEWRITER,
74         RC_SCREEN_FONT_MENU,
75         RC_SCREEN_FONT_POPUP,
76         RC_SCREEN_FONT_ENCODING,
77         RC_AUTOSAVE,
78         RC_SGML_EXTRA_OPTIONS,
79         RC_DOCUMENTPATH,
80         RC_TEMPLATEPATH,
81         RC_TEMPDIRPATH,
82         RC_USETEMPDIR,
83         RC_LASTFILES,
84         RC_AUTOREGIONDELETE,
85         RC_BIND,
86         RC_SERVERPIPE,
87         RC_NOMENUACCELERATORS,
88         RC_INPUT,
89         RC_BINDFILE,
90         RC_KBMAP,
91         RC_KBMAP_PRIMARY,
92         RC_KBMAP_SECONDARY,
93         RC_FAST_SELECTION,
94         RC_SELECTION_COLOR,
95         RC_BACKGROUND_COLOR,
96         RC_FAX_COMMAND,
97         RC_PHONEBOOK,
98         RC_FAXPROGRAM,
99         RC_ASCIIROFF_COMMAND,
100         RC_ASCII_LINELEN,
101         RC_NUMLASTFILES,
102         RC_CHECKLASTFILES,
103         RC_VIEWDVI_COMMAND,
104         RC_DEFAULT_PAPERSIZE,
105         RC_PS_COMMAND,
106         RC_VIEWPS_COMMAND,
107         RC_VIEWPSPIC_COMMAND,
108         RC_ACCEPT_COMPOUND,
109         RC_SPELL_COMMAND,
110         RC_USE_INP_ENC,
111         RC_USE_ALT_LANG,
112         RC_USE_PERS_DICT,
113         RC_USE_ESC_CHARS,
114         RC_SCREEN_FONT_SCALABLE,
115         RC_ALT_LANG,
116         RC_PERS_DICT,
117         RC_ESC_CHARS,
118         RC_CHKTEX_COMMAND,
119         RC_CURSOR_FOLLOWS_SCROLLBAR,
120         RC_EXIT_CONFIRMATION,
121         RC_DISPLAY_SHORTCUTS,
122         RC_RELYX_COMMAND,
123         RC_HTML_COMMAND,
124         RC_LAST 
125 };
126
127 static keyword_item lyxrcTags[] = {
128         { "\\accept_compound", RC_ACCEPT_COMPOUND },
129         { "\\alternate_language", RC_ALT_LANG },
130         { "\\ascii_linelen", RC_ASCII_LINELEN },
131         { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
132         { "\\auto_region_delete", RC_AUTOREGIONDELETE },
133         { "\\autosave", RC_AUTOSAVE },
134         { "\\background_color", RC_BACKGROUND_COLOR },
135         { "\\begin_toolbar", RC_BEGINTOOLBAR },
136         { "\\bind", RC_BIND },
137         { "\\bind_file", RC_BINDFILE },
138         { "\\build_command", RC_BUILD_COMMAND },
139         { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
140         { "\\check_lastfiles", RC_CHECKLASTFILES },
141         { "\\chktex_command", RC_CHKTEX_COMMAND },
142         { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
143         { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
144         { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
145         { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
146         { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
147         { "\\document_path", RC_DOCUMENTPATH },
148         { "\\escape_chars", RC_ESC_CHARS },
149         { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
150         { "\\fast_selection", RC_FAST_SELECTION },
151         { "\\fax_command", RC_FAX_COMMAND },
152         { "\\fax_program", RC_FAXPROGRAM },
153         { "\\font_encoding", RC_FONT_ENCODING },
154         { "\\html_command", RC_HTML_COMMAND },
155         { "\\input", RC_INPUT },
156         { "\\kbmap", RC_KBMAP },
157         { "\\kbmap_primary", RC_KBMAP_PRIMARY },
158         { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
159         { "\\lastfiles", RC_LASTFILES },
160         { "\\latex_command", RC_LATEX_COMMAND },
161         { "\\literate_command", RC_LITERATE_COMMAND },
162         { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
163         { "\\literate_extension", RC_LITERATE_EXTENSION },
164         { "\\num_lastfiles", RC_NUMLASTFILES },
165         { "\\personal_dictionary", RC_PERS_DICT },
166         { "\\phone_book", RC_PHONEBOOK },
167         { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
168         { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
169         { "\\print_command", RC_PRINT_COMMAND },
170         { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
171         { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
172         { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
173         { "\\print_file_extension", RC_PRINTFILEEXTENSION },
174         { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
175         { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
176         { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
177         { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
178         { "\\print_paper_flag", RC_PRINTPAPERFLAG },
179         { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
180         { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
181         { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
182         { "\\print_to_file", RC_PRINTTOFILE },
183         { "\\print_to_printer", RC_PRINTTOPRINTER },
184         { "\\printer", RC_PRINTER },
185         { "\\ps_command", RC_PS_COMMAND },
186         { "\\relyx_command", RC_RELYX_COMMAND },
187         { "\\screen_dpi", RC_SCREEN_DPI },
188         { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
189         { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
190         { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
191         { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
192         { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
193         { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
194         { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
195         { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
196         { "\\screen_zoom", RC_SCREEN_ZOOM },
197         { "\\selection_color", RC_SELECTION_COLOR },
198         { "\\serverpipe", RC_SERVERPIPE },
199         { "\\sgml_extra_options", RC_SGML_EXTRA_OPTIONS },
200         { "\\spell_command", RC_SPELL_COMMAND },
201         { "\\tempdir_path", RC_TEMPDIRPATH },
202         { "\\template_path", RC_TEMPLATEPATH },
203         { "\\use_alt_language", RC_USE_ALT_LANG },
204         { "\\use_escape_chars", RC_USE_ESC_CHARS },
205         { "\\use_input_encoding", RC_USE_INP_ENC },
206         { "\\use_personal_dictionary", RC_USE_PERS_DICT },
207         { "\\use_tempdir", RC_USETEMPDIR },
208         { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
209         { "\\view_ps_command", RC_VIEWPS_COMMAND },
210         { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
211 };
212
213 /* Let the range depend of the size of lyxrcTags.  Alejandro 240596 */
214 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
215
216 // Should this be moved inside LyXAction? 
217 static inline
218 int bindKey(char const* seq, int action)
219
220         return toplevel_keymap->bind(seq, action); 
221 }
222
223
224 LyXRC::LyXRC()
225 {
226         // Get printer from the environment. If fail, use default "",
227         // assuming that everything is set up correctly.
228         printer = GetEnv("PRINTER");
229         print_command = "dvips";
230         print_evenpage_flag = "-B";
231         print_oddpage_flag = "-A";
232         print_pagerange_flag = "-pp";
233         print_copies_flag = "-c";
234         print_collcopies_flag = "-C";
235         print_reverse_flag = "-r";
236         print_landscape_flag = "-t landscape";
237         print_to_printer = "-P";
238         print_to_file = "-o ";
239         print_file_extension = ".ps";
240         print_paper_flag = "-t";
241         print_paper_dimension_flag = "-T";
242         document_path = GetEnvPath("HOME");
243         tempdir_path = "/tmp";
244         use_tempdir = true;
245         latex_command = "latex";
246         literate_command = "none";
247         literate_extension = "none";
248         literate_error_filter = "cat";
249         build_command = "make";
250         build_error_filter = "cat";
251         relyx_command = "reLyX";
252         ps_command = "gs";
253         view_ps_command = "ghostview -swap";
254         view_pspic_command = "ghostview";
255         view_dvi_command = "xdvi";
256         default_papersize = PAPER_USLETTER;
257         custom_export_format = "ps";
258         chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
259         html_command = "tth -t";
260         fontenc = "default";
261         dpi = 75;
262         // Because a screen typically is wider than a piece of paper:
263         zoom = 150;
264         // Default LaTeX font size:
265         font_sizes[LyXFont::SIZE_TINY] = 5.0;
266         font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
267         font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
268         font_sizes[LyXFont::SIZE_SMALL] = 9.0;
269         font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
270         font_sizes[LyXFont::SIZE_LARGE] = 12.0;
271         font_sizes[LyXFont::SIZE_LARGER] = 14.4;
272         font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
273         font_sizes[LyXFont::SIZE_HUGE] = 20.74;
274         font_sizes[LyXFont::SIZE_HUGER] = 24.88;
275         use_scalable_fonts = true;
276         roman_font_name = "-*-times";
277         sans_font_name = "-*-helvetica";
278         typewriter_font_name = "-*-courier";
279         menu_font_name = "-*-helvetica-bold-r";
280         popup_font_name = "-*-helvetica-medium-r";
281         font_norm = "iso8859-1";
282         autosave = 300;
283         auto_region_delete = true;
284         ascii_linelen = 75;
285         num_lastfiles = 4;
286         check_lastfiles = true;
287         exit_confirmation = true;
288         display_shortcuts = true;
289         // Spellchecker settings:
290         isp_command = "ispell";
291         isp_accept_compound = false;
292         isp_use_input_encoding = false;
293         isp_use_alt_lang = false;
294         isp_use_pers_dict = false;
295         isp_use_esc_chars = false;
296         use_kbmap = false;
297         hasBindFile = false;
298         defaultKeyBindings();
299 }
300
301
302 LyXRC::~LyXRC()
303 {
304 }
305
306 int LyXRC::ReadBindFile(string name)
307 {
308         hasBindFile = true;
309         string tmp = i18nLibFileSearch("bind",name,"bind");
310         lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
311         int result = Read(tmp);
312         if (result) {
313                 lyxerr << "Error reading bind file: " << tmp << endl;
314         }
315         return result;
316 }
317
318 int LyXRC::Read(string const &filename)
319 {
320         // Default bindfile.
321         string bindFile = "cua";
322
323         LyXLex lexrc(lyxrcTags, lyxrcCount);
324         if (lyxerr.debugging(Debug::PARSER))
325                 lexrc.printTable();
326         
327         lexrc.setFile(filename);
328         if (!lexrc.IsOK()) return -2;
329
330         lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
331         
332         while (lexrc.IsOK()) {
333
334                 switch(lexrc.lex()) {
335                 case LyXLex::LEX_FEOF:
336                         break;
337                 case RC_INPUT: // Include file
338                         if (lexrc.next()) {
339                                 string tmp = LibFileSearch(string(),
340                                                            lexrc.GetString()); 
341                                 if (Read(tmp)) {
342                                         lexrc.printError("Error reading "
343                                                         "included file: "+tmp);
344                                 }
345                         }
346                         break;
347                 case RC_BINDFILE:                     // RVDK_PATCH_5
348                         if (lexrc.next()) 
349                                 ReadBindFile(lexrc.GetString());
350                         break;
351
352                 case RC_BEGINTOOLBAR:
353                         // this toolbar should be changed to be a completely
354                         // non gui toolbar. (Lgb)
355                         toolbar.read(lexrc);
356                         break;
357                         
358                 case RC_KBMAP:
359                         if (lexrc.next())
360                                 use_kbmap = lexrc.GetBool();
361                         break;
362
363                 case RC_EXIT_CONFIRMATION:
364                         if (lexrc.next())
365                                 exit_confirmation = lexrc.GetBool();
366                         break;
367
368                 case RC_DISPLAY_SHORTCUTS:
369                         if (lexrc.next())
370                                 display_shortcuts = lexrc.GetBool();
371                         break;
372
373                 case RC_KBMAP_PRIMARY:
374                         if (lexrc.next())
375                                 primary_kbmap = lexrc.GetString();
376                         break;
377
378                 case RC_KBMAP_SECONDARY:
379                         if (lexrc.next())
380                                 secondary_kbmap = lexrc.GetString();
381                         break;
382                           
383                 case RC_FONT_ENCODING:
384                         if (lexrc.next())
385                                 fontenc = lexrc.GetString();
386                         break;
387                         
388                 case RC_PRINTER:
389                         if (lexrc.next())
390                                 printer = lexrc.GetString();
391                         break;
392                         
393                 case RC_PRINT_COMMAND:
394                         if (lexrc.next())
395                                 print_command = lexrc.GetString();
396                         break;
397                         
398                 case RC_PRINTEVENPAGEFLAG:
399                         if (lexrc.next())
400                                 print_evenpage_flag = lexrc.GetString();
401                         break;
402                         
403                 case RC_PRINTODDPAGEFLAG:
404                         if (lexrc.next())
405                                 print_oddpage_flag = lexrc.GetString();
406                         break;
407                         
408                 case RC_PRINTPAGERANGEFLAG:
409                         if (lexrc.next())
410                                 print_pagerange_flag = lexrc.GetString();
411                         break;
412
413                 case RC_PRINTCOPIESFLAG:
414                         if (lexrc.next())
415                                 print_copies_flag = lexrc.GetString();
416                         break;
417
418                 case RC_PRINTCOLLCOPIESFLAG:
419                         if (lexrc.next())
420                                 print_collcopies_flag = lexrc.GetString();
421                         break;
422                         
423                 case RC_PRINTREVERSEFLAG:
424                         if (lexrc.next())
425                                 print_reverse_flag = lexrc.GetString();
426                         break;
427                         
428                 case RC_PRINTLANDSCAPEFLAG:
429                         if (lexrc.next())
430                                 print_landscape_flag = lexrc.GetString();
431                         break;
432                         
433                 case RC_PRINTTOPRINTER:
434                         if (lexrc.next())
435                                 print_to_printer = lexrc.GetString();
436                         break;
437                         
438                 case RC_PRINT_ADAPTOUTPUT:
439                         if (lexrc.next())
440                                 print_adapt_output = lexrc.GetBool();
441                         break;
442                         
443                 case RC_PRINTTOFILE:
444                         if (lexrc.next())
445                                 print_to_file = lexrc.GetString();
446                         break;
447                         
448                 case RC_PRINTFILEEXTENSION:
449                         if (lexrc.next())
450                                 print_file_extension = lexrc.GetString();
451                         break;
452                         
453                 case RC_PRINTEXSTRAOPTIONS:
454                         if (lexrc.next())
455                                 print_extra_options = lexrc.GetString();
456                         break;
457                         
458                 case RC_PRINTSPOOL_COMMAND:
459                         if (lexrc.next())
460                                 print_spool_command = lexrc.GetString();
461                         break;
462                         
463                 case RC_PRINTSPOOL_PRINTERPREFIX:
464                         if (lexrc.next())
465                                 print_spool_printerprefix = lexrc.GetString();
466                         break;
467
468                 case RC_PRINTPAPERDIMENSIONFLAG:
469                         if (lexrc.next())
470                                 print_paper_dimension_flag = lexrc.GetString();
471                         break;
472
473                 case RC_PRINTPAPERFLAG:
474                         if (lexrc.next())
475                                 print_paper_flag = lexrc.GetString();
476                         break;
477                         
478                 case RC_CUSTOM_EXPORT_COMMAND:
479                         if (lexrc.next())
480                                 custom_export_command = lexrc.GetString();
481                         break;
482
483                 case RC_CUSTOM_EXPORT_FORMAT:
484                         if (lexrc.next())
485                                 custom_export_format = lexrc.GetString();
486                         break;
487                         
488                 case RC_LATEX_COMMAND:
489                         if (lexrc.next())
490                                 latex_command = lexrc.GetString();
491                         break;
492
493                 case RC_LITERATE_COMMAND:
494                         if (lexrc.next())
495                                 literate_command = lexrc.GetString();
496                         break;
497  
498                 case RC_LITERATE_EXTENSION:
499                         if (lexrc.next())
500                                 literate_extension = lexrc.GetString();
501                         break;
502
503                 case RC_LITERATE_ERROR_FILTER:
504                         if (lexrc.next())
505                                 literate_error_filter = lexrc.GetString();
506                         break;
507
508                 case RC_BUILD_COMMAND:
509                         if (lexrc.next())
510                                 build_command = lexrc.GetString();
511                         break;
512
513                 case RC_BUILD_ERROR_FILTER:
514                         if (lexrc.next())
515                                 build_error_filter = lexrc.GetString();
516                          break;
517  
518                 case RC_RELYX_COMMAND:
519                         if (lexrc.next())
520                                 relyx_command = lexrc.GetString();
521                         break;
522
523                 case RC_DEFAULT_PAPERSIZE:
524                         if (lexrc.next()) {
525                                 string size = lowercase(lexrc.GetString());
526                                 if (size == "usletter")
527                                         default_papersize = PAPER_USLETTER;
528                                 else if (size == "legal")
529                                         default_papersize = PAPER_LEGALPAPER;
530                                 else if (size == "executive")
531                                         default_papersize = PAPER_EXECUTIVEPAPER;
532                                 else if (size == "a3")
533                                         default_papersize = PAPER_A3PAPER;
534                                 else if (size == "a4")
535                                         default_papersize = PAPER_A4PAPER;
536                                 else if (size == "a5")
537                                         default_papersize = PAPER_A5PAPER;
538                                 else if (size == "b5")
539                                         default_papersize = PAPER_B5PAPER;
540                         }
541                         break;
542                 case RC_VIEWDVI_COMMAND:
543                         if (lexrc.next())
544                                 view_dvi_command = lexrc.GetString();
545                         break;
546
547                 case RC_PS_COMMAND:
548                         if (lexrc.next())
549                                 ps_command = lexrc.GetString();
550                         break;
551
552                 case RC_VIEWPS_COMMAND:
553                         if (lexrc.next())
554                                 view_ps_command = lexrc.GetString();
555                         break;
556
557                 case RC_VIEWPSPIC_COMMAND:
558                         if (lexrc.next())
559                                 view_pspic_command = lexrc.GetString();
560                         break;
561
562                 case RC_CHKTEX_COMMAND:
563                         if (lexrc.next())
564                                 chktex_command = lexrc.GetString();
565                         break;
566
567                 case RC_HTML_COMMAND:
568                         if (lexrc.next())
569                                 html_command = lexrc.GetString();
570                         break;
571
572                 case RC_SCREEN_DPI:
573                         if (lexrc.next())
574                                 dpi = lexrc.GetInteger();
575                         break;
576
577                 case RC_SCREEN_ZOOM:
578                         if (lexrc.next())
579                                 zoom = lexrc.GetInteger();
580                         break;
581
582                 case RC_SCREEN_FONT_SIZES:
583                         if (lexrc.next())
584                                 font_sizes[LyXFont::SIZE_TINY] =
585                                         lexrc.GetFloat();
586                         if (lexrc.next())
587                                 font_sizes[LyXFont::SIZE_SCRIPT] =
588                                         lexrc.GetFloat();
589                         if (lexrc.next())
590                                 font_sizes[LyXFont::SIZE_FOOTNOTE] =
591                                         lexrc.GetFloat();
592                         if (lexrc.next())
593                                 font_sizes[LyXFont::SIZE_SMALL] =
594                                         lexrc.GetFloat();
595                         if (lexrc.next())
596                                 font_sizes[LyXFont::SIZE_NORMAL] =
597                                         lexrc.GetFloat();
598                         if (lexrc.next())
599                                 font_sizes[LyXFont::SIZE_LARGE] =
600                                         lexrc.GetFloat();
601                         if (lexrc.next())
602                                 font_sizes[LyXFont::SIZE_LARGER] =
603                                         lexrc.GetFloat();
604                         if (lexrc.next())
605                                 font_sizes[LyXFont::SIZE_LARGEST] =
606                                         lexrc.GetFloat();
607                         if (lexrc.next())
608                                 font_sizes[LyXFont::SIZE_HUGE] =
609                                         lexrc.GetFloat();
610                         if (lexrc.next())
611                                 font_sizes[LyXFont::SIZE_HUGER] =
612                                         lexrc.GetFloat();
613                         break;
614
615                 case RC_SCREEN_FONT_SCALABLE:
616                         if (lexrc.next())
617                                 use_scalable_fonts = lexrc.GetBool();
618                         break;
619
620                 case RC_AUTOSAVE:
621                         if (lexrc.next())
622                                 autosave = lexrc.GetInteger();
623                         break;
624                         
625                 case RC_SGML_EXTRA_OPTIONS:
626                         if (lexrc.next())
627                                 sgml_extra_options = lexrc.GetString();
628                         break;
629
630                 case RC_DOCUMENTPATH:
631                         if (lexrc.next()) {
632                                 document_path = ExpandPath(lexrc.GetString());
633                         }
634                         break;
635
636                 case RC_TEMPLATEPATH:
637                         if (lexrc.next())
638                                 template_path = ExpandPath(lexrc.GetString());
639                         break;
640
641                 case RC_TEMPDIRPATH:
642                         if (lexrc.next())
643                                 tempdir_path = ExpandPath(lexrc.GetString());
644                         break;
645                         
646                 case RC_USETEMPDIR:
647                         if (lexrc.next())
648                                 use_tempdir = lexrc.GetBool();
649                         break;
650
651                 case RC_LASTFILES:
652                         if (lexrc.next())
653                                 lastfiles = ExpandPath(lexrc.GetString());
654                         break;
655
656                 case RC_NUMLASTFILES:
657                         if (lexrc.next())
658                                 num_lastfiles = lexrc.GetInteger();
659                         break;
660
661                 case RC_CHECKLASTFILES:
662                         if (lexrc.next())
663                                 check_lastfiles = lexrc.GetBool();
664                         break;
665
666                 case RC_SCREEN_FONT_ROMAN:
667                         if (lexrc.next())
668                                 roman_font_name = lexrc.GetString();
669                         break;
670
671                 case RC_SCREEN_FONT_SANS:
672                         if (lexrc.next())
673                                 sans_font_name = lexrc.GetString();
674                         break;
675
676                 case RC_SCREEN_FONT_TYPEWRITER:
677                         if (lexrc.next())
678                                 typewriter_font_name = lexrc.GetString();
679                         break;
680                         
681                 case RC_SCREEN_FONT_MENU:
682                         if (lexrc.next())
683                                 menu_font_name = lexrc.GetString();
684                         break;
685                         
686                 case RC_SCREEN_FONT_POPUP:
687                         if (lexrc.next())
688                                 popup_font_name = lexrc.GetString();
689                         break;
690                         
691                 case RC_SCREEN_FONT_ENCODING:
692                         if (lexrc.next())
693                                 font_norm = lexrc.GetString();
694                         break;
695                         
696                 case RC_AUTOREGIONDELETE:
697                         // Auto region delete defaults to true
698                         if (lexrc.next())
699                                 auto_region_delete = lexrc.GetBool();
700                         break;
701                         
702                 case RC_BIND:
703                 {
704                         // we should not do an explicit binding before
705                         // loading a bind file. So, in this case, load
706                         // the default bind file.
707                         if (!hasBindFile)
708                                 ReadBindFile();
709
710                         // !!!chb, dynamic key binding...
711                         int action, res=0;
712                         string seq, cmd;
713
714                         if (lexrc.lex()==LyXLex::LEX_DATA)  {
715                                 seq = lexrc.GetString();
716                         } else {
717                                 lexrc.printError("Bad key sequence: `$$Token'");
718                                 break;
719                         }
720
721                         if (lexrc.lex()==LyXLex::LEX_DATA) {
722                                 cmd = lexrc.GetString();
723                         } else {
724                                 lexrc.printError("Bad command: `$$Token'");
725                                 break;
726                         }
727
728                         if ((action = lyxaction.LookupFunc(cmd.c_str()))>=0) {
729                                 if (lyxerr.debugging(Debug::KEY)) {
730                                         lyxerr << "RC_BIND: Sequence `"
731                                                << seq << "' Command `"
732                                                << cmd << "' Action `"
733                                                << action << '\'' << endl;
734                                 }
735                                 res = bindKey(seq.c_str(), action);
736                                 if (res != 0) {
737                                         lexrc.printError(
738                                               "Invalid key sequence `"
739                                               + seq + '\''); 
740                                 }
741                         } else {// cmd is the last token read.
742                                 lexrc.printError(
743                                             "Unknown LyX function `$$Token'");
744                         }
745                         break;
746                 }
747                 case RC_SERVERPIPE:
748                         if (lexrc.next())
749                                 lyxpipes = ExpandPath(lexrc.GetString());
750                         break;
751                         
752                 case RC_CURSOR_FOLLOWS_SCROLLBAR:
753                         if (lexrc.next())
754                                 cursor_follows_scrollbar = lexrc.GetBool();
755                         break;
756                 case RC_FAST_SELECTION:
757                         if (lexrc.next())
758                                 fast_selection = lexrc.GetBool();
759                         break;
760                 case RC_BACKGROUND_COLOR:
761                         if (lexrc.next())
762                                 background_color = lexrc.GetString();
763                         break;
764                 case RC_SELECTION_COLOR:
765                         if (lexrc.next())
766                                 strncpy(selection_color,
767                                         lexrc.GetString().c_str(),31);
768                         break;
769                 case RC_FAX_COMMAND:
770                         if (lexrc.next())
771                                 fax_command = lexrc.GetString();
772                         break;
773                 case RC_FAXPROGRAM:
774                         if (lexrc.next())
775                                 fax_program = lexrc.GetString();
776                         break;
777                 case RC_PHONEBOOK:
778                         if (lexrc.next()) {
779                                 string s = lexrc.GetString();
780                                 if (AbsolutePath(s))
781                                         phone_book = s;
782                                 else
783                                         phone_book = user_lyxdir + s;
784                         }
785                         break;
786                 case RC_ASCIIROFF_COMMAND:
787                         if (lexrc.next())
788                             ascii_roff_command = lexrc.GetString();
789                         break;
790                 case RC_ASCII_LINELEN:
791                         if (lexrc.next())
792                             ascii_linelen = lexrc.GetInteger();
793                         break;
794                 // Spellchecker settings:
795                 case RC_SPELL_COMMAND:
796                         if (lexrc.next())
797                                 isp_command = lexrc.GetString();
798                         break;
799                 case RC_ACCEPT_COMPOUND:
800                         if (lexrc.next())
801                                 isp_accept_compound = lexrc.GetBool();
802                         break;
803                 case RC_USE_INP_ENC:
804                         if (lexrc.next())
805                                 isp_use_input_encoding = lexrc.GetBool();
806                         break;
807                 case RC_USE_ALT_LANG:
808                         if (lexrc.next())
809                                 isp_use_alt_lang = lexrc.GetBool();
810                         break;
811                 case RC_USE_PERS_DICT:
812                         if (lexrc.next())
813                                 isp_use_pers_dict = lexrc.GetBool();
814                         break;
815                 case RC_USE_ESC_CHARS:
816                         if (lexrc.next())
817                                 isp_use_esc_chars = lexrc.GetBool();
818                         break;
819                 case RC_ALT_LANG:
820                         if (lexrc.next())
821                                 isp_alt_lang = lexrc.GetString();
822                         break;
823                 case RC_PERS_DICT:
824                         if (lexrc.next())
825                                 isp_pers_dict = lexrc.GetString();
826                         break;
827                 case RC_ESC_CHARS:
828                         if (lexrc.next())
829                                 isp_esc_chars = lexrc.GetString();
830                         break;
831
832                 default:
833                         lexrc.printError("Unknown tag `$$Token'");
834                         break;
835                 }
836         }
837
838         return 0;
839 }
840
841
842 void LyXRC::Print()
843 {
844         lyxerr << "The current internal LyXRC:" << endl;
845 }
846
847
848 /// define the default key bindings for LyX.
849 void LyXRC::defaultKeyBindings()
850 {
851         bindKey("Right",   LFUN_RIGHT);
852         bindKey("Left",    LFUN_LEFT);
853         bindKey("Up",      LFUN_UP);
854         bindKey("Down",    LFUN_DOWN);
855
856         bindKey("Tab",  LFUN_TAB);
857
858         bindKey("Home",    LFUN_HOME);
859         bindKey("End",     LFUN_END);
860         bindKey("Prior",   LFUN_PRIOR);
861         bindKey("Next",    LFUN_NEXT);
862
863         bindKey("Return",  LFUN_BREAKPARAGRAPH);
864         bindKey("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
865
866         bindKey("Delete",  LFUN_DELETE);
867         bindKey("BackSpace",    LFUN_BACKSPACE);
868         // bindKeyings for transparent handling of deadkeys
869         // The keysyms are gotten from XFree86 X11R6
870         bindKey("~C-~S-~M-dead_acute",           LFUN_ACUTE);
871         bindKey("~C-~S-~M-dead_breve",           LFUN_BREVE);
872         bindKey("~C-~S-~M-dead_caron",           LFUN_CARON);
873         bindKey("~C-~S-~M-dead_cedilla",         LFUN_CEDILLA);
874         bindKey("~C-~S-~M-dead_abovering",          LFUN_CIRCLE);
875         bindKey("~C-~S-~M-dead_circumflex",      LFUN_CIRCUMFLEX);
876         bindKey("~C-~S-~M-dead_abovedot",             LFUN_DOT);
877         bindKey("~C-~S-~M-dead_grave",           LFUN_GRAVE);
878         bindKey("~C-~S-~M-dead_doubleacute",     LFUN_HUNG_UMLAUT);
879         bindKey("~C-~S-~M-dead_macron",          LFUN_MACRON);
880         // nothing with this name
881         // bindKey("~C-~S-~M-dead_special_caron",   LFUN_SPECIAL_CARON);
882         bindKey("~C-~S-~M-dead_tilde",           LFUN_TILDE);
883         bindKey("~C-~S-~M-dead_diaeresis",       LFUN_UMLAUT);
884         // nothing with this name either...
885         //bindKey("~C-~S-~M-dead_underbar",        LFUN_UNDERBAR);
886         bindKey("~C-~S-~M-dead_belowdot",        LFUN_UNDERDOT);
887         bindKey("~C-~S-~M-dead_tie",             LFUN_TIE);
888         bindKey("~C-~S-~M-dead_ogonek",           LFUN_OGONEK);
889
890         // bindings to utilize the use of the numeric keypad
891         // e.g. Num Lock set
892         bindKey("KP_0",        LFUN_SELFINSERT);
893         bindKey("KP_Decimal",  LFUN_SELFINSERT);
894         bindKey("KP_Enter",    LFUN_SELFINSERT);
895         bindKey("KP_1",        LFUN_SELFINSERT);
896         bindKey("KP_2",        LFUN_SELFINSERT);
897         bindKey("KP_3",        LFUN_SELFINSERT);
898         bindKey("KP_4",        LFUN_SELFINSERT);
899         bindKey("KP_5",        LFUN_SELFINSERT);
900         bindKey("KP_6",        LFUN_SELFINSERT);
901         bindKey("KP_Add",      LFUN_SELFINSERT);
902         bindKey("KP_7",        LFUN_SELFINSERT);
903         bindKey("KP_8",        LFUN_SELFINSERT);
904         bindKey("KP_9",        LFUN_SELFINSERT);
905         bindKey("KP_Divide",   LFUN_SELFINSERT);
906         bindKey("KP_Multiply", LFUN_SELFINSERT);
907         bindKey("KP_Subtract", LFUN_SELFINSERT);
908     
909         /* Most self-insert keys are handled in the 'default:' section of
910          * WorkAreaKeyPress - so we don't have to define them all.
911          * However keys explicit decleared as self-insert are
912          * handled seperatly (LFUN_SELFINSERT.) Lgb. */
913
914         bindKey("C-Tab",  LFUN_TABINSERT);  // ale970515
915 }