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;
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,
96 RC_OVERRIDE_X_DEADKEYS,
106 RC_ASCIIROFF_COMMAND,
111 RC_VIEWDVI_PAPEROPTION,
112 RC_DEFAULT_PAPERSIZE,
115 RC_VIEWPSPIC_COMMAND,
122 RC_SCREEN_FONT_SCALABLE,
127 RC_CURSOR_FOLLOWS_SCROLLBAR,
128 RC_EXIT_CONFIRMATION,
129 RC_DISPLAY_SHORTCUTS,
136 RC_MARK_FOREIGN_LANGUAGE,
138 RC_LANGUAGE_AUTO_BEGIN,
139 RC_LANGUAGE_AUTO_END,
140 RC_LANGUAGE_COMMAND_BEGIN,
141 RC_LANGUAGE_COMMAND_END,
145 RC_PDF_TO_PS_COMMAND,
146 RC_DVI_TO_PS_COMMAND,
147 RC_DATE_INSERT_FORMAT,
150 RC_LINUXDOC_TO_LYX_COMMAND,
151 RC_LINUXDOC_TO_HTML_COMMAND,
152 RC_LINUXDOC_TO_LATEX_COMMAND,
153 RC_DOCBOOK_TO_DVI_COMMAND,
154 RC_DOCBOOK_TO_HTML_COMMAND,
155 RC_DOCBOOK_TO_PDF_COMMAND,
161 keyword_item lyxrcTags[] = {
162 { "\\accept_compound", RC_ACCEPT_COMPOUND },
163 { "\\alternate_language", RC_ALT_LANG },
164 { "\\ascii_linelen", RC_ASCII_LINELEN },
165 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
166 { "\\auto_number", RC_AUTO_NUMBER },
167 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
168 { "\\autosave", RC_AUTOSAVE },
169 { "\\backupdir_path", RC_BACKUPDIR_PATH },
170 { "\\begin_toolbar", RC_BEGINTOOLBAR },
171 { "\\bind", RC_BIND },
172 { "\\bind_file", RC_BINDFILE },
173 { "\\build_command", RC_BUILD_COMMAND },
174 { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
175 { "\\check_lastfiles", RC_CHECKLASTFILES },
176 { "\\chktex_command", RC_CHKTEX_COMMAND },
177 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
178 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
179 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
180 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
181 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
182 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
183 { "\\docbook_to_dvi_command", RC_DOCBOOK_TO_DVI_COMMAND },
184 { "\\docbook_to_html_command", RC_DOCBOOK_TO_HTML_COMMAND },
185 { "\\docbook_to_pdf_command", RC_DOCBOOK_TO_PDF_COMMAND },
186 { "\\document_path", RC_DOCUMENTPATH },
187 { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
188 { "\\escape_chars", RC_ESC_CHARS },
189 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
190 { "\\fax_command", RC_FAX_COMMAND },
191 { "\\fax_program", RC_FAXPROGRAM },
192 { "\\font_encoding", RC_FONT_ENCODING },
193 { "\\html_command", RC_HTML_COMMAND },
194 { "\\input", RC_INPUT },
195 { "\\kbmap", RC_KBMAP },
196 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
197 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
198 { "\\language_auto_begin", RC_LANGUAGE_AUTO_BEGIN },
199 { "\\language_auto_end", RC_LANGUAGE_AUTO_END },
200 { "\\language_command_begin", RC_LANGUAGE_COMMAND_BEGIN },
201 { "\\language_command_end", RC_LANGUAGE_COMMAND_END },
202 { "\\language_package", RC_LANGUAGE_PACKAGE },
203 { "\\lastfiles", RC_LASTFILES },
204 { "\\latex_command", RC_LATEX_COMMAND },
205 { "\\linuxdoc_to_html_command", RC_LINUXDOC_TO_HTML_COMMAND },
206 { "\\linuxdoc_to_latex_command", RC_LINUXDOC_TO_LATEX_COMMAND },
207 { "\\linuxdoc_to_lyx_command", RC_LINUXDOC_TO_LYX_COMMAND },
208 { "\\literate_command", RC_LITERATE_COMMAND },
209 { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
210 { "\\literate_extension", RC_LITERATE_EXTENSION },
211 { "\\make_backup", RC_MAKE_BACKUP },
212 { "\\mark_foreign_language", RC_MARK_FOREIGN_LANGUAGE },
213 { "\\num_lastfiles", RC_NUMLASTFILES },
214 { "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
215 { "\\pdf_mode", RC_PDF_MODE },
216 { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
217 { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
218 { "\\personal_dictionary", RC_PERS_DICT },
219 { "\\phone_book", RC_PHONEBOOK },
220 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
221 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
222 { "\\print_command", RC_PRINT_COMMAND },
223 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
224 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
225 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
226 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
227 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
228 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
229 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
230 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
231 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
232 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
233 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
234 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
235 { "\\print_to_file", RC_PRINTTOFILE },
236 { "\\print_to_printer", RC_PRINTTOPRINTER },
237 { "\\printer", RC_PRINTER },
238 { "\\ps_command", RC_PS_COMMAND },
239 { "\\relyx_command", RC_RELYX_COMMAND },
240 { "\\rtl", RC_RTL_SUPPORT },
241 { "\\screen_dpi", RC_SCREEN_DPI },
242 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
243 { "\\screen_font_encoding_menu", RC_SCREEN_FONT_ENCODING_MENU },
244 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
245 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
246 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
247 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
248 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
249 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
250 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
251 { "\\screen_zoom", RC_SCREEN_ZOOM },
252 { "\\serverpipe", RC_SERVERPIPE },
253 { "\\show_banner", RC_SHOW_BANNER },
254 { "\\spell_command", RC_SPELL_COMMAND },
255 { "\\tempdir_path", RC_TEMPDIRPATH },
256 { "\\template_path", RC_TEMPLATEPATH },
257 { "\\use_alt_language", RC_USE_ALT_LANG },
258 { "\\use_escape_chars", RC_USE_ESC_CHARS },
259 { "\\use_gui", RC_USE_GUI },
260 { "\\use_input_encoding", RC_USE_INP_ENC },
261 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
262 { "\\use_tempdir", RC_USETEMPDIR },
263 { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
264 { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
265 { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
266 { "\\view_ps_command", RC_VIEWPS_COMMAND },
267 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
270 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
271 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
280 void LyXRC::setDefaults() {
281 // Get printer from the environment. If fail, use default "",
282 // assuming that everything is set up correctly.
283 printer = GetEnv("PRINTER");
284 print_adapt_output = false;
285 print_command = "dvips";
286 print_evenpage_flag = "-B";
287 print_oddpage_flag = "-A";
288 print_pagerange_flag = "-pp";
289 print_copies_flag = "-c";
290 print_collcopies_flag = "-C";
291 print_reverse_flag = "-r";
292 print_landscape_flag = "-t landscape";
293 print_to_printer = "-P";
294 print_to_file = "-o ";
295 print_file_extension = ".ps";
296 print_paper_flag = "-t";
297 print_paper_dimension_flag = "-T";
298 document_path = GetEnvPath("HOME");
299 tempdir_path = "/tmp";
302 latex_command = "latex";
303 pdflatex_command = "pdflatex";
304 pdf_to_ps_command = "pdf2ps";
305 dvi_to_ps_command = "dvips";
306 literate_command = "none";
307 literate_extension = "none";
308 literate_error_filter = "cat";
309 build_command = "make";
310 build_error_filter = "cat";
311 relyx_command = "reLyX";
313 view_ps_command = "ghostview -swap";
314 view_pspic_command = "ghostview";
315 view_dvi_command = "xdvi";
316 view_dvi_paper_option = "-paper";
317 view_pdf_command = "xpdf";
318 default_papersize = BufferParams::PAPER_USLETTER;
319 custom_export_format = "ps";
320 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
321 html_command = "tth -t";
324 // Because a screen typically is wider than a piece of paper:
326 // Default LaTeX font size:
327 font_sizes[LyXFont::SIZE_TINY] = 5.0;
328 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
329 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
330 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
331 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
332 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
333 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
334 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
335 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
336 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
337 use_scalable_fonts = true;
338 roman_font_name = "-*-times";
339 sans_font_name = "-*-helvetica";
340 typewriter_font_name = "-*-courier";
341 menu_font_name = "-*-helvetica-bold-r";
342 popup_font_name = "-*-helvetica-medium-r";
343 font_norm = "iso8859-1";
345 override_x_deadkeys = true;
347 auto_region_delete = true;
350 check_lastfiles = true;
353 exit_confirmation = true;
354 display_shortcuts = true;
355 // Spellchecker settings:
356 isp_command = "ispell";
357 isp_accept_compound = false;
358 isp_use_input_encoding = false;
359 isp_use_alt_lang = false;
360 isp_use_pers_dict = false;
361 isp_use_esc_chars = false;
366 mark_foreign_language = true;
367 language_package = "\\usepackage{babel}";
368 language_auto_begin = true;
369 language_auto_end = true;
370 language_command_begin = "\\selectlanguage{$$lang}";
371 language_command_end = "\\selectlanguage{$$lang}";
374 date_insert_format = "%A, %e %B %Y";
379 linuxdoc_to_latex_command="none";
380 linuxdoc_to_lyx_command="none";
381 linuxdoc_to_html_command="none";
383 docbook_to_dvi_command="none";
384 docbook_to_html_command="none";
385 docbook_to_pdf_command="none";
389 int LyXRC::ReadBindFile(string const & name)
392 string tmp = i18nLibFileSearch("bind", name, "bind");
393 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
394 int result = read(tmp);
396 lyxerr << "Error reading bind file: " << tmp << endl;
402 int LyXRC::read(string const & filename)
405 string bindFile = "cua";
407 LyXLex lexrc(lyxrcTags, lyxrcCount);
408 if (lyxerr.debugging(Debug::PARSER))
409 lexrc.printTable(lyxerr);
411 lexrc.setFile(filename);
412 if (!lexrc.IsOK()) return -2;
414 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
416 while (lexrc.IsOK()) {
417 // By using two switches we take advantage of the compiler
418 // telling us if we have missed a LyXRCTags element in
419 // the second switch.
420 // Note that this also shows a problem with LyXLex since it
421 // helps us avoid taking advantage of the strictness of the
424 int le = lexrc.lex();
426 case LyXLex::LEX_UNDEF:
427 lexrc.printError("Unknown tag `$$Token'");
429 case LyXLex::LEX_FEOF:
433 switch (static_cast<LyXRCTags>(le)) {
434 case RC_INPUT: // Include file
436 string tmp = LibFileSearch(string(),
439 lexrc.printError("Error reading "
440 "included file: "+tmp);
444 case RC_BINDFILE: // RVDK_PATCH_5
446 ReadBindFile(lexrc.GetString());
450 case RC_BEGINTOOLBAR:
451 // this toolbar should be changed to be a completely
452 // non gui toolbar. (Lgb)
453 toolbardefaults.read(lexrc);
458 use_kbmap = lexrc.GetBool();
461 case RC_EXIT_CONFIRMATION:
463 exit_confirmation = lexrc.GetBool();
466 case RC_DISPLAY_SHORTCUTS:
468 display_shortcuts = lexrc.GetBool();
471 case RC_KBMAP_PRIMARY:
473 primary_kbmap = lexrc.GetString();
476 case RC_KBMAP_SECONDARY:
478 secondary_kbmap = lexrc.GetString();
481 case RC_FONT_ENCODING:
483 fontenc = lexrc.GetString();
488 printer = lexrc.GetString();
491 case RC_PRINT_COMMAND:
493 print_command = lexrc.GetString();
496 case RC_PRINTEVENPAGEFLAG:
498 print_evenpage_flag = lexrc.GetString();
501 case RC_PRINTODDPAGEFLAG:
503 print_oddpage_flag = lexrc.GetString();
506 case RC_PRINTPAGERANGEFLAG:
508 print_pagerange_flag = lexrc.GetString();
511 case RC_PRINTCOPIESFLAG:
513 print_copies_flag = lexrc.GetString();
516 case RC_PRINTCOLLCOPIESFLAG:
518 print_collcopies_flag = lexrc.GetString();
521 case RC_PRINTREVERSEFLAG:
523 print_reverse_flag = lexrc.GetString();
526 case RC_PRINTLANDSCAPEFLAG:
528 print_landscape_flag = lexrc.GetString();
531 case RC_PRINTTOPRINTER:
533 print_to_printer = lexrc.GetString();
536 case RC_PRINT_ADAPTOUTPUT:
538 print_adapt_output = lexrc.GetBool();
543 print_to_file = lexrc.GetString();
546 case RC_PRINTFILEEXTENSION:
548 print_file_extension = lexrc.GetString();
551 case RC_PRINTEXSTRAOPTIONS:
553 print_extra_options = lexrc.GetString();
556 case RC_PRINTSPOOL_COMMAND:
558 print_spool_command = lexrc.GetString();
561 case RC_PRINTSPOOL_PRINTERPREFIX:
563 print_spool_printerprefix = lexrc.GetString();
566 case RC_PRINTPAPERDIMENSIONFLAG:
568 print_paper_dimension_flag = lexrc.GetString();
571 case RC_PRINTPAPERFLAG:
573 print_paper_flag = lexrc.GetString();
576 case RC_CUSTOM_EXPORT_COMMAND:
578 custom_export_command = lexrc.GetString();
581 case RC_CUSTOM_EXPORT_FORMAT:
583 custom_export_format = lexrc.GetString();
588 pdf_mode = lexrc.GetBool();
591 case RC_LATEX_COMMAND:
593 latex_command = lexrc.GetString();
596 case RC_PDFLATEX_COMMAND:
598 pdflatex_command = lexrc.GetString();
601 case RC_PDF_TO_PS_COMMAND:
603 pdf_to_ps_command = lexrc.GetString();
606 case RC_DVI_TO_PS_COMMAND:
608 dvi_to_ps_command = lexrc.GetString();
611 case RC_LITERATE_COMMAND:
613 literate_command = lexrc.GetString();
616 case RC_LITERATE_EXTENSION:
618 literate_extension = lexrc.GetString();
621 case RC_LITERATE_ERROR_FILTER:
623 literate_error_filter = lexrc.GetString();
626 case RC_BUILD_COMMAND:
628 build_command = lexrc.GetString();
631 case RC_BUILD_ERROR_FILTER:
633 build_error_filter = lexrc.GetString();
636 case RC_RELYX_COMMAND:
638 relyx_command = lexrc.GetString();
641 case RC_DEFAULT_PAPERSIZE:
643 string size = lowercase(lexrc.GetString());
644 if (size == "usletter")
646 BufferParams::PAPER_USLETTER;
647 else if (size == "legal")
649 BufferParams::PAPER_LEGALPAPER;
650 else if (size == "executive")
652 BufferParams::PAPER_EXECUTIVEPAPER;
653 else if (size == "a3")
655 BufferParams::PAPER_A3PAPER;
656 else if (size == "a4")
658 BufferParams::PAPER_A4PAPER;
659 else if (size == "a5")
661 BufferParams::PAPER_A5PAPER;
662 else if (size == "b5")
664 BufferParams::PAPER_B5PAPER;
667 case RC_VIEWDVI_COMMAND:
669 view_dvi_command = lexrc.GetString();
672 case RC_VIEWDVI_PAPEROPTION:
674 view_dvi_paper_option = lexrc.GetString();
676 view_dvi_paper_option = "";
679 case RC_VIEWPDF_COMMAND:
681 view_pdf_command = lexrc.GetString();
686 ps_command = lexrc.GetString();
689 case RC_VIEWPS_COMMAND:
691 view_ps_command = lexrc.GetString();
694 case RC_VIEWPSPIC_COMMAND:
696 view_pspic_command = lexrc.GetString();
699 case RC_CHKTEX_COMMAND:
701 chktex_command = lexrc.GetString();
704 case RC_HTML_COMMAND:
706 html_command = lexrc.GetString();
711 dpi = lexrc.GetInteger();
716 zoom = lexrc.GetInteger();
719 case RC_SCREEN_FONT_SIZES:
721 font_sizes[LyXFont::SIZE_TINY] =
724 font_sizes[LyXFont::SIZE_SCRIPT] =
727 font_sizes[LyXFont::SIZE_FOOTNOTE] =
730 font_sizes[LyXFont::SIZE_SMALL] =
733 font_sizes[LyXFont::SIZE_NORMAL] =
736 font_sizes[LyXFont::SIZE_LARGE] =
739 font_sizes[LyXFont::SIZE_LARGER] =
742 font_sizes[LyXFont::SIZE_LARGEST] =
745 font_sizes[LyXFont::SIZE_HUGE] =
748 font_sizes[LyXFont::SIZE_HUGER] =
752 case RC_SCREEN_FONT_SCALABLE:
754 use_scalable_fonts = lexrc.GetBool();
759 autosave = lexrc.GetInteger();
762 case RC_DOCUMENTPATH:
764 document_path = ExpandPath(lexrc.GetString());
768 case RC_TEMPLATEPATH:
770 template_path = ExpandPath(lexrc.GetString());
775 tempdir_path = ExpandPath(lexrc.GetString());
780 use_tempdir = lexrc.GetBool();
785 lastfiles = ExpandPath(lexrc.GetString());
788 case RC_NUMLASTFILES:
790 num_lastfiles = lexrc.GetInteger();
793 case RC_CHECKLASTFILES:
795 check_lastfiles = lexrc.GetBool();
798 case RC_SCREEN_FONT_ROMAN:
800 roman_font_name = lexrc.GetString();
803 case RC_SCREEN_FONT_SANS:
805 sans_font_name = lexrc.GetString();
808 case RC_SCREEN_FONT_TYPEWRITER:
810 typewriter_font_name = lexrc.GetString();
813 case RC_SCREEN_FONT_MENU:
815 menu_font_name = lexrc.GetString();
818 case RC_SCREEN_FONT_POPUP:
820 popup_font_name = lexrc.GetString();
823 case RC_SCREEN_FONT_ENCODING:
825 font_norm = lexrc.GetString();
828 case RC_SCREEN_FONT_ENCODING_MENU:
830 font_norm_menu = lexrc.GetString();
833 case RC_AUTOREGIONDELETE:
834 // Auto region delete defaults to true
836 auto_region_delete = lexrc.GetBool();
841 // we should not do an explicit binding before
842 // loading a bind file. So, in this case, load
843 // the default bind file.
847 // !!!chb, dynamic key binding...
851 if (lexrc.lex() == LyXLex::LEX_DATA) {
852 seq = lexrc.GetString();
854 lexrc.printError("Bad key sequence: `$$Token'");
858 if (lexrc.lex() == LyXLex::LEX_DATA) {
859 cmd = lexrc.GetString();
861 lexrc.printError("Bad command: `$$Token'");
865 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
866 if (lyxerr.debugging(Debug::KEY)) {
867 lyxerr << "RC_BIND: Sequence `"
868 << seq << "' Command `"
869 << cmd << "' Action `"
870 << action << '\'' << endl;
872 res = toplevel_keymap->bind(seq.c_str(),
876 "Invalid key sequence `"
879 } else {// cmd is the last token read.
881 "Unknown LyX function `$$Token'");
885 case RC_OVERRIDE_X_DEADKEYS:
887 override_x_deadkeys = lexrc.GetBool();
892 lyxpipes = ExpandPath(lexrc.GetString());
895 case RC_CURSOR_FOLLOWS_SCROLLBAR:
897 cursor_follows_scrollbar = lexrc.GetBool();
902 fax_command = lexrc.GetString();
906 fax_program = lexrc.GetString();
910 string s = lexrc.GetString();
914 phone_book = user_lyxdir + s;
917 case RC_ASCIIROFF_COMMAND:
919 ascii_roff_command = lexrc.GetString();
921 case RC_ASCII_LINELEN:
923 ascii_linelen = lexrc.GetInteger();
925 // Spellchecker settings:
926 case RC_SPELL_COMMAND:
928 isp_command = lexrc.GetString();
930 case RC_ACCEPT_COMPOUND:
932 isp_accept_compound = lexrc.GetBool();
936 isp_use_input_encoding = lexrc.GetBool();
938 case RC_USE_ALT_LANG:
940 isp_use_alt_lang = lexrc.GetBool();
942 case RC_USE_PERS_DICT:
944 isp_use_pers_dict = lexrc.GetBool();
946 case RC_USE_ESC_CHARS:
948 isp_use_esc_chars = lexrc.GetBool();
952 isp_alt_lang = lexrc.GetString();
956 isp_pers_dict = lexrc.GetString();
960 isp_esc_chars = lexrc.GetString();
964 make_backup = lexrc.GetBool();
966 case RC_BACKUPDIR_PATH:
968 backupdir_path = ExpandPath(lexrc.GetString());
970 case RC_DATE_INSERT_FORMAT:
972 date_insert_format = lexrc.GetString();
974 case RC_LANGUAGE_PACKAGE:
976 language_package = lexrc.GetString();
978 case RC_LANGUAGE_AUTO_BEGIN:
980 language_auto_begin = lexrc.GetBool();
982 case RC_LANGUAGE_AUTO_END:
984 language_auto_end = lexrc.GetBool();
986 case RC_LANGUAGE_COMMAND_BEGIN:
988 language_command_begin = lexrc.GetString();
990 case RC_LANGUAGE_COMMAND_END:
992 language_command_end = lexrc.GetString();
996 rtl_support = lexrc.GetBool();
1000 auto_number = lexrc.GetBool();
1002 case RC_MARK_FOREIGN_LANGUAGE:
1004 mark_foreign_language = lexrc.GetBool();
1006 case RC_SHOW_BANNER:
1008 show_banner = lexrc.GetBool();
1012 use_gui = lexrc.GetBool();
1014 case RC_LINUXDOC_TO_LYX_COMMAND:
1016 linuxdoc_to_lyx_command = lexrc.GetString();
1018 case RC_LINUXDOC_TO_HTML_COMMAND:
1020 linuxdoc_to_html_command = lexrc.GetString();
1022 case RC_LINUXDOC_TO_LATEX_COMMAND:
1024 linuxdoc_to_latex_command = lexrc.GetString();
1026 case RC_DOCBOOK_TO_DVI_COMMAND:
1028 docbook_to_dvi_command = lexrc.GetString();
1030 case RC_DOCBOOK_TO_HTML_COMMAND:
1032 docbook_to_html_command = lexrc.GetString();
1034 case RC_DOCBOOK_TO_PDF_COMMAND:
1036 docbook_to_pdf_command = lexrc.GetString();
1038 case RC_LAST: break; // this is just a dummy
1046 void LyXRC::write(string const & filename) const
1048 ofstream ofs(filename.c_str());
1054 void LyXRC::print() const
1056 if (lyxerr.debugging())
1063 void LyXRC::output(ostream & os) const
1065 os << "### This file is part of\n"
1066 << "### ========================================================\n"
1067 << "### LyX, The Document Processor\n"
1069 << "### Copyright 1995 Matthias Ettrich\n"
1070 << "### Copyright 1995-1998 The LyX Team.\n"
1072 << "### ========================================================\n"
1074 << "# This file is written by LyX, if you want to make your own\n"
1075 << "# modifications you should do them from inside LyX and save\n"
1076 << "# your preferences, or you can also make your modifications\n"
1077 << "# to lyxrc by hand. It is not advisable to edit this file.\n"
1080 // Why the switch you might ask. It is a trick to ensure that all
1081 // the elements in the LyXRCTags enum is handled. As you can see
1082 // there are no breaks at all. So it is just a huge fall-through.
1083 // The nice thing is that we will get a warning from the compiler
1084 // if we forget an element.
1085 LyXRCTags tag = RC_LAST;
1089 // input/include files are not done here
1091 // bindings is not written to the preferences file.
1093 // bind files are not done here.
1094 case RC_BEGINTOOLBAR:
1095 // Toolbar is not written here (yet).
1096 case RC_FONT_ENCODING:
1097 os << "\\font_encoding \"" << fontenc << "\"\n";
1099 os << "\\printer \"" << printer << "\"\n";
1100 case RC_PRINT_COMMAND:
1101 os << "\\print_command \"" << print_command << "\"\n";
1102 case RC_PRINTEVENPAGEFLAG:
1103 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1105 case RC_PRINTODDPAGEFLAG:
1106 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1108 case RC_PRINTPAGERANGEFLAG:
1109 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1111 case RC_PRINTCOPIESFLAG:
1112 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1113 case RC_PRINTCOLLCOPIESFLAG:
1114 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1116 case RC_PRINTREVERSEFLAG:
1117 os << "\\print_reverse_flag \"" << print_reverse_flag
1119 case RC_PRINTLANDSCAPEFLAG:
1120 os << "\\print_landscape_flag \"" << print_landscape_flag
1122 case RC_PRINTTOPRINTER:
1123 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1124 case RC_PRINT_ADAPTOUTPUT:
1125 os << "\\print_adapt_output " << tostr(print_adapt_output)
1127 case RC_PRINTTOFILE:
1128 os << "\\print_to_file \"" << print_to_file << "\"\n";
1129 case RC_PRINTFILEEXTENSION:
1130 os << "\\print_file_extension \"" << print_file_extension
1132 case RC_PRINTEXSTRAOPTIONS:
1133 os << "\\print_extra_options \"" << print_extra_options
1135 case RC_PRINTSPOOL_COMMAND:
1136 os << "\\print_spool_command \"" << print_spool_command
1138 case RC_PRINTSPOOL_PRINTERPREFIX:
1139 os << "\\print_spool_printerprefix \""
1140 << print_spool_printerprefix << "\"\n";
1141 case RC_PRINTPAPERDIMENSIONFLAG:
1142 os << "\\print_paper_dimension_flag \""
1143 << print_paper_dimension_flag << "\"\n";
1144 case RC_PRINTPAPERFLAG:
1145 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1146 case RC_CUSTOM_EXPORT_COMMAND:
1147 os << "\\custom_export_command \"" << custom_export_command
1149 case RC_CUSTOM_EXPORT_FORMAT:
1150 os << "\\custom_export_format \"" << custom_export_format
1153 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1154 case RC_LATEX_COMMAND:
1155 os << "\\latex_command \"" << latex_command << "\"\n";
1156 case RC_PDFLATEX_COMMAND:
1157 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1158 case RC_PDF_TO_PS_COMMAND:
1159 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1160 case RC_DVI_TO_PS_COMMAND:
1161 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1162 case RC_LITERATE_COMMAND:
1163 os << "\\literate_command \"" << literate_command << "\"\n";
1164 case RC_LITERATE_EXTENSION:
1165 os << "\\literate_extension \"" << literate_extension
1167 case RC_LITERATE_ERROR_FILTER:
1168 os << "\\literate_error_filter \"" << literate_error_filter
1170 case RC_BUILD_COMMAND:
1171 os << "\\build_command \"" << build_command << "\"\n";
1172 case RC_BUILD_ERROR_FILTER:
1173 os << "\\build_error_filter \"" << build_error_filter
1176 os << "\\screen_dpi " << dpi << "\n";
1177 case RC_SCREEN_ZOOM:
1178 os << "\\screen_zoom " << zoom << "\n";
1179 case RC_SCREEN_FONT_SIZES:
1180 os.setf(ios::fixed);
1182 os << "\\screen_font_sizes";
1183 os << " " << font_sizes[LyXFont::SIZE_TINY];
1184 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1185 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1186 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1187 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1188 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1189 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1190 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1191 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1192 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1194 case RC_OVERRIDE_X_DEADKEYS:
1195 os << "\\override_x_deadkeys "
1196 << override_x_deadkeys << "\n";
1197 case RC_AUTOREGIONDELETE:
1198 os << "\\auto_region_delete " << tostr(auto_region_delete)
1201 os << "\\autosave " << autosave << "\n";
1202 case RC_EXIT_CONFIRMATION:
1203 os << "\\exit_confirmation " << tostr(exit_confirmation)
1205 case RC_DISPLAY_SHORTCUTS:
1206 os << "\\display_shortcuts " << tostr(display_shortcuts)
1208 case RC_VIEWDVI_COMMAND:
1209 os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1210 case RC_VIEWDVI_PAPEROPTION:
1211 os << "\\view_dvi_paper_option \"" << view_dvi_paper_option << "\"\n";
1212 case RC_VIEWPDF_COMMAND:
1213 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1214 case RC_DEFAULT_PAPERSIZE:
1215 os << "\\default_papersize \"";
1216 switch (default_papersize) {
1217 case BufferParams::PAPER_USLETTER:
1218 os << "usletter"; break;
1219 case BufferParams::PAPER_LEGALPAPER:
1220 os << "legal"; break;
1221 case BufferParams::PAPER_EXECUTIVEPAPER:
1222 os << "executive"; break;
1223 case BufferParams::PAPER_A3PAPER:
1225 case BufferParams::PAPER_A4PAPER:
1227 case BufferParams::PAPER_A5PAPER:
1229 case BufferParams::PAPER_B5PAPER:
1231 case BufferParams::PAPER_DEFAULT: break;
1234 case RC_VIEWPS_COMMAND:
1235 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1236 case RC_VIEWPSPIC_COMMAND:
1237 os << "\\view_pspic_command \"" << view_pspic_command
1240 os << "\\ps_command \"" << ps_command << "\"\n";
1241 case RC_CHKTEX_COMMAND:
1242 os << "\\chktex_command \"" << chktex_command << "\"\n";
1243 case RC_HTML_COMMAND:
1244 os << "\\html_command \"" << html_command << "\"\n";
1246 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1247 case RC_KBMAP_PRIMARY:
1248 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1249 case RC_KBMAP_SECONDARY:
1250 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1252 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1253 case RC_RELYX_COMMAND:
1254 os << "\\relyx_command \"" << relyx_command << "\"\n";
1255 case RC_DOCUMENTPATH:
1256 os << "\\document_path \"" << document_path << "\"\n";
1257 case RC_TEMPLATEPATH:
1258 os << "\\template_path \"" << template_path << "\"\n";
1259 case RC_TEMPDIRPATH:
1260 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1262 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1264 os << "\\lastfiles \"" << lastfiles << "\"\n";
1265 case RC_NUMLASTFILES:
1266 os << "\\num_lastfiles " << num_lastfiles << "\n";
1267 case RC_CHECKLASTFILES:
1268 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1269 case RC_SCREEN_FONT_ROMAN:
1270 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1271 case RC_SCREEN_FONT_SANS:
1272 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1273 case RC_SCREEN_FONT_TYPEWRITER:
1274 os << "\\screen_font_typewriter \""
1275 << typewriter_font_name << "\"\n";
1276 case RC_SCREEN_FONT_MENU:
1277 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1278 case RC_SCREEN_FONT_POPUP:
1279 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1280 case RC_SCREEN_FONT_ENCODING:
1281 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1282 case RC_SCREEN_FONT_ENCODING_MENU:
1283 os << "\\screen_font_encoding_menu \"" << font_norm_menu
1285 case RC_SCREEN_FONT_SCALABLE:
1286 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1288 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1289 os << "\\cursor_follows_scrollbar "
1290 << tostr(cursor_follows_scrollbar) << "\n";
1291 case RC_FAX_COMMAND:
1292 os << "\\fax_command \"" << fax_command << "\"\n";
1294 os << "\\fax_program \"" << fax_program << "\"\n";
1296 os << "\\phone_book \"" << phone_book << "\"\n";
1297 case RC_ASCIIROFF_COMMAND:
1298 os << "\\ascii_roff_command \"" << ascii_roff_command
1300 case RC_ASCII_LINELEN:
1301 os << "\\ascii_linelen " << ascii_linelen << "\n";
1302 case RC_SPELL_COMMAND:
1303 os << "\\spell_command \"" << isp_command << "\"\n";
1304 case RC_ACCEPT_COMPOUND:
1305 os << "\\accept_compound " << tostr(isp_accept_compound)
1307 case RC_USE_INP_ENC:
1308 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1310 case RC_USE_ALT_LANG:
1311 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1312 case RC_USE_PERS_DICT:
1313 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1315 case RC_USE_ESC_CHARS:
1316 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1319 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1321 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1323 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1324 case RC_RTL_SUPPORT:
1325 os << "\\rtl " << tostr(rtl_support) << "\n";
1326 case RC_AUTO_NUMBER:
1327 os << "\\auto_number" << tostr(auto_number) << "\n";
1328 case RC_MARK_FOREIGN_LANGUAGE:
1329 os << "\\mark_foreign_language " <<
1330 tostr(mark_foreign_language) << "\n";
1331 case RC_LANGUAGE_AUTO_BEGIN:
1332 os << "\\language_auto_begin "
1333 << tostr(language_auto_begin) << "\n";
1334 case RC_LANGUAGE_AUTO_END:
1335 os << "\\language_auto_end "
1336 << tostr(language_auto_end) << "\n";
1337 case RC_LANGUAGE_PACKAGE:
1338 os << "\\language_package \"" << language_package << "\"\n";
1339 case RC_LANGUAGE_COMMAND_BEGIN:
1340 os << "\\language_command_begin \"" << language_command_begin
1342 case RC_LANGUAGE_COMMAND_END:
1343 os << "\\language_command_end \"" << language_command_end
1345 case RC_MAKE_BACKUP:
1346 os << "\\make_backup " << tostr(make_backup) << "\n";
1347 case RC_BACKUPDIR_PATH:
1348 os << "\\backupdir_path" << backupdir_path << "\n";
1349 case RC_DATE_INSERT_FORMAT:
1350 os << "\\date_insert_format \"" << date_insert_format
1352 case RC_SHOW_BANNER:
1353 os << "\\show_banner " << tostr(show_banner) << "\n";
1355 os << "\\use_gui " << tostr(show_banner) << "\n";
1356 case RC_LINUXDOC_TO_LYX_COMMAND:
1357 os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command
1359 case RC_LINUXDOC_TO_HTML_COMMAND:
1360 os << "\\linuxdoc_to_html_command \"" << linuxdoc_to_html_command
1362 case RC_LINUXDOC_TO_LATEX_COMMAND:
1363 os << "\\linuxdoc_to_latex_command \"" << linuxdoc_to_latex_command
1365 case RC_DOCBOOK_TO_DVI_COMMAND:
1366 os << "\\docbook_to_dvi_command \"" << docbook_to_dvi_command
1368 case RC_DOCBOOK_TO_HTML_COMMAND:
1369 os << "\\docbook_to_html_command \"" << docbook_to_html_command
1371 case RC_DOCBOOK_TO_PDF_COMMAND:
1372 os << "\\docbook_to_pdf_command \"" << docbook_to_pdf_command
1379 // The global instance