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"
33 #include "converter.h"
41 // this is crappy... why are those colors command line arguments and
42 // not in lyxrc?? (Matthias)
43 // Because nobody put them there. (Asger)
45 extern bool cursor_follows_scrollbar;
46 extern LyXAction lyxaction;
47 extern kb_keymap * toplevel_keymap;
56 RC_PRINTPAGERANGEFLAG,
58 RC_PRINTCOLLCOPIESFLAG,
60 RC_PRINTLANDSCAPEFLAG,
64 RC_PRINTFILEEXTENSION,
65 RC_PRINTEXSTRAOPTIONS,
66 RC_PRINTSPOOL_COMMAND,
67 RC_PRINTSPOOL_PRINTERPREFIX,
69 RC_PRINTPAPERDIMENSIONFLAG,
70 RC_CUSTOM_EXPORT_COMMAND,
71 RC_CUSTOM_EXPORT_FORMAT,
74 RC_LITERATE_EXTENSION,
75 RC_LITERATE_ERROR_FILTER,
77 RC_BUILD_ERROR_FILTER,
83 RC_SCREEN_FONT_TYPEWRITER,
86 RC_SCREEN_FONT_ENCODING,
87 RC_SCREEN_FONT_ENCODING_MENU,
97 RC_OVERRIDE_X_DEADKEYS,
108 RC_ASCIIROFF_COMMAND,
113 RC_VIEWDVI_PAPEROPTION,
114 RC_DEFAULT_PAPERSIZE,
117 RC_VIEWPSPIC_COMMAND,
124 RC_SCREEN_FONT_SCALABLE,
129 RC_CURSOR_FOLLOWS_SCROLLBAR,
130 RC_EXIT_CONFIRMATION,
131 RC_DISPLAY_SHORTCUTS,
138 RC_MARK_FOREIGN_LANGUAGE,
140 RC_LANGUAGE_AUTO_BEGIN,
141 RC_LANGUAGE_AUTO_END,
142 RC_LANGUAGE_COMMAND_BEGIN,
143 RC_LANGUAGE_COMMAND_END,
147 RC_PDF_TO_PS_COMMAND,
148 RC_DVI_TO_PS_COMMAND,
149 RC_DATE_INSERT_FORMAT,
152 RC_LINUXDOC_TO_LYX_COMMAND,
153 RC_LINUXDOC_TO_HTML_COMMAND,
154 RC_LINUXDOC_TO_LATEX_COMMAND,
155 RC_DOCBOOK_TO_DVI_COMMAND,
156 RC_DOCBOOK_TO_HTML_COMMAND,
157 RC_DOCBOOK_TO_PDF_COMMAND,
168 keyword_item lyxrcTags[] = {
169 { "\\accept_compound", RC_ACCEPT_COMPOUND },
170 { "\\alternate_language", RC_ALT_LANG },
171 { "\\ascii_linelen", RC_ASCII_LINELEN },
172 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
173 { "\\auto_number", RC_AUTO_NUMBER },
174 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
175 { "\\autosave", RC_AUTOSAVE },
176 { "\\backupdir_path", RC_BACKUPDIR_PATH },
177 { "\\bind", RC_BIND },
178 { "\\bind_file", RC_BINDFILE },
179 { "\\build_command", RC_BUILD_COMMAND },
180 { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
181 { "\\check_lastfiles", RC_CHECKLASTFILES },
182 { "\\chktex_command", RC_CHKTEX_COMMAND },
183 { "\\converter", RC_CONVERTER },
184 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
185 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
186 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
187 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
188 { "\\default_language", RC_DEFAULT_LANGUAGE },
189 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
190 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
191 { "\\docbook_to_dvi_command", RC_DOCBOOK_TO_DVI_COMMAND },
192 { "\\docbook_to_html_command", RC_DOCBOOK_TO_HTML_COMMAND },
193 { "\\docbook_to_pdf_command", RC_DOCBOOK_TO_PDF_COMMAND },
194 { "\\document_path", RC_DOCUMENTPATH },
195 { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
196 { "\\escape_chars", RC_ESC_CHARS },
197 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
198 { "\\fax_command", RC_FAX_COMMAND },
199 { "\\fax_program", RC_FAXPROGRAM },
200 { "\\font_encoding", RC_FONT_ENCODING },
201 { "\\html_command", RC_HTML_COMMAND },
202 { "\\input", RC_INPUT },
203 { "\\kbmap", RC_KBMAP },
204 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
205 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
206 { "\\language_auto_begin", RC_LANGUAGE_AUTO_BEGIN },
207 { "\\language_auto_end", RC_LANGUAGE_AUTO_END },
208 { "\\language_command_begin", RC_LANGUAGE_COMMAND_BEGIN },
209 { "\\language_command_end", RC_LANGUAGE_COMMAND_END },
210 { "\\language_package", RC_LANGUAGE_PACKAGE },
211 { "\\lastfiles", RC_LASTFILES },
212 { "\\latex_command", RC_LATEX_COMMAND },
213 { "\\linuxdoc_to_html_command", RC_LINUXDOC_TO_HTML_COMMAND },
214 { "\\linuxdoc_to_latex_command", RC_LINUXDOC_TO_LATEX_COMMAND },
215 { "\\linuxdoc_to_lyx_command", RC_LINUXDOC_TO_LYX_COMMAND },
216 { "\\literate_command", RC_LITERATE_COMMAND },
217 { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
218 { "\\literate_extension", RC_LITERATE_EXTENSION },
219 { "\\make_backup", RC_MAKE_BACKUP },
220 { "\\mark_foreign_language", RC_MARK_FOREIGN_LANGUAGE },
221 { "\\new_ask_filename", RC_NEW_ASK_FILENAME },
222 { "\\num_lastfiles", RC_NUMLASTFILES },
223 { "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
224 { "\\pdf_mode", RC_PDF_MODE },
225 { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
226 { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
227 { "\\personal_dictionary", RC_PERS_DICT },
228 { "\\phone_book", RC_PHONEBOOK },
229 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
230 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
231 { "\\print_command", RC_PRINT_COMMAND },
232 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
233 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
234 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
235 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
236 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
237 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
238 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
239 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
240 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
241 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
242 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
243 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
244 { "\\print_to_file", RC_PRINTTOFILE },
245 { "\\print_to_printer", RC_PRINTTOPRINTER },
246 { "\\printer", RC_PRINTER },
247 { "\\ps_command", RC_PS_COMMAND },
248 { "\\relyx_command", RC_RELYX_COMMAND },
249 { "\\rtl", RC_RTL_SUPPORT },
250 { "\\screen_dpi", RC_SCREEN_DPI },
251 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
252 { "\\screen_font_encoding_menu", RC_SCREEN_FONT_ENCODING_MENU },
253 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
254 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
255 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
256 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
257 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
258 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
259 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
260 { "\\screen_zoom", RC_SCREEN_ZOOM },
261 { "\\serverpipe", RC_SERVERPIPE },
262 { "\\set_color", RC_SET_COLOR },
263 { "\\show_banner", RC_SHOW_BANNER },
264 { "\\spell_command", RC_SPELL_COMMAND },
265 { "\\tempdir_path", RC_TEMPDIRPATH },
266 { "\\template_path", RC_TEMPLATEPATH },
267 { "\\ui_file", RC_UIFILE },
268 { "\\use_alt_language", RC_USE_ALT_LANG },
269 { "\\use_escape_chars", RC_USE_ESC_CHARS },
270 { "\\use_gui", RC_USE_GUI },
271 { "\\use_input_encoding", RC_USE_INP_ENC },
272 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
273 { "\\use_tempdir", RC_USETEMPDIR },
274 { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
275 { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
276 { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
277 { "\\view_ps_command", RC_VIEWPS_COMMAND },
278 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND },
279 { "\\viewer" ,RC_VIEWER},
280 { "\\wheel_jump", RC_WHEEL_JUMP }
283 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
284 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
293 void LyXRC::setDefaults() {
295 // Get printer from the environment. If fail, use default "",
296 // assuming that everything is set up correctly.
297 printer = GetEnv("PRINTER");
298 print_adapt_output = false;
299 print_command = "dvips";
300 print_evenpage_flag = "-B";
301 print_oddpage_flag = "-A";
302 print_pagerange_flag = "-pp";
303 print_copies_flag = "-c";
304 print_collcopies_flag = "-C";
305 print_reverse_flag = "-r";
306 print_landscape_flag = "-t landscape";
307 print_to_printer = "-P";
308 print_to_file = "-o ";
309 print_file_extension = ".ps";
310 print_paper_flag = "-t";
311 print_paper_dimension_flag = "-T";
312 document_path = GetEnvPath("HOME");
313 tempdir_path = "/tmp";
316 latex_command = "latex";
317 pdflatex_command = "pdflatex";
318 pdf_to_ps_command = "pdf2ps";
319 dvi_to_ps_command = "dvips";
320 literate_command = "none";
321 literate_extension = "none";
322 literate_error_filter = "cat";
323 build_command = "make";
324 build_error_filter = "cat";
325 relyx_command = "reLyX";
327 view_ps_command = "ghostview -swap";
328 view_pspic_command = "ghostview";
329 view_dvi_command = "xdvi";
330 view_dvi_paper_option = "-paper";
331 view_pdf_command = "xpdf";
332 default_papersize = BufferParams::PAPER_USLETTER;
333 custom_export_format = "ps";
334 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
335 html_command = "tth -t";
338 // Because a screen typically is wider than a piece of paper:
341 // Default LaTeX font size:
342 font_sizes[LyXFont::SIZE_TINY] = 5.0;
343 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
344 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
345 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
346 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
347 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
348 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
349 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
350 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
351 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
352 use_scalable_fonts = true;
353 roman_font_name = "-*-times";
354 sans_font_name = "-*-helvetica";
355 typewriter_font_name = "-*-courier";
356 menu_font_name = "-*-helvetica-bold-r";
357 popup_font_name = "-*-helvetica-medium-r";
358 font_norm = "iso8859-1";
359 font_norm_type = OTHER_ENCODING;
361 override_x_deadkeys = true;
363 auto_region_delete = true;
366 check_lastfiles = true;
369 exit_confirmation = true;
370 display_shortcuts = true;
371 // Spellchecker settings:
372 isp_command = "ispell";
373 isp_accept_compound = false;
374 isp_use_input_encoding = false;
375 isp_use_alt_lang = false;
376 isp_use_pers_dict = false;
377 isp_use_esc_chars = false;
382 mark_foreign_language = true;
383 language_package = "\\usepackage{babel}";
384 language_auto_begin = true;
385 language_auto_end = true;
386 language_command_begin = "\\selectlanguage{$$lang}";
387 language_command_end = "\\selectlanguage{$$lang}";
388 default_language = "english";
390 new_ask_filename = false;
393 date_insert_format = "%A, %e %B %Y";
398 linuxdoc_to_latex_command="none";
399 linuxdoc_to_lyx_command="none";
400 linuxdoc_to_html_command="none";
402 docbook_to_dvi_command="none";
403 docbook_to_html_command="none";
404 docbook_to_pdf_command="none";
408 int LyXRC::ReadBindFile(string const & name)
411 string tmp = i18nLibFileSearch("bind", name, "bind");
412 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
413 int result = read(tmp);
415 lyxerr << "Error reading bind file: " << tmp << endl;
421 int LyXRC::read(string const & filename)
424 string bindFile = "cua";
426 LyXLex lexrc(lyxrcTags, lyxrcCount);
427 if (lyxerr.debugging(Debug::PARSER))
428 lexrc.printTable(lyxerr);
430 lexrc.setFile(filename);
431 if (!lexrc.IsOK()) return -2;
433 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
435 while (lexrc.IsOK()) {
436 // By using two switches we take advantage of the compiler
437 // telling us if we have missed a LyXRCTags element in
438 // the second switch.
439 // Note that this also shows a problem with LyXLex since it
440 // helps us avoid taking advantage of the strictness of the
443 int le = lexrc.lex();
445 case LyXLex::LEX_UNDEF:
446 lexrc.printError("Unknown tag `$$Token'");
448 case LyXLex::LEX_FEOF:
452 switch (static_cast<LyXRCTags>(le)) {
453 case RC_INPUT: // Include file
455 string tmp = LibFileSearch(string(),
458 lexrc.printError("Error reading "
459 "included file: "+tmp);
463 case RC_BINDFILE: // RVDK_PATCH_5
465 string tmp(lexrc.GetString());
466 if (bind_file.empty()) {
467 // we only need the name of the first
468 // bind file since that (usually)
469 // includes several others.
478 ui_file = lexrc.GetString();
482 case RC_EXIT_CONFIRMATION:
484 exit_confirmation = lexrc.GetBool();
487 case RC_DISPLAY_SHORTCUTS:
489 display_shortcuts = lexrc.GetBool();
494 use_kbmap = lexrc.GetBool();
497 case RC_KBMAP_PRIMARY:
499 string kmap(lexrc.GetString());
502 } else if (!LibFileSearch("kbd", kmap,
504 primary_kbmap = kmap;
506 lexrc.printError("LyX: Keymap `$$Token' not found");
510 case RC_KBMAP_SECONDARY:
512 string kmap(lexrc.GetString());
515 } else if (!LibFileSearch("kbd", kmap,
517 secondary_kbmap = kmap;
519 lexrc.printError("LyX: Keymap `$$Token' not found");
523 case RC_FONT_ENCODING:
525 fontenc = lexrc.GetString();
530 printer = lexrc.GetString();
533 case RC_PRINT_COMMAND:
535 print_command = lexrc.GetString();
538 case RC_PRINTEVENPAGEFLAG:
540 print_evenpage_flag = lexrc.GetString();
543 case RC_PRINTODDPAGEFLAG:
545 print_oddpage_flag = lexrc.GetString();
548 case RC_PRINTPAGERANGEFLAG:
550 print_pagerange_flag = lexrc.GetString();
553 case RC_PRINTCOPIESFLAG:
555 print_copies_flag = lexrc.GetString();
558 case RC_PRINTCOLLCOPIESFLAG:
560 print_collcopies_flag = lexrc.GetString();
563 case RC_PRINTREVERSEFLAG:
565 print_reverse_flag = lexrc.GetString();
568 case RC_PRINTLANDSCAPEFLAG:
570 print_landscape_flag = lexrc.GetString();
573 case RC_PRINTTOPRINTER:
575 print_to_printer = lexrc.GetString();
578 case RC_PRINT_ADAPTOUTPUT:
580 print_adapt_output = lexrc.GetBool();
585 print_to_file = lexrc.GetString();
588 case RC_PRINTFILEEXTENSION:
590 print_file_extension = lexrc.GetString();
593 case RC_PRINTEXSTRAOPTIONS:
595 print_extra_options = lexrc.GetString();
598 case RC_PRINTSPOOL_COMMAND:
600 print_spool_command = lexrc.GetString();
603 case RC_PRINTSPOOL_PRINTERPREFIX:
605 print_spool_printerprefix = lexrc.GetString();
608 case RC_PRINTPAPERDIMENSIONFLAG:
610 print_paper_dimension_flag = lexrc.GetString();
613 case RC_PRINTPAPERFLAG:
615 print_paper_flag = lexrc.GetString();
618 case RC_CUSTOM_EXPORT_COMMAND:
620 custom_export_command = lexrc.GetString();
623 case RC_CUSTOM_EXPORT_FORMAT:
625 custom_export_format = lexrc.GetString();
630 pdf_mode = lexrc.GetBool();
633 case RC_LATEX_COMMAND:
635 latex_command = lexrc.GetString();
638 case RC_PDFLATEX_COMMAND:
640 pdflatex_command = lexrc.GetString();
643 case RC_PDF_TO_PS_COMMAND:
645 pdf_to_ps_command = lexrc.GetString();
648 case RC_DVI_TO_PS_COMMAND:
650 dvi_to_ps_command = lexrc.GetString();
653 case RC_LITERATE_COMMAND:
655 literate_command = lexrc.GetString();
658 case RC_LITERATE_EXTENSION:
660 literate_extension = lexrc.GetString();
663 case RC_LITERATE_ERROR_FILTER:
665 literate_error_filter = lexrc.GetString();
668 case RC_BUILD_COMMAND:
670 build_command = lexrc.GetString();
673 case RC_BUILD_ERROR_FILTER:
675 build_error_filter = lexrc.GetString();
678 case RC_RELYX_COMMAND:
680 relyx_command = lexrc.GetString();
683 case RC_DEFAULT_PAPERSIZE:
685 string size = lowercase(lexrc.GetString());
686 if (size == "usletter")
688 BufferParams::PAPER_USLETTER;
689 else if (size == "legal")
691 BufferParams::PAPER_LEGALPAPER;
692 else if (size == "executive")
694 BufferParams::PAPER_EXECUTIVEPAPER;
695 else if (size == "a3")
697 BufferParams::PAPER_A3PAPER;
698 else if (size == "a4")
700 BufferParams::PAPER_A4PAPER;
701 else if (size == "a5")
703 BufferParams::PAPER_A5PAPER;
704 else if (size == "b5")
706 BufferParams::PAPER_B5PAPER;
709 case RC_VIEWDVI_COMMAND:
711 view_dvi_command = lexrc.GetString();
714 case RC_VIEWDVI_PAPEROPTION:
716 view_dvi_paper_option = lexrc.GetString();
718 view_dvi_paper_option = "";
721 case RC_VIEWPDF_COMMAND:
723 view_pdf_command = lexrc.GetString();
728 ps_command = lexrc.GetString();
731 case RC_VIEWPS_COMMAND:
733 view_ps_command = lexrc.GetString();
736 case RC_VIEWPSPIC_COMMAND:
738 view_pspic_command = lexrc.GetString();
741 case RC_CHKTEX_COMMAND:
743 chktex_command = lexrc.GetString();
746 case RC_HTML_COMMAND:
748 html_command = lexrc.GetString();
753 dpi = lexrc.GetInteger();
758 zoom = lexrc.GetInteger();
763 wheel_jump = lexrc.GetInteger();
766 case RC_SCREEN_FONT_SIZES:
768 font_sizes[LyXFont::SIZE_TINY] =
771 font_sizes[LyXFont::SIZE_SCRIPT] =
774 font_sizes[LyXFont::SIZE_FOOTNOTE] =
777 font_sizes[LyXFont::SIZE_SMALL] =
780 font_sizes[LyXFont::SIZE_NORMAL] =
783 font_sizes[LyXFont::SIZE_LARGE] =
786 font_sizes[LyXFont::SIZE_LARGER] =
789 font_sizes[LyXFont::SIZE_LARGEST] =
792 font_sizes[LyXFont::SIZE_HUGE] =
795 font_sizes[LyXFont::SIZE_HUGER] =
799 case RC_SCREEN_FONT_SCALABLE:
801 use_scalable_fonts = lexrc.GetBool();
806 autosave = lexrc.GetInteger();
809 case RC_DOCUMENTPATH:
811 document_path = ExpandPath(lexrc.GetString());
815 case RC_TEMPLATEPATH:
817 template_path = ExpandPath(lexrc.GetString());
822 tempdir_path = ExpandPath(lexrc.GetString());
827 use_tempdir = lexrc.GetBool();
832 lastfiles = ExpandPath(lexrc.GetString());
835 case RC_NUMLASTFILES:
837 num_lastfiles = lexrc.GetInteger();
840 case RC_CHECKLASTFILES:
842 check_lastfiles = lexrc.GetBool();
845 case RC_SCREEN_FONT_ROMAN:
847 roman_font_name = lexrc.GetString();
850 case RC_SCREEN_FONT_SANS:
852 sans_font_name = lexrc.GetString();
855 case RC_SCREEN_FONT_TYPEWRITER:
857 typewriter_font_name = lexrc.GetString();
860 case RC_SCREEN_FONT_MENU:
862 menu_font_name = lexrc.GetString();
865 case RC_SCREEN_FONT_POPUP:
867 popup_font_name = lexrc.GetString();
870 case RC_SCREEN_FONT_ENCODING:
872 font_norm = lexrc.GetString();
873 set_font_norm_type();
877 case RC_SCREEN_FONT_ENCODING_MENU:
879 font_norm_menu = lexrc.GetString();
884 string lyx_name, x11_name;
887 lyx_name = lexrc.GetString();
889 lexrc.printError("Missing color tag.");
894 x11_name = lexrc.GetString();
896 lexrc.printError("Missing color name for color : `$$Token'");
900 if (!lcolor.setColor(lyx_name, x11_name))
901 lyxerr << "Bad lyxrc set_color for "
906 case RC_AUTOREGIONDELETE:
907 // Auto region delete defaults to true
909 auto_region_delete = lexrc.GetBool();
914 // we should not do an explicit binding before
915 // loading a bind file. So, in this case, load
916 // the default bind file.
919 bind_file = bindFile;
921 // !!!chb, dynamic key binding...
925 if (lexrc.lex() == LyXLex::LEX_DATA) {
926 seq = lexrc.GetString();
928 lexrc.printError("Bad key sequence: `$$Token'");
932 if (lexrc.lex() == LyXLex::LEX_DATA) {
933 cmd = lexrc.GetString();
935 lexrc.printError("Bad command: `$$Token'");
939 if ((action = lyxaction.LookupFunc(cmd))>= 0) {
940 if (lyxerr.debugging(Debug::KBMAP)) {
941 lyxerr << "RC_BIND: Sequence `"
942 << seq << "' Command `"
943 << cmd << "' Action `"
944 << action << '\'' << endl;
946 res = toplevel_keymap->bind(seq, action);
949 "Invalid key sequence `"
952 } else {// cmd is the last token read.
954 "Unknown LyX function `$$Token'");
958 case RC_OVERRIDE_X_DEADKEYS:
960 override_x_deadkeys = lexrc.GetBool();
965 lyxpipes = ExpandPath(lexrc.GetString());
968 case RC_CURSOR_FOLLOWS_SCROLLBAR:
970 cursor_follows_scrollbar = lexrc.GetBool();
975 fax_command = lexrc.GetString();
979 fax_program = lexrc.GetString();
983 string s = lexrc.GetString();
987 phone_book = user_lyxdir + s;
990 case RC_ASCIIROFF_COMMAND:
992 ascii_roff_command = lexrc.GetString();
994 case RC_ASCII_LINELEN:
996 ascii_linelen = lexrc.GetInteger();
998 // Spellchecker settings:
999 case RC_SPELL_COMMAND:
1001 isp_command = lexrc.GetString();
1003 case RC_ACCEPT_COMPOUND:
1005 isp_accept_compound = lexrc.GetBool();
1007 case RC_USE_INP_ENC:
1009 isp_use_input_encoding = lexrc.GetBool();
1011 case RC_USE_ALT_LANG:
1013 isp_use_alt_lang = lexrc.GetBool();
1015 case RC_USE_PERS_DICT:
1017 isp_use_pers_dict = lexrc.GetBool();
1019 case RC_USE_ESC_CHARS:
1021 isp_use_esc_chars = lexrc.GetBool();
1025 isp_alt_lang = lexrc.GetString();
1029 isp_pers_dict = lexrc.GetString();
1033 isp_esc_chars = lexrc.GetString();
1035 case RC_MAKE_BACKUP:
1037 make_backup = lexrc.GetBool();
1039 case RC_BACKUPDIR_PATH:
1041 backupdir_path = ExpandPath(lexrc.GetString());
1043 case RC_DATE_INSERT_FORMAT:
1045 date_insert_format = lexrc.GetString();
1047 case RC_LANGUAGE_PACKAGE:
1049 language_package = lexrc.GetString();
1051 case RC_LANGUAGE_AUTO_BEGIN:
1053 language_auto_begin = lexrc.GetBool();
1055 case RC_LANGUAGE_AUTO_END:
1057 language_auto_end = lexrc.GetBool();
1059 case RC_LANGUAGE_COMMAND_BEGIN:
1061 language_command_begin = lexrc.GetString();
1063 case RC_LANGUAGE_COMMAND_END:
1065 language_command_end = lexrc.GetString();
1067 case RC_RTL_SUPPORT:
1069 rtl_support = lexrc.GetBool();
1071 case RC_AUTO_NUMBER:
1073 auto_number = lexrc.GetBool();
1075 case RC_MARK_FOREIGN_LANGUAGE:
1077 mark_foreign_language = lexrc.GetBool();
1079 case RC_SHOW_BANNER:
1081 show_banner = lexrc.GetBool();
1085 use_gui = lexrc.GetBool();
1087 case RC_LINUXDOC_TO_LYX_COMMAND:
1089 linuxdoc_to_lyx_command = lexrc.GetString();
1091 case RC_LINUXDOC_TO_HTML_COMMAND:
1093 linuxdoc_to_html_command = lexrc.GetString();
1095 case RC_LINUXDOC_TO_LATEX_COMMAND:
1097 linuxdoc_to_latex_command = lexrc.GetString();
1099 case RC_DOCBOOK_TO_DVI_COMMAND:
1101 docbook_to_dvi_command = lexrc.GetString();
1103 case RC_DOCBOOK_TO_HTML_COMMAND:
1105 docbook_to_html_command = lexrc.GetString();
1107 case RC_DOCBOOK_TO_PDF_COMMAND:
1109 docbook_to_pdf_command = lexrc.GetString();
1112 case RC_NEW_ASK_FILENAME:
1114 new_ask_filename = lexrc.GetBool();
1118 string from, to, command, flags;
1120 from = lexrc.GetString();
1122 to = lexrc.GetString();
1124 command = lexrc.GetString();
1126 flags = lexrc.GetString();
1127 Converter::Add(from, to, command, flags);
1132 string format, command;
1134 format = lexrc.GetString();
1136 command = lexrc.GetString();
1137 Formats::SetViewer(format, command);
1140 case RC_DEFAULT_LANGUAGE:
1142 default_language = lexrc.GetString();
1145 case RC_LAST: break; // this is just a dummy
1153 void LyXRC::write(string const & filename) const
1155 ofstream ofs(filename.c_str());
1161 void LyXRC::print() const
1163 if (lyxerr.debugging())
1170 void LyXRC::output(ostream & os) const
1172 os << "### This file is part of\n"
1173 << "### ========================================================\n"
1174 << "### LyX, The Document Processor\n"
1176 << "### Copyright 1995 Matthias Ettrich\n"
1177 << "### Copyright 1995-2000 The LyX Team.\n"
1179 << "### ========================================================\n"
1181 << "# This file is written by LyX, if you want to make your own\n"
1182 << "# modifications you should do them from inside LyX and save\n"
1185 // Why the switch you might ask. It is a trick to ensure that all
1186 // the elements in the LyXRCTags enum is handled. As you can see
1187 // there are no breaks at all. So it is just a huge fall-through.
1188 // The nice thing is that we will get a warning from the compiler
1189 // if we forget an element.
1190 LyXRCTags tag = RC_LAST;
1194 // input/include files are not done here
1196 // bindings is not written to the preferences file.
1198 os << "\\bind_file " << bind_file << "\n";
1204 << "# MISC SECTION ######################################\n"
1207 case RC_SHOW_BANNER:
1208 os << "# Set to false to inhibit the startup banner.\n"
1209 << "\\show_banner " << tostr(show_banner) << "\n";
1211 // bind files are not done here.
1213 os << "\\ui_file \"" << ui_file << "\"\n";
1214 case RC_AUTOREGIONDELETE:
1215 os << "# Set to false to inhibit automatic replacement of\n"
1216 << "# the current selection.\n"
1217 << "\\auto_region_delete " << tostr(auto_region_delete)
1220 os << "# The time interval between auto-saves in seconds.\n"
1221 << "\\autosave " << autosave << "\n";
1222 case RC_EXIT_CONFIRMATION:
1223 os << "# Ask for confirmation before exit if there are\n"
1224 << "# unsaved changed documents.\n"
1225 << "\\exit_confirmation " << tostr(exit_confirmation)
1227 case RC_DISPLAY_SHORTCUTS:
1228 os << "# Display name of the last command executed, with a\n"
1229 << "# list of short-cuts in the minibuffer.\n"
1230 << "\\display_shortcuts " << tostr(display_shortcuts)
1232 case RC_VIEWDVI_COMMAND:
1233 os << "# Program used to view dvi files.\n"
1234 << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1235 case RC_VIEWDVI_PAPEROPTION:
1236 os << "# Options used to specify paper size to the\n"
1237 << "# view_dvi_command\n"
1238 << "\\view_dvi_paper_option \""
1239 << view_dvi_paper_option << "\"\n";
1240 case RC_DEFAULT_PAPERSIZE:
1241 os << "# The default papersize to use.\n"
1242 << "\\default_papersize \"";
1243 switch (default_papersize) {
1244 case BufferParams::PAPER_USLETTER:
1245 os << "usletter"; break;
1246 case BufferParams::PAPER_LEGALPAPER:
1247 os << "legal"; break;
1248 case BufferParams::PAPER_EXECUTIVEPAPER:
1249 os << "executive"; break;
1250 case BufferParams::PAPER_A3PAPER:
1252 case BufferParams::PAPER_A4PAPER:
1254 case BufferParams::PAPER_A5PAPER:
1256 case BufferParams::PAPER_B5PAPER:
1258 case BufferParams::PAPER_DEFAULT: break;
1261 case RC_VIEWPDF_COMMAND:
1262 os << "# Command used to view PDF files.\n"
1263 << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1264 case RC_VIEWPS_COMMAND:
1265 os << "# Command used to view PostScript files.\n"
1266 << "\\view_ps_command \"" << view_ps_command << "\"\n";
1267 case RC_VIEWPSPIC_COMMAND:
1268 os << "# Command used to view full screen included PS\n"
1270 << "\\view_pspic_command \"" << view_pspic_command
1273 os << "# Program used for interpreting postscript.\n"
1274 << "\\ps_command \"" << ps_command << "\"\n";
1275 case RC_CHKTEX_COMMAND:
1276 os << "\\chktex_command \"" << chktex_command << "\"\n";
1277 case RC_HTML_COMMAND:
1278 os << "\\html_command \"" << html_command << "\"\n";
1280 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1281 case RC_KBMAP_PRIMARY:
1282 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1283 case RC_KBMAP_SECONDARY:
1284 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1286 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1287 case RC_RELYX_COMMAND:
1288 os << "\\relyx_command \"" << relyx_command << "\"\n";
1289 case RC_DATE_INSERT_FORMAT:
1290 os << "\\date_insert_format \"" << date_insert_format
1295 << "# SCREEN & FONTS SECTION ############################\n"
1299 os << "\\screen_dpi " << dpi << "\n";
1300 case RC_SCREEN_ZOOM:
1301 os << "\\screen_zoom " << zoom << "\n";
1303 os << "\\wheel_jump " << wheel_jump << "\n";
1304 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1305 os << "\\cursor_follows_scrollbar "
1306 << tostr(cursor_follows_scrollbar) << "\n";
1307 case RC_SCREEN_FONT_ROMAN:
1308 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1309 case RC_SCREEN_FONT_SANS:
1310 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1311 case RC_SCREEN_FONT_TYPEWRITER:
1312 os << "\\screen_font_typewriter \""
1313 << typewriter_font_name << "\"\n";
1314 case RC_SCREEN_FONT_SCALABLE:
1315 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1317 case RC_SCREEN_FONT_ENCODING:
1318 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1319 case RC_SCREEN_FONT_POPUP:
1320 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1321 case RC_SCREEN_FONT_MENU:
1322 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1323 case RC_SCREEN_FONT_SIZES:
1324 os.setf(ios::fixed);
1326 os << "\\screen_font_sizes";
1327 os << " " << font_sizes[LyXFont::SIZE_TINY];
1328 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1329 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1330 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1331 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1332 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1333 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1334 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1335 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1336 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1338 //case RC_SET_COLOR:
1339 // color bindings not written to preference file.
1340 // And we want to be warned about that. (Lgb)
1343 << "# PRINTER SECTION ###################################\n"
1347 os << "\\printer \"" << printer << "\"\n";
1348 case RC_PRINT_ADAPTOUTPUT:
1349 os << "\\print_adapt_output " << tostr(print_adapt_output)
1351 case RC_PRINT_COMMAND:
1352 os << "\\print_command \"" << print_command << "\"\n";
1353 case RC_PRINTEXSTRAOPTIONS:
1354 os << "\\print_extra_options \"" << print_extra_options
1356 case RC_PRINTSPOOL_COMMAND:
1357 os << "\\print_spool_command \"" << print_spool_command
1359 case RC_PRINTSPOOL_PRINTERPREFIX:
1360 os << "\\print_spool_printerprefix \""
1361 << print_spool_printerprefix << "\"\n";
1362 case RC_PRINTEVENPAGEFLAG:
1363 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1365 case RC_PRINTODDPAGEFLAG:
1366 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1368 case RC_PRINTREVERSEFLAG:
1369 os << "\\print_reverse_flag \"" << print_reverse_flag
1371 case RC_PRINTLANDSCAPEFLAG:
1372 os << "\\print_landscape_flag \"" << print_landscape_flag
1374 case RC_PRINTPAGERANGEFLAG:
1375 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1377 case RC_PRINTCOPIESFLAG:
1378 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1379 case RC_PRINTCOLLCOPIESFLAG:
1380 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1382 case RC_PRINTPAPERFLAG:
1383 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1384 case RC_PRINTPAPERDIMENSIONFLAG:
1385 os << "\\print_paper_dimension_flag \""
1386 << print_paper_dimension_flag << "\"\n";
1387 case RC_PRINTTOPRINTER:
1388 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1389 case RC_PRINTTOFILE:
1390 os << "\\print_to_file \"" << print_to_file << "\"\n";
1391 case RC_PRINTFILEEXTENSION:
1392 os << "\\print_file_extension \"" << print_file_extension
1396 << "# EXPORT SECTION ####################################\n"
1399 case RC_CUSTOM_EXPORT_COMMAND:
1400 os << "\\custom_export_command \"" << custom_export_command
1402 case RC_CUSTOM_EXPORT_FORMAT:
1403 os << "\\custom_export_format \"" << custom_export_format
1407 << "# TEX SECTION #######################################\n"
1410 case RC_LATEX_COMMAND:
1411 os << "\\latex_command \"" << latex_command << "\"\n";
1412 case RC_PDFLATEX_COMMAND:
1413 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1415 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1416 case RC_FONT_ENCODING:
1417 os << "\\font_encoding \"" << fontenc << "\"\n";
1420 << "# LINUXDOC SECTION ##################################\n"
1423 case RC_LINUXDOC_TO_LATEX_COMMAND:
1424 os << "\\linuxdoc_to_latex_command \"" << linuxdoc_to_latex_command
1426 case RC_LINUXDOC_TO_HTML_COMMAND:
1427 os << "\\linuxdoc_to_html_command \"" << linuxdoc_to_html_command
1429 case RC_LINUXDOC_TO_LYX_COMMAND:
1430 os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command
1434 << "# DOCBOOK SECTION ###################################\n"
1437 case RC_DOCBOOK_TO_DVI_COMMAND:
1438 os << "\\docbook_to_dvi_command \"" << docbook_to_dvi_command
1440 case RC_DOCBOOK_TO_HTML_COMMAND:
1441 os << "\\docbook_to_html_command \"" << docbook_to_html_command
1443 case RC_DOCBOOK_TO_PDF_COMMAND:
1444 os << "\\docbook_to_pdf_command \"" << docbook_to_pdf_command
1448 << "# FILE SECTION ######################################\n"
1451 case RC_DOCUMENTPATH:
1452 os << "\\document_path \"" << document_path << "\"\n";
1454 os << "\\lastfiles \"" << lastfiles << "\"\n";
1455 case RC_NUMLASTFILES:
1456 os << "\\num_lastfiles " << num_lastfiles << "\n";
1457 case RC_CHECKLASTFILES:
1458 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1459 case RC_TEMPLATEPATH:
1460 os << "\\template_path \"" << template_path << "\"\n";
1461 case RC_TEMPDIRPATH:
1462 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1464 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1465 case RC_ASCII_LINELEN:
1466 os << "\\ascii_linelen " << ascii_linelen << "\n";
1467 case RC_MAKE_BACKUP:
1468 os << "\\make_backup " << tostr(make_backup) << "\n";
1469 case RC_BACKUPDIR_PATH:
1470 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1473 << "# FAX SECTION #######################################\n"
1476 case RC_FAX_COMMAND:
1477 os << "\\fax_command \"" << fax_command << "\"\n";
1479 os << "\\phone_book \"" << phone_book << "\"\n";
1481 os << "\\fax_program \"" << fax_program << "\"\n";
1484 << "# ASCII EXPORT SECTION ##############################\n"
1487 case RC_ASCIIROFF_COMMAND:
1488 os << "\\ascii_roff_command \"" << ascii_roff_command
1492 << "# SPELLCHECKER SECTION ##############################\n"
1495 case RC_SPELL_COMMAND:
1496 os << "\\spell_command \"" << isp_command << "\"\n";
1497 case RC_ACCEPT_COMPOUND:
1498 os << "\\accept_compound " << tostr(isp_accept_compound)
1500 case RC_USE_ALT_LANG:
1501 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1503 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1504 case RC_USE_ESC_CHARS:
1505 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1508 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1509 case RC_USE_PERS_DICT:
1510 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1513 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1514 case RC_USE_INP_ENC:
1515 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1519 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1522 case RC_RTL_SUPPORT:
1523 os << "\\rtl " << tostr(rtl_support) << "\n";
1524 case RC_LANGUAGE_PACKAGE:
1525 os << "\\language_package \"" << language_package << "\"\n";
1526 case RC_LANGUAGE_COMMAND_BEGIN:
1527 os << "\\language_command_begin \"" << language_command_begin
1529 case RC_LANGUAGE_COMMAND_END:
1530 os << "\\language_command_end \"" << language_command_end
1532 case RC_LANGUAGE_AUTO_BEGIN:
1533 os << "\\language_auto_begin "
1534 << tostr(language_auto_begin) << "\n";
1535 case RC_LANGUAGE_AUTO_END:
1536 os << "\\language_auto_end "
1537 << tostr(language_auto_end) << "\n";
1538 case RC_MARK_FOREIGN_LANGUAGE:
1539 os << "\\mark_foreign_language " <<
1540 tostr(mark_foreign_language) << "\n";
1543 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1546 case RC_PDF_TO_PS_COMMAND:
1547 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1548 case RC_DVI_TO_PS_COMMAND:
1549 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1550 case RC_LITERATE_COMMAND:
1551 os << "\\literate_command \"" << literate_command << "\"\n";
1552 case RC_LITERATE_EXTENSION:
1553 os << "\\literate_extension \"" << literate_extension
1555 case RC_LITERATE_ERROR_FILTER:
1556 os << "\\literate_error_filter \"" << literate_error_filter
1558 case RC_BUILD_COMMAND:
1559 os << "\\build_command \"" << build_command << "\"\n";
1560 case RC_BUILD_ERROR_FILTER:
1561 os << "\\build_error_filter \"" << build_error_filter
1563 case RC_OVERRIDE_X_DEADKEYS:
1564 os << "\\override_x_deadkeys "
1565 << tostr(override_x_deadkeys) << "\n";
1566 case RC_SCREEN_FONT_ENCODING_MENU:
1567 os << "\\screen_font_encoding_menu \"" << font_norm_menu
1569 case RC_AUTO_NUMBER:
1570 os << "\\auto_number " << tostr(auto_number) << "\n";
1572 os << "\\use_gui " << tostr(use_gui) << "\n";
1573 case RC_NEW_ASK_FILENAME:
1574 os << "\\new_ask_filename " << tostr(new_ask_filename) << "\n";
1575 case RC_DEFAULT_LANGUAGE:
1576 os << "\\default_language " << default_language << "\n";
1581 void LyXRC::set_font_norm_type()
1583 if (font_norm == "iso10646-1")
1584 font_norm_type = ISO_10646_1;
1585 else if (font_norm == "iso8859-6.8x")
1586 font_norm_type = ISO_8859_6_8;
1588 font_norm_type = OTHER_ENCODING;
1591 // The global instance
1594 // The global copy of the system lyxrc entries (everything except preferences)
1595 //LyXRC system_lyxrc;