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,
167 keyword_item lyxrcTags[] = {
168 { "\\accept_compound", RC_ACCEPT_COMPOUND },
169 { "\\alternate_language", RC_ALT_LANG },
170 { "\\ascii_linelen", RC_ASCII_LINELEN },
171 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
172 { "\\auto_number", RC_AUTO_NUMBER },
173 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
174 { "\\autosave", RC_AUTOSAVE },
175 { "\\backupdir_path", RC_BACKUPDIR_PATH },
176 { "\\bind", RC_BIND },
177 { "\\bind_file", RC_BINDFILE },
178 { "\\build_command", RC_BUILD_COMMAND },
179 { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
180 { "\\check_lastfiles", RC_CHECKLASTFILES },
181 { "\\chktex_command", RC_CHKTEX_COMMAND },
182 { "\\converter", RC_CONVERTER },
183 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
184 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
185 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
186 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
187 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
188 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
189 { "\\docbook_to_dvi_command", RC_DOCBOOK_TO_DVI_COMMAND },
190 { "\\docbook_to_html_command", RC_DOCBOOK_TO_HTML_COMMAND },
191 { "\\docbook_to_pdf_command", RC_DOCBOOK_TO_PDF_COMMAND },
192 { "\\document_path", RC_DOCUMENTPATH },
193 { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
194 { "\\escape_chars", RC_ESC_CHARS },
195 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
196 { "\\fax_command", RC_FAX_COMMAND },
197 { "\\fax_program", RC_FAXPROGRAM },
198 { "\\font_encoding", RC_FONT_ENCODING },
199 { "\\html_command", RC_HTML_COMMAND },
200 { "\\input", RC_INPUT },
201 { "\\kbmap", RC_KBMAP },
202 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
203 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
204 { "\\language_auto_begin", RC_LANGUAGE_AUTO_BEGIN },
205 { "\\language_auto_end", RC_LANGUAGE_AUTO_END },
206 { "\\language_command_begin", RC_LANGUAGE_COMMAND_BEGIN },
207 { "\\language_command_end", RC_LANGUAGE_COMMAND_END },
208 { "\\language_package", RC_LANGUAGE_PACKAGE },
209 { "\\lastfiles", RC_LASTFILES },
210 { "\\latex_command", RC_LATEX_COMMAND },
211 { "\\linuxdoc_to_html_command", RC_LINUXDOC_TO_HTML_COMMAND },
212 { "\\linuxdoc_to_latex_command", RC_LINUXDOC_TO_LATEX_COMMAND },
213 { "\\linuxdoc_to_lyx_command", RC_LINUXDOC_TO_LYX_COMMAND },
214 { "\\literate_command", RC_LITERATE_COMMAND },
215 { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
216 { "\\literate_extension", RC_LITERATE_EXTENSION },
217 { "\\make_backup", RC_MAKE_BACKUP },
218 { "\\mark_foreign_language", RC_MARK_FOREIGN_LANGUAGE },
219 { "\\new_ask_filename", RC_NEW_ASK_FILENAME },
220 { "\\num_lastfiles", RC_NUMLASTFILES },
221 { "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
222 { "\\pdf_mode", RC_PDF_MODE },
223 { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
224 { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
225 { "\\personal_dictionary", RC_PERS_DICT },
226 { "\\phone_book", RC_PHONEBOOK },
227 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
228 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
229 { "\\print_command", RC_PRINT_COMMAND },
230 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
231 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
232 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
233 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
234 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
235 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
236 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
237 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
238 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
239 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
240 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
241 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
242 { "\\print_to_file", RC_PRINTTOFILE },
243 { "\\print_to_printer", RC_PRINTTOPRINTER },
244 { "\\printer", RC_PRINTER },
245 { "\\ps_command", RC_PS_COMMAND },
246 { "\\relyx_command", RC_RELYX_COMMAND },
247 { "\\rtl", RC_RTL_SUPPORT },
248 { "\\screen_dpi", RC_SCREEN_DPI },
249 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
250 { "\\screen_font_encoding_menu", RC_SCREEN_FONT_ENCODING_MENU },
251 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
252 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
253 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
254 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
255 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
256 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
257 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
258 { "\\screen_zoom", RC_SCREEN_ZOOM },
259 { "\\serverpipe", RC_SERVERPIPE },
260 { "\\set_color", RC_SET_COLOR },
261 { "\\show_banner", RC_SHOW_BANNER },
262 { "\\spell_command", RC_SPELL_COMMAND },
263 { "\\tempdir_path", RC_TEMPDIRPATH },
264 { "\\template_path", RC_TEMPLATEPATH },
265 { "\\ui_file", RC_UIFILE },
266 { "\\use_alt_language", RC_USE_ALT_LANG },
267 { "\\use_escape_chars", RC_USE_ESC_CHARS },
268 { "\\use_gui", RC_USE_GUI },
269 { "\\use_input_encoding", RC_USE_INP_ENC },
270 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
271 { "\\use_tempdir", RC_USETEMPDIR },
272 { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
273 { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
274 { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
275 { "\\view_ps_command", RC_VIEWPS_COMMAND },
276 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND },
277 { "\\viewer" ,RC_VIEWER},
278 { "\\wheel_jump", RC_WHEEL_JUMP }
281 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
282 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
291 void LyXRC::setDefaults() {
293 // Get printer from the environment. If fail, use default "",
294 // assuming that everything is set up correctly.
295 printer = GetEnv("PRINTER");
296 print_adapt_output = false;
297 print_command = "dvips";
298 print_evenpage_flag = "-B";
299 print_oddpage_flag = "-A";
300 print_pagerange_flag = "-pp";
301 print_copies_flag = "-c";
302 print_collcopies_flag = "-C";
303 print_reverse_flag = "-r";
304 print_landscape_flag = "-t landscape";
305 print_to_printer = "-P";
306 print_to_file = "-o ";
307 print_file_extension = ".ps";
308 print_paper_flag = "-t";
309 print_paper_dimension_flag = "-T";
310 document_path = GetEnvPath("HOME");
311 tempdir_path = "/tmp";
314 latex_command = "latex";
315 pdflatex_command = "pdflatex";
316 pdf_to_ps_command = "pdf2ps";
317 dvi_to_ps_command = "dvips";
318 literate_command = "none";
319 literate_extension = "none";
320 literate_error_filter = "cat";
321 build_command = "make";
322 build_error_filter = "cat";
323 relyx_command = "reLyX";
325 view_ps_command = "ghostview -swap";
326 view_pspic_command = "ghostview";
327 view_dvi_command = "xdvi";
328 view_dvi_paper_option = "-paper";
329 view_pdf_command = "xpdf";
330 default_papersize = BufferParams::PAPER_USLETTER;
331 custom_export_format = "ps";
332 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
333 html_command = "tth -t";
336 // Because a screen typically is wider than a piece of paper:
339 // Default LaTeX font size:
340 font_sizes[LyXFont::SIZE_TINY] = 5.0;
341 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
342 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
343 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
344 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
345 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
346 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
347 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
348 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
349 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
350 use_scalable_fonts = true;
351 roman_font_name = "-*-times";
352 sans_font_name = "-*-helvetica";
353 typewriter_font_name = "-*-courier";
354 menu_font_name = "-*-helvetica-bold-r";
355 popup_font_name = "-*-helvetica-medium-r";
356 font_norm = "iso8859-1";
357 font_norm_type = OTHER_ENCODING;
359 override_x_deadkeys = true;
361 auto_region_delete = true;
364 check_lastfiles = true;
367 exit_confirmation = true;
368 display_shortcuts = true;
369 // Spellchecker settings:
370 isp_command = "ispell";
371 isp_accept_compound = false;
372 isp_use_input_encoding = false;
373 isp_use_alt_lang = false;
374 isp_use_pers_dict = false;
375 isp_use_esc_chars = false;
380 mark_foreign_language = true;
381 language_package = "\\usepackage{babel}";
382 language_auto_begin = true;
383 language_auto_end = true;
384 language_command_begin = "\\selectlanguage{$$lang}";
385 language_command_end = "\\selectlanguage{$$lang}";
387 new_ask_filename = false;
390 date_insert_format = "%A, %e %B %Y";
395 linuxdoc_to_latex_command="none";
396 linuxdoc_to_lyx_command="none";
397 linuxdoc_to_html_command="none";
399 docbook_to_dvi_command="none";
400 docbook_to_html_command="none";
401 docbook_to_pdf_command="none";
405 int LyXRC::ReadBindFile(string const & name)
408 string tmp = i18nLibFileSearch("bind", name, "bind");
409 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
410 int result = read(tmp);
412 lyxerr << "Error reading bind file: " << tmp << endl;
418 int LyXRC::read(string const & filename)
421 string bindFile = "cua";
423 LyXLex lexrc(lyxrcTags, lyxrcCount);
424 if (lyxerr.debugging(Debug::PARSER))
425 lexrc.printTable(lyxerr);
427 lexrc.setFile(filename);
428 if (!lexrc.IsOK()) return -2;
430 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
432 while (lexrc.IsOK()) {
433 // By using two switches we take advantage of the compiler
434 // telling us if we have missed a LyXRCTags element in
435 // the second switch.
436 // Note that this also shows a problem with LyXLex since it
437 // helps us avoid taking advantage of the strictness of the
440 int le = lexrc.lex();
442 case LyXLex::LEX_UNDEF:
443 lexrc.printError("Unknown tag `$$Token'");
445 case LyXLex::LEX_FEOF:
449 switch (static_cast<LyXRCTags>(le)) {
450 case RC_INPUT: // Include file
452 string tmp = LibFileSearch(string(),
455 lexrc.printError("Error reading "
456 "included file: "+tmp);
460 case RC_BINDFILE: // RVDK_PATCH_5
462 string tmp(lexrc.GetString());
463 if (bind_file.empty()) {
464 // we only need the name of the first
465 // bind file since that (usually)
466 // includes several others.
475 ui_file = lexrc.GetString();
479 case RC_EXIT_CONFIRMATION:
481 exit_confirmation = lexrc.GetBool();
484 case RC_DISPLAY_SHORTCUTS:
486 display_shortcuts = lexrc.GetBool();
491 use_kbmap = lexrc.GetBool();
494 case RC_KBMAP_PRIMARY:
496 string kmap(lexrc.GetString());
499 } else if (!LibFileSearch("kbd", kmap,
501 primary_kbmap = kmap;
503 lexrc.printError("LyX: Keymap `$$Token' not found");
507 case RC_KBMAP_SECONDARY:
509 string kmap(lexrc.GetString());
512 } else if (!LibFileSearch("kbd", kmap,
514 secondary_kbmap = kmap;
516 lexrc.printError("LyX: Keymap `$$Token' not found");
520 case RC_FONT_ENCODING:
522 fontenc = lexrc.GetString();
527 printer = lexrc.GetString();
530 case RC_PRINT_COMMAND:
532 print_command = lexrc.GetString();
535 case RC_PRINTEVENPAGEFLAG:
537 print_evenpage_flag = lexrc.GetString();
540 case RC_PRINTODDPAGEFLAG:
542 print_oddpage_flag = lexrc.GetString();
545 case RC_PRINTPAGERANGEFLAG:
547 print_pagerange_flag = lexrc.GetString();
550 case RC_PRINTCOPIESFLAG:
552 print_copies_flag = lexrc.GetString();
555 case RC_PRINTCOLLCOPIESFLAG:
557 print_collcopies_flag = lexrc.GetString();
560 case RC_PRINTREVERSEFLAG:
562 print_reverse_flag = lexrc.GetString();
565 case RC_PRINTLANDSCAPEFLAG:
567 print_landscape_flag = lexrc.GetString();
570 case RC_PRINTTOPRINTER:
572 print_to_printer = lexrc.GetString();
575 case RC_PRINT_ADAPTOUTPUT:
577 print_adapt_output = lexrc.GetBool();
582 print_to_file = lexrc.GetString();
585 case RC_PRINTFILEEXTENSION:
587 print_file_extension = lexrc.GetString();
590 case RC_PRINTEXSTRAOPTIONS:
592 print_extra_options = lexrc.GetString();
595 case RC_PRINTSPOOL_COMMAND:
597 print_spool_command = lexrc.GetString();
600 case RC_PRINTSPOOL_PRINTERPREFIX:
602 print_spool_printerprefix = lexrc.GetString();
605 case RC_PRINTPAPERDIMENSIONFLAG:
607 print_paper_dimension_flag = lexrc.GetString();
610 case RC_PRINTPAPERFLAG:
612 print_paper_flag = lexrc.GetString();
615 case RC_CUSTOM_EXPORT_COMMAND:
617 custom_export_command = lexrc.GetString();
620 case RC_CUSTOM_EXPORT_FORMAT:
622 custom_export_format = lexrc.GetString();
627 pdf_mode = lexrc.GetBool();
630 case RC_LATEX_COMMAND:
632 latex_command = lexrc.GetString();
635 case RC_PDFLATEX_COMMAND:
637 pdflatex_command = lexrc.GetString();
640 case RC_PDF_TO_PS_COMMAND:
642 pdf_to_ps_command = lexrc.GetString();
645 case RC_DVI_TO_PS_COMMAND:
647 dvi_to_ps_command = lexrc.GetString();
650 case RC_LITERATE_COMMAND:
652 literate_command = lexrc.GetString();
655 case RC_LITERATE_EXTENSION:
657 literate_extension = lexrc.GetString();
660 case RC_LITERATE_ERROR_FILTER:
662 literate_error_filter = lexrc.GetString();
665 case RC_BUILD_COMMAND:
667 build_command = lexrc.GetString();
670 case RC_BUILD_ERROR_FILTER:
672 build_error_filter = lexrc.GetString();
675 case RC_RELYX_COMMAND:
677 relyx_command = lexrc.GetString();
680 case RC_DEFAULT_PAPERSIZE:
682 string size = lowercase(lexrc.GetString());
683 if (size == "usletter")
685 BufferParams::PAPER_USLETTER;
686 else if (size == "legal")
688 BufferParams::PAPER_LEGALPAPER;
689 else if (size == "executive")
691 BufferParams::PAPER_EXECUTIVEPAPER;
692 else if (size == "a3")
694 BufferParams::PAPER_A3PAPER;
695 else if (size == "a4")
697 BufferParams::PAPER_A4PAPER;
698 else if (size == "a5")
700 BufferParams::PAPER_A5PAPER;
701 else if (size == "b5")
703 BufferParams::PAPER_B5PAPER;
706 case RC_VIEWDVI_COMMAND:
708 view_dvi_command = lexrc.GetString();
711 case RC_VIEWDVI_PAPEROPTION:
713 view_dvi_paper_option = lexrc.GetString();
715 view_dvi_paper_option = "";
718 case RC_VIEWPDF_COMMAND:
720 view_pdf_command = lexrc.GetString();
725 ps_command = lexrc.GetString();
728 case RC_VIEWPS_COMMAND:
730 view_ps_command = lexrc.GetString();
733 case RC_VIEWPSPIC_COMMAND:
735 view_pspic_command = lexrc.GetString();
738 case RC_CHKTEX_COMMAND:
740 chktex_command = lexrc.GetString();
743 case RC_HTML_COMMAND:
745 html_command = lexrc.GetString();
750 dpi = lexrc.GetInteger();
755 zoom = lexrc.GetInteger();
760 wheel_jump = lexrc.GetInteger();
763 case RC_SCREEN_FONT_SIZES:
765 font_sizes[LyXFont::SIZE_TINY] =
768 font_sizes[LyXFont::SIZE_SCRIPT] =
771 font_sizes[LyXFont::SIZE_FOOTNOTE] =
774 font_sizes[LyXFont::SIZE_SMALL] =
777 font_sizes[LyXFont::SIZE_NORMAL] =
780 font_sizes[LyXFont::SIZE_LARGE] =
783 font_sizes[LyXFont::SIZE_LARGER] =
786 font_sizes[LyXFont::SIZE_LARGEST] =
789 font_sizes[LyXFont::SIZE_HUGE] =
792 font_sizes[LyXFont::SIZE_HUGER] =
796 case RC_SCREEN_FONT_SCALABLE:
798 use_scalable_fonts = lexrc.GetBool();
803 autosave = lexrc.GetInteger();
806 case RC_DOCUMENTPATH:
808 document_path = ExpandPath(lexrc.GetString());
812 case RC_TEMPLATEPATH:
814 template_path = ExpandPath(lexrc.GetString());
819 tempdir_path = ExpandPath(lexrc.GetString());
824 use_tempdir = lexrc.GetBool();
829 lastfiles = ExpandPath(lexrc.GetString());
832 case RC_NUMLASTFILES:
834 num_lastfiles = lexrc.GetInteger();
837 case RC_CHECKLASTFILES:
839 check_lastfiles = lexrc.GetBool();
842 case RC_SCREEN_FONT_ROMAN:
844 roman_font_name = lexrc.GetString();
847 case RC_SCREEN_FONT_SANS:
849 sans_font_name = lexrc.GetString();
852 case RC_SCREEN_FONT_TYPEWRITER:
854 typewriter_font_name = lexrc.GetString();
857 case RC_SCREEN_FONT_MENU:
859 menu_font_name = lexrc.GetString();
862 case RC_SCREEN_FONT_POPUP:
864 popup_font_name = lexrc.GetString();
867 case RC_SCREEN_FONT_ENCODING:
869 font_norm = lexrc.GetString();
870 set_font_norm_type();
874 case RC_SCREEN_FONT_ENCODING_MENU:
876 font_norm_menu = lexrc.GetString();
881 string lyx_name, x11_name;
884 lyx_name = lexrc.GetString();
886 lexrc.printError("Missing color tag.");
891 x11_name = lexrc.GetString();
893 lexrc.printError("Missing color name for color : `$$Token'");
897 if (!lcolor.setColor(lyx_name, x11_name))
898 lyxerr << "Bad lyxrc set_color for "
903 case RC_AUTOREGIONDELETE:
904 // Auto region delete defaults to true
906 auto_region_delete = lexrc.GetBool();
911 // we should not do an explicit binding before
912 // loading a bind file. So, in this case, load
913 // the default bind file.
916 bind_file = bindFile;
918 // !!!chb, dynamic key binding...
922 if (lexrc.lex() == LyXLex::LEX_DATA) {
923 seq = lexrc.GetString();
925 lexrc.printError("Bad key sequence: `$$Token'");
929 if (lexrc.lex() == LyXLex::LEX_DATA) {
930 cmd = lexrc.GetString();
932 lexrc.printError("Bad command: `$$Token'");
936 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
937 if (lyxerr.debugging(Debug::KBMAP)) {
938 lyxerr << "RC_BIND: Sequence `"
939 << seq << "' Command `"
940 << cmd << "' Action `"
941 << action << '\'' << endl;
943 res = toplevel_keymap->bind(seq.c_str(),
947 "Invalid key sequence `"
950 } else {// cmd is the last token read.
952 "Unknown LyX function `$$Token'");
956 case RC_OVERRIDE_X_DEADKEYS:
958 override_x_deadkeys = lexrc.GetBool();
963 lyxpipes = ExpandPath(lexrc.GetString());
966 case RC_CURSOR_FOLLOWS_SCROLLBAR:
968 cursor_follows_scrollbar = lexrc.GetBool();
973 fax_command = lexrc.GetString();
977 fax_program = lexrc.GetString();
981 string s = lexrc.GetString();
985 phone_book = user_lyxdir + s;
988 case RC_ASCIIROFF_COMMAND:
990 ascii_roff_command = lexrc.GetString();
992 case RC_ASCII_LINELEN:
994 ascii_linelen = lexrc.GetInteger();
996 // Spellchecker settings:
997 case RC_SPELL_COMMAND:
999 isp_command = lexrc.GetString();
1001 case RC_ACCEPT_COMPOUND:
1003 isp_accept_compound = lexrc.GetBool();
1005 case RC_USE_INP_ENC:
1007 isp_use_input_encoding = lexrc.GetBool();
1009 case RC_USE_ALT_LANG:
1011 isp_use_alt_lang = lexrc.GetBool();
1013 case RC_USE_PERS_DICT:
1015 isp_use_pers_dict = lexrc.GetBool();
1017 case RC_USE_ESC_CHARS:
1019 isp_use_esc_chars = lexrc.GetBool();
1023 isp_alt_lang = lexrc.GetString();
1027 isp_pers_dict = lexrc.GetString();
1031 isp_esc_chars = lexrc.GetString();
1033 case RC_MAKE_BACKUP:
1035 make_backup = lexrc.GetBool();
1037 case RC_BACKUPDIR_PATH:
1039 backupdir_path = ExpandPath(lexrc.GetString());
1041 case RC_DATE_INSERT_FORMAT:
1043 date_insert_format = lexrc.GetString();
1045 case RC_LANGUAGE_PACKAGE:
1047 language_package = lexrc.GetString();
1049 case RC_LANGUAGE_AUTO_BEGIN:
1051 language_auto_begin = lexrc.GetBool();
1053 case RC_LANGUAGE_AUTO_END:
1055 language_auto_end = lexrc.GetBool();
1057 case RC_LANGUAGE_COMMAND_BEGIN:
1059 language_command_begin = lexrc.GetString();
1061 case RC_LANGUAGE_COMMAND_END:
1063 language_command_end = lexrc.GetString();
1065 case RC_RTL_SUPPORT:
1067 rtl_support = lexrc.GetBool();
1069 case RC_AUTO_NUMBER:
1071 auto_number = lexrc.GetBool();
1073 case RC_MARK_FOREIGN_LANGUAGE:
1075 mark_foreign_language = lexrc.GetBool();
1077 case RC_SHOW_BANNER:
1079 show_banner = lexrc.GetBool();
1083 use_gui = lexrc.GetBool();
1085 case RC_LINUXDOC_TO_LYX_COMMAND:
1087 linuxdoc_to_lyx_command = lexrc.GetString();
1089 case RC_LINUXDOC_TO_HTML_COMMAND:
1091 linuxdoc_to_html_command = lexrc.GetString();
1093 case RC_LINUXDOC_TO_LATEX_COMMAND:
1095 linuxdoc_to_latex_command = lexrc.GetString();
1097 case RC_DOCBOOK_TO_DVI_COMMAND:
1099 docbook_to_dvi_command = lexrc.GetString();
1101 case RC_DOCBOOK_TO_HTML_COMMAND:
1103 docbook_to_html_command = lexrc.GetString();
1105 case RC_DOCBOOK_TO_PDF_COMMAND:
1107 docbook_to_pdf_command = lexrc.GetString();
1110 case RC_NEW_ASK_FILENAME:
1112 new_ask_filename = lexrc.GetBool();
1116 string from, to, command, flags;
1118 from = lexrc.GetString();
1120 to = lexrc.GetString();
1122 command = lexrc.GetString();
1124 flags = lexrc.GetString();
1125 Converter::Add(from, to, command, flags);
1130 string format, command;
1132 format = lexrc.GetString();
1134 command = lexrc.GetString();
1135 Formats::SetViewer(format, command);
1139 case RC_LAST: break; // this is just a dummy
1147 void LyXRC::write(string const & filename) const
1149 ofstream ofs(filename.c_str());
1155 void LyXRC::print() const
1157 if (lyxerr.debugging())
1164 void LyXRC::output(ostream & os) const
1166 os << "### This file is part of\n"
1167 << "### ========================================================\n"
1168 << "### LyX, The Document Processor\n"
1170 << "### Copyright 1995 Matthias Ettrich\n"
1171 << "### Copyright 1995-2000 The LyX Team.\n"
1173 << "### ========================================================\n"
1175 << "# This file is written by LyX, if you want to make your own\n"
1176 << "# modifications you should do them from inside LyX and save\n"
1179 // Why the switch you might ask. It is a trick to ensure that all
1180 // the elements in the LyXRCTags enum is handled. As you can see
1181 // there are no breaks at all. So it is just a huge fall-through.
1182 // The nice thing is that we will get a warning from the compiler
1183 // if we forget an element.
1184 LyXRCTags tag = RC_LAST;
1188 // input/include files are not done here
1190 // bindings is not written to the preferences file.
1192 os << "\\bind_file " << bind_file << "\n";
1198 << "# MISC SECTION ######################################\n"
1201 case RC_SHOW_BANNER:
1202 os << "# Set to false to inhibit the startup banner.\n"
1203 << "\\show_banner " << tostr(show_banner) << "\n";
1205 // bind files are not done here.
1207 os << "\\ui_file \"" << ui_file << "\"\n";
1208 case RC_AUTOREGIONDELETE:
1209 os << "# Set to false to inhibit automatic replacement of\n"
1210 << "# the current selection.\n"
1211 << "\\auto_region_delete " << tostr(auto_region_delete)
1214 os << "# The time interval between auto-saves in seconds.\n"
1215 << "\\autosave " << autosave << "\n";
1216 case RC_EXIT_CONFIRMATION:
1217 os << "# Ask for confirmation before exit if there are\n"
1218 << "# unsaved changed documents.\n"
1219 << "\\exit_confirmation " << tostr(exit_confirmation)
1221 case RC_DISPLAY_SHORTCUTS:
1222 os << "# Display name of the last command executed, with a\n"
1223 << "# list of short-cuts in the minibuffer.\n"
1224 << "\\display_shortcuts " << tostr(display_shortcuts)
1226 case RC_VIEWDVI_COMMAND:
1227 os << "# Program used to view dvi files.\n"
1228 << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1229 case RC_VIEWDVI_PAPEROPTION:
1230 os << "# Options used to specify paper size to the\n"
1231 << "# view_dvi_command\n"
1232 << "\\view_dvi_paper_option \""
1233 << view_dvi_paper_option << "\"\n";
1234 case RC_DEFAULT_PAPERSIZE:
1235 os << "# The default papersize to use.\n"
1236 << "\\default_papersize \"";
1237 switch (default_papersize) {
1238 case BufferParams::PAPER_USLETTER:
1239 os << "usletter"; break;
1240 case BufferParams::PAPER_LEGALPAPER:
1241 os << "legal"; break;
1242 case BufferParams::PAPER_EXECUTIVEPAPER:
1243 os << "executive"; break;
1244 case BufferParams::PAPER_A3PAPER:
1246 case BufferParams::PAPER_A4PAPER:
1248 case BufferParams::PAPER_A5PAPER:
1250 case BufferParams::PAPER_B5PAPER:
1252 case BufferParams::PAPER_DEFAULT: break;
1255 case RC_VIEWPDF_COMMAND:
1256 os << "# Command used to view PDF files.\n"
1257 << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1258 case RC_VIEWPS_COMMAND:
1259 os << "# Command used to view PostScript files.\n"
1260 << "\\view_ps_command \"" << view_ps_command << "\"\n";
1261 case RC_VIEWPSPIC_COMMAND:
1262 os << "# Command used to view full screen included PS\n"
1264 << "\\view_pspic_command \"" << view_pspic_command
1267 os << "# Program used for interpreting postscript.\n"
1268 << "\\ps_command \"" << ps_command << "\"\n";
1269 case RC_CHKTEX_COMMAND:
1270 os << "\\chktex_command \"" << chktex_command << "\"\n";
1271 case RC_HTML_COMMAND:
1272 os << "\\html_command \"" << html_command << "\"\n";
1274 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1275 case RC_KBMAP_PRIMARY:
1276 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1277 case RC_KBMAP_SECONDARY:
1278 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1280 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1281 case RC_RELYX_COMMAND:
1282 os << "\\relyx_command \"" << relyx_command << "\"\n";
1283 case RC_DATE_INSERT_FORMAT:
1284 os << "\\date_insert_format \"" << date_insert_format
1289 << "# SCREEN & FONTS SECTION ############################\n"
1293 os << "\\screen_dpi " << dpi << "\n";
1294 case RC_SCREEN_ZOOM:
1295 os << "\\screen_zoom " << zoom << "\n";
1297 os << "\\wheel_jump " << wheel_jump << "\n";
1298 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1299 os << "\\cursor_follows_scrollbar "
1300 << tostr(cursor_follows_scrollbar) << "\n";
1301 case RC_SCREEN_FONT_ROMAN:
1302 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1303 case RC_SCREEN_FONT_SANS:
1304 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1305 case RC_SCREEN_FONT_TYPEWRITER:
1306 os << "\\screen_font_typewriter \""
1307 << typewriter_font_name << "\"\n";
1308 case RC_SCREEN_FONT_SCALABLE:
1309 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1311 case RC_SCREEN_FONT_ENCODING:
1312 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1313 case RC_SCREEN_FONT_POPUP:
1314 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1315 case RC_SCREEN_FONT_MENU:
1316 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1317 case RC_SCREEN_FONT_SIZES:
1318 os.setf(ios::fixed);
1320 os << "\\screen_font_sizes";
1321 os << " " << font_sizes[LyXFont::SIZE_TINY];
1322 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1323 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1324 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1325 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1326 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1327 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1328 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1329 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1330 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1332 //case RC_SET_COLOR:
1333 // color bindings not written to preference file.
1334 // And we want to be warned about that. (Lgb)
1337 << "# PRINTER SECTION ###################################\n"
1341 os << "\\printer \"" << printer << "\"\n";
1342 case RC_PRINT_ADAPTOUTPUT:
1343 os << "\\print_adapt_output " << tostr(print_adapt_output)
1345 case RC_PRINT_COMMAND:
1346 os << "\\print_command \"" << print_command << "\"\n";
1347 case RC_PRINTEXSTRAOPTIONS:
1348 os << "\\print_extra_options \"" << print_extra_options
1350 case RC_PRINTSPOOL_COMMAND:
1351 os << "\\print_spool_command \"" << print_spool_command
1353 case RC_PRINTSPOOL_PRINTERPREFIX:
1354 os << "\\print_spool_printerprefix \""
1355 << print_spool_printerprefix << "\"\n";
1356 case RC_PRINTEVENPAGEFLAG:
1357 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1359 case RC_PRINTODDPAGEFLAG:
1360 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1362 case RC_PRINTREVERSEFLAG:
1363 os << "\\print_reverse_flag \"" << print_reverse_flag
1365 case RC_PRINTLANDSCAPEFLAG:
1366 os << "\\print_landscape_flag \"" << print_landscape_flag
1368 case RC_PRINTPAGERANGEFLAG:
1369 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1371 case RC_PRINTCOPIESFLAG:
1372 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1373 case RC_PRINTCOLLCOPIESFLAG:
1374 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1376 case RC_PRINTPAPERFLAG:
1377 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1378 case RC_PRINTPAPERDIMENSIONFLAG:
1379 os << "\\print_paper_dimension_flag \""
1380 << print_paper_dimension_flag << "\"\n";
1381 case RC_PRINTTOPRINTER:
1382 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1383 case RC_PRINTTOFILE:
1384 os << "\\print_to_file \"" << print_to_file << "\"\n";
1385 case RC_PRINTFILEEXTENSION:
1386 os << "\\print_file_extension \"" << print_file_extension
1390 << "# EXPORT SECTION ####################################\n"
1393 case RC_CUSTOM_EXPORT_COMMAND:
1394 os << "\\custom_export_command \"" << custom_export_command
1396 case RC_CUSTOM_EXPORT_FORMAT:
1397 os << "\\custom_export_format \"" << custom_export_format
1401 << "# TEX SECTION #######################################\n"
1404 case RC_LATEX_COMMAND:
1405 os << "\\latex_command \"" << latex_command << "\"\n";
1406 case RC_PDFLATEX_COMMAND:
1407 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1409 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1410 case RC_FONT_ENCODING:
1411 os << "\\font_encoding \"" << fontenc << "\"\n";
1414 << "# LINUXDOC SECTION ##################################\n"
1417 case RC_LINUXDOC_TO_LATEX_COMMAND:
1418 os << "\\linuxdoc_to_latex_command \"" << linuxdoc_to_latex_command
1420 case RC_LINUXDOC_TO_HTML_COMMAND:
1421 os << "\\linuxdoc_to_html_command \"" << linuxdoc_to_html_command
1423 case RC_LINUXDOC_TO_LYX_COMMAND:
1424 os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command
1428 << "# DOCBOOK SECTION ###################################\n"
1431 case RC_DOCBOOK_TO_DVI_COMMAND:
1432 os << "\\docbook_to_dvi_command \"" << docbook_to_dvi_command
1434 case RC_DOCBOOK_TO_HTML_COMMAND:
1435 os << "\\docbook_to_html_command \"" << docbook_to_html_command
1437 case RC_DOCBOOK_TO_PDF_COMMAND:
1438 os << "\\docbook_to_pdf_command \"" << docbook_to_pdf_command
1442 << "# FILE SECTION ######################################\n"
1445 case RC_DOCUMENTPATH:
1446 os << "\\document_path \"" << document_path << "\"\n";
1448 os << "\\lastfiles \"" << lastfiles << "\"\n";
1449 case RC_NUMLASTFILES:
1450 os << "\\num_lastfiles " << num_lastfiles << "\n";
1451 case RC_CHECKLASTFILES:
1452 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1453 case RC_TEMPLATEPATH:
1454 os << "\\template_path \"" << template_path << "\"\n";
1455 case RC_TEMPDIRPATH:
1456 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1458 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1459 case RC_ASCII_LINELEN:
1460 os << "\\ascii_linelen " << ascii_linelen << "\n";
1461 case RC_MAKE_BACKUP:
1462 os << "\\make_backup " << tostr(make_backup) << "\n";
1463 case RC_BACKUPDIR_PATH:
1464 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1467 << "# FAX SECTION #######################################\n"
1470 case RC_FAX_COMMAND:
1471 os << "\\fax_command \"" << fax_command << "\"\n";
1473 os << "\\phone_book \"" << phone_book << "\"\n";
1475 os << "\\fax_program \"" << fax_program << "\"\n";
1478 << "# ASCII EXPORT SECTION ##############################\n"
1481 case RC_ASCIIROFF_COMMAND:
1482 os << "\\ascii_roff_command \"" << ascii_roff_command
1486 << "# SPELLCHECKER SECTION ##############################\n"
1489 case RC_SPELL_COMMAND:
1490 os << "\\spell_command \"" << isp_command << "\"\n";
1491 case RC_ACCEPT_COMPOUND:
1492 os << "\\accept_compound " << tostr(isp_accept_compound)
1494 case RC_USE_ALT_LANG:
1495 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1497 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1498 case RC_USE_ESC_CHARS:
1499 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1502 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1503 case RC_USE_PERS_DICT:
1504 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1507 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1508 case RC_USE_INP_ENC:
1509 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1513 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1516 case RC_RTL_SUPPORT:
1517 os << "\\rtl " << tostr(rtl_support) << "\n";
1518 case RC_LANGUAGE_PACKAGE:
1519 os << "\\language_package \"" << language_package << "\"\n";
1520 case RC_LANGUAGE_COMMAND_BEGIN:
1521 os << "\\language_command_begin \"" << language_command_begin
1523 case RC_LANGUAGE_COMMAND_END:
1524 os << "\\language_command_end \"" << language_command_end
1526 case RC_LANGUAGE_AUTO_BEGIN:
1527 os << "\\language_auto_begin "
1528 << tostr(language_auto_begin) << "\n";
1529 case RC_LANGUAGE_AUTO_END:
1530 os << "\\language_auto_end "
1531 << tostr(language_auto_end) << "\n";
1532 case RC_MARK_FOREIGN_LANGUAGE:
1533 os << "\\mark_foreign_language " <<
1534 tostr(mark_foreign_language) << "\n";
1537 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1540 case RC_PDF_TO_PS_COMMAND:
1541 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1542 case RC_DVI_TO_PS_COMMAND:
1543 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1544 case RC_LITERATE_COMMAND:
1545 os << "\\literate_command \"" << literate_command << "\"\n";
1546 case RC_LITERATE_EXTENSION:
1547 os << "\\literate_extension \"" << literate_extension
1549 case RC_LITERATE_ERROR_FILTER:
1550 os << "\\literate_error_filter \"" << literate_error_filter
1552 case RC_BUILD_COMMAND:
1553 os << "\\build_command \"" << build_command << "\"\n";
1554 case RC_BUILD_ERROR_FILTER:
1555 os << "\\build_error_filter \"" << build_error_filter
1557 case RC_OVERRIDE_X_DEADKEYS:
1558 os << "\\override_x_deadkeys "
1559 << tostr(override_x_deadkeys) << "\n";
1560 case RC_SCREEN_FONT_ENCODING_MENU:
1561 os << "\\screen_font_encoding_menu \"" << font_norm_menu
1563 case RC_AUTO_NUMBER:
1564 os << "\\auto_number " << tostr(auto_number) << "\n";
1566 os << "\\use_gui " << tostr(use_gui) << "\n";
1567 case RC_NEW_ASK_FILENAME:
1568 os << "\\new_ask_filename " << tostr(new_ask_filename) << "\n";
1573 void LyXRC::set_font_norm_type()
1575 if (font_norm == "iso10646-1")
1576 font_norm_type = ISO_10646_1;
1577 else if (font_norm == "iso8859-6.8x")
1578 font_norm_type = ISO_8859_6_8;
1580 font_norm_type = OTHER_ENCODING;
1583 // The global instance
1586 // The global copy of the system lyxrc entries (everything except preferences)
1587 //LyXRC system_lyxrc;