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 string background_color;
45 extern char selection_color[];
46 extern bool cursor_follows_scrollbar;
47 extern LyXAction lyxaction;
48 extern kb_keymap * toplevel_keymap;
58 RC_PRINTPAGERANGEFLAG,
60 RC_PRINTCOLLCOPIESFLAG,
62 RC_PRINTLANDSCAPEFLAG,
66 RC_PRINTFILEEXTENSION,
67 RC_PRINTEXSTRAOPTIONS,
68 RC_PRINTSPOOL_COMMAND,
69 RC_PRINTSPOOL_PRINTERPREFIX,
71 RC_PRINTPAPERDIMENSIONFLAG,
72 RC_CUSTOM_EXPORT_COMMAND,
73 RC_CUSTOM_EXPORT_FORMAT,
76 RC_LITERATE_EXTENSION,
77 RC_LITERATE_ERROR_FILTER,
79 RC_BUILD_ERROR_FILTER,
85 RC_SCREEN_FONT_TYPEWRITER,
88 RC_SCREEN_FONT_ENCODING,
89 RC_SCREEN_FONT_ENCODING_MENU,
98 RC_OVERRIDE_X_DEADKEYS,
110 RC_ASCIIROFF_COMMAND,
115 RC_VIEWDVI_PAPEROPTION,
116 RC_DEFAULT_PAPERSIZE,
119 RC_VIEWPSPIC_COMMAND,
126 RC_SCREEN_FONT_SCALABLE,
131 RC_CURSOR_FOLLOWS_SCROLLBAR,
132 RC_EXIT_CONFIRMATION,
133 RC_DISPLAY_SHORTCUTS,
141 RC_LANGUAGE_AUTO_BEGIN,
142 RC_LANGUAGE_AUTO_END,
143 RC_LANGUAGE_COMMAND_BEGIN,
144 RC_LANGUAGE_COMMAND_END,
148 RC_PDF_TO_PS_COMMAND,
149 RC_DVI_TO_PS_COMMAND,
150 RC_DATE_INSERT_FORMAT,
153 RC_LINUXDOC_TO_LYX_COMMAND,
154 RC_LINUXDOC_TO_HTML_COMMAND,
155 RC_LINUXDOC_TO_LATEX_COMMAND,
156 RC_DOCBOOK_TO_DVI_COMMAND,
157 RC_DOCBOOK_TO_HTML_COMMAND,
158 RC_DOCBOOK_TO_PDF_COMMAND,
164 keyword_item lyxrcTags[] = {
165 { "\\accept_compound", RC_ACCEPT_COMPOUND },
166 { "\\alternate_language", RC_ALT_LANG },
167 { "\\ascii_linelen", RC_ASCII_LINELEN },
168 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
169 { "\\auto_number", RC_AUTO_NUMBER },
170 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
171 { "\\autosave", RC_AUTOSAVE },
172 { "\\background_color", RC_BACKGROUND_COLOR },
173 { "\\backupdir_path", RC_BACKUPDIR_PATH },
174 { "\\begin_toolbar", RC_BEGINTOOLBAR },
175 { "\\bind", RC_BIND },
176 { "\\bind_file", RC_BINDFILE },
177 { "\\build_command", RC_BUILD_COMMAND },
178 { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
179 { "\\check_lastfiles", RC_CHECKLASTFILES },
180 { "\\chktex_command", RC_CHKTEX_COMMAND },
181 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
182 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
183 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
184 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
185 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
186 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
187 { "\\docbook_to_dvi_command", RC_DOCBOOK_TO_DVI_COMMAND },
188 { "\\docbook_to_html_command", RC_DOCBOOK_TO_HTML_COMMAND },
189 { "\\docbook_to_pdf_command", RC_DOCBOOK_TO_PDF_COMMAND },
190 { "\\document_path", RC_DOCUMENTPATH },
191 { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
192 { "\\escape_chars", RC_ESC_CHARS },
193 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
194 { "\\fax_command", RC_FAX_COMMAND },
195 { "\\fax_program", RC_FAXPROGRAM },
196 { "\\font_encoding", RC_FONT_ENCODING },
197 { "\\html_command", RC_HTML_COMMAND },
198 { "\\input", RC_INPUT },
199 { "\\kbmap", RC_KBMAP },
200 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
201 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
202 { "\\language_auto_begin", RC_LANGUAGE_AUTO_BEGIN },
203 { "\\language_auto_end", RC_LANGUAGE_AUTO_END },
204 { "\\language_command_begin", RC_LANGUAGE_COMMAND_BEGIN },
205 { "\\language_command_end", RC_LANGUAGE_COMMAND_END },
206 { "\\language_package", RC_LANGUAGE_PACKAGE },
207 { "\\lastfiles", RC_LASTFILES },
208 { "\\latex_command", RC_LATEX_COMMAND },
209 { "\\linuxdoc_to_html_command", RC_LINUXDOC_TO_HTML_COMMAND },
210 { "\\linuxdoc_to_latex_command", RC_LINUXDOC_TO_LATEX_COMMAND },
211 { "\\linuxdoc_to_lyx_command", RC_LINUXDOC_TO_LYX_COMMAND },
212 { "\\literate_command", RC_LITERATE_COMMAND },
213 { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
214 { "\\literate_extension", RC_LITERATE_EXTENSION },
215 { "\\make_backup", RC_MAKE_BACKUP },
216 { "\\num_lastfiles", RC_NUMLASTFILES },
217 { "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
218 { "\\pdf_mode", RC_PDF_MODE },
219 { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
220 { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
221 { "\\personal_dictionary", RC_PERS_DICT },
222 { "\\phone_book", RC_PHONEBOOK },
223 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
224 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
225 { "\\print_command", RC_PRINT_COMMAND },
226 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
227 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
228 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
229 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
230 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
231 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
232 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
233 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
234 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
235 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
236 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
237 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
238 { "\\print_to_file", RC_PRINTTOFILE },
239 { "\\print_to_printer", RC_PRINTTOPRINTER },
240 { "\\printer", RC_PRINTER },
241 { "\\ps_command", RC_PS_COMMAND },
242 { "\\relyx_command", RC_RELYX_COMMAND },
243 { "\\rtl", RC_RTL_SUPPORT },
244 { "\\screen_dpi", RC_SCREEN_DPI },
245 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
246 { "\\screen_font_encoding_menu", RC_SCREEN_FONT_ENCODING_MENU },
247 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
248 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
249 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
250 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
251 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
252 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
253 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
254 { "\\screen_zoom", RC_SCREEN_ZOOM },
255 { "\\selection_color", RC_SELECTION_COLOR },
256 { "\\serverpipe", RC_SERVERPIPE },
257 { "\\show_banner", RC_SHOW_BANNER },
258 { "\\spell_command", RC_SPELL_COMMAND },
259 { "\\tempdir_path", RC_TEMPDIRPATH },
260 { "\\template_path", RC_TEMPLATEPATH },
261 { "\\use_alt_language", RC_USE_ALT_LANG },
262 { "\\use_escape_chars", RC_USE_ESC_CHARS },
263 { "\\use_gui", RC_USE_GUI },
264 { "\\use_input_encoding", RC_USE_INP_ENC },
265 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
266 { "\\use_tempdir", RC_USETEMPDIR },
267 { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
268 { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
269 { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
270 { "\\view_ps_command", RC_VIEWPS_COMMAND },
271 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
274 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
275 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
284 void LyXRC::setDefaults() {
285 // Get printer from the environment. If fail, use default "",
286 // assuming that everything is set up correctly.
287 printer = GetEnv("PRINTER");
288 print_adapt_output = false;
289 print_command = "dvips";
290 print_evenpage_flag = "-B";
291 print_oddpage_flag = "-A";
292 print_pagerange_flag = "-pp";
293 print_copies_flag = "-c";
294 print_collcopies_flag = "-C";
295 print_reverse_flag = "-r";
296 print_landscape_flag = "-t landscape";
297 print_to_printer = "-P";
298 print_to_file = "-o ";
299 print_file_extension = ".ps";
300 print_paper_flag = "-t";
301 print_paper_dimension_flag = "-T";
302 document_path = GetEnvPath("HOME");
303 tempdir_path = "/tmp";
306 latex_command = "latex";
307 pdflatex_command = "pdflatex";
308 pdf_to_ps_command = "pdf2ps";
309 dvi_to_ps_command = "dvips";
310 literate_command = "none";
311 literate_extension = "none";
312 literate_error_filter = "cat";
313 build_command = "make";
314 build_error_filter = "cat";
315 relyx_command = "reLyX";
317 view_ps_command = "ghostview -swap";
318 view_pspic_command = "ghostview";
319 view_dvi_command = "xdvi";
320 view_dvi_paper_option = "-paper";
321 view_pdf_command = "xpdf";
322 default_papersize = BufferParams::PAPER_USLETTER;
323 custom_export_format = "ps";
324 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
325 html_command = "tth -t";
328 // Because a screen typically is wider than a piece of paper:
330 // Default LaTeX font size:
331 font_sizes[LyXFont::SIZE_TINY] = 5.0;
332 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
333 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
334 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
335 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
336 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
337 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
338 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
339 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
340 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
341 use_scalable_fonts = true;
342 roman_font_name = "-*-times";
343 sans_font_name = "-*-helvetica";
344 typewriter_font_name = "-*-courier";
345 menu_font_name = "-*-helvetica-bold-r";
346 popup_font_name = "-*-helvetica-medium-r";
347 font_norm = "iso8859-1";
349 override_x_deadkeys = true;
351 auto_region_delete = true;
354 check_lastfiles = true;
357 exit_confirmation = true;
358 display_shortcuts = true;
359 // Spellchecker settings:
360 isp_command = "ispell";
361 isp_accept_compound = false;
362 isp_use_input_encoding = false;
363 isp_use_alt_lang = false;
364 isp_use_pers_dict = false;
365 isp_use_esc_chars = false;
370 language_package = "\\usepackage{babel}";
371 language_auto_begin = true;
372 language_auto_end = true;
373 language_command_begin = "\\selectlanguage{$$lang}";
374 language_command_end = "\\selectlanguage{$$lang}";
377 date_insert_format = "%A, %e %B %Y";
382 linuxdoc_to_latex_command="none";
383 linuxdoc_to_lyx_command="none";
384 linuxdoc_to_html_command="none";
386 docbook_to_dvi_command="none";
387 docbook_to_html_command="none";
388 docbook_to_pdf_command="none";
392 int LyXRC::ReadBindFile(string const & name)
395 string tmp = i18nLibFileSearch("bind", name, "bind");
396 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
397 int result = read(tmp);
399 lyxerr << "Error reading bind file: " << tmp << endl;
405 int LyXRC::read(string const & filename)
408 string bindFile = "cua";
410 LyXLex lexrc(lyxrcTags, lyxrcCount);
411 if (lyxerr.debugging(Debug::PARSER))
412 lexrc.printTable(lyxerr);
414 lexrc.setFile(filename);
415 if (!lexrc.IsOK()) return -2;
417 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
419 while (lexrc.IsOK()) {
420 // By using two switches we take advantage of the compiler
421 // telling us if we have missed a LyXRCTags element in
422 // the second switch.
423 // Note that this also shows a problem with LyXLex since it
424 // helps us avoid taking advantage of the strictness of the
427 int le = lexrc.lex();
429 case LyXLex::LEX_UNDEF:
430 lexrc.printError("Unknown tag `$$Token'");
432 case LyXLex::LEX_FEOF:
436 switch (static_cast<LyXRCTags>(le)) {
437 case RC_INPUT: // Include file
439 string tmp = LibFileSearch(string(),
442 lexrc.printError("Error reading "
443 "included file: "+tmp);
447 case RC_BINDFILE: // RVDK_PATCH_5
449 ReadBindFile(lexrc.GetString());
453 case RC_BEGINTOOLBAR:
454 // this toolbar should be changed to be a completely
455 // non gui toolbar. (Lgb)
456 toolbardefaults.read(lexrc);
461 use_kbmap = lexrc.GetBool();
464 case RC_EXIT_CONFIRMATION:
466 exit_confirmation = lexrc.GetBool();
469 case RC_DISPLAY_SHORTCUTS:
471 display_shortcuts = lexrc.GetBool();
474 case RC_KBMAP_PRIMARY:
476 primary_kbmap = lexrc.GetString();
479 case RC_KBMAP_SECONDARY:
481 secondary_kbmap = lexrc.GetString();
484 case RC_FONT_ENCODING:
486 fontenc = lexrc.GetString();
491 printer = lexrc.GetString();
494 case RC_PRINT_COMMAND:
496 print_command = lexrc.GetString();
499 case RC_PRINTEVENPAGEFLAG:
501 print_evenpage_flag = lexrc.GetString();
504 case RC_PRINTODDPAGEFLAG:
506 print_oddpage_flag = lexrc.GetString();
509 case RC_PRINTPAGERANGEFLAG:
511 print_pagerange_flag = lexrc.GetString();
514 case RC_PRINTCOPIESFLAG:
516 print_copies_flag = lexrc.GetString();
519 case RC_PRINTCOLLCOPIESFLAG:
521 print_collcopies_flag = lexrc.GetString();
524 case RC_PRINTREVERSEFLAG:
526 print_reverse_flag = lexrc.GetString();
529 case RC_PRINTLANDSCAPEFLAG:
531 print_landscape_flag = lexrc.GetString();
534 case RC_PRINTTOPRINTER:
536 print_to_printer = lexrc.GetString();
539 case RC_PRINT_ADAPTOUTPUT:
541 print_adapt_output = lexrc.GetBool();
546 print_to_file = lexrc.GetString();
549 case RC_PRINTFILEEXTENSION:
551 print_file_extension = lexrc.GetString();
554 case RC_PRINTEXSTRAOPTIONS:
556 print_extra_options = lexrc.GetString();
559 case RC_PRINTSPOOL_COMMAND:
561 print_spool_command = lexrc.GetString();
564 case RC_PRINTSPOOL_PRINTERPREFIX:
566 print_spool_printerprefix = lexrc.GetString();
569 case RC_PRINTPAPERDIMENSIONFLAG:
571 print_paper_dimension_flag = lexrc.GetString();
574 case RC_PRINTPAPERFLAG:
576 print_paper_flag = lexrc.GetString();
579 case RC_CUSTOM_EXPORT_COMMAND:
581 custom_export_command = lexrc.GetString();
584 case RC_CUSTOM_EXPORT_FORMAT:
586 custom_export_format = lexrc.GetString();
591 pdf_mode = lexrc.GetBool();
594 case RC_LATEX_COMMAND:
596 latex_command = lexrc.GetString();
599 case RC_PDFLATEX_COMMAND:
601 pdflatex_command = lexrc.GetString();
604 case RC_PDF_TO_PS_COMMAND:
606 pdf_to_ps_command = lexrc.GetString();
609 case RC_DVI_TO_PS_COMMAND:
611 dvi_to_ps_command = lexrc.GetString();
614 case RC_LITERATE_COMMAND:
616 literate_command = lexrc.GetString();
619 case RC_LITERATE_EXTENSION:
621 literate_extension = lexrc.GetString();
624 case RC_LITERATE_ERROR_FILTER:
626 literate_error_filter = lexrc.GetString();
629 case RC_BUILD_COMMAND:
631 build_command = lexrc.GetString();
634 case RC_BUILD_ERROR_FILTER:
636 build_error_filter = lexrc.GetString();
639 case RC_RELYX_COMMAND:
641 relyx_command = lexrc.GetString();
644 case RC_DEFAULT_PAPERSIZE:
646 string size = lowercase(lexrc.GetString());
647 if (size == "usletter")
649 BufferParams::PAPER_USLETTER;
650 else if (size == "legal")
652 BufferParams::PAPER_LEGALPAPER;
653 else if (size == "executive")
655 BufferParams::PAPER_EXECUTIVEPAPER;
656 else if (size == "a3")
658 BufferParams::PAPER_A3PAPER;
659 else if (size == "a4")
661 BufferParams::PAPER_A4PAPER;
662 else if (size == "a5")
664 BufferParams::PAPER_A5PAPER;
665 else if (size == "b5")
667 BufferParams::PAPER_B5PAPER;
670 case RC_VIEWDVI_COMMAND:
672 view_dvi_command = lexrc.GetString();
675 case RC_VIEWDVI_PAPEROPTION:
677 view_dvi_paper_option = lexrc.GetString();
679 view_dvi_paper_option = "";
682 case RC_VIEWPDF_COMMAND:
684 view_pdf_command = lexrc.GetString();
689 ps_command = lexrc.GetString();
692 case RC_VIEWPS_COMMAND:
694 view_ps_command = lexrc.GetString();
697 case RC_VIEWPSPIC_COMMAND:
699 view_pspic_command = lexrc.GetString();
702 case RC_CHKTEX_COMMAND:
704 chktex_command = lexrc.GetString();
707 case RC_HTML_COMMAND:
709 html_command = lexrc.GetString();
714 dpi = lexrc.GetInteger();
719 zoom = lexrc.GetInteger();
722 case RC_SCREEN_FONT_SIZES:
724 font_sizes[LyXFont::SIZE_TINY] =
727 font_sizes[LyXFont::SIZE_SCRIPT] =
730 font_sizes[LyXFont::SIZE_FOOTNOTE] =
733 font_sizes[LyXFont::SIZE_SMALL] =
736 font_sizes[LyXFont::SIZE_NORMAL] =
739 font_sizes[LyXFont::SIZE_LARGE] =
742 font_sizes[LyXFont::SIZE_LARGER] =
745 font_sizes[LyXFont::SIZE_LARGEST] =
748 font_sizes[LyXFont::SIZE_HUGE] =
751 font_sizes[LyXFont::SIZE_HUGER] =
755 case RC_SCREEN_FONT_SCALABLE:
757 use_scalable_fonts = lexrc.GetBool();
762 autosave = lexrc.GetInteger();
765 case RC_DOCUMENTPATH:
767 document_path = ExpandPath(lexrc.GetString());
771 case RC_TEMPLATEPATH:
773 template_path = ExpandPath(lexrc.GetString());
778 tempdir_path = ExpandPath(lexrc.GetString());
783 use_tempdir = lexrc.GetBool();
788 lastfiles = ExpandPath(lexrc.GetString());
791 case RC_NUMLASTFILES:
793 num_lastfiles = lexrc.GetInteger();
796 case RC_CHECKLASTFILES:
798 check_lastfiles = lexrc.GetBool();
801 case RC_SCREEN_FONT_ROMAN:
803 roman_font_name = lexrc.GetString();
806 case RC_SCREEN_FONT_SANS:
808 sans_font_name = lexrc.GetString();
811 case RC_SCREEN_FONT_TYPEWRITER:
813 typewriter_font_name = lexrc.GetString();
816 case RC_SCREEN_FONT_MENU:
818 menu_font_name = lexrc.GetString();
821 case RC_SCREEN_FONT_POPUP:
823 popup_font_name = lexrc.GetString();
826 case RC_SCREEN_FONT_ENCODING:
828 font_norm = lexrc.GetString();
831 case RC_SCREEN_FONT_ENCODING_MENU:
833 font_norm_menu = lexrc.GetString();
836 case RC_AUTOREGIONDELETE:
837 // Auto region delete defaults to true
839 auto_region_delete = lexrc.GetBool();
844 // we should not do an explicit binding before
845 // loading a bind file. So, in this case, load
846 // the default bind file.
850 // !!!chb, dynamic key binding...
854 if (lexrc.lex() == LyXLex::LEX_DATA) {
855 seq = lexrc.GetString();
857 lexrc.printError("Bad key sequence: `$$Token'");
861 if (lexrc.lex() == LyXLex::LEX_DATA) {
862 cmd = lexrc.GetString();
864 lexrc.printError("Bad command: `$$Token'");
868 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
869 if (lyxerr.debugging(Debug::KEY)) {
870 lyxerr << "RC_BIND: Sequence `"
871 << seq << "' Command `"
872 << cmd << "' Action `"
873 << action << '\'' << endl;
875 res = toplevel_keymap->bind(seq.c_str(),
879 "Invalid key sequence `"
882 } else {// cmd is the last token read.
884 "Unknown LyX function `$$Token'");
888 case RC_OVERRIDE_X_DEADKEYS:
890 override_x_deadkeys = lexrc.GetBool();
895 lyxpipes = ExpandPath(lexrc.GetString());
898 case RC_CURSOR_FOLLOWS_SCROLLBAR:
900 cursor_follows_scrollbar = lexrc.GetBool();
903 case RC_BACKGROUND_COLOR:
905 background_color = lexrc.GetString();
907 case RC_SELECTION_COLOR:
909 strncpy(selection_color,
910 lexrc.GetString().c_str(), 31);
914 fax_command = lexrc.GetString();
918 fax_program = lexrc.GetString();
922 string s = lexrc.GetString();
926 phone_book = user_lyxdir + s;
929 case RC_ASCIIROFF_COMMAND:
931 ascii_roff_command = lexrc.GetString();
933 case RC_ASCII_LINELEN:
935 ascii_linelen = lexrc.GetInteger();
937 // Spellchecker settings:
938 case RC_SPELL_COMMAND:
940 isp_command = lexrc.GetString();
942 case RC_ACCEPT_COMPOUND:
944 isp_accept_compound = lexrc.GetBool();
948 isp_use_input_encoding = lexrc.GetBool();
950 case RC_USE_ALT_LANG:
952 isp_use_alt_lang = lexrc.GetBool();
954 case RC_USE_PERS_DICT:
956 isp_use_pers_dict = lexrc.GetBool();
958 case RC_USE_ESC_CHARS:
960 isp_use_esc_chars = lexrc.GetBool();
964 isp_alt_lang = lexrc.GetString();
968 isp_pers_dict = lexrc.GetString();
972 isp_esc_chars = lexrc.GetString();
976 make_backup = lexrc.GetBool();
978 case RC_BACKUPDIR_PATH:
980 backupdir_path = ExpandPath(lexrc.GetString());
982 case RC_DATE_INSERT_FORMAT:
984 date_insert_format = lexrc.GetString();
986 case RC_LANGUAGE_PACKAGE:
988 language_package = lexrc.GetString();
990 case RC_LANGUAGE_AUTO_BEGIN:
992 language_auto_begin = lexrc.GetBool();
994 case RC_LANGUAGE_AUTO_END:
996 language_auto_end = lexrc.GetBool();
998 case RC_LANGUAGE_COMMAND_BEGIN:
1000 language_command_begin = lexrc.GetString();
1002 case RC_LANGUAGE_COMMAND_END:
1004 language_command_end = lexrc.GetString();
1006 case RC_RTL_SUPPORT:
1008 rtl_support = lexrc.GetBool();
1010 case RC_AUTO_NUMBER:
1012 auto_number = lexrc.GetBool();
1014 case RC_SHOW_BANNER:
1016 show_banner = lexrc.GetBool();
1020 use_gui = lexrc.GetBool();
1022 case RC_LINUXDOC_TO_LYX_COMMAND:
1024 linuxdoc_to_lyx_command = lexrc.GetString();
1026 case RC_LINUXDOC_TO_HTML_COMMAND:
1028 linuxdoc_to_html_command = lexrc.GetString();
1030 case RC_LINUXDOC_TO_LATEX_COMMAND:
1032 linuxdoc_to_latex_command = lexrc.GetString();
1034 case RC_DOCBOOK_TO_DVI_COMMAND:
1036 docbook_to_dvi_command = lexrc.GetString();
1038 case RC_DOCBOOK_TO_HTML_COMMAND:
1040 docbook_to_html_command = lexrc.GetString();
1042 case RC_DOCBOOK_TO_PDF_COMMAND:
1044 docbook_to_pdf_command = lexrc.GetString();
1046 case RC_LAST: break; // this is just a dummy
1054 void LyXRC::write(string const & filename) const
1056 ofstream ofs(filename.c_str());
1062 void LyXRC::print() const
1064 if (lyxerr.debugging())
1071 void LyXRC::output(ostream & os) const
1073 os << "### This file is part of\n"
1074 << "### ========================================================\n"
1075 << "### LyX, The Document Processor\n"
1077 << "### Copyright 1995 Matthias Ettrich\n"
1078 << "### Copyright 1995-1998 The LyX Team.\n"
1080 << "### ========================================================\n"
1082 << "# This file is written by LyX, if you want to make your own\n"
1083 << "# modifications you should do them from inside LyX and save\n"
1084 << "# your preferences, or you can also make your modifications\n"
1085 << "# to lyxrc by hand. It is not advisable to edit this file.\n"
1088 // Why the switch you might ask. It is a trick to ensure that all
1089 // the elements in the LyXRCTags enum is handled. As you can see
1090 // there are no breaks at all. So it is just a huge fall-through.
1091 // The nice thing is that we will get a warning from the compiler
1092 // if we forget an element.
1093 LyXRCTags tag = RC_LAST;
1097 // input/include files are not done here
1099 // bindings is not written to the preferences file.
1101 // bind files are not done here.
1102 case RC_BEGINTOOLBAR:
1103 // Toolbar is not written here (yet).
1104 case RC_FONT_ENCODING:
1105 os << "\\font_encoding \"" << fontenc << "\"\n";
1107 os << "\\printer \"" << printer << "\"\n";
1108 case RC_PRINT_COMMAND:
1109 os << "\\print_command \"" << print_command << "\"\n";
1110 case RC_PRINTEVENPAGEFLAG:
1111 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1113 case RC_PRINTODDPAGEFLAG:
1114 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1116 case RC_PRINTPAGERANGEFLAG:
1117 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1119 case RC_PRINTCOPIESFLAG:
1120 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1121 case RC_PRINTCOLLCOPIESFLAG:
1122 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1124 case RC_PRINTREVERSEFLAG:
1125 os << "\\print_reverse_flag \"" << print_reverse_flag
1127 case RC_PRINTLANDSCAPEFLAG:
1128 os << "\\print_landscape_flag \"" << print_landscape_flag
1130 case RC_PRINTTOPRINTER:
1131 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1132 case RC_PRINT_ADAPTOUTPUT:
1133 os << "\\print_adapt_output " << tostr(print_adapt_output)
1135 case RC_PRINTTOFILE:
1136 os << "\\print_to_file \"" << print_to_file << "\"\n";
1137 case RC_PRINTFILEEXTENSION:
1138 os << "\\print_file_extension \"" << print_file_extension
1140 case RC_PRINTEXSTRAOPTIONS:
1141 os << "\\print_extra_options \"" << print_extra_options
1143 case RC_PRINTSPOOL_COMMAND:
1144 os << "\\print_spool_command \"" << print_spool_command
1146 case RC_PRINTSPOOL_PRINTERPREFIX:
1147 os << "\\print_spool_printerprefix \""
1148 << print_spool_printerprefix << "\"\n";
1149 case RC_PRINTPAPERDIMENSIONFLAG:
1150 os << "\\print_paper_dimension_flag \""
1151 << print_paper_dimension_flag << "\"\n";
1152 case RC_PRINTPAPERFLAG:
1153 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1154 case RC_CUSTOM_EXPORT_COMMAND:
1155 os << "\\custom_export_command \"" << custom_export_command
1157 case RC_CUSTOM_EXPORT_FORMAT:
1158 os << "\\custom_export_format \"" << custom_export_format
1161 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1162 case RC_LATEX_COMMAND:
1163 os << "\\latex_command \"" << latex_command << "\"\n";
1164 case RC_PDFLATEX_COMMAND:
1165 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1166 case RC_PDF_TO_PS_COMMAND:
1167 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1168 case RC_DVI_TO_PS_COMMAND:
1169 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1170 case RC_LITERATE_COMMAND:
1171 os << "\\literate_command \"" << literate_command << "\"\n";
1172 case RC_LITERATE_EXTENSION:
1173 os << "\\literate_extension \"" << literate_extension
1175 case RC_LITERATE_ERROR_FILTER:
1176 os << "\\literate_error_filter \"" << literate_error_filter
1178 case RC_BUILD_COMMAND:
1179 os << "\\build_command \"" << build_command << "\"\n";
1180 case RC_BUILD_ERROR_FILTER:
1181 os << "\\build_error_filter \"" << build_error_filter
1184 os << "\\screen_dpi " << dpi << "\n";
1185 case RC_SCREEN_ZOOM:
1186 os << "\\screen_zoom " << zoom << "\n";
1187 case RC_SCREEN_FONT_SIZES:
1188 os.setf(ios::fixed);
1190 os << "\\screen_font_sizes";
1191 os << " " << font_sizes[LyXFont::SIZE_TINY];
1192 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1193 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1194 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1195 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1196 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1197 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1198 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1199 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1200 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1202 case RC_OVERRIDE_X_DEADKEYS:
1203 os << "\\override_x_deadkeys "
1204 << override_x_deadkeys << "\n";
1205 case RC_AUTOREGIONDELETE:
1206 os << "\\auto_region_delete " << tostr(auto_region_delete)
1209 os << "\\autosave " << autosave << "\n";
1210 case RC_EXIT_CONFIRMATION:
1211 os << "\\exit_confirmation " << tostr(exit_confirmation)
1213 case RC_DISPLAY_SHORTCUTS:
1214 os << "\\display_shortcuts " << tostr(display_shortcuts)
1216 case RC_VIEWDVI_COMMAND:
1217 os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1218 case RC_VIEWDVI_PAPEROPTION:
1219 os << "\\view_dvi_paper_option \"" << view_dvi_paper_option << "\"\n";
1220 case RC_VIEWPDF_COMMAND:
1221 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1222 case RC_DEFAULT_PAPERSIZE:
1223 os << "\\default_papersize \"";
1224 switch (default_papersize) {
1225 case BufferParams::PAPER_USLETTER:
1226 os << "usletter"; break;
1227 case BufferParams::PAPER_LEGALPAPER:
1228 os << "legal"; break;
1229 case BufferParams::PAPER_EXECUTIVEPAPER:
1230 os << "executive"; break;
1231 case BufferParams::PAPER_A3PAPER:
1233 case BufferParams::PAPER_A4PAPER:
1235 case BufferParams::PAPER_A5PAPER:
1237 case BufferParams::PAPER_B5PAPER:
1239 case BufferParams::PAPER_DEFAULT: break;
1242 case RC_VIEWPS_COMMAND:
1243 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1244 case RC_VIEWPSPIC_COMMAND:
1245 os << "\\view_pspic_command \"" << view_pspic_command
1248 os << "\\ps_command \"" << ps_command << "\"\n";
1249 case RC_CHKTEX_COMMAND:
1250 os << "\\chktex_command \"" << chktex_command << "\"\n";
1251 case RC_HTML_COMMAND:
1252 os << "\\html_command \"" << html_command << "\"\n";
1254 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1255 case RC_KBMAP_PRIMARY:
1256 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1257 case RC_KBMAP_SECONDARY:
1258 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1260 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1261 case RC_RELYX_COMMAND:
1262 os << "\\relyx_command \"" << relyx_command << "\"\n";
1263 case RC_DOCUMENTPATH:
1264 os << "\\document_path \"" << document_path << "\"\n";
1265 case RC_TEMPLATEPATH:
1266 os << "\\template_path \"" << template_path << "\"\n";
1267 case RC_TEMPDIRPATH:
1268 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1270 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1272 os << "\\lastfiles \"" << lastfiles << "\"\n";
1273 case RC_NUMLASTFILES:
1274 os << "\\num_lastfiles " << num_lastfiles << "\n";
1275 case RC_CHECKLASTFILES:
1276 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1277 case RC_SCREEN_FONT_ROMAN:
1278 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1279 case RC_SCREEN_FONT_SANS:
1280 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1281 case RC_SCREEN_FONT_TYPEWRITER:
1282 os << "\\screen_font_typewriter \""
1283 << typewriter_font_name << "\"\n";
1284 case RC_SCREEN_FONT_MENU:
1285 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1286 case RC_SCREEN_FONT_POPUP:
1287 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1288 case RC_SCREEN_FONT_ENCODING:
1289 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1290 case RC_SCREEN_FONT_ENCODING_MENU:
1291 os << "\\screen_font_encoding_menu \"" << font_norm_menu
1293 case RC_SCREEN_FONT_SCALABLE:
1294 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1296 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1297 os << "\\cursor_follows_scrollbar "
1298 << tostr(cursor_follows_scrollbar) << "\n";
1299 case RC_BACKGROUND_COLOR:
1300 os << "\\background_color \"" << background_color << "\"\n";
1301 case RC_SELECTION_COLOR:
1302 os << "\\selection_color \"" << selection_color << "\"\n";
1303 case RC_FAX_COMMAND:
1304 os << "\\fax_command \"" << fax_command << "\"\n";
1306 os << "\\fax_program \"" << fax_program << "\"\n";
1308 os << "\\phone_book \"" << phone_book << "\"\n";
1309 case RC_ASCIIROFF_COMMAND:
1310 os << "\\ascii_roff_command \"" << ascii_roff_command
1312 case RC_ASCII_LINELEN:
1313 os << "\\ascii_linelen " << ascii_linelen << "\n";
1314 case RC_SPELL_COMMAND:
1315 os << "\\spell_command \"" << isp_command << "\"\n";
1316 case RC_ACCEPT_COMPOUND:
1317 os << "\\accept_compound " << tostr(isp_accept_compound)
1319 case RC_USE_INP_ENC:
1320 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1322 case RC_USE_ALT_LANG:
1323 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1324 case RC_USE_PERS_DICT:
1325 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1327 case RC_USE_ESC_CHARS:
1328 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1331 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1333 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1335 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1336 case RC_RTL_SUPPORT:
1337 os << "\\rtl " << tostr(rtl_support) << "\n";
1338 case RC_AUTO_NUMBER:
1339 os << "\\auto_number" << tostr(auto_number) << "\n";
1340 case RC_LANGUAGE_AUTO_BEGIN:
1341 os << "\\language_auto_begin "
1342 << tostr(language_auto_begin) << "\n";
1343 case RC_LANGUAGE_AUTO_END:
1344 os << "\\language_auto_end "
1345 << tostr(language_auto_end) << "\n";
1346 case RC_LANGUAGE_PACKAGE:
1347 os << "\\language_package \"" << language_package << "\"\n";
1348 case RC_LANGUAGE_COMMAND_BEGIN:
1349 os << "\\language_command_begin \"" << language_command_begin
1351 case RC_LANGUAGE_COMMAND_END:
1352 os << "\\language_command_end \"" << language_command_end
1354 case RC_MAKE_BACKUP:
1355 os << "\\make_backup " << tostr(make_backup) << "\n";
1356 case RC_BACKUPDIR_PATH:
1357 os << "\\backupdir_path" << backupdir_path << "\n";
1358 case RC_DATE_INSERT_FORMAT:
1359 os << "\\date_insert_format \"" << date_insert_format
1361 case RC_SHOW_BANNER:
1362 os << "\\show_banner " << tostr(show_banner) << "\n";
1364 os << "\\use_gui " << tostr(show_banner) << "\n";
1365 case RC_LINUXDOC_TO_LYX_COMMAND:
1366 os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command
1368 case RC_LINUXDOC_TO_HTML_COMMAND:
1369 os << "\\linuxdoc_to_html_command \"" << linuxdoc_to_html_command
1371 case RC_LINUXDOC_TO_LATEX_COMMAND:
1372 os << "\\linuxdoc_to_latex_command \"" << linuxdoc_to_latex_command
1374 case RC_DOCBOOK_TO_DVI_COMMAND:
1375 os << "\\docbook_to_dvi_command \"" << docbook_to_dvi_command
1377 case RC_DOCBOOK_TO_HTML_COMMAND:
1378 os << "\\docbook_to_html_command \"" << docbook_to_html_command
1380 case RC_DOCBOOK_TO_PDF_COMMAND:
1381 os << "\\docbook_to_pdf_command \"" << docbook_to_pdf_command
1388 // The global instance