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"
29 #include "LyXAction.h"
30 #include "lyxserver.h"
33 #include "tex-strings.h"
34 #include "support/path.h"
35 #include "support/filetools.h"
38 // this is crappy... why are those colors command line arguments and
39 // not in lyxrc?? (Matthias)
40 // Because nobody put them there. (Asger)
42 extern string background_color;
43 extern char selection_color[];
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,
89 RC_SGML_EXTRA_OPTIONS,
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_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,
154 keyword_item lyxrcTags[] = {
155 { "\\accept_compound", RC_ACCEPT_COMPOUND },
156 { "\\alternate_language", RC_ALT_LANG },
157 { "\\ascii_linelen", RC_ASCII_LINELEN },
158 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
159 { "\\auto_mathmode", RC_AUTO_MATHMODE },
160 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
161 { "\\autosave", RC_AUTOSAVE },
162 { "\\background_color", RC_BACKGROUND_COLOR },
163 { "\\begin_toolbar", RC_BEGINTOOLBAR },
164 { "\\bind", RC_BIND },
165 { "\\bind_file", RC_BINDFILE },
166 { "\\build_command", RC_BUILD_COMMAND },
167 { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
168 { "\\check_lastfiles", RC_CHECKLASTFILES },
169 { "\\chktex_command", RC_CHKTEX_COMMAND },
170 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
171 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
172 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
173 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
174 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
175 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
176 { "\\document_path", RC_DOCUMENTPATH },
177 { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
178 { "\\escape_chars", RC_ESC_CHARS },
179 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
180 { "\\fax_command", RC_FAX_COMMAND },
181 { "\\fax_program", RC_FAXPROGRAM },
182 { "\\font_encoding", RC_FONT_ENCODING },
183 { "\\html_command", RC_HTML_COMMAND },
184 { "\\input", RC_INPUT },
185 { "\\kbmap", RC_KBMAP },
186 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
187 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
188 { "\\language_auto_begin", RC_LANGUAGE_AUTO_BEGIN },
189 { "\\language_auto_end", RC_LANGUAGE_AUTO_END },
190 { "\\language_command_begin", RC_LANGUAGE_COMMAND_BEGIN },
191 { "\\language_command_end", RC_LANGUAGE_COMMAND_END },
192 { "\\language_package", RC_LANGUAGE_PACKAGE },
193 { "\\lastfiles", RC_LASTFILES },
194 { "\\latex_command", RC_LATEX_COMMAND },
195 { "\\literate_command", RC_LITERATE_COMMAND },
196 { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
197 { "\\literate_extension", RC_LITERATE_EXTENSION },
198 { "\\make_backup", RC_MAKE_BACKUP },
199 { "\\num_lastfiles", RC_NUMLASTFILES },
200 { "\\pdf_mode", RC_PDF_MODE },
201 { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
202 { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
203 { "\\personal_dictionary", RC_PERS_DICT },
204 { "\\phone_book", RC_PHONEBOOK },
205 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
206 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
207 { "\\print_command", RC_PRINT_COMMAND },
208 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
209 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
210 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
211 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
212 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
213 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
214 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
215 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
216 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
217 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
218 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
219 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
220 { "\\print_to_file", RC_PRINTTOFILE },
221 { "\\print_to_printer", RC_PRINTTOPRINTER },
222 { "\\printer", RC_PRINTER },
223 { "\\ps_command", RC_PS_COMMAND },
224 { "\\relyx_command", RC_RELYX_COMMAND },
225 { "\\rtl", RC_RTL_SUPPORT },
226 { "\\screen_dpi", RC_SCREEN_DPI },
227 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
228 { "\\screen_font_encoding_menu", RC_SCREEN_FONT_ENCODING_MENU },
229 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
230 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
231 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
232 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
233 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
234 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
235 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
236 { "\\screen_zoom", RC_SCREEN_ZOOM },
237 { "\\selection_color", RC_SELECTION_COLOR },
238 { "\\serverpipe", RC_SERVERPIPE },
239 { "\\sgml_extra_options", RC_SGML_EXTRA_OPTIONS },
240 { "\\show_banner", RC_SHOW_BANNER },
241 { "\\spell_command", RC_SPELL_COMMAND },
242 { "\\tempdir_path", RC_TEMPDIRPATH },
243 { "\\template_path", RC_TEMPLATEPATH },
244 { "\\use_alt_language", RC_USE_ALT_LANG },
245 { "\\use_escape_chars", RC_USE_ESC_CHARS },
246 { "\\use_input_encoding", RC_USE_INP_ENC },
247 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
248 { "\\use_tempdir", RC_USETEMPDIR },
249 { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
250 { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
251 { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
252 { "\\view_ps_command", RC_VIEWPS_COMMAND },
253 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
256 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
257 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
266 void LyXRC::setDefaults() {
267 // Get printer from the environment. If fail, use default "",
268 // assuming that everything is set up correctly.
269 printer = GetEnv("PRINTER");
270 print_adapt_output = false;
271 print_command = "dvips";
272 print_evenpage_flag = "-B";
273 print_oddpage_flag = "-A";
274 print_pagerange_flag = "-pp";
275 print_copies_flag = "-c";
276 print_collcopies_flag = "-C";
277 print_reverse_flag = "-r";
278 print_landscape_flag = "-t landscape";
279 print_to_printer = "-P";
280 print_to_file = "-o ";
281 print_file_extension = ".ps";
282 print_paper_flag = "-t";
283 print_paper_dimension_flag = "-T";
284 document_path = GetEnvPath("HOME");
285 tempdir_path = "/tmp";
288 latex_command = "latex";
289 pdflatex_command = "pdflatex";
290 pdf_to_ps_command = "pdf2ps";
291 dvi_to_ps_command = "dvips";
292 literate_command = "none";
293 literate_extension = "none";
294 literate_error_filter = "cat";
295 build_command = "make";
296 build_error_filter = "cat";
297 relyx_command = "reLyX";
299 view_ps_command = "ghostview -swap";
300 view_pspic_command = "ghostview";
301 view_dvi_command = "xdvi";
302 view_dvi_paper_option = "-paper";
303 view_pdf_command = "xpdf";
304 default_papersize = BufferParams::PAPER_USLETTER;
305 custom_export_format = "ps";
306 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
307 html_command = "tth -t";
310 // Because a screen typically is wider than a piece of paper:
312 // Default LaTeX font size:
313 font_sizes[LyXFont::SIZE_TINY] = 5.0;
314 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
315 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
316 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
317 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
318 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
319 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
320 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
321 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
322 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
323 use_scalable_fonts = true;
324 roman_font_name = "-*-times";
325 sans_font_name = "-*-helvetica";
326 typewriter_font_name = "-*-courier";
327 menu_font_name = "-*-helvetica-bold-r";
328 popup_font_name = "-*-helvetica-medium-r";
329 font_norm = "iso8859-1";
332 auto_region_delete = true;
335 check_lastfiles = true;
337 exit_confirmation = true;
338 display_shortcuts = true;
339 // Spellchecker settings:
340 isp_command = "ispell";
341 isp_accept_compound = false;
342 isp_use_input_encoding = false;
343 isp_use_alt_lang = false;
344 isp_use_pers_dict = false;
345 isp_use_esc_chars = false;
349 auto_mathmode = "rtl";
350 language_package = "\\usepackage{babel}";
351 language_auto_begin = true;
352 language_auto_end = true;
353 language_command_begin = "\\selectlanguage{$$lang}";
354 language_command_end = "\\selectlanguage{$$lang}";
357 date_insert_format = "%A, %e %B %Y";
360 defaultKeyBindings();
364 int LyXRC::ReadBindFile(string const & name)
367 string tmp = i18nLibFileSearch("bind", name, "bind");
368 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
369 int result = read(tmp);
371 lyxerr << "Error reading bind file: " << tmp << endl;
377 int LyXRC::read(string const & filename)
380 string bindFile = "cua";
382 LyXLex lexrc(lyxrcTags, lyxrcCount);
383 if (lyxerr.debugging(Debug::PARSER))
384 lexrc.printTable(lyxerr);
386 lexrc.setFile(filename);
387 if (!lexrc.IsOK()) return -2;
389 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
391 while (lexrc.IsOK()) {
392 // By using two switches we take advantage of the compiler
393 // telling us if we have missed a LyXRCTags element in
394 // the second switch.
395 // Note that this also shows a problem with LyXLex since it
396 // helps us avoid taking advantage of the strictness of the
399 int le = lexrc.lex();
401 case LyXLex::LEX_UNDEF:
402 lexrc.printError("Unknown tag `$$Token'");
404 case LyXLex::LEX_FEOF:
408 switch (static_cast<LyXRCTags>(le)) {
409 case RC_INPUT: // Include file
411 string tmp = LibFileSearch(string(),
414 lexrc.printError("Error reading "
415 "included file: "+tmp);
419 case RC_BINDFILE: // RVDK_PATCH_5
421 ReadBindFile(lexrc.GetString());
425 case RC_BEGINTOOLBAR:
426 // this toolbar should be changed to be a completely
427 // non gui toolbar. (Lgb)
428 toolbardefaults.read(lexrc);
433 use_kbmap = lexrc.GetBool();
436 case RC_EXIT_CONFIRMATION:
438 exit_confirmation = lexrc.GetBool();
441 case RC_DISPLAY_SHORTCUTS:
443 display_shortcuts = lexrc.GetBool();
446 case RC_KBMAP_PRIMARY:
448 primary_kbmap = lexrc.GetString();
451 case RC_KBMAP_SECONDARY:
453 secondary_kbmap = lexrc.GetString();
456 case RC_FONT_ENCODING:
458 fontenc = lexrc.GetString();
463 printer = lexrc.GetString();
466 case RC_PRINT_COMMAND:
468 print_command = lexrc.GetString();
471 case RC_PRINTEVENPAGEFLAG:
473 print_evenpage_flag = lexrc.GetString();
476 case RC_PRINTODDPAGEFLAG:
478 print_oddpage_flag = lexrc.GetString();
481 case RC_PRINTPAGERANGEFLAG:
483 print_pagerange_flag = lexrc.GetString();
486 case RC_PRINTCOPIESFLAG:
488 print_copies_flag = lexrc.GetString();
491 case RC_PRINTCOLLCOPIESFLAG:
493 print_collcopies_flag = lexrc.GetString();
496 case RC_PRINTREVERSEFLAG:
498 print_reverse_flag = lexrc.GetString();
501 case RC_PRINTLANDSCAPEFLAG:
503 print_landscape_flag = lexrc.GetString();
506 case RC_PRINTTOPRINTER:
508 print_to_printer = lexrc.GetString();
511 case RC_PRINT_ADAPTOUTPUT:
513 print_adapt_output = lexrc.GetBool();
518 print_to_file = lexrc.GetString();
521 case RC_PRINTFILEEXTENSION:
523 print_file_extension = lexrc.GetString();
526 case RC_PRINTEXSTRAOPTIONS:
528 print_extra_options = lexrc.GetString();
531 case RC_PRINTSPOOL_COMMAND:
533 print_spool_command = lexrc.GetString();
536 case RC_PRINTSPOOL_PRINTERPREFIX:
538 print_spool_printerprefix = lexrc.GetString();
541 case RC_PRINTPAPERDIMENSIONFLAG:
543 print_paper_dimension_flag = lexrc.GetString();
546 case RC_PRINTPAPERFLAG:
548 print_paper_flag = lexrc.GetString();
551 case RC_CUSTOM_EXPORT_COMMAND:
553 custom_export_command = lexrc.GetString();
556 case RC_CUSTOM_EXPORT_FORMAT:
558 custom_export_format = lexrc.GetString();
563 pdf_mode = lexrc.GetBool();
566 case RC_LATEX_COMMAND:
568 latex_command = lexrc.GetString();
571 case RC_PDFLATEX_COMMAND:
573 pdflatex_command = lexrc.GetString();
576 case RC_PDF_TO_PS_COMMAND:
578 pdf_to_ps_command = lexrc.GetString();
581 case RC_DVI_TO_PS_COMMAND:
583 dvi_to_ps_command = lexrc.GetString();
586 case RC_LITERATE_COMMAND:
588 literate_command = lexrc.GetString();
591 case RC_LITERATE_EXTENSION:
593 literate_extension = lexrc.GetString();
596 case RC_LITERATE_ERROR_FILTER:
598 literate_error_filter = lexrc.GetString();
601 case RC_BUILD_COMMAND:
603 build_command = lexrc.GetString();
606 case RC_BUILD_ERROR_FILTER:
608 build_error_filter = lexrc.GetString();
611 case RC_RELYX_COMMAND:
613 relyx_command = lexrc.GetString();
616 case RC_DEFAULT_PAPERSIZE:
618 string size = lowercase(lexrc.GetString());
619 if (size == "usletter")
621 BufferParams::PAPER_USLETTER;
622 else if (size == "legal")
624 BufferParams::PAPER_LEGALPAPER;
625 else if (size == "executive")
627 BufferParams::PAPER_EXECUTIVEPAPER;
628 else if (size == "a3")
630 BufferParams::PAPER_A3PAPER;
631 else if (size == "a4")
633 BufferParams::PAPER_A4PAPER;
634 else if (size == "a5")
636 BufferParams::PAPER_A5PAPER;
637 else if (size == "b5")
639 BufferParams::PAPER_B5PAPER;
642 case RC_VIEWDVI_COMMAND:
644 view_dvi_command = lexrc.GetString();
647 case RC_VIEWDVI_PAPEROPTION:
649 view_dvi_paper_option = lexrc.GetString();
651 view_dvi_paper_option = "";
654 case RC_VIEWPDF_COMMAND:
656 view_pdf_command = lexrc.GetString();
661 ps_command = lexrc.GetString();
664 case RC_VIEWPS_COMMAND:
666 view_ps_command = lexrc.GetString();
669 case RC_VIEWPSPIC_COMMAND:
671 view_pspic_command = lexrc.GetString();
674 case RC_CHKTEX_COMMAND:
676 chktex_command = lexrc.GetString();
679 case RC_HTML_COMMAND:
681 html_command = lexrc.GetString();
686 dpi = lexrc.GetInteger();
691 zoom = lexrc.GetInteger();
694 case RC_SCREEN_FONT_SIZES:
696 font_sizes[LyXFont::SIZE_TINY] =
699 font_sizes[LyXFont::SIZE_SCRIPT] =
702 font_sizes[LyXFont::SIZE_FOOTNOTE] =
705 font_sizes[LyXFont::SIZE_SMALL] =
708 font_sizes[LyXFont::SIZE_NORMAL] =
711 font_sizes[LyXFont::SIZE_LARGE] =
714 font_sizes[LyXFont::SIZE_LARGER] =
717 font_sizes[LyXFont::SIZE_LARGEST] =
720 font_sizes[LyXFont::SIZE_HUGE] =
723 font_sizes[LyXFont::SIZE_HUGER] =
727 case RC_SCREEN_FONT_SCALABLE:
729 use_scalable_fonts = lexrc.GetBool();
734 autosave = lexrc.GetInteger();
737 case RC_SGML_EXTRA_OPTIONS:
739 sgml_extra_options = lexrc.GetString();
742 case RC_DOCUMENTPATH:
744 document_path = ExpandPath(lexrc.GetString());
748 case RC_TEMPLATEPATH:
750 template_path = ExpandPath(lexrc.GetString());
755 tempdir_path = ExpandPath(lexrc.GetString());
760 use_tempdir = lexrc.GetBool();
765 lastfiles = ExpandPath(lexrc.GetString());
768 case RC_NUMLASTFILES:
770 num_lastfiles = lexrc.GetInteger();
773 case RC_CHECKLASTFILES:
775 check_lastfiles = lexrc.GetBool();
778 case RC_SCREEN_FONT_ROMAN:
780 roman_font_name = lexrc.GetString();
783 case RC_SCREEN_FONT_SANS:
785 sans_font_name = lexrc.GetString();
788 case RC_SCREEN_FONT_TYPEWRITER:
790 typewriter_font_name = lexrc.GetString();
793 case RC_SCREEN_FONT_MENU:
795 menu_font_name = lexrc.GetString();
798 case RC_SCREEN_FONT_POPUP:
800 popup_font_name = lexrc.GetString();
803 case RC_SCREEN_FONT_ENCODING:
805 font_norm = lexrc.GetString();
808 case RC_SCREEN_FONT_ENCODING_MENU:
810 font_norm_menu = lexrc.GetString();
813 case RC_AUTOREGIONDELETE:
814 // Auto region delete defaults to true
816 auto_region_delete = lexrc.GetBool();
821 // we should not do an explicit binding before
822 // loading a bind file. So, in this case, load
823 // the default bind file.
827 // !!!chb, dynamic key binding...
831 if (lexrc.lex() == LyXLex::LEX_DATA) {
832 seq = lexrc.GetString();
834 lexrc.printError("Bad key sequence: `$$Token'");
838 if (lexrc.lex() == LyXLex::LEX_DATA) {
839 cmd = lexrc.GetString();
841 lexrc.printError("Bad command: `$$Token'");
845 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
846 if (lyxerr.debugging(Debug::KEY)) {
847 lyxerr << "RC_BIND: Sequence `"
848 << seq << "' Command `"
849 << cmd << "' Action `"
850 << action << '\'' << endl;
852 res = toplevel_keymap->bind(seq.c_str(),
856 "Invalid key sequence `"
859 } else {// cmd is the last token read.
861 "Unknown LyX function `$$Token'");
867 lyxpipes = ExpandPath(lexrc.GetString());
870 case RC_CURSOR_FOLLOWS_SCROLLBAR:
872 cursor_follows_scrollbar = lexrc.GetBool();
875 case RC_BACKGROUND_COLOR:
877 background_color = lexrc.GetString();
879 case RC_SELECTION_COLOR:
881 strncpy(selection_color,
882 lexrc.GetString().c_str(), 31);
886 fax_command = lexrc.GetString();
890 fax_program = lexrc.GetString();
894 string s = lexrc.GetString();
898 phone_book = user_lyxdir + s;
901 case RC_ASCIIROFF_COMMAND:
903 ascii_roff_command = lexrc.GetString();
905 case RC_ASCII_LINELEN:
907 ascii_linelen = lexrc.GetInteger();
909 // Spellchecker settings:
910 case RC_SPELL_COMMAND:
912 isp_command = lexrc.GetString();
914 case RC_ACCEPT_COMPOUND:
916 isp_accept_compound = lexrc.GetBool();
920 isp_use_input_encoding = lexrc.GetBool();
922 case RC_USE_ALT_LANG:
924 isp_use_alt_lang = lexrc.GetBool();
926 case RC_USE_PERS_DICT:
928 isp_use_pers_dict = lexrc.GetBool();
930 case RC_USE_ESC_CHARS:
932 isp_use_esc_chars = lexrc.GetBool();
936 isp_alt_lang = lexrc.GetString();
940 isp_pers_dict = lexrc.GetString();
944 isp_esc_chars = lexrc.GetString();
948 make_backup = lexrc.GetBool();
950 case RC_DATE_INSERT_FORMAT:
952 date_insert_format = lexrc.GetString();
954 case RC_LANGUAGE_PACKAGE:
956 language_package = lexrc.GetString();
958 case RC_LANGUAGE_AUTO_BEGIN:
960 language_auto_begin = lexrc.GetBool();
962 case RC_LANGUAGE_AUTO_END:
964 language_auto_end = lexrc.GetBool();
966 case RC_LANGUAGE_COMMAND_BEGIN:
968 language_command_begin = lexrc.GetString();
970 case RC_LANGUAGE_COMMAND_END:
972 language_command_end = lexrc.GetString();
976 rtl_support = lexrc.GetBool();
978 case RC_AUTO_MATHMODE:
980 auto_mathmode = lowercase(lexrc.GetString());
984 show_banner = lexrc.GetBool();
986 case RC_LAST: break; // this is just a dummy
994 void LyXRC::write(string const & filename) const
996 ofstream ofs(filename.c_str());
1002 void LyXRC::print() const
1004 if (lyxerr.debugging())
1011 void LyXRC::output(ostream & os) const
1013 os << "### This file is part of\n"
1014 << "### ========================================================\n"
1015 << "### LyX, The Document Processor\n"
1017 << "### Copyright 1995 Matthias Ettrich\n"
1018 << "### Copyright 1995-1998 The LyX Team.\n"
1020 << "### ========================================================\n"
1022 << "# This file is written by LyX, if you want to make your own\n"
1023 << "# modifications you should do them from inside LyX and save\n"
1024 << "# your preferences, or you can also make your modifications\n"
1025 << "# to lyxrc by hand. It is not advisable to edit this file.\n"
1028 // Why the switch you might ask. It is a trick to ensure that all
1029 // the elements in the LyXRCTags enum is handled. As you can see
1030 // there are no breaks at all. So it is just a huge fall-through.
1031 // The nice thing is that we will get a warning from the compiler
1032 // if we forget an element.
1033 LyXRCTags tag = RC_LAST;
1037 // input/include files are not done here
1039 // bindings is not written to the preferences file.
1041 // bind files are not done here.
1042 case RC_BEGINTOOLBAR:
1043 // Toolbar is not written here (yet).
1044 case RC_FONT_ENCODING:
1045 os << "\\font_encoding \"" << fontenc << "\"\n";
1047 os << "\\printer \"" << printer << "\"\n";
1048 case RC_PRINT_COMMAND:
1049 os << "\\print_command \"" << print_command << "\"\n";
1050 case RC_PRINTEVENPAGEFLAG:
1051 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1053 case RC_PRINTODDPAGEFLAG:
1054 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1056 case RC_PRINTPAGERANGEFLAG:
1057 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1059 case RC_PRINTCOPIESFLAG:
1060 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1061 case RC_PRINTCOLLCOPIESFLAG:
1062 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1064 case RC_PRINTREVERSEFLAG:
1065 os << "\\print_reverse_flag \"" << print_reverse_flag
1067 case RC_PRINTLANDSCAPEFLAG:
1068 os << "\\print_landscape_flag \"" << print_landscape_flag
1070 case RC_PRINTTOPRINTER:
1071 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1072 case RC_PRINT_ADAPTOUTPUT:
1073 os << "\\print_adapt_output " << tostr(print_adapt_output)
1075 case RC_PRINTTOFILE:
1076 os << "\\print_to_file \"" << print_to_file << "\"\n";
1077 case RC_PRINTFILEEXTENSION:
1078 os << "\\print_file_extension \"" << print_file_extension
1080 case RC_PRINTEXSTRAOPTIONS:
1081 os << "\\print_extra_options \"" << print_extra_options
1083 case RC_PRINTSPOOL_COMMAND:
1084 os << "\\print_spool_command \"" << print_spool_command
1086 case RC_PRINTSPOOL_PRINTERPREFIX:
1087 os << "\\print_spool_printerprefix \""
1088 << print_spool_printerprefix << "\"\n";
1089 case RC_PRINTPAPERDIMENSIONFLAG:
1090 os << "\\print_paper_dimension_flag \""
1091 << print_paper_dimension_flag << "\"\n";
1092 case RC_PRINTPAPERFLAG:
1093 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1094 case RC_CUSTOM_EXPORT_COMMAND:
1095 os << "\\custom_export_command \"" << custom_export_command
1097 case RC_CUSTOM_EXPORT_FORMAT:
1098 os << "\\custom_export_format \"" << custom_export_format
1101 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1102 case RC_LATEX_COMMAND:
1103 os << "\\latex_command \"" << latex_command << "\"\n";
1104 case RC_PDFLATEX_COMMAND:
1105 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1106 case RC_PDF_TO_PS_COMMAND:
1107 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1108 case RC_DVI_TO_PS_COMMAND:
1109 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1110 case RC_LITERATE_COMMAND:
1111 os << "\\literate_command \"" << literate_command << "\"\n";
1112 case RC_LITERATE_EXTENSION:
1113 os << "\\literate_extension \"" << literate_extension
1115 case RC_LITERATE_ERROR_FILTER:
1116 os << "\\literate_error_filter \"" << literate_error_filter
1118 case RC_BUILD_COMMAND:
1119 os << "\\build_command \"" << build_command << "\"\n";
1120 case RC_BUILD_ERROR_FILTER:
1121 os << "\\build_error_filter \"" << build_error_filter
1124 os << "\\screen_dpi " << dpi << "\n";
1125 case RC_SCREEN_ZOOM:
1126 os << "\\screen_zoom " << zoom << "\n";
1127 case RC_SCREEN_FONT_SIZES:
1128 os.setf(ios::fixed);
1130 os << "\\screen_font_sizes";
1131 os << " " << font_sizes[LyXFont::SIZE_TINY];
1132 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1133 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1134 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1135 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1136 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1137 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1138 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1139 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1140 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1142 case RC_AUTOREGIONDELETE:
1143 os << "\\auto_region_delete " << tostr(auto_region_delete)
1146 os << "\\autosave " << autosave << "\n";
1147 case RC_EXIT_CONFIRMATION:
1148 os << "\\exit_confirmation " << tostr(exit_confirmation)
1150 case RC_DISPLAY_SHORTCUTS:
1151 os << "\\display_shortcuts " << tostr(display_shortcuts)
1153 case RC_VIEWDVI_COMMAND:
1154 os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1155 case RC_VIEWDVI_PAPEROPTION:
1156 os << "\\view_dvi_paper_option \"" << view_dvi_paper_option << "\"\n";
1157 case RC_VIEWPDF_COMMAND:
1158 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1159 case RC_DEFAULT_PAPERSIZE:
1160 os << "\\default_papersize \"";
1161 switch (default_papersize) {
1162 case BufferParams::PAPER_USLETTER:
1163 os << "usletter"; break;
1164 case BufferParams::PAPER_LEGALPAPER:
1165 os << "legal"; break;
1166 case BufferParams::PAPER_EXECUTIVEPAPER:
1167 os << "executive"; break;
1168 case BufferParams::PAPER_A3PAPER:
1170 case BufferParams::PAPER_A4PAPER:
1172 case BufferParams::PAPER_A5PAPER:
1174 case BufferParams::PAPER_B5PAPER:
1176 case BufferParams::PAPER_DEFAULT: break;
1179 case RC_VIEWPS_COMMAND:
1180 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1181 case RC_VIEWPSPIC_COMMAND:
1182 os << "\\view_pspic_command \"" << view_pspic_command
1185 os << "\\ps_command \"" << ps_command << "\"\n";
1186 case RC_CHKTEX_COMMAND:
1187 os << "\\chktex_command \"" << chktex_command << "\"\n";
1188 case RC_HTML_COMMAND:
1189 os << "\\html_command \"" << html_command << "\"\n";
1190 case RC_SGML_EXTRA_OPTIONS:
1191 os << "\\sgml_extra_options \"" << sgml_extra_options
1194 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1195 case RC_KBMAP_PRIMARY:
1196 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1197 case RC_KBMAP_SECONDARY:
1198 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1200 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1201 case RC_RELYX_COMMAND:
1202 os << "\\relyx_command \"" << relyx_command << "\"\n";
1203 case RC_DOCUMENTPATH:
1204 os << "\\document_path \"" << document_path << "\"\n";
1205 case RC_TEMPLATEPATH:
1206 os << "\\template_path \"" << template_path << "\"\n";
1207 case RC_TEMPDIRPATH:
1208 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1210 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1212 os << "\\lastfiles \"" << lastfiles << "\"\n";
1213 case RC_NUMLASTFILES:
1214 os << "\\num_lastfiles " << num_lastfiles << "\n";
1215 case RC_CHECKLASTFILES:
1216 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1217 case RC_SCREEN_FONT_ROMAN:
1218 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1219 case RC_SCREEN_FONT_SANS:
1220 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1221 case RC_SCREEN_FONT_TYPEWRITER:
1222 os << "\\screen_font_typewriter \""
1223 << typewriter_font_name << "\"\n";
1224 case RC_SCREEN_FONT_MENU:
1225 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1226 case RC_SCREEN_FONT_POPUP:
1227 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1228 case RC_SCREEN_FONT_ENCODING:
1229 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1230 case RC_SCREEN_FONT_ENCODING_MENU:
1231 os << "\\screen_font_encoding_menu \"" << font_norm_menu
1233 case RC_SCREEN_FONT_SCALABLE:
1234 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1236 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1237 os << "\\cursor_follows_scrollbar "
1238 << tostr(cursor_follows_scrollbar) << "\n";
1239 case RC_BACKGROUND_COLOR:
1240 os << "\\background_color \"" << background_color << "\"\n";
1241 case RC_SELECTION_COLOR:
1242 os << "\\selection_color \"" << selection_color << "\"\n";
1243 case RC_FAX_COMMAND:
1244 os << "\\fax_command \"" << fax_command << "\"\n";
1246 os << "\\fax_program \"" << fax_program << "\"\n";
1248 os << "\\phone_book \"" << phone_book << "\"\n";
1249 case RC_ASCIIROFF_COMMAND:
1250 os << "\\ascii_roff_command \"" << ascii_roff_command
1252 case RC_ASCII_LINELEN:
1253 os << "\\ascii_linelen " << ascii_linelen << "\n";
1254 case RC_SPELL_COMMAND:
1255 os << "\\spell_command \"" << isp_command << "\"\n";
1256 case RC_ACCEPT_COMPOUND:
1257 os << "\\accept_compound " << tostr(isp_accept_compound)
1259 case RC_USE_INP_ENC:
1260 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1262 case RC_USE_ALT_LANG:
1263 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1264 case RC_USE_PERS_DICT:
1265 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1267 case RC_USE_ESC_CHARS:
1268 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1271 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1273 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1275 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1276 case RC_RTL_SUPPORT:
1277 os << "\\rtl " << tostr(rtl_support) << "\n";
1278 case RC_AUTO_MATHMODE:
1279 os << "\\auto_mathmode" << auto_mathmode << "\n";
1280 case RC_LANGUAGE_AUTO_BEGIN:
1281 os << "\\language_auto_begin "
1282 << tostr(language_auto_begin) << "\n";
1283 case RC_LANGUAGE_AUTO_END:
1284 os << "\\language_auto_end "
1285 << tostr(language_auto_end) << "\n";
1286 case RC_LANGUAGE_PACKAGE:
1287 os << "\\language_package \"" << language_package << "\"\n";
1288 case RC_LANGUAGE_COMMAND_BEGIN:
1289 os << "\\language_command_begin \"" << language_command_begin
1291 case RC_LANGUAGE_COMMAND_END:
1292 os << "\\language_command_end \"" << language_command_end
1294 case RC_MAKE_BACKUP:
1295 os << "\\make_backup " << tostr(make_backup) << "\n";
1296 case RC_DATE_INSERT_FORMAT:
1297 os << "\\date_insert_format \"" << date_insert_format
1299 case RC_SHOW_BANNER:
1300 os << "\\show_banner " << tostr(show_banner) << "\n";
1306 /// define the default key bindings for LyX.
1307 void LyXRC::defaultKeyBindings()
1309 bindings["Right"] = LFUN_RIGHT;
1310 bindings["Left"] = LFUN_LEFT;
1311 bindings["Up"] = LFUN_UP;
1312 bindings["Down"] = LFUN_DOWN;
1314 bindings["Tab"] = LFUN_TAB;
1316 bindings["Home"] = LFUN_HOME;
1317 bindings["End"] = LFUN_END;
1318 bindings["Prior"] = LFUN_PRIOR;
1319 bindings["Next"] = LFUN_NEXT;
1321 bindings["Return"] = LFUN_BREAKPARAGRAPH;
1322 bindings["~C-~S-~M-nobreakspace"] = LFUN_PROTECTEDSPACE;
1324 bindings["Delete"] = LFUN_DELETE;
1325 bindings["BackSpace"] = LFUN_BACKSPACE;
1326 // bindKeyings for transparent handling of deadkeys
1327 // The keysyms are gotten from XFree86 X11R6
1328 bindings["~C-~S-~M-dead_acute"] = LFUN_ACUTE;
1329 bindings["~C-~S-~M-dead_breve"] = LFUN_BREVE;
1330 bindings["~C-~S-~M-dead_caron"] = LFUN_CARON;
1331 bindings["~C-~S-~M-dead_cedilla"] = LFUN_CEDILLA;
1332 bindings["~C-~S-~M-dead_abovering"] = LFUN_CIRCLE;
1333 bindings["~C-~S-~M-dead_circumflex"] = LFUN_CIRCUMFLEX;
1334 bindings["~C-~S-~M-dead_abovedot"] = LFUN_DOT;
1335 bindings["~C-~S-~M-dead_grave"] = LFUN_GRAVE;
1336 bindings["~C-~S-~M-dead_doubleacute"] = LFUN_HUNG_UMLAUT;
1337 bindings["~C-~S-~M-dead_macron"] = LFUN_MACRON;
1338 // nothing with this name
1339 // bindings["~C-~S-~M-dead_special_caron"] = LFUN_SPECIAL_CARON;
1340 bindings["~C-~S-~M-dead_tilde"] = LFUN_TILDE;
1341 bindings["~C-~S-~M-dead_diaeresis"] = LFUN_UMLAUT;
1342 // nothing with this name either...
1343 //bindings["~C-~S-~M-dead_underbar"] = LFUN_UNDERBAR;
1344 bindings["~C-~S-~M-dead_belowdot"] = LFUN_UNDERDOT;
1345 bindings["~C-~S-~M-dead_tie"] = LFUN_TIE;
1346 bindings["~C-~S-~M-dead_ogonek"] = LFUN_OGONEK;
1348 // bindings to utilize the use of the numeric keypad
1349 // e.g. Num Lock set
1350 bindings["KP_0"] = LFUN_SELFINSERT;
1351 bindings["KP_Decimal"] = LFUN_SELFINSERT;
1352 bindings["KP_Enter"] = LFUN_SELFINSERT;
1353 bindings["KP_1"] = LFUN_SELFINSERT;
1354 bindings["KP_2"] = LFUN_SELFINSERT;
1355 bindings["KP_3"] = LFUN_SELFINSERT;
1356 bindings["KP_4"] = LFUN_SELFINSERT;
1357 bindings["KP_5"] = LFUN_SELFINSERT;
1358 bindings["KP_6"] = LFUN_SELFINSERT;
1359 bindings["KP_Add"] = LFUN_SELFINSERT;
1360 bindings["KP_7"] = LFUN_SELFINSERT;
1361 bindings["KP_8"] = LFUN_SELFINSERT;
1362 bindings["KP_9"] = LFUN_SELFINSERT;
1363 bindings["KP_Divide"] = LFUN_SELFINSERT;
1364 bindings["KP_Multiply"] = LFUN_SELFINSERT;
1365 bindings["KP_Subtract"] = LFUN_SELFINSERT;
1367 /* Most self-insert keys are handled in the 'default:' section of
1368 * WorkAreaKeyPress - so we don't have to define them all.
1369 * However keys explicit decleared as self-insert are
1370 * handled seperatly (LFUN_SELFINSERT.) Lgb. */
1372 bindings["C-Tab"] = LFUN_TABINSERT; // ale970515
1375 // The global instance