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