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,
163 keyword_item lyxrcTags[] = {
164 { "\\accept_compound", RC_ACCEPT_COMPOUND },
165 { "\\alternate_language", RC_ALT_LANG },
166 { "\\ascii_linelen", RC_ASCII_LINELEN },
167 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
168 { "\\auto_number", RC_AUTO_NUMBER },
169 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
170 { "\\autosave", RC_AUTOSAVE },
171 { "\\backupdir_path", RC_BACKUPDIR_PATH },
172 { "\\bind", RC_BIND },
173 { "\\bind_file", RC_BINDFILE },
174 { "\\build_command", RC_BUILD_COMMAND },
175 { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
176 { "\\check_lastfiles", RC_CHECKLASTFILES },
177 { "\\chktex_command", RC_CHKTEX_COMMAND },
178 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
179 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
180 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
181 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
182 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
183 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
184 { "\\docbook_to_dvi_command", RC_DOCBOOK_TO_DVI_COMMAND },
185 { "\\docbook_to_html_command", RC_DOCBOOK_TO_HTML_COMMAND },
186 { "\\docbook_to_pdf_command", RC_DOCBOOK_TO_PDF_COMMAND },
187 { "\\document_path", RC_DOCUMENTPATH },
188 { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
189 { "\\escape_chars", RC_ESC_CHARS },
190 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
191 { "\\fax_command", RC_FAX_COMMAND },
192 { "\\fax_program", RC_FAXPROGRAM },
193 { "\\font_encoding", RC_FONT_ENCODING },
194 { "\\html_command", RC_HTML_COMMAND },
195 { "\\input", RC_INPUT },
196 { "\\kbmap", RC_KBMAP },
197 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
198 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
199 { "\\language_auto_begin", RC_LANGUAGE_AUTO_BEGIN },
200 { "\\language_auto_end", RC_LANGUAGE_AUTO_END },
201 { "\\language_command_begin", RC_LANGUAGE_COMMAND_BEGIN },
202 { "\\language_command_end", RC_LANGUAGE_COMMAND_END },
203 { "\\language_package", RC_LANGUAGE_PACKAGE },
204 { "\\lastfiles", RC_LASTFILES },
205 { "\\latex_command", RC_LATEX_COMMAND },
206 { "\\linuxdoc_to_html_command", RC_LINUXDOC_TO_HTML_COMMAND },
207 { "\\linuxdoc_to_latex_command", RC_LINUXDOC_TO_LATEX_COMMAND },
208 { "\\linuxdoc_to_lyx_command", RC_LINUXDOC_TO_LYX_COMMAND },
209 { "\\literate_command", RC_LITERATE_COMMAND },
210 { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
211 { "\\literate_extension", RC_LITERATE_EXTENSION },
212 { "\\make_backup", RC_MAKE_BACKUP },
213 { "\\mark_foreign_language", RC_MARK_FOREIGN_LANGUAGE },
214 { "\\num_lastfiles", RC_NUMLASTFILES },
215 { "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
216 { "\\pdf_mode", RC_PDF_MODE },
217 { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
218 { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
219 { "\\personal_dictionary", RC_PERS_DICT },
220 { "\\phone_book", RC_PHONEBOOK },
221 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
222 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
223 { "\\print_command", RC_PRINT_COMMAND },
224 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
225 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
226 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
227 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
228 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
229 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
230 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
231 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
232 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
233 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
234 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
235 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
236 { "\\print_to_file", RC_PRINTTOFILE },
237 { "\\print_to_printer", RC_PRINTTOPRINTER },
238 { "\\printer", RC_PRINTER },
239 { "\\ps_command", RC_PS_COMMAND },
240 { "\\relyx_command", RC_RELYX_COMMAND },
241 { "\\rtl", RC_RTL_SUPPORT },
242 { "\\screen_dpi", RC_SCREEN_DPI },
243 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
244 { "\\screen_font_encoding_menu", RC_SCREEN_FONT_ENCODING_MENU },
245 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
246 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
247 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
248 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
249 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
250 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
251 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
252 { "\\screen_zoom", RC_SCREEN_ZOOM },
253 { "\\serverpipe", RC_SERVERPIPE },
254 { "\\set_color", RC_SET_COLOR },
255 { "\\show_banner", RC_SHOW_BANNER },
256 { "\\spell_command", RC_SPELL_COMMAND },
257 { "\\tempdir_path", RC_TEMPDIRPATH },
258 { "\\template_path", RC_TEMPLATEPATH },
259 { "\\ui_file", RC_UIFILE },
260 { "\\use_alt_language", RC_USE_ALT_LANG },
261 { "\\use_escape_chars", RC_USE_ESC_CHARS },
262 { "\\use_gui", RC_USE_GUI },
263 { "\\use_input_encoding", RC_USE_INP_ENC },
264 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
265 { "\\use_tempdir", RC_USETEMPDIR },
266 { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
267 { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
268 { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
269 { "\\view_ps_command", RC_VIEWPS_COMMAND },
270 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND },
271 { "\\wheel_jump", RC_WHEEL_JUMP }
274 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
275 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
284 void LyXRC::setDefaults() {
286 // Get printer from the environment. If fail, use default "",
287 // assuming that everything is set up correctly.
288 printer = GetEnv("PRINTER");
289 print_adapt_output = false;
290 print_command = "dvips";
291 print_evenpage_flag = "-B";
292 print_oddpage_flag = "-A";
293 print_pagerange_flag = "-pp";
294 print_copies_flag = "-c";
295 print_collcopies_flag = "-C";
296 print_reverse_flag = "-r";
297 print_landscape_flag = "-t landscape";
298 print_to_printer = "-P";
299 print_to_file = "-o ";
300 print_file_extension = ".ps";
301 print_paper_flag = "-t";
302 print_paper_dimension_flag = "-T";
303 document_path = GetEnvPath("HOME");
304 tempdir_path = "/tmp";
307 latex_command = "latex";
308 pdflatex_command = "pdflatex";
309 pdf_to_ps_command = "pdf2ps";
310 dvi_to_ps_command = "dvips";
311 literate_command = "none";
312 literate_extension = "none";
313 literate_error_filter = "cat";
314 build_command = "make";
315 build_error_filter = "cat";
316 relyx_command = "reLyX";
318 view_ps_command = "ghostview -swap";
319 view_pspic_command = "ghostview";
320 view_dvi_command = "xdvi";
321 view_dvi_paper_option = "-paper";
322 view_pdf_command = "xpdf";
323 default_papersize = BufferParams::PAPER_USLETTER;
324 custom_export_format = "ps";
325 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
326 html_command = "tth -t";
329 // Because a screen typically is wider than a piece of paper:
332 // Default LaTeX font size:
333 font_sizes[LyXFont::SIZE_TINY] = 5.0;
334 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
335 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
336 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
337 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
338 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
339 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
340 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
341 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
342 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
343 use_scalable_fonts = true;
344 roman_font_name = "-*-times";
345 sans_font_name = "-*-helvetica";
346 typewriter_font_name = "-*-courier";
347 menu_font_name = "-*-helvetica-bold-r";
348 popup_font_name = "-*-helvetica-medium-r";
349 font_norm = "iso8859-1";
350 font_norm_type = OTHER_ENCODING;
352 override_x_deadkeys = true;
354 auto_region_delete = true;
357 check_lastfiles = true;
360 exit_confirmation = true;
361 display_shortcuts = true;
362 // Spellchecker settings:
363 isp_command = "ispell";
364 isp_accept_compound = false;
365 isp_use_input_encoding = false;
366 isp_use_alt_lang = false;
367 isp_use_pers_dict = false;
368 isp_use_esc_chars = false;
373 mark_foreign_language = true;
374 language_package = "\\usepackage{babel}";
375 language_auto_begin = true;
376 language_auto_end = true;
377 language_command_begin = "\\selectlanguage{$$lang}";
378 language_command_end = "\\selectlanguage{$$lang}";
381 date_insert_format = "%A, %e %B %Y";
386 linuxdoc_to_latex_command="none";
387 linuxdoc_to_lyx_command="none";
388 linuxdoc_to_html_command="none";
390 docbook_to_dvi_command="none";
391 docbook_to_html_command="none";
392 docbook_to_pdf_command="none";
396 int LyXRC::ReadBindFile(string const & name)
399 string tmp = i18nLibFileSearch("bind", name, "bind");
400 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
401 int result = read(tmp);
403 lyxerr << "Error reading bind file: " << tmp << endl;
409 int LyXRC::read(string const & filename)
412 string bindFile = "cua";
414 LyXLex lexrc(lyxrcTags, lyxrcCount);
415 if (lyxerr.debugging(Debug::PARSER))
416 lexrc.printTable(lyxerr);
418 lexrc.setFile(filename);
419 if (!lexrc.IsOK()) return -2;
421 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
423 while (lexrc.IsOK()) {
424 // By using two switches we take advantage of the compiler
425 // telling us if we have missed a LyXRCTags element in
426 // the second switch.
427 // Note that this also shows a problem with LyXLex since it
428 // helps us avoid taking advantage of the strictness of the
431 int le = lexrc.lex();
433 case LyXLex::LEX_UNDEF:
434 lexrc.printError("Unknown tag `$$Token'");
436 case LyXLex::LEX_FEOF:
440 switch (static_cast<LyXRCTags>(le)) {
441 case RC_INPUT: // Include file
443 string tmp = LibFileSearch(string(),
446 lexrc.printError("Error reading "
447 "included file: "+tmp);
451 case RC_BINDFILE: // RVDK_PATCH_5
453 string tmp(lexrc.GetString());
454 if (bind_file.empty()) {
455 // we only need the name of the first
456 // bind file since that (usually)
457 // includes several others.
466 ui_file = lexrc.GetString();
470 case RC_EXIT_CONFIRMATION:
472 exit_confirmation = lexrc.GetBool();
475 case RC_DISPLAY_SHORTCUTS:
477 display_shortcuts = lexrc.GetBool();
482 use_kbmap = lexrc.GetBool();
485 case RC_KBMAP_PRIMARY:
487 string kmap(lexrc.GetString());
490 } else if (!LibFileSearch("kbd", kmap,
492 primary_kbmap = kmap;
494 lexrc.printError("LyX: Keymap `$$Token' not found");
498 case RC_KBMAP_SECONDARY:
500 string kmap(lexrc.GetString());
503 } else if (!LibFileSearch("kbd", kmap,
505 secondary_kbmap = kmap;
507 lexrc.printError("LyX: Keymap `$$Token' not found");
511 case RC_FONT_ENCODING:
513 fontenc = lexrc.GetString();
518 printer = lexrc.GetString();
521 case RC_PRINT_COMMAND:
523 print_command = lexrc.GetString();
526 case RC_PRINTEVENPAGEFLAG:
528 print_evenpage_flag = lexrc.GetString();
531 case RC_PRINTODDPAGEFLAG:
533 print_oddpage_flag = lexrc.GetString();
536 case RC_PRINTPAGERANGEFLAG:
538 print_pagerange_flag = lexrc.GetString();
541 case RC_PRINTCOPIESFLAG:
543 print_copies_flag = lexrc.GetString();
546 case RC_PRINTCOLLCOPIESFLAG:
548 print_collcopies_flag = lexrc.GetString();
551 case RC_PRINTREVERSEFLAG:
553 print_reverse_flag = lexrc.GetString();
556 case RC_PRINTLANDSCAPEFLAG:
558 print_landscape_flag = lexrc.GetString();
561 case RC_PRINTTOPRINTER:
563 print_to_printer = lexrc.GetString();
566 case RC_PRINT_ADAPTOUTPUT:
568 print_adapt_output = lexrc.GetBool();
573 print_to_file = lexrc.GetString();
576 case RC_PRINTFILEEXTENSION:
578 print_file_extension = lexrc.GetString();
581 case RC_PRINTEXSTRAOPTIONS:
583 print_extra_options = lexrc.GetString();
586 case RC_PRINTSPOOL_COMMAND:
588 print_spool_command = lexrc.GetString();
591 case RC_PRINTSPOOL_PRINTERPREFIX:
593 print_spool_printerprefix = lexrc.GetString();
596 case RC_PRINTPAPERDIMENSIONFLAG:
598 print_paper_dimension_flag = lexrc.GetString();
601 case RC_PRINTPAPERFLAG:
603 print_paper_flag = lexrc.GetString();
606 case RC_CUSTOM_EXPORT_COMMAND:
608 custom_export_command = lexrc.GetString();
611 case RC_CUSTOM_EXPORT_FORMAT:
613 custom_export_format = lexrc.GetString();
618 pdf_mode = lexrc.GetBool();
621 case RC_LATEX_COMMAND:
623 latex_command = lexrc.GetString();
626 case RC_PDFLATEX_COMMAND:
628 pdflatex_command = lexrc.GetString();
631 case RC_PDF_TO_PS_COMMAND:
633 pdf_to_ps_command = lexrc.GetString();
636 case RC_DVI_TO_PS_COMMAND:
638 dvi_to_ps_command = lexrc.GetString();
641 case RC_LITERATE_COMMAND:
643 literate_command = lexrc.GetString();
646 case RC_LITERATE_EXTENSION:
648 literate_extension = lexrc.GetString();
651 case RC_LITERATE_ERROR_FILTER:
653 literate_error_filter = lexrc.GetString();
656 case RC_BUILD_COMMAND:
658 build_command = lexrc.GetString();
661 case RC_BUILD_ERROR_FILTER:
663 build_error_filter = lexrc.GetString();
666 case RC_RELYX_COMMAND:
668 relyx_command = lexrc.GetString();
671 case RC_DEFAULT_PAPERSIZE:
673 string size = lowercase(lexrc.GetString());
674 if (size == "usletter")
676 BufferParams::PAPER_USLETTER;
677 else if (size == "legal")
679 BufferParams::PAPER_LEGALPAPER;
680 else if (size == "executive")
682 BufferParams::PAPER_EXECUTIVEPAPER;
683 else if (size == "a3")
685 BufferParams::PAPER_A3PAPER;
686 else if (size == "a4")
688 BufferParams::PAPER_A4PAPER;
689 else if (size == "a5")
691 BufferParams::PAPER_A5PAPER;
692 else if (size == "b5")
694 BufferParams::PAPER_B5PAPER;
697 case RC_VIEWDVI_COMMAND:
699 view_dvi_command = lexrc.GetString();
702 case RC_VIEWDVI_PAPEROPTION:
704 view_dvi_paper_option = lexrc.GetString();
706 view_dvi_paper_option = "";
709 case RC_VIEWPDF_COMMAND:
711 view_pdf_command = lexrc.GetString();
716 ps_command = lexrc.GetString();
719 case RC_VIEWPS_COMMAND:
721 view_ps_command = lexrc.GetString();
724 case RC_VIEWPSPIC_COMMAND:
726 view_pspic_command = lexrc.GetString();
729 case RC_CHKTEX_COMMAND:
731 chktex_command = lexrc.GetString();
734 case RC_HTML_COMMAND:
736 html_command = lexrc.GetString();
741 dpi = lexrc.GetInteger();
746 zoom = lexrc.GetInteger();
751 wheel_jump = lexrc.GetInteger();
754 case RC_SCREEN_FONT_SIZES:
756 font_sizes[LyXFont::SIZE_TINY] =
759 font_sizes[LyXFont::SIZE_SCRIPT] =
762 font_sizes[LyXFont::SIZE_FOOTNOTE] =
765 font_sizes[LyXFont::SIZE_SMALL] =
768 font_sizes[LyXFont::SIZE_NORMAL] =
771 font_sizes[LyXFont::SIZE_LARGE] =
774 font_sizes[LyXFont::SIZE_LARGER] =
777 font_sizes[LyXFont::SIZE_LARGEST] =
780 font_sizes[LyXFont::SIZE_HUGE] =
783 font_sizes[LyXFont::SIZE_HUGER] =
787 case RC_SCREEN_FONT_SCALABLE:
789 use_scalable_fonts = lexrc.GetBool();
794 autosave = lexrc.GetInteger();
797 case RC_DOCUMENTPATH:
799 document_path = ExpandPath(lexrc.GetString());
803 case RC_TEMPLATEPATH:
805 template_path = ExpandPath(lexrc.GetString());
810 tempdir_path = ExpandPath(lexrc.GetString());
815 use_tempdir = lexrc.GetBool();
820 lastfiles = ExpandPath(lexrc.GetString());
823 case RC_NUMLASTFILES:
825 num_lastfiles = lexrc.GetInteger();
828 case RC_CHECKLASTFILES:
830 check_lastfiles = lexrc.GetBool();
833 case RC_SCREEN_FONT_ROMAN:
835 roman_font_name = lexrc.GetString();
838 case RC_SCREEN_FONT_SANS:
840 sans_font_name = lexrc.GetString();
843 case RC_SCREEN_FONT_TYPEWRITER:
845 typewriter_font_name = lexrc.GetString();
848 case RC_SCREEN_FONT_MENU:
850 menu_font_name = lexrc.GetString();
853 case RC_SCREEN_FONT_POPUP:
855 popup_font_name = lexrc.GetString();
858 case RC_SCREEN_FONT_ENCODING:
860 font_norm = lexrc.GetString();
861 set_font_norm_type();
865 case RC_SCREEN_FONT_ENCODING_MENU:
867 font_norm_menu = lexrc.GetString();
872 string lyx_name, x11_name;
875 lyx_name = lexrc.GetString();
877 lexrc.printError("Missing color tag.");
882 x11_name = lexrc.GetString();
884 lexrc.printError("Missing color name for color : `$$Token'");
888 if (!lcolor.setColor(lyx_name, x11_name))
889 lyxerr << "Bad lyxrc set_color for "
894 case RC_AUTOREGIONDELETE:
895 // Auto region delete defaults to true
897 auto_region_delete = lexrc.GetBool();
902 // we should not do an explicit binding before
903 // loading a bind file. So, in this case, load
904 // the default bind file.
907 bind_file = bindFile;
909 // !!!chb, dynamic key binding...
913 if (lexrc.lex() == LyXLex::LEX_DATA) {
914 seq = lexrc.GetString();
916 lexrc.printError("Bad key sequence: `$$Token'");
920 if (lexrc.lex() == LyXLex::LEX_DATA) {
921 cmd = lexrc.GetString();
923 lexrc.printError("Bad command: `$$Token'");
927 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
928 if (lyxerr.debugging(Debug::KEY)) {
929 lyxerr << "RC_BIND: Sequence `"
930 << seq << "' Command `"
931 << cmd << "' Action `"
932 << action << '\'' << endl;
934 res = toplevel_keymap->bind(seq.c_str(),
938 "Invalid key sequence `"
941 } else {// cmd is the last token read.
943 "Unknown LyX function `$$Token'");
947 case RC_OVERRIDE_X_DEADKEYS:
949 override_x_deadkeys = lexrc.GetBool();
954 lyxpipes = ExpandPath(lexrc.GetString());
957 case RC_CURSOR_FOLLOWS_SCROLLBAR:
959 cursor_follows_scrollbar = lexrc.GetBool();
964 fax_command = lexrc.GetString();
968 fax_program = lexrc.GetString();
972 string s = lexrc.GetString();
976 phone_book = user_lyxdir + s;
979 case RC_ASCIIROFF_COMMAND:
981 ascii_roff_command = lexrc.GetString();
983 case RC_ASCII_LINELEN:
985 ascii_linelen = lexrc.GetInteger();
987 // Spellchecker settings:
988 case RC_SPELL_COMMAND:
990 isp_command = lexrc.GetString();
992 case RC_ACCEPT_COMPOUND:
994 isp_accept_compound = lexrc.GetBool();
998 isp_use_input_encoding = lexrc.GetBool();
1000 case RC_USE_ALT_LANG:
1002 isp_use_alt_lang = lexrc.GetBool();
1004 case RC_USE_PERS_DICT:
1006 isp_use_pers_dict = lexrc.GetBool();
1008 case RC_USE_ESC_CHARS:
1010 isp_use_esc_chars = lexrc.GetBool();
1014 isp_alt_lang = lexrc.GetString();
1018 isp_pers_dict = lexrc.GetString();
1022 isp_esc_chars = lexrc.GetString();
1024 case RC_MAKE_BACKUP:
1026 make_backup = lexrc.GetBool();
1028 case RC_BACKUPDIR_PATH:
1030 backupdir_path = ExpandPath(lexrc.GetString());
1032 case RC_DATE_INSERT_FORMAT:
1034 date_insert_format = lexrc.GetString();
1036 case RC_LANGUAGE_PACKAGE:
1038 language_package = lexrc.GetString();
1040 case RC_LANGUAGE_AUTO_BEGIN:
1042 language_auto_begin = lexrc.GetBool();
1044 case RC_LANGUAGE_AUTO_END:
1046 language_auto_end = lexrc.GetBool();
1048 case RC_LANGUAGE_COMMAND_BEGIN:
1050 language_command_begin = lexrc.GetString();
1052 case RC_LANGUAGE_COMMAND_END:
1054 language_command_end = lexrc.GetString();
1056 case RC_RTL_SUPPORT:
1058 rtl_support = lexrc.GetBool();
1060 case RC_AUTO_NUMBER:
1062 auto_number = lexrc.GetBool();
1064 case RC_MARK_FOREIGN_LANGUAGE:
1066 mark_foreign_language = lexrc.GetBool();
1068 case RC_SHOW_BANNER:
1070 show_banner = lexrc.GetBool();
1074 use_gui = lexrc.GetBool();
1076 case RC_LINUXDOC_TO_LYX_COMMAND:
1078 linuxdoc_to_lyx_command = lexrc.GetString();
1080 case RC_LINUXDOC_TO_HTML_COMMAND:
1082 linuxdoc_to_html_command = lexrc.GetString();
1084 case RC_LINUXDOC_TO_LATEX_COMMAND:
1086 linuxdoc_to_latex_command = lexrc.GetString();
1088 case RC_DOCBOOK_TO_DVI_COMMAND:
1090 docbook_to_dvi_command = lexrc.GetString();
1092 case RC_DOCBOOK_TO_HTML_COMMAND:
1094 docbook_to_html_command = lexrc.GetString();
1096 case RC_DOCBOOK_TO_PDF_COMMAND:
1098 docbook_to_pdf_command = lexrc.GetString();
1101 case RC_LAST: break; // this is just a dummy
1109 void LyXRC::write(string const & filename) const
1111 ofstream ofs(filename.c_str());
1117 void LyXRC::print() const
1119 if (lyxerr.debugging())
1126 void LyXRC::output(ostream & os) const
1128 os << "### This file is part of\n"
1129 << "### ========================================================\n"
1130 << "### LyX, The Document Processor\n"
1132 << "### Copyright 1995 Matthias Ettrich\n"
1133 << "### Copyright 1995-2000 The LyX Team.\n"
1135 << "### ========================================================\n"
1137 << "# This file is written by LyX, if you want to make your own\n"
1138 << "# modifications you should do them from inside LyX and save\n"
1141 // Why the switch you might ask. It is a trick to ensure that all
1142 // the elements in the LyXRCTags enum is handled. As you can see
1143 // there are no breaks at all. So it is just a huge fall-through.
1144 // The nice thing is that we will get a warning from the compiler
1145 // if we forget an element.
1146 LyXRCTags tag = RC_LAST;
1150 // input/include files are not done here
1152 // bindings is not written to the preferences file.
1154 os << "\\bind_file " << bind_file << "\n";
1160 << "# MISC SECTION ######################################\n"
1163 case RC_SHOW_BANNER:
1164 os << "# Set to false to inhibit the startup banner.\n"
1165 << "\\show_banner " << tostr(show_banner) << "\n";
1167 // bind files are not done here.
1169 os << "\\ui_file \"" << ui_file << "\"\n";
1170 case RC_AUTOREGIONDELETE:
1171 os << "# Set to false to inhibit automatic replacement of\n"
1172 << "# the current selection.\n"
1173 << "\\auto_region_delete " << tostr(auto_region_delete)
1176 os << "# The time interval between auto-saves in seconds.\n"
1177 << "\\autosave " << autosave << "\n";
1178 case RC_EXIT_CONFIRMATION:
1179 os << "# Ask for confirmation before exit if there are\n"
1180 << "# unsaved changed documents.\n"
1181 << "\\exit_confirmation " << tostr(exit_confirmation)
1183 case RC_DISPLAY_SHORTCUTS:
1184 os << "# Display name of the last command executed, with a\n"
1185 << "# list of short-cuts in the minibuffer.\n"
1186 << "\\display_shortcuts " << tostr(display_shortcuts)
1188 case RC_VIEWDVI_COMMAND:
1189 os << "# Program used to view dvi files.\n"
1190 << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1191 case RC_VIEWDVI_PAPEROPTION:
1192 os << "# Options used to specify paper size to the\n"
1193 << "# view_dvi_command\n"
1194 << "\\view_dvi_paper_option \""
1195 << view_dvi_paper_option << "\"\n";
1196 case RC_DEFAULT_PAPERSIZE:
1197 os << "# The default papersize to use.\n"
1198 << "\\default_papersize \"";
1199 switch (default_papersize) {
1200 case BufferParams::PAPER_USLETTER:
1201 os << "usletter"; break;
1202 case BufferParams::PAPER_LEGALPAPER:
1203 os << "legal"; break;
1204 case BufferParams::PAPER_EXECUTIVEPAPER:
1205 os << "executive"; break;
1206 case BufferParams::PAPER_A3PAPER:
1208 case BufferParams::PAPER_A4PAPER:
1210 case BufferParams::PAPER_A5PAPER:
1212 case BufferParams::PAPER_B5PAPER:
1214 case BufferParams::PAPER_DEFAULT: break;
1217 case RC_VIEWPDF_COMMAND:
1218 os << "# Command used to view PDF files.\n"
1219 << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1220 case RC_VIEWPS_COMMAND:
1221 os << "# Command used to view PostScript files.\n"
1222 << "\\view_ps_command \"" << view_ps_command << "\"\n";
1223 case RC_VIEWPSPIC_COMMAND:
1224 os << "# Command used to view full screen included PS\n"
1226 << "\\view_pspic_command \"" << view_pspic_command
1229 os << "# Program used for interpreting postscript.\n"
1230 << "\\ps_command \"" << ps_command << "\"\n";
1231 case RC_CHKTEX_COMMAND:
1232 os << "\\chktex_command \"" << chktex_command << "\"\n";
1233 case RC_HTML_COMMAND:
1234 os << "\\html_command \"" << html_command << "\"\n";
1236 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1237 case RC_KBMAP_PRIMARY:
1238 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1239 case RC_KBMAP_SECONDARY:
1240 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1242 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1243 case RC_RELYX_COMMAND:
1244 os << "\\relyx_command \"" << relyx_command << "\"\n";
1245 case RC_DATE_INSERT_FORMAT:
1246 os << "\\date_insert_format \"" << date_insert_format
1251 << "# SCREEN & FONTS SECTION ############################\n"
1255 os << "\\screen_dpi " << dpi << "\n";
1256 case RC_SCREEN_ZOOM:
1257 os << "\\screen_zoom " << zoom << "\n";
1259 os << "\\wheel_jump " << wheel_jump << "\n";
1260 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1261 os << "\\cursor_follows_scrollbar "
1262 << tostr(cursor_follows_scrollbar) << "\n";
1263 case RC_SCREEN_FONT_ROMAN:
1264 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1265 case RC_SCREEN_FONT_SANS:
1266 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1267 case RC_SCREEN_FONT_TYPEWRITER:
1268 os << "\\screen_font_typewriter \""
1269 << typewriter_font_name << "\"\n";
1270 case RC_SCREEN_FONT_SCALABLE:
1271 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1273 case RC_SCREEN_FONT_ENCODING:
1274 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1275 case RC_SCREEN_FONT_POPUP:
1276 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1277 case RC_SCREEN_FONT_MENU:
1278 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1279 case RC_SCREEN_FONT_SIZES:
1280 os.setf(ios::fixed);
1282 os << "\\screen_font_sizes";
1283 os << " " << font_sizes[LyXFont::SIZE_TINY];
1284 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1285 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1286 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1287 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1288 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1289 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1290 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1291 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1292 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1294 //case RC_SET_COLOR:
1295 // color bindings not written to preference file.
1296 // And we want to be warned about that. (Lgb)
1299 << "# PRINTER SECTION ###################################\n"
1303 os << "\\printer \"" << printer << "\"\n";
1304 case RC_PRINT_ADAPTOUTPUT:
1305 os << "\\print_adapt_output " << tostr(print_adapt_output)
1307 case RC_PRINT_COMMAND:
1308 os << "\\print_command \"" << print_command << "\"\n";
1309 case RC_PRINTEXSTRAOPTIONS:
1310 os << "\\print_extra_options \"" << print_extra_options
1312 case RC_PRINTSPOOL_COMMAND:
1313 os << "\\print_spool_command \"" << print_spool_command
1315 case RC_PRINTSPOOL_PRINTERPREFIX:
1316 os << "\\print_spool_printerprefix \""
1317 << print_spool_printerprefix << "\"\n";
1318 case RC_PRINTEVENPAGEFLAG:
1319 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1321 case RC_PRINTODDPAGEFLAG:
1322 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1324 case RC_PRINTREVERSEFLAG:
1325 os << "\\print_reverse_flag \"" << print_reverse_flag
1327 case RC_PRINTLANDSCAPEFLAG:
1328 os << "\\print_landscape_flag \"" << print_landscape_flag
1330 case RC_PRINTPAGERANGEFLAG:
1331 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1333 case RC_PRINTCOPIESFLAG:
1334 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1335 case RC_PRINTCOLLCOPIESFLAG:
1336 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1338 case RC_PRINTPAPERFLAG:
1339 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1340 case RC_PRINTPAPERDIMENSIONFLAG:
1341 os << "\\print_paper_dimension_flag \""
1342 << print_paper_dimension_flag << "\"\n";
1343 case RC_PRINTTOPRINTER:
1344 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1345 case RC_PRINTTOFILE:
1346 os << "\\print_to_file \"" << print_to_file << "\"\n";
1347 case RC_PRINTFILEEXTENSION:
1348 os << "\\print_file_extension \"" << print_file_extension
1352 << "# EXPORT SECTION ####################################\n"
1355 case RC_CUSTOM_EXPORT_COMMAND:
1356 os << "\\custom_export_command \"" << custom_export_command
1358 case RC_CUSTOM_EXPORT_FORMAT:
1359 os << "\\custom_export_format \"" << custom_export_format
1363 << "# TEX SECTION #######################################\n"
1366 case RC_LATEX_COMMAND:
1367 os << "\\latex_command \"" << latex_command << "\"\n";
1368 case RC_PDFLATEX_COMMAND:
1369 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1371 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1372 case RC_FONT_ENCODING:
1373 os << "\\font_encoding \"" << fontenc << "\"\n";
1376 << "# LINUXDOC SECTION ##################################\n"
1379 case RC_LINUXDOC_TO_LATEX_COMMAND:
1380 os << "\\linuxdoc_to_latex_command \"" << linuxdoc_to_latex_command
1382 case RC_LINUXDOC_TO_HTML_COMMAND:
1383 os << "\\linuxdoc_to_html_command \"" << linuxdoc_to_html_command
1385 case RC_LINUXDOC_TO_LYX_COMMAND:
1386 os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command
1390 << "# DOCBOOK SECTION ###################################\n"
1393 case RC_DOCBOOK_TO_DVI_COMMAND:
1394 os << "\\docbook_to_dvi_command \"" << docbook_to_dvi_command
1396 case RC_DOCBOOK_TO_HTML_COMMAND:
1397 os << "\\docbook_to_html_command \"" << docbook_to_html_command
1399 case RC_DOCBOOK_TO_PDF_COMMAND:
1400 os << "\\docbook_to_pdf_command \"" << docbook_to_pdf_command
1404 << "# FILE SECTION ######################################\n"
1407 case RC_DOCUMENTPATH:
1408 os << "\\document_path \"" << document_path << "\"\n";
1410 os << "\\lastfiles \"" << lastfiles << "\"\n";
1411 case RC_NUMLASTFILES:
1412 os << "\\num_lastfiles " << num_lastfiles << "\n";
1413 case RC_CHECKLASTFILES:
1414 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1415 case RC_TEMPLATEPATH:
1416 os << "\\template_path \"" << template_path << "\"\n";
1417 case RC_TEMPDIRPATH:
1418 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1420 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1421 case RC_ASCII_LINELEN:
1422 os << "\\ascii_linelen " << ascii_linelen << "\n";
1423 case RC_MAKE_BACKUP:
1424 os << "\\make_backup " << tostr(make_backup) << "\n";
1425 case RC_BACKUPDIR_PATH:
1426 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1429 << "# FAX SECTION #######################################\n"
1432 case RC_FAX_COMMAND:
1433 os << "\\fax_command \"" << fax_command << "\"\n";
1435 os << "\\phone_book \"" << phone_book << "\"\n";
1437 os << "\\fax_program \"" << fax_program << "\"\n";
1440 << "# ASCII EXPORT SECTION ##############################\n"
1443 case RC_ASCIIROFF_COMMAND:
1444 os << "\\ascii_roff_command \"" << ascii_roff_command
1448 << "# SPELLCHECKER SECTION ##############################\n"
1451 case RC_SPELL_COMMAND:
1452 os << "\\spell_command \"" << isp_command << "\"\n";
1453 case RC_ACCEPT_COMPOUND:
1454 os << "\\accept_compound " << tostr(isp_accept_compound)
1456 case RC_USE_ALT_LANG:
1457 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1459 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1460 case RC_USE_ESC_CHARS:
1461 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1464 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1465 case RC_USE_PERS_DICT:
1466 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1469 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1470 case RC_USE_INP_ENC:
1471 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1475 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1478 case RC_RTL_SUPPORT:
1479 os << "\\rtl " << tostr(rtl_support) << "\n";
1480 case RC_LANGUAGE_PACKAGE:
1481 os << "\\language_package \"" << language_package << "\"\n";
1482 case RC_LANGUAGE_COMMAND_BEGIN:
1483 os << "\\language_command_begin \"" << language_command_begin
1485 case RC_LANGUAGE_COMMAND_END:
1486 os << "\\language_command_end \"" << language_command_end
1488 case RC_LANGUAGE_AUTO_BEGIN:
1489 os << "\\language_auto_begin "
1490 << tostr(language_auto_begin) << "\n";
1491 case RC_LANGUAGE_AUTO_END:
1492 os << "\\language_auto_end "
1493 << tostr(language_auto_end) << "\n";
1494 case RC_MARK_FOREIGN_LANGUAGE:
1495 os << "\\mark_foreign_language " <<
1496 tostr(mark_foreign_language) << "\n";
1499 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1502 case RC_PDF_TO_PS_COMMAND:
1503 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1504 case RC_DVI_TO_PS_COMMAND:
1505 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1506 case RC_LITERATE_COMMAND:
1507 os << "\\literate_command \"" << literate_command << "\"\n";
1508 case RC_LITERATE_EXTENSION:
1509 os << "\\literate_extension \"" << literate_extension
1511 case RC_LITERATE_ERROR_FILTER:
1512 os << "\\literate_error_filter \"" << literate_error_filter
1514 case RC_BUILD_COMMAND:
1515 os << "\\build_command \"" << build_command << "\"\n";
1516 case RC_BUILD_ERROR_FILTER:
1517 os << "\\build_error_filter \"" << build_error_filter
1519 case RC_OVERRIDE_X_DEADKEYS:
1520 os << "\\override_x_deadkeys "
1521 << tostr(override_x_deadkeys) << "\n";
1522 case RC_SCREEN_FONT_ENCODING_MENU:
1523 os << "\\screen_font_encoding_menu \"" << font_norm_menu
1525 case RC_AUTO_NUMBER:
1526 os << "\\auto_number " << tostr(auto_number) << "\n";
1528 os << "\\use_gui " << tostr(use_gui) << "\n";
1533 void LyXRC::set_font_norm_type()
1535 if (font_norm == "iso10646-1")
1536 font_norm_type = ISO_10646_1;
1537 else if (font_norm == "iso8859-6.8x")
1538 font_norm_type = ISO_8859_6_8;
1540 font_norm_type = OTHER_ENCODING;
1543 // The global instance