1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
14 #pragma implementation "lyxrc.h"
25 #include "LyXAction.h"
26 #include "lyxserver.h"
29 #include "tex-strings.h"
30 #include "support/path.h"
31 #include "support/filetools.h"
40 // this is crappy... why are those colors command line arguments and
41 // not in lyxrc?? (Matthias)
42 // Because nobody put them there. (Asger)
44 extern bool cursor_follows_scrollbar;
45 extern LyXAction lyxaction;
46 extern kb_keymap * toplevel_keymap;
55 RC_PRINTPAGERANGEFLAG,
57 RC_PRINTCOLLCOPIESFLAG,
59 RC_PRINTLANDSCAPEFLAG,
63 RC_PRINTFILEEXTENSION,
64 RC_PRINTEXSTRAOPTIONS,
65 RC_PRINTSPOOL_COMMAND,
66 RC_PRINTSPOOL_PRINTERPREFIX,
68 RC_PRINTPAPERDIMENSIONFLAG,
69 RC_CUSTOM_EXPORT_COMMAND,
70 RC_CUSTOM_EXPORT_FORMAT,
73 RC_LITERATE_EXTENSION,
74 RC_LITERATE_ERROR_FILTER,
76 RC_BUILD_ERROR_FILTER,
82 RC_SCREEN_FONT_TYPEWRITER,
85 RC_SCREEN_FONT_ENCODING,
86 RC_SCREEN_FONT_ENCODING_MENU,
96 RC_OVERRIDE_X_DEADKEYS,
107 RC_ASCIIROFF_COMMAND,
112 RC_VIEWDVI_PAPEROPTION,
113 RC_DEFAULT_PAPERSIZE,
116 RC_VIEWPSPIC_COMMAND,
123 RC_SCREEN_FONT_SCALABLE,
128 RC_CURSOR_FOLLOWS_SCROLLBAR,
129 RC_EXIT_CONFIRMATION,
130 RC_DISPLAY_SHORTCUTS,
137 RC_MARK_FOREIGN_LANGUAGE,
139 RC_LANGUAGE_AUTO_BEGIN,
140 RC_LANGUAGE_AUTO_END,
141 RC_LANGUAGE_COMMAND_BEGIN,
142 RC_LANGUAGE_COMMAND_END,
146 RC_PDF_TO_PS_COMMAND,
147 RC_DVI_TO_PS_COMMAND,
148 RC_DATE_INSERT_FORMAT,
151 RC_LINUXDOC_TO_LYX_COMMAND,
152 RC_LINUXDOC_TO_HTML_COMMAND,
153 RC_LINUXDOC_TO_LATEX_COMMAND,
154 RC_DOCBOOK_TO_DVI_COMMAND,
155 RC_DOCBOOK_TO_HTML_COMMAND,
156 RC_DOCBOOK_TO_PDF_COMMAND,
164 keyword_item lyxrcTags[] = {
165 { "\\accept_compound", RC_ACCEPT_COMPOUND },
166 { "\\alternate_language", RC_ALT_LANG },
167 { "\\ascii_linelen", RC_ASCII_LINELEN },
168 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
169 { "\\auto_number", RC_AUTO_NUMBER },
170 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
171 { "\\autosave", RC_AUTOSAVE },
172 { "\\backupdir_path", RC_BACKUPDIR_PATH },
173 { "\\bind", RC_BIND },
174 { "\\bind_file", RC_BINDFILE },
175 { "\\build_command", RC_BUILD_COMMAND },
176 { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
177 { "\\check_lastfiles", RC_CHECKLASTFILES },
178 { "\\chktex_command", RC_CHKTEX_COMMAND },
179 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
180 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
181 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
182 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
183 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
184 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
185 { "\\docbook_to_dvi_command", RC_DOCBOOK_TO_DVI_COMMAND },
186 { "\\docbook_to_html_command", RC_DOCBOOK_TO_HTML_COMMAND },
187 { "\\docbook_to_pdf_command", RC_DOCBOOK_TO_PDF_COMMAND },
188 { "\\document_path", RC_DOCUMENTPATH },
189 { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
190 { "\\escape_chars", RC_ESC_CHARS },
191 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
192 { "\\fax_command", RC_FAX_COMMAND },
193 { "\\fax_program", RC_FAXPROGRAM },
194 { "\\font_encoding", RC_FONT_ENCODING },
195 { "\\html_command", RC_HTML_COMMAND },
196 { "\\input", RC_INPUT },
197 { "\\kbmap", RC_KBMAP },
198 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
199 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
200 { "\\language_auto_begin", RC_LANGUAGE_AUTO_BEGIN },
201 { "\\language_auto_end", RC_LANGUAGE_AUTO_END },
202 { "\\language_command_begin", RC_LANGUAGE_COMMAND_BEGIN },
203 { "\\language_command_end", RC_LANGUAGE_COMMAND_END },
204 { "\\language_package", RC_LANGUAGE_PACKAGE },
205 { "\\lastfiles", RC_LASTFILES },
206 { "\\latex_command", RC_LATEX_COMMAND },
207 { "\\linuxdoc_to_html_command", RC_LINUXDOC_TO_HTML_COMMAND },
208 { "\\linuxdoc_to_latex_command", RC_LINUXDOC_TO_LATEX_COMMAND },
209 { "\\linuxdoc_to_lyx_command", RC_LINUXDOC_TO_LYX_COMMAND },
210 { "\\literate_command", RC_LITERATE_COMMAND },
211 { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
212 { "\\literate_extension", RC_LITERATE_EXTENSION },
213 { "\\make_backup", RC_MAKE_BACKUP },
214 { "\\mark_foreign_language", RC_MARK_FOREIGN_LANGUAGE },
215 { "\\new_ask_filename", RC_NEW_ASK_FILENAME },
216 { "\\num_lastfiles", RC_NUMLASTFILES },
217 { "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
218 { "\\pdf_mode", RC_PDF_MODE },
219 { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
220 { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
221 { "\\personal_dictionary", RC_PERS_DICT },
222 { "\\phone_book", RC_PHONEBOOK },
223 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
224 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
225 { "\\print_command", RC_PRINT_COMMAND },
226 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
227 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
228 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
229 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
230 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
231 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
232 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
233 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
234 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
235 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
236 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
237 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
238 { "\\print_to_file", RC_PRINTTOFILE },
239 { "\\print_to_printer", RC_PRINTTOPRINTER },
240 { "\\printer", RC_PRINTER },
241 { "\\ps_command", RC_PS_COMMAND },
242 { "\\relyx_command", RC_RELYX_COMMAND },
243 { "\\rtl", RC_RTL_SUPPORT },
244 { "\\screen_dpi", RC_SCREEN_DPI },
245 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
246 { "\\screen_font_encoding_menu", RC_SCREEN_FONT_ENCODING_MENU },
247 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
248 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
249 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
250 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
251 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
252 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
253 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
254 { "\\screen_zoom", RC_SCREEN_ZOOM },
255 { "\\serverpipe", RC_SERVERPIPE },
256 { "\\set_color", RC_SET_COLOR },
257 { "\\show_banner", RC_SHOW_BANNER },
258 { "\\spell_command", RC_SPELL_COMMAND },
259 { "\\tempdir_path", RC_TEMPDIRPATH },
260 { "\\template_path", RC_TEMPLATEPATH },
261 { "\\ui_file", RC_UIFILE },
262 { "\\use_alt_language", RC_USE_ALT_LANG },
263 { "\\use_escape_chars", RC_USE_ESC_CHARS },
264 { "\\use_gui", RC_USE_GUI },
265 { "\\use_input_encoding", RC_USE_INP_ENC },
266 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
267 { "\\use_tempdir", RC_USETEMPDIR },
268 { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
269 { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
270 { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
271 { "\\view_ps_command", RC_VIEWPS_COMMAND },
272 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND },
273 { "\\wheel_jump", RC_WHEEL_JUMP }
276 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
277 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
286 void LyXRC::setDefaults() {
288 // Get printer from the environment. If fail, use default "",
289 // assuming that everything is set up correctly.
290 printer = GetEnv("PRINTER");
291 print_adapt_output = false;
292 print_command = "dvips";
293 print_evenpage_flag = "-B";
294 print_oddpage_flag = "-A";
295 print_pagerange_flag = "-pp";
296 print_copies_flag = "-c";
297 print_collcopies_flag = "-C";
298 print_reverse_flag = "-r";
299 print_landscape_flag = "-t landscape";
300 print_to_printer = "-P";
301 print_to_file = "-o ";
302 print_file_extension = ".ps";
303 print_paper_flag = "-t";
304 print_paper_dimension_flag = "-T";
305 document_path = GetEnvPath("HOME");
306 tempdir_path = "/tmp";
309 latex_command = "latex";
310 pdflatex_command = "pdflatex";
311 pdf_to_ps_command = "pdf2ps";
312 dvi_to_ps_command = "dvips";
313 literate_command = "none";
314 literate_extension = "none";
315 literate_error_filter = "cat";
316 build_command = "make";
317 build_error_filter = "cat";
318 relyx_command = "reLyX";
320 view_ps_command = "ghostview -swap";
321 view_pspic_command = "ghostview";
322 view_dvi_command = "xdvi";
323 view_dvi_paper_option = "-paper";
324 view_pdf_command = "xpdf";
325 default_papersize = BufferParams::PAPER_USLETTER;
326 custom_export_format = "ps";
327 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
328 html_command = "tth -t";
331 // Because a screen typically is wider than a piece of paper:
334 // Default LaTeX font size:
335 font_sizes[LyXFont::SIZE_TINY] = 5.0;
336 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
337 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
338 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
339 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
340 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
341 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
342 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
343 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
344 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
345 use_scalable_fonts = true;
346 roman_font_name = "-*-times";
347 sans_font_name = "-*-helvetica";
348 typewriter_font_name = "-*-courier";
349 menu_font_name = "-*-helvetica-bold-r";
350 popup_font_name = "-*-helvetica-medium-r";
351 font_norm = "iso8859-1";
352 font_norm_type = OTHER_ENCODING;
354 override_x_deadkeys = true;
356 auto_region_delete = true;
359 check_lastfiles = true;
362 exit_confirmation = true;
363 display_shortcuts = true;
364 // Spellchecker settings:
365 isp_command = "ispell";
366 isp_accept_compound = false;
367 isp_use_input_encoding = false;
368 isp_use_alt_lang = false;
369 isp_use_pers_dict = false;
370 isp_use_esc_chars = false;
375 mark_foreign_language = true;
376 language_package = "\\usepackage{babel}";
377 language_auto_begin = true;
378 language_auto_end = true;
379 language_command_begin = "\\selectlanguage{$$lang}";
380 language_command_end = "\\selectlanguage{$$lang}";
382 new_ask_filename = false;
385 date_insert_format = "%A, %e %B %Y";
390 linuxdoc_to_latex_command="none";
391 linuxdoc_to_lyx_command="none";
392 linuxdoc_to_html_command="none";
394 docbook_to_dvi_command="none";
395 docbook_to_html_command="none";
396 docbook_to_pdf_command="none";
400 int LyXRC::ReadBindFile(string const & name)
403 string tmp = i18nLibFileSearch("bind", name, "bind");
404 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
405 int result = read(tmp);
407 lyxerr << "Error reading bind file: " << tmp << endl;
413 int LyXRC::read(string const & filename)
416 string bindFile = "cua";
418 LyXLex lexrc(lyxrcTags, lyxrcCount);
419 if (lyxerr.debugging(Debug::PARSER))
420 lexrc.printTable(lyxerr);
422 lexrc.setFile(filename);
423 if (!lexrc.IsOK()) return -2;
425 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
427 while (lexrc.IsOK()) {
428 // By using two switches we take advantage of the compiler
429 // telling us if we have missed a LyXRCTags element in
430 // the second switch.
431 // Note that this also shows a problem with LyXLex since it
432 // helps us avoid taking advantage of the strictness of the
435 int le = lexrc.lex();
437 case LyXLex::LEX_UNDEF:
438 lexrc.printError("Unknown tag `$$Token'");
440 case LyXLex::LEX_FEOF:
444 switch (static_cast<LyXRCTags>(le)) {
445 case RC_INPUT: // Include file
447 string tmp = LibFileSearch(string(),
450 lexrc.printError("Error reading "
451 "included file: "+tmp);
455 case RC_BINDFILE: // RVDK_PATCH_5
457 string tmp(lexrc.GetString());
458 if (bind_file.empty()) {
459 // we only need the name of the first
460 // bind file since that (usually)
461 // includes several others.
470 ui_file = lexrc.GetString();
474 case RC_EXIT_CONFIRMATION:
476 exit_confirmation = lexrc.GetBool();
479 case RC_DISPLAY_SHORTCUTS:
481 display_shortcuts = lexrc.GetBool();
486 use_kbmap = lexrc.GetBool();
489 case RC_KBMAP_PRIMARY:
491 string kmap(lexrc.GetString());
494 } else if (!LibFileSearch("kbd", kmap,
496 primary_kbmap = kmap;
498 lexrc.printError("LyX: Keymap `$$Token' not found");
502 case RC_KBMAP_SECONDARY:
504 string kmap(lexrc.GetString());
507 } else if (!LibFileSearch("kbd", kmap,
509 secondary_kbmap = kmap;
511 lexrc.printError("LyX: Keymap `$$Token' not found");
515 case RC_FONT_ENCODING:
517 fontenc = lexrc.GetString();
522 printer = lexrc.GetString();
525 case RC_PRINT_COMMAND:
527 print_command = lexrc.GetString();
530 case RC_PRINTEVENPAGEFLAG:
532 print_evenpage_flag = lexrc.GetString();
535 case RC_PRINTODDPAGEFLAG:
537 print_oddpage_flag = lexrc.GetString();
540 case RC_PRINTPAGERANGEFLAG:
542 print_pagerange_flag = lexrc.GetString();
545 case RC_PRINTCOPIESFLAG:
547 print_copies_flag = lexrc.GetString();
550 case RC_PRINTCOLLCOPIESFLAG:
552 print_collcopies_flag = lexrc.GetString();
555 case RC_PRINTREVERSEFLAG:
557 print_reverse_flag = lexrc.GetString();
560 case RC_PRINTLANDSCAPEFLAG:
562 print_landscape_flag = lexrc.GetString();
565 case RC_PRINTTOPRINTER:
567 print_to_printer = lexrc.GetString();
570 case RC_PRINT_ADAPTOUTPUT:
572 print_adapt_output = lexrc.GetBool();
577 print_to_file = lexrc.GetString();
580 case RC_PRINTFILEEXTENSION:
582 print_file_extension = lexrc.GetString();
585 case RC_PRINTEXSTRAOPTIONS:
587 print_extra_options = lexrc.GetString();
590 case RC_PRINTSPOOL_COMMAND:
592 print_spool_command = lexrc.GetString();
595 case RC_PRINTSPOOL_PRINTERPREFIX:
597 print_spool_printerprefix = lexrc.GetString();
600 case RC_PRINTPAPERDIMENSIONFLAG:
602 print_paper_dimension_flag = lexrc.GetString();
605 case RC_PRINTPAPERFLAG:
607 print_paper_flag = lexrc.GetString();
610 case RC_CUSTOM_EXPORT_COMMAND:
612 custom_export_command = lexrc.GetString();
615 case RC_CUSTOM_EXPORT_FORMAT:
617 custom_export_format = lexrc.GetString();
622 pdf_mode = lexrc.GetBool();
625 case RC_LATEX_COMMAND:
627 latex_command = lexrc.GetString();
630 case RC_PDFLATEX_COMMAND:
632 pdflatex_command = lexrc.GetString();
635 case RC_PDF_TO_PS_COMMAND:
637 pdf_to_ps_command = lexrc.GetString();
640 case RC_DVI_TO_PS_COMMAND:
642 dvi_to_ps_command = lexrc.GetString();
645 case RC_LITERATE_COMMAND:
647 literate_command = lexrc.GetString();
650 case RC_LITERATE_EXTENSION:
652 literate_extension = lexrc.GetString();
655 case RC_LITERATE_ERROR_FILTER:
657 literate_error_filter = lexrc.GetString();
660 case RC_BUILD_COMMAND:
662 build_command = lexrc.GetString();
665 case RC_BUILD_ERROR_FILTER:
667 build_error_filter = lexrc.GetString();
670 case RC_RELYX_COMMAND:
672 relyx_command = lexrc.GetString();
675 case RC_DEFAULT_PAPERSIZE:
677 string size = lowercase(lexrc.GetString());
678 if (size == "usletter")
680 BufferParams::PAPER_USLETTER;
681 else if (size == "legal")
683 BufferParams::PAPER_LEGALPAPER;
684 else if (size == "executive")
686 BufferParams::PAPER_EXECUTIVEPAPER;
687 else if (size == "a3")
689 BufferParams::PAPER_A3PAPER;
690 else if (size == "a4")
692 BufferParams::PAPER_A4PAPER;
693 else if (size == "a5")
695 BufferParams::PAPER_A5PAPER;
696 else if (size == "b5")
698 BufferParams::PAPER_B5PAPER;
701 case RC_VIEWDVI_COMMAND:
703 view_dvi_command = lexrc.GetString();
706 case RC_VIEWDVI_PAPEROPTION:
708 view_dvi_paper_option = lexrc.GetString();
710 view_dvi_paper_option = "";
713 case RC_VIEWPDF_COMMAND:
715 view_pdf_command = lexrc.GetString();
720 ps_command = lexrc.GetString();
723 case RC_VIEWPS_COMMAND:
725 view_ps_command = lexrc.GetString();
728 case RC_VIEWPSPIC_COMMAND:
730 view_pspic_command = lexrc.GetString();
733 case RC_CHKTEX_COMMAND:
735 chktex_command = lexrc.GetString();
738 case RC_HTML_COMMAND:
740 html_command = lexrc.GetString();
745 dpi = lexrc.GetInteger();
750 zoom = lexrc.GetInteger();
755 wheel_jump = lexrc.GetInteger();
758 case RC_SCREEN_FONT_SIZES:
760 font_sizes[LyXFont::SIZE_TINY] =
763 font_sizes[LyXFont::SIZE_SCRIPT] =
766 font_sizes[LyXFont::SIZE_FOOTNOTE] =
769 font_sizes[LyXFont::SIZE_SMALL] =
772 font_sizes[LyXFont::SIZE_NORMAL] =
775 font_sizes[LyXFont::SIZE_LARGE] =
778 font_sizes[LyXFont::SIZE_LARGER] =
781 font_sizes[LyXFont::SIZE_LARGEST] =
784 font_sizes[LyXFont::SIZE_HUGE] =
787 font_sizes[LyXFont::SIZE_HUGER] =
791 case RC_SCREEN_FONT_SCALABLE:
793 use_scalable_fonts = lexrc.GetBool();
798 autosave = lexrc.GetInteger();
801 case RC_DOCUMENTPATH:
803 document_path = ExpandPath(lexrc.GetString());
807 case RC_TEMPLATEPATH:
809 template_path = ExpandPath(lexrc.GetString());
814 tempdir_path = ExpandPath(lexrc.GetString());
819 use_tempdir = lexrc.GetBool();
824 lastfiles = ExpandPath(lexrc.GetString());
827 case RC_NUMLASTFILES:
829 num_lastfiles = lexrc.GetInteger();
832 case RC_CHECKLASTFILES:
834 check_lastfiles = lexrc.GetBool();
837 case RC_SCREEN_FONT_ROMAN:
839 roman_font_name = lexrc.GetString();
842 case RC_SCREEN_FONT_SANS:
844 sans_font_name = lexrc.GetString();
847 case RC_SCREEN_FONT_TYPEWRITER:
849 typewriter_font_name = lexrc.GetString();
852 case RC_SCREEN_FONT_MENU:
854 menu_font_name = lexrc.GetString();
857 case RC_SCREEN_FONT_POPUP:
859 popup_font_name = lexrc.GetString();
862 case RC_SCREEN_FONT_ENCODING:
864 font_norm = lexrc.GetString();
865 set_font_norm_type();
869 case RC_SCREEN_FONT_ENCODING_MENU:
871 font_norm_menu = lexrc.GetString();
876 string lyx_name, x11_name;
879 lyx_name = lexrc.GetString();
881 lexrc.printError("Missing color tag.");
886 x11_name = lexrc.GetString();
888 lexrc.printError("Missing color name for color : `$$Token'");
892 if (!lcolor.setColor(lyx_name, x11_name))
893 lyxerr << "Bad lyxrc set_color for "
898 case RC_AUTOREGIONDELETE:
899 // Auto region delete defaults to true
901 auto_region_delete = lexrc.GetBool();
906 // we should not do an explicit binding before
907 // loading a bind file. So, in this case, load
908 // the default bind file.
911 bind_file = bindFile;
913 // !!!chb, dynamic key binding...
917 if (lexrc.lex() == LyXLex::LEX_DATA) {
918 seq = lexrc.GetString();
920 lexrc.printError("Bad key sequence: `$$Token'");
924 if (lexrc.lex() == LyXLex::LEX_DATA) {
925 cmd = lexrc.GetString();
927 lexrc.printError("Bad command: `$$Token'");
931 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
932 if (lyxerr.debugging(Debug::KEY)) {
933 lyxerr << "RC_BIND: Sequence `"
934 << seq << "' Command `"
935 << cmd << "' Action `"
936 << action << '\'' << endl;
938 res = toplevel_keymap->bind(seq.c_str(),
942 "Invalid key sequence `"
945 } else {// cmd is the last token read.
947 "Unknown LyX function `$$Token'");
951 case RC_OVERRIDE_X_DEADKEYS:
953 override_x_deadkeys = lexrc.GetBool();
958 lyxpipes = ExpandPath(lexrc.GetString());
961 case RC_CURSOR_FOLLOWS_SCROLLBAR:
963 cursor_follows_scrollbar = lexrc.GetBool();
968 fax_command = lexrc.GetString();
972 fax_program = lexrc.GetString();
976 string s = lexrc.GetString();
980 phone_book = user_lyxdir + s;
983 case RC_ASCIIROFF_COMMAND:
985 ascii_roff_command = lexrc.GetString();
987 case RC_ASCII_LINELEN:
989 ascii_linelen = lexrc.GetInteger();
991 // Spellchecker settings:
992 case RC_SPELL_COMMAND:
994 isp_command = lexrc.GetString();
996 case RC_ACCEPT_COMPOUND:
998 isp_accept_compound = lexrc.GetBool();
1000 case RC_USE_INP_ENC:
1002 isp_use_input_encoding = lexrc.GetBool();
1004 case RC_USE_ALT_LANG:
1006 isp_use_alt_lang = lexrc.GetBool();
1008 case RC_USE_PERS_DICT:
1010 isp_use_pers_dict = lexrc.GetBool();
1012 case RC_USE_ESC_CHARS:
1014 isp_use_esc_chars = lexrc.GetBool();
1018 isp_alt_lang = lexrc.GetString();
1022 isp_pers_dict = lexrc.GetString();
1026 isp_esc_chars = lexrc.GetString();
1028 case RC_MAKE_BACKUP:
1030 make_backup = lexrc.GetBool();
1032 case RC_BACKUPDIR_PATH:
1034 backupdir_path = ExpandPath(lexrc.GetString());
1036 case RC_DATE_INSERT_FORMAT:
1038 date_insert_format = lexrc.GetString();
1040 case RC_LANGUAGE_PACKAGE:
1042 language_package = lexrc.GetString();
1044 case RC_LANGUAGE_AUTO_BEGIN:
1046 language_auto_begin = lexrc.GetBool();
1048 case RC_LANGUAGE_AUTO_END:
1050 language_auto_end = lexrc.GetBool();
1052 case RC_LANGUAGE_COMMAND_BEGIN:
1054 language_command_begin = lexrc.GetString();
1056 case RC_LANGUAGE_COMMAND_END:
1058 language_command_end = lexrc.GetString();
1060 case RC_RTL_SUPPORT:
1062 rtl_support = lexrc.GetBool();
1064 case RC_AUTO_NUMBER:
1066 auto_number = lexrc.GetBool();
1068 case RC_MARK_FOREIGN_LANGUAGE:
1070 mark_foreign_language = lexrc.GetBool();
1072 case RC_SHOW_BANNER:
1074 show_banner = lexrc.GetBool();
1078 use_gui = lexrc.GetBool();
1080 case RC_LINUXDOC_TO_LYX_COMMAND:
1082 linuxdoc_to_lyx_command = lexrc.GetString();
1084 case RC_LINUXDOC_TO_HTML_COMMAND:
1086 linuxdoc_to_html_command = lexrc.GetString();
1088 case RC_LINUXDOC_TO_LATEX_COMMAND:
1090 linuxdoc_to_latex_command = lexrc.GetString();
1092 case RC_DOCBOOK_TO_DVI_COMMAND:
1094 docbook_to_dvi_command = lexrc.GetString();
1096 case RC_DOCBOOK_TO_HTML_COMMAND:
1098 docbook_to_html_command = lexrc.GetString();
1100 case RC_DOCBOOK_TO_PDF_COMMAND:
1102 docbook_to_pdf_command = lexrc.GetString();
1105 case RC_NEW_ASK_FILENAME:
1107 new_ask_filename = lexrc.GetBool();
1110 case RC_LAST: break; // this is just a dummy
1118 void LyXRC::write(string const & filename) const
1120 ofstream ofs(filename.c_str());
1126 void LyXRC::print() const
1128 if (lyxerr.debugging())
1135 void LyXRC::output(ostream & os) const
1137 os << "### This file is part of\n"
1138 << "### ========================================================\n"
1139 << "### LyX, The Document Processor\n"
1141 << "### Copyright 1995 Matthias Ettrich\n"
1142 << "### Copyright 1995-2000 The LyX Team.\n"
1144 << "### ========================================================\n"
1146 << "# This file is written by LyX, if you want to make your own\n"
1147 << "# modifications you should do them from inside LyX and save\n"
1150 // Why the switch you might ask. It is a trick to ensure that all
1151 // the elements in the LyXRCTags enum is handled. As you can see
1152 // there are no breaks at all. So it is just a huge fall-through.
1153 // The nice thing is that we will get a warning from the compiler
1154 // if we forget an element.
1155 LyXRCTags tag = RC_LAST;
1159 // input/include files are not done here
1161 // bindings is not written to the preferences file.
1163 os << "\\bind_file " << bind_file << "\n";
1169 << "# MISC SECTION ######################################\n"
1172 case RC_SHOW_BANNER:
1173 os << "# Set to false to inhibit the startup banner.\n"
1174 << "\\show_banner " << tostr(show_banner) << "\n";
1176 // bind files are not done here.
1178 os << "\\ui_file \"" << ui_file << "\"\n";
1179 case RC_AUTOREGIONDELETE:
1180 os << "# Set to false to inhibit automatic replacement of\n"
1181 << "# the current selection.\n"
1182 << "\\auto_region_delete " << tostr(auto_region_delete)
1185 os << "# The time interval between auto-saves in seconds.\n"
1186 << "\\autosave " << autosave << "\n";
1187 case RC_EXIT_CONFIRMATION:
1188 os << "# Ask for confirmation before exit if there are\n"
1189 << "# unsaved changed documents.\n"
1190 << "\\exit_confirmation " << tostr(exit_confirmation)
1192 case RC_DISPLAY_SHORTCUTS:
1193 os << "# Display name of the last command executed, with a\n"
1194 << "# list of short-cuts in the minibuffer.\n"
1195 << "\\display_shortcuts " << tostr(display_shortcuts)
1197 case RC_VIEWDVI_COMMAND:
1198 os << "# Program used to view dvi files.\n"
1199 << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1200 case RC_VIEWDVI_PAPEROPTION:
1201 os << "# Options used to specify paper size to the\n"
1202 << "# view_dvi_command\n"
1203 << "\\view_dvi_paper_option \""
1204 << view_dvi_paper_option << "\"\n";
1205 case RC_DEFAULT_PAPERSIZE:
1206 os << "# The default papersize to use.\n"
1207 << "\\default_papersize \"";
1208 switch (default_papersize) {
1209 case BufferParams::PAPER_USLETTER:
1210 os << "usletter"; break;
1211 case BufferParams::PAPER_LEGALPAPER:
1212 os << "legal"; break;
1213 case BufferParams::PAPER_EXECUTIVEPAPER:
1214 os << "executive"; break;
1215 case BufferParams::PAPER_A3PAPER:
1217 case BufferParams::PAPER_A4PAPER:
1219 case BufferParams::PAPER_A5PAPER:
1221 case BufferParams::PAPER_B5PAPER:
1223 case BufferParams::PAPER_DEFAULT: break;
1226 case RC_VIEWPDF_COMMAND:
1227 os << "# Command used to view PDF files.\n"
1228 << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1229 case RC_VIEWPS_COMMAND:
1230 os << "# Command used to view PostScript files.\n"
1231 << "\\view_ps_command \"" << view_ps_command << "\"\n";
1232 case RC_VIEWPSPIC_COMMAND:
1233 os << "# Command used to view full screen included PS\n"
1235 << "\\view_pspic_command \"" << view_pspic_command
1238 os << "# Program used for interpreting postscript.\n"
1239 << "\\ps_command \"" << ps_command << "\"\n";
1240 case RC_CHKTEX_COMMAND:
1241 os << "\\chktex_command \"" << chktex_command << "\"\n";
1242 case RC_HTML_COMMAND:
1243 os << "\\html_command \"" << html_command << "\"\n";
1245 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1246 case RC_KBMAP_PRIMARY:
1247 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1248 case RC_KBMAP_SECONDARY:
1249 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1251 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1252 case RC_RELYX_COMMAND:
1253 os << "\\relyx_command \"" << relyx_command << "\"\n";
1254 case RC_DATE_INSERT_FORMAT:
1255 os << "\\date_insert_format \"" << date_insert_format
1260 << "# SCREEN & FONTS SECTION ############################\n"
1264 os << "\\screen_dpi " << dpi << "\n";
1265 case RC_SCREEN_ZOOM:
1266 os << "\\screen_zoom " << zoom << "\n";
1268 os << "\\wheel_jump " << wheel_jump << "\n";
1269 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1270 os << "\\cursor_follows_scrollbar "
1271 << tostr(cursor_follows_scrollbar) << "\n";
1272 case RC_SCREEN_FONT_ROMAN:
1273 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1274 case RC_SCREEN_FONT_SANS:
1275 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1276 case RC_SCREEN_FONT_TYPEWRITER:
1277 os << "\\screen_font_typewriter \""
1278 << typewriter_font_name << "\"\n";
1279 case RC_SCREEN_FONT_SCALABLE:
1280 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1282 case RC_SCREEN_FONT_ENCODING:
1283 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1284 case RC_SCREEN_FONT_POPUP:
1285 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1286 case RC_SCREEN_FONT_MENU:
1287 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1288 case RC_SCREEN_FONT_SIZES:
1289 os.setf(ios::fixed);
1291 os << "\\screen_font_sizes";
1292 os << " " << font_sizes[LyXFont::SIZE_TINY];
1293 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1294 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1295 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1296 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1297 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1298 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1299 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1300 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1301 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1303 //case RC_SET_COLOR:
1304 // color bindings not written to preference file.
1305 // And we want to be warned about that. (Lgb)
1308 << "# PRINTER SECTION ###################################\n"
1312 os << "\\printer \"" << printer << "\"\n";
1313 case RC_PRINT_ADAPTOUTPUT:
1314 os << "\\print_adapt_output " << tostr(print_adapt_output)
1316 case RC_PRINT_COMMAND:
1317 os << "\\print_command \"" << print_command << "\"\n";
1318 case RC_PRINTEXSTRAOPTIONS:
1319 os << "\\print_extra_options \"" << print_extra_options
1321 case RC_PRINTSPOOL_COMMAND:
1322 os << "\\print_spool_command \"" << print_spool_command
1324 case RC_PRINTSPOOL_PRINTERPREFIX:
1325 os << "\\print_spool_printerprefix \""
1326 << print_spool_printerprefix << "\"\n";
1327 case RC_PRINTEVENPAGEFLAG:
1328 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1330 case RC_PRINTODDPAGEFLAG:
1331 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1333 case RC_PRINTREVERSEFLAG:
1334 os << "\\print_reverse_flag \"" << print_reverse_flag
1336 case RC_PRINTLANDSCAPEFLAG:
1337 os << "\\print_landscape_flag \"" << print_landscape_flag
1339 case RC_PRINTPAGERANGEFLAG:
1340 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1342 case RC_PRINTCOPIESFLAG:
1343 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1344 case RC_PRINTCOLLCOPIESFLAG:
1345 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1347 case RC_PRINTPAPERFLAG:
1348 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1349 case RC_PRINTPAPERDIMENSIONFLAG:
1350 os << "\\print_paper_dimension_flag \""
1351 << print_paper_dimension_flag << "\"\n";
1352 case RC_PRINTTOPRINTER:
1353 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1354 case RC_PRINTTOFILE:
1355 os << "\\print_to_file \"" << print_to_file << "\"\n";
1356 case RC_PRINTFILEEXTENSION:
1357 os << "\\print_file_extension \"" << print_file_extension
1361 << "# EXPORT SECTION ####################################\n"
1364 case RC_CUSTOM_EXPORT_COMMAND:
1365 os << "\\custom_export_command \"" << custom_export_command
1367 case RC_CUSTOM_EXPORT_FORMAT:
1368 os << "\\custom_export_format \"" << custom_export_format
1372 << "# TEX SECTION #######################################\n"
1375 case RC_LATEX_COMMAND:
1376 os << "\\latex_command \"" << latex_command << "\"\n";
1377 case RC_PDFLATEX_COMMAND:
1378 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1380 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1381 case RC_FONT_ENCODING:
1382 os << "\\font_encoding \"" << fontenc << "\"\n";
1385 << "# LINUXDOC SECTION ##################################\n"
1388 case RC_LINUXDOC_TO_LATEX_COMMAND:
1389 os << "\\linuxdoc_to_latex_command \"" << linuxdoc_to_latex_command
1391 case RC_LINUXDOC_TO_HTML_COMMAND:
1392 os << "\\linuxdoc_to_html_command \"" << linuxdoc_to_html_command
1394 case RC_LINUXDOC_TO_LYX_COMMAND:
1395 os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command
1399 << "# DOCBOOK SECTION ###################################\n"
1402 case RC_DOCBOOK_TO_DVI_COMMAND:
1403 os << "\\docbook_to_dvi_command \"" << docbook_to_dvi_command
1405 case RC_DOCBOOK_TO_HTML_COMMAND:
1406 os << "\\docbook_to_html_command \"" << docbook_to_html_command
1408 case RC_DOCBOOK_TO_PDF_COMMAND:
1409 os << "\\docbook_to_pdf_command \"" << docbook_to_pdf_command
1413 << "# FILE SECTION ######################################\n"
1416 case RC_DOCUMENTPATH:
1417 os << "\\document_path \"" << document_path << "\"\n";
1419 os << "\\lastfiles \"" << lastfiles << "\"\n";
1420 case RC_NUMLASTFILES:
1421 os << "\\num_lastfiles " << num_lastfiles << "\n";
1422 case RC_CHECKLASTFILES:
1423 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1424 case RC_TEMPLATEPATH:
1425 os << "\\template_path \"" << template_path << "\"\n";
1426 case RC_TEMPDIRPATH:
1427 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1429 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1430 case RC_ASCII_LINELEN:
1431 os << "\\ascii_linelen " << ascii_linelen << "\n";
1432 case RC_MAKE_BACKUP:
1433 os << "\\make_backup " << tostr(make_backup) << "\n";
1434 case RC_BACKUPDIR_PATH:
1435 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1438 << "# FAX SECTION #######################################\n"
1441 case RC_FAX_COMMAND:
1442 os << "\\fax_command \"" << fax_command << "\"\n";
1444 os << "\\phone_book \"" << phone_book << "\"\n";
1446 os << "\\fax_program \"" << fax_program << "\"\n";
1449 << "# ASCII EXPORT SECTION ##############################\n"
1452 case RC_ASCIIROFF_COMMAND:
1453 os << "\\ascii_roff_command \"" << ascii_roff_command
1457 << "# SPELLCHECKER SECTION ##############################\n"
1460 case RC_SPELL_COMMAND:
1461 os << "\\spell_command \"" << isp_command << "\"\n";
1462 case RC_ACCEPT_COMPOUND:
1463 os << "\\accept_compound " << tostr(isp_accept_compound)
1465 case RC_USE_ALT_LANG:
1466 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1468 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1469 case RC_USE_ESC_CHARS:
1470 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1473 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1474 case RC_USE_PERS_DICT:
1475 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1478 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1479 case RC_USE_INP_ENC:
1480 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1484 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1487 case RC_RTL_SUPPORT:
1488 os << "\\rtl " << tostr(rtl_support) << "\n";
1489 case RC_LANGUAGE_PACKAGE:
1490 os << "\\language_package \"" << language_package << "\"\n";
1491 case RC_LANGUAGE_COMMAND_BEGIN:
1492 os << "\\language_command_begin \"" << language_command_begin
1494 case RC_LANGUAGE_COMMAND_END:
1495 os << "\\language_command_end \"" << language_command_end
1497 case RC_LANGUAGE_AUTO_BEGIN:
1498 os << "\\language_auto_begin "
1499 << tostr(language_auto_begin) << "\n";
1500 case RC_LANGUAGE_AUTO_END:
1501 os << "\\language_auto_end "
1502 << tostr(language_auto_end) << "\n";
1503 case RC_MARK_FOREIGN_LANGUAGE:
1504 os << "\\mark_foreign_language " <<
1505 tostr(mark_foreign_language) << "\n";
1508 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1511 case RC_PDF_TO_PS_COMMAND:
1512 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1513 case RC_DVI_TO_PS_COMMAND:
1514 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1515 case RC_LITERATE_COMMAND:
1516 os << "\\literate_command \"" << literate_command << "\"\n";
1517 case RC_LITERATE_EXTENSION:
1518 os << "\\literate_extension \"" << literate_extension
1520 case RC_LITERATE_ERROR_FILTER:
1521 os << "\\literate_error_filter \"" << literate_error_filter
1523 case RC_BUILD_COMMAND:
1524 os << "\\build_command \"" << build_command << "\"\n";
1525 case RC_BUILD_ERROR_FILTER:
1526 os << "\\build_error_filter \"" << build_error_filter
1528 case RC_OVERRIDE_X_DEADKEYS:
1529 os << "\\override_x_deadkeys "
1530 << tostr(override_x_deadkeys) << "\n";
1531 case RC_SCREEN_FONT_ENCODING_MENU:
1532 os << "\\screen_font_encoding_menu \"" << font_norm_menu
1534 case RC_AUTO_NUMBER:
1535 os << "\\auto_number " << tostr(auto_number) << "\n";
1537 os << "\\use_gui " << tostr(use_gui) << "\n";
1538 case RC_NEW_ASK_FILENAME:
1539 os << "\\new_ask_filename " << tostr(new_ask_filename) << "\n";
1544 void LyXRC::set_font_norm_type()
1546 if (font_norm == "iso10646-1")
1547 font_norm_type = ISO_10646_1;
1548 else if (font_norm == "iso8859-6.8x")
1549 font_norm_type = ISO_8859_6_8;
1551 font_norm_type = OTHER_ENCODING;
1554 // The global instance
1557 // The global copy of the system lyxrc entries (everything except preferences)
1558 //LyXRC system_lyxrc;