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