]> git.lyx.org Git - lyx.git/blob - src/lyxrc.C
white-space changes, removed definitions.h several enum changes because of this,...
[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 = BufferParams::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 int LyXRC::ReadBindFile(string const & name)
303 {
304         hasBindFile = true;
305         string tmp = i18nLibFileSearch("bind", name, "bind");
306         lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
307         int result = Read(tmp);
308         if (result) {
309                 lyxerr << "Error reading bind file: " << tmp << endl;
310         }
311         return result;
312 }
313
314 int LyXRC::Read(string const &filename)
315 {
316         // Default bindfile.
317         string bindFile = "cua";
318
319         LyXLex lexrc(lyxrcTags, lyxrcCount);
320         if (lyxerr.debugging(Debug::PARSER))
321                 lexrc.printTable();
322         
323         lexrc.setFile(filename);
324         if (!lexrc.IsOK()) return -2;
325
326         lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
327         
328         while (lexrc.IsOK()) {
329
330                 switch(lexrc.lex()) {
331                 case LyXLex::LEX_FEOF:
332                         break;
333                 case RC_INPUT: // Include file
334                         if (lexrc.next()) {
335                                 string tmp = LibFileSearch(string(),
336                                                            lexrc.GetString()); 
337                                 if (Read(tmp)) {
338                                         lexrc.printError("Error reading "
339                                                         "included file: "+tmp);
340                                 }
341                         }
342                         break;
343                 case RC_BINDFILE:                     // RVDK_PATCH_5
344                         if (lexrc.next()) 
345                                 ReadBindFile(lexrc.GetString());
346                         break;
347
348                 case RC_BEGINTOOLBAR:
349                         // this toolbar should be changed to be a completely
350                         // non gui toolbar. (Lgb)
351                         toolbar.read(lexrc);
352                         break;
353                         
354                 case RC_KBMAP:
355                         if (lexrc.next())
356                                 use_kbmap = lexrc.GetBool();
357                         break;
358
359                 case RC_EXIT_CONFIRMATION:
360                         if (lexrc.next())
361                                 exit_confirmation = lexrc.GetBool();
362                         break;
363
364                 case RC_DISPLAY_SHORTCUTS:
365                         if (lexrc.next())
366                                 display_shortcuts = lexrc.GetBool();
367                         break;
368
369                 case RC_KBMAP_PRIMARY:
370                         if (lexrc.next())
371                                 primary_kbmap = lexrc.GetString();
372                         break;
373
374                 case RC_KBMAP_SECONDARY:
375                         if (lexrc.next())
376                                 secondary_kbmap = lexrc.GetString();
377                         break;
378                           
379                 case RC_FONT_ENCODING:
380                         if (lexrc.next())
381                                 fontenc = lexrc.GetString();
382                         break;
383                         
384                 case RC_PRINTER:
385                         if (lexrc.next())
386                                 printer = lexrc.GetString();
387                         break;
388                         
389                 case RC_PRINT_COMMAND:
390                         if (lexrc.next())
391                                 print_command = lexrc.GetString();
392                         break;
393                         
394                 case RC_PRINTEVENPAGEFLAG:
395                         if (lexrc.next())
396                                 print_evenpage_flag = lexrc.GetString();
397                         break;
398                         
399                 case RC_PRINTODDPAGEFLAG:
400                         if (lexrc.next())
401                                 print_oddpage_flag = lexrc.GetString();
402                         break;
403                         
404                 case RC_PRINTPAGERANGEFLAG:
405                         if (lexrc.next())
406                                 print_pagerange_flag = lexrc.GetString();
407                         break;
408
409                 case RC_PRINTCOPIESFLAG:
410                         if (lexrc.next())
411                                 print_copies_flag = lexrc.GetString();
412                         break;
413
414                 case RC_PRINTCOLLCOPIESFLAG:
415                         if (lexrc.next())
416                                 print_collcopies_flag = lexrc.GetString();
417                         break;
418                         
419                 case RC_PRINTREVERSEFLAG:
420                         if (lexrc.next())
421                                 print_reverse_flag = lexrc.GetString();
422                         break;
423                         
424                 case RC_PRINTLANDSCAPEFLAG:
425                         if (lexrc.next())
426                                 print_landscape_flag = lexrc.GetString();
427                         break;
428                         
429                 case RC_PRINTTOPRINTER:
430                         if (lexrc.next())
431                                 print_to_printer = lexrc.GetString();
432                         break;
433                         
434                 case RC_PRINT_ADAPTOUTPUT:
435                         if (lexrc.next())
436                                 print_adapt_output = lexrc.GetBool();
437                         break;
438                         
439                 case RC_PRINTTOFILE:
440                         if (lexrc.next())
441                                 print_to_file = lexrc.GetString();
442                         break;
443                         
444                 case RC_PRINTFILEEXTENSION:
445                         if (lexrc.next())
446                                 print_file_extension = lexrc.GetString();
447                         break;
448                         
449                 case RC_PRINTEXSTRAOPTIONS:
450                         if (lexrc.next())
451                                 print_extra_options = lexrc.GetString();
452                         break;
453                         
454                 case RC_PRINTSPOOL_COMMAND:
455                         if (lexrc.next())
456                                 print_spool_command = lexrc.GetString();
457                         break;
458                         
459                 case RC_PRINTSPOOL_PRINTERPREFIX:
460                         if (lexrc.next())
461                                 print_spool_printerprefix = lexrc.GetString();
462                         break;
463
464                 case RC_PRINTPAPERDIMENSIONFLAG:
465                         if (lexrc.next())
466                                 print_paper_dimension_flag = lexrc.GetString();
467                         break;
468
469                 case RC_PRINTPAPERFLAG:
470                         if (lexrc.next())
471                                 print_paper_flag = lexrc.GetString();
472                         break;
473                         
474                 case RC_CUSTOM_EXPORT_COMMAND:
475                         if (lexrc.next())
476                                 custom_export_command = lexrc.GetString();
477                         break;
478
479                 case RC_CUSTOM_EXPORT_FORMAT:
480                         if (lexrc.next())
481                                 custom_export_format = lexrc.GetString();
482                         break;
483                         
484                 case RC_LATEX_COMMAND:
485                         if (lexrc.next())
486                                 latex_command = lexrc.GetString();
487                         break;
488
489                 case RC_LITERATE_COMMAND:
490                         if (lexrc.next())
491                                 literate_command = lexrc.GetString();
492                         break;
493  
494                 case RC_LITERATE_EXTENSION:
495                         if (lexrc.next())
496                                 literate_extension = lexrc.GetString();
497                         break;
498
499                 case RC_LITERATE_ERROR_FILTER:
500                         if (lexrc.next())
501                                 literate_error_filter = lexrc.GetString();
502                         break;
503
504                 case RC_BUILD_COMMAND:
505                         if (lexrc.next())
506                                 build_command = lexrc.GetString();
507                         break;
508
509                 case RC_BUILD_ERROR_FILTER:
510                         if (lexrc.next())
511                                 build_error_filter = lexrc.GetString();
512                          break;
513  
514                 case RC_RELYX_COMMAND:
515                         if (lexrc.next())
516                                 relyx_command = lexrc.GetString();
517                         break;
518
519                 case RC_DEFAULT_PAPERSIZE:
520                         if (lexrc.next()) {
521                                 string size = lowercase(lexrc.GetString());
522                                 if (size == "usletter")
523                                         default_papersize = BufferParams::PAPER_USLETTER;
524                                 else if (size == "legal")
525                                         default_papersize = BufferParams::PAPER_LEGALPAPER;
526                                 else if (size == "executive")
527                                         default_papersize = BufferParams::PAPER_EXECUTIVEPAPER;
528                                 else if (size == "a3")
529                                         default_papersize = BufferParams::PAPER_A3PAPER;
530                                 else if (size == "a4")
531                                         default_papersize = BufferParams::PAPER_A4PAPER;
532                                 else if (size == "a5")
533                                         default_papersize = BufferParams::PAPER_A5PAPER;
534                                 else if (size == "b5")
535                                         default_papersize = BufferParams::PAPER_B5PAPER;
536                         }
537                         break;
538                 case RC_VIEWDVI_COMMAND:
539                         if (lexrc.next())
540                                 view_dvi_command = lexrc.GetString();
541                         break;
542
543                 case RC_PS_COMMAND:
544                         if (lexrc.next())
545                                 ps_command = lexrc.GetString();
546                         break;
547
548                 case RC_VIEWPS_COMMAND:
549                         if (lexrc.next())
550                                 view_ps_command = lexrc.GetString();
551                         break;
552
553                 case RC_VIEWPSPIC_COMMAND:
554                         if (lexrc.next())
555                                 view_pspic_command = lexrc.GetString();
556                         break;
557
558                 case RC_CHKTEX_COMMAND:
559                         if (lexrc.next())
560                                 chktex_command = lexrc.GetString();
561                         break;
562
563                 case RC_HTML_COMMAND:
564                         if (lexrc.next())
565                                 html_command = lexrc.GetString();
566                         break;
567
568                 case RC_SCREEN_DPI:
569                         if (lexrc.next())
570                                 dpi = lexrc.GetInteger();
571                         break;
572
573                 case RC_SCREEN_ZOOM:
574                         if (lexrc.next())
575                                 zoom = lexrc.GetInteger();
576                         break;
577
578                 case RC_SCREEN_FONT_SIZES:
579                         if (lexrc.next())
580                                 font_sizes[LyXFont::SIZE_TINY] =
581                                         lexrc.GetFloat();
582                         if (lexrc.next())
583                                 font_sizes[LyXFont::SIZE_SCRIPT] =
584                                         lexrc.GetFloat();
585                         if (lexrc.next())
586                                 font_sizes[LyXFont::SIZE_FOOTNOTE] =
587                                         lexrc.GetFloat();
588                         if (lexrc.next())
589                                 font_sizes[LyXFont::SIZE_SMALL] =
590                                         lexrc.GetFloat();
591                         if (lexrc.next())
592                                 font_sizes[LyXFont::SIZE_NORMAL] =
593                                         lexrc.GetFloat();
594                         if (lexrc.next())
595                                 font_sizes[LyXFont::SIZE_LARGE] =
596                                         lexrc.GetFloat();
597                         if (lexrc.next())
598                                 font_sizes[LyXFont::SIZE_LARGER] =
599                                         lexrc.GetFloat();
600                         if (lexrc.next())
601                                 font_sizes[LyXFont::SIZE_LARGEST] =
602                                         lexrc.GetFloat();
603                         if (lexrc.next())
604                                 font_sizes[LyXFont::SIZE_HUGE] =
605                                         lexrc.GetFloat();
606                         if (lexrc.next())
607                                 font_sizes[LyXFont::SIZE_HUGER] =
608                                         lexrc.GetFloat();
609                         break;
610
611                 case RC_SCREEN_FONT_SCALABLE:
612                         if (lexrc.next())
613                                 use_scalable_fonts = lexrc.GetBool();
614                         break;
615
616                 case RC_AUTOSAVE:
617                         if (lexrc.next())
618                                 autosave = lexrc.GetInteger();
619                         break;
620                         
621                 case RC_SGML_EXTRA_OPTIONS:
622                         if (lexrc.next())
623                                 sgml_extra_options = lexrc.GetString();
624                         break;
625
626                 case RC_DOCUMENTPATH:
627                         if (lexrc.next()) {
628                                 document_path = ExpandPath(lexrc.GetString());
629                         }
630                         break;
631
632                 case RC_TEMPLATEPATH:
633                         if (lexrc.next())
634                                 template_path = ExpandPath(lexrc.GetString());
635                         break;
636
637                 case RC_TEMPDIRPATH:
638                         if (lexrc.next())
639                                 tempdir_path = ExpandPath(lexrc.GetString());
640                         break;
641                         
642                 case RC_USETEMPDIR:
643                         if (lexrc.next())
644                                 use_tempdir = lexrc.GetBool();
645                         break;
646
647                 case RC_LASTFILES:
648                         if (lexrc.next())
649                                 lastfiles = ExpandPath(lexrc.GetString());
650                         break;
651
652                 case RC_NUMLASTFILES:
653                         if (lexrc.next())
654                                 num_lastfiles = lexrc.GetInteger();
655                         break;
656
657                 case RC_CHECKLASTFILES:
658                         if (lexrc.next())
659                                 check_lastfiles = lexrc.GetBool();
660                         break;
661
662                 case RC_SCREEN_FONT_ROMAN:
663                         if (lexrc.next())
664                                 roman_font_name = lexrc.GetString();
665                         break;
666
667                 case RC_SCREEN_FONT_SANS:
668                         if (lexrc.next())
669                                 sans_font_name = lexrc.GetString();
670                         break;
671
672                 case RC_SCREEN_FONT_TYPEWRITER:
673                         if (lexrc.next())
674                                 typewriter_font_name = lexrc.GetString();
675                         break;
676                         
677                 case RC_SCREEN_FONT_MENU:
678                         if (lexrc.next())
679                                 menu_font_name = lexrc.GetString();
680                         break;
681                         
682                 case RC_SCREEN_FONT_POPUP:
683                         if (lexrc.next())
684                                 popup_font_name = lexrc.GetString();
685                         break;
686                         
687                 case RC_SCREEN_FONT_ENCODING:
688                         if (lexrc.next())
689                                 font_norm = lexrc.GetString();
690                         break;
691                         
692                 case RC_AUTOREGIONDELETE:
693                         // Auto region delete defaults to true
694                         if (lexrc.next())
695                                 auto_region_delete = lexrc.GetBool();
696                         break;
697                         
698                 case RC_BIND:
699                 {
700                         // we should not do an explicit binding before
701                         // loading a bind file. So, in this case, load
702                         // the default bind file.
703                         if (!hasBindFile)
704                                 ReadBindFile();
705
706                         // !!!chb, dynamic key binding...
707                         int action, res = 0;
708                         string seq, cmd;
709
710                         if (lexrc.lex() == LyXLex::LEX_DATA)  {
711                                 seq = lexrc.GetString();
712                         } else {
713                                 lexrc.printError("Bad key sequence: `$$Token'");
714                                 break;
715                         }
716
717                         if (lexrc.lex() == LyXLex::LEX_DATA) {
718                                 cmd = lexrc.GetString();
719                         } else {
720                                 lexrc.printError("Bad command: `$$Token'");
721                                 break;
722                         }
723
724                         if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
725                                 if (lyxerr.debugging(Debug::KEY)) {
726                                         lyxerr << "RC_BIND: Sequence `"
727                                                << seq << "' Command `"
728                                                << cmd << "' Action `"
729                                                << action << '\'' << endl;
730                                 }
731                                 res = bindKey(seq.c_str(), action);
732                                 if (res != 0) {
733                                         lexrc.printError(
734                                               "Invalid key sequence `"
735                                               + seq + '\''); 
736                                 }
737                         } else {// cmd is the last token read.
738                                 lexrc.printError(
739                                             "Unknown LyX function `$$Token'");
740                         }
741                         break;
742                 }
743                 case RC_SERVERPIPE:
744                         if (lexrc.next())
745                                 lyxpipes = ExpandPath(lexrc.GetString());
746                         break;
747                         
748                 case RC_CURSOR_FOLLOWS_SCROLLBAR:
749                         if (lexrc.next())
750                                 cursor_follows_scrollbar = lexrc.GetBool();
751                         break;
752                 case RC_FAST_SELECTION:
753                         if (lexrc.next())
754                                 fast_selection = lexrc.GetBool();
755                         break;
756                 case RC_BACKGROUND_COLOR:
757                         if (lexrc.next())
758                                 background_color = lexrc.GetString();
759                         break;
760                 case RC_SELECTION_COLOR:
761                         if (lexrc.next())
762                                 strncpy(selection_color,
763                                         lexrc.GetString().c_str(), 31);
764                         break;
765                 case RC_FAX_COMMAND:
766                         if (lexrc.next())
767                                 fax_command = lexrc.GetString();
768                         break;
769                 case RC_FAXPROGRAM:
770                         if (lexrc.next())
771                                 fax_program = lexrc.GetString();
772                         break;
773                 case RC_PHONEBOOK:
774                         if (lexrc.next()) {
775                                 string s = lexrc.GetString();
776                                 if (AbsolutePath(s))
777                                         phone_book = s;
778                                 else
779                                         phone_book = user_lyxdir + s;
780                         }
781                         break;
782                 case RC_ASCIIROFF_COMMAND:
783                         if (lexrc.next())
784                             ascii_roff_command = lexrc.GetString();
785                         break;
786                 case RC_ASCII_LINELEN:
787                         if (lexrc.next())
788                             ascii_linelen = lexrc.GetInteger();
789                         break;
790                 // Spellchecker settings:
791                 case RC_SPELL_COMMAND:
792                         if (lexrc.next())
793                                 isp_command = lexrc.GetString();
794                         break;
795                 case RC_ACCEPT_COMPOUND:
796                         if (lexrc.next())
797                                 isp_accept_compound = lexrc.GetBool();
798                         break;
799                 case RC_USE_INP_ENC:
800                         if (lexrc.next())
801                                 isp_use_input_encoding = lexrc.GetBool();
802                         break;
803                 case RC_USE_ALT_LANG:
804                         if (lexrc.next())
805                                 isp_use_alt_lang = lexrc.GetBool();
806                         break;
807                 case RC_USE_PERS_DICT:
808                         if (lexrc.next())
809                                 isp_use_pers_dict = lexrc.GetBool();
810                         break;
811                 case RC_USE_ESC_CHARS:
812                         if (lexrc.next())
813                                 isp_use_esc_chars = lexrc.GetBool();
814                         break;
815                 case RC_ALT_LANG:
816                         if (lexrc.next())
817                                 isp_alt_lang = lexrc.GetString();
818                         break;
819                 case RC_PERS_DICT:
820                         if (lexrc.next())
821                                 isp_pers_dict = lexrc.GetString();
822                         break;
823                 case RC_ESC_CHARS:
824                         if (lexrc.next())
825                                 isp_esc_chars = lexrc.GetString();
826                         break;
827
828                 default:
829                         lexrc.printError("Unknown tag `$$Token'");
830                         break;
831                 }
832         }
833
834         return 0;
835 }
836
837
838 void LyXRC::Print()
839 {
840         lyxerr << "The current internal LyXRC:" << endl;
841 }
842
843
844 /// define the default key bindings for LyX.
845 void LyXRC::defaultKeyBindings()
846 {
847         bindKey("Right",   LFUN_RIGHT);
848         bindKey("Left",    LFUN_LEFT);
849         bindKey("Up",      LFUN_UP);
850         bindKey("Down",    LFUN_DOWN);
851
852         bindKey("Tab",  LFUN_TAB);
853
854         bindKey("Home",    LFUN_HOME);
855         bindKey("End",     LFUN_END);
856         bindKey("Prior",   LFUN_PRIOR);
857         bindKey("Next",    LFUN_NEXT);
858
859         bindKey("Return",  LFUN_BREAKPARAGRAPH);
860         bindKey("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
861
862         bindKey("Delete",  LFUN_DELETE);
863         bindKey("BackSpace",    LFUN_BACKSPACE);
864         // bindKeyings for transparent handling of deadkeys
865         // The keysyms are gotten from XFree86 X11R6
866         bindKey("~C-~S-~M-dead_acute",           LFUN_ACUTE);
867         bindKey("~C-~S-~M-dead_breve",           LFUN_BREVE);
868         bindKey("~C-~S-~M-dead_caron",           LFUN_CARON);
869         bindKey("~C-~S-~M-dead_cedilla",         LFUN_CEDILLA);
870         bindKey("~C-~S-~M-dead_abovering",          LFUN_CIRCLE);
871         bindKey("~C-~S-~M-dead_circumflex",      LFUN_CIRCUMFLEX);
872         bindKey("~C-~S-~M-dead_abovedot",             LFUN_DOT);
873         bindKey("~C-~S-~M-dead_grave",           LFUN_GRAVE);
874         bindKey("~C-~S-~M-dead_doubleacute",     LFUN_HUNG_UMLAUT);
875         bindKey("~C-~S-~M-dead_macron",          LFUN_MACRON);
876         // nothing with this name
877         // bindKey("~C-~S-~M-dead_special_caron",   LFUN_SPECIAL_CARON);
878         bindKey("~C-~S-~M-dead_tilde",           LFUN_TILDE);
879         bindKey("~C-~S-~M-dead_diaeresis",       LFUN_UMLAUT);
880         // nothing with this name either...
881         //bindKey("~C-~S-~M-dead_underbar",        LFUN_UNDERBAR);
882         bindKey("~C-~S-~M-dead_belowdot",        LFUN_UNDERDOT);
883         bindKey("~C-~S-~M-dead_tie",             LFUN_TIE);
884         bindKey("~C-~S-~M-dead_ogonek",           LFUN_OGONEK);
885
886         // bindings to utilize the use of the numeric keypad
887         // e.g. Num Lock set
888         bindKey("KP_0",        LFUN_SELFINSERT);
889         bindKey("KP_Decimal",  LFUN_SELFINSERT);
890         bindKey("KP_Enter",    LFUN_SELFINSERT);
891         bindKey("KP_1",        LFUN_SELFINSERT);
892         bindKey("KP_2",        LFUN_SELFINSERT);
893         bindKey("KP_3",        LFUN_SELFINSERT);
894         bindKey("KP_4",        LFUN_SELFINSERT);
895         bindKey("KP_5",        LFUN_SELFINSERT);
896         bindKey("KP_6",        LFUN_SELFINSERT);
897         bindKey("KP_Add",      LFUN_SELFINSERT);
898         bindKey("KP_7",        LFUN_SELFINSERT);
899         bindKey("KP_8",        LFUN_SELFINSERT);
900         bindKey("KP_9",        LFUN_SELFINSERT);
901         bindKey("KP_Divide",   LFUN_SELFINSERT);
902         bindKey("KP_Multiply", LFUN_SELFINSERT);
903         bindKey("KP_Subtract", LFUN_SELFINSERT);
904     
905         /* Most self-insert keys are handled in the 'default:' section of
906          * WorkAreaKeyPress - so we don't have to define them all.
907          * However keys explicit decleared as self-insert are
908          * handled seperatly (LFUN_SELFINSERT.) Lgb. */
909
910         bindKey("C-Tab",  LFUN_TABINSERT);  // ale970515
911 }