1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
14 #pragma implementation "lyxrc.h"
25 #include "LyXAction.h"
26 #include "lyxserver.h"
29 #include "tex-strings.h"
30 #include "support/path.h"
31 #include "support/filetools.h"
33 #include "converter.h"
41 // this is crappy... why are those colors command line arguments and
42 // not in lyxrc?? (Matthias)
43 // Because nobody put them there. (Asger)
45 extern bool cursor_follows_scrollbar;
46 extern LyXAction lyxaction;
47 extern kb_keymap * toplevel_keymap;
56 RC_PRINTPAGERANGEFLAG,
58 RC_PRINTCOLLCOPIESFLAG,
60 RC_PRINTLANDSCAPEFLAG,
64 RC_PRINTFILEEXTENSION,
65 RC_PRINTEXSTRAOPTIONS,
66 RC_PRINTSPOOL_COMMAND,
67 RC_PRINTSPOOL_PRINTERPREFIX,
69 RC_PRINTPAPERDIMENSIONFLAG,
70 RC_CUSTOM_EXPORT_COMMAND,
71 RC_CUSTOM_EXPORT_FORMAT,
72 RC_LITERATE_EXTENSION,
78 RC_SCREEN_FONT_TYPEWRITER,
81 RC_SCREEN_FONT_ENCODING,
82 RC_SCREEN_FONT_ENCODING_MENU,
92 RC_OVERRIDE_X_DEADKEYS,
103 RC_ASCIIROFF_COMMAND,
107 RC_VIEWDVI_PAPEROPTION,
108 RC_DEFAULT_PAPERSIZE,
116 RC_SCREEN_FONT_SCALABLE,
121 RC_CURSOR_FOLLOWS_SCROLLBAR,
122 RC_EXIT_CONFIRMATION,
123 RC_DISPLAY_SHORTCUTS,
129 RC_MARK_FOREIGN_LANGUAGE,
131 RC_LANGUAGE_AUTO_BEGIN,
132 RC_LANGUAGE_AUTO_END,
133 RC_LANGUAGE_COMMAND_BEGIN,
134 RC_LANGUAGE_COMMAND_END,
135 RC_DATE_INSERT_FORMAT,
137 RC_LINUXDOC_TO_LYX_COMMAND,
148 keyword_item lyxrcTags[] = {
149 { "\\accept_compound", RC_ACCEPT_COMPOUND },
150 { "\\alternate_language", RC_ALT_LANG },
151 { "\\ascii_linelen", RC_ASCII_LINELEN },
152 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
153 { "\\auto_number", RC_AUTO_NUMBER },
154 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
155 { "\\autosave", RC_AUTOSAVE },
156 { "\\backupdir_path", RC_BACKUPDIR_PATH },
157 { "\\bind", RC_BIND },
158 { "\\bind_file", RC_BINDFILE },
159 { "\\check_lastfiles", RC_CHECKLASTFILES },
160 { "\\chktex_command", RC_CHKTEX_COMMAND },
161 { "\\converter", RC_CONVERTER },
162 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
163 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
164 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
165 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
166 { "\\default_language", RC_DEFAULT_LANGUAGE },
167 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
168 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
169 { "\\document_path", RC_DOCUMENTPATH },
170 { "\\escape_chars", RC_ESC_CHARS },
171 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
172 { "\\fax_command", RC_FAX_COMMAND },
173 { "\\fax_program", RC_FAXPROGRAM },
174 { "\\font_encoding", RC_FONT_ENCODING },
175 { "\\input", RC_INPUT },
176 { "\\kbmap", RC_KBMAP },
177 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
178 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
179 { "\\language_auto_begin", RC_LANGUAGE_AUTO_BEGIN },
180 { "\\language_auto_end", RC_LANGUAGE_AUTO_END },
181 { "\\language_command_begin", RC_LANGUAGE_COMMAND_BEGIN },
182 { "\\language_command_end", RC_LANGUAGE_COMMAND_END },
183 { "\\language_package", RC_LANGUAGE_PACKAGE },
184 { "\\lastfiles", RC_LASTFILES },
185 { "\\linuxdoc_to_lyx_command", RC_LINUXDOC_TO_LYX_COMMAND },
186 { "\\literate_extension", RC_LITERATE_EXTENSION },
187 { "\\make_backup", RC_MAKE_BACKUP },
188 { "\\mark_foreign_language", RC_MARK_FOREIGN_LANGUAGE },
189 { "\\new_ask_filename", RC_NEW_ASK_FILENAME },
190 { "\\num_lastfiles", RC_NUMLASTFILES },
191 { "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
192 { "\\personal_dictionary", RC_PERS_DICT },
193 { "\\phone_book", RC_PHONEBOOK },
194 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
195 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
196 { "\\print_command", RC_PRINT_COMMAND },
197 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
198 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
199 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
200 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
201 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
202 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
203 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
204 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
205 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
206 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
207 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
208 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
209 { "\\print_to_file", RC_PRINTTOFILE },
210 { "\\print_to_printer", RC_PRINTTOPRINTER },
211 { "\\printer", RC_PRINTER },
212 { "\\ps_command", RC_PS_COMMAND },
213 { "\\relyx_command", RC_RELYX_COMMAND },
214 { "\\rtl", RC_RTL_SUPPORT },
215 { "\\screen_dpi", RC_SCREEN_DPI },
216 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
217 { "\\screen_font_encoding_menu", RC_SCREEN_FONT_ENCODING_MENU },
218 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
219 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
220 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
221 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
222 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
223 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
224 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
225 { "\\screen_zoom", RC_SCREEN_ZOOM },
226 { "\\serverpipe", RC_SERVERPIPE },
227 { "\\set_color", RC_SET_COLOR },
228 { "\\show_banner", RC_SHOW_BANNER },
229 { "\\spell_command", RC_SPELL_COMMAND },
230 { "\\tempdir_path", RC_TEMPDIRPATH },
231 { "\\template_path", RC_TEMPLATEPATH },
232 { "\\ui_file", RC_UIFILE },
233 { "\\use_alt_language", RC_USE_ALT_LANG },
234 { "\\use_escape_chars", RC_USE_ESC_CHARS },
235 { "\\use_input_encoding", RC_USE_INP_ENC },
236 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
237 { "\\use_tempdir", RC_USETEMPDIR },
238 { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
239 { "\\viewer" ,RC_VIEWER},
240 { "\\wheel_jump", RC_WHEEL_JUMP }
243 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
244 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
253 void LyXRC::setDefaults() {
255 // Get printer from the environment. If fail, use default "",
256 // assuming that everything is set up correctly.
257 printer = GetEnv("PRINTER");
258 print_adapt_output = false;
259 print_command = "dvips";
260 print_evenpage_flag = "-B";
261 print_oddpage_flag = "-A";
262 print_pagerange_flag = "-pp";
263 print_copies_flag = "-c";
264 print_collcopies_flag = "-C";
265 print_reverse_flag = "-r";
266 print_landscape_flag = "-t landscape";
267 print_to_printer = "-P";
268 print_to_file = "-o ";
269 print_file_extension = ".ps";
270 print_paper_flag = "-t";
271 print_paper_dimension_flag = "-T";
272 document_path = GetEnvPath("HOME");
273 tempdir_path = "/tmp";
275 literate_extension = "none";
276 relyx_command = "reLyX";
278 view_dvi_paper_option = "-paper";
279 default_papersize = BufferParams::PAPER_USLETTER;
280 custom_export_format = "ps";
281 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
284 // Because a screen typically is wider than a piece of paper:
287 // Default LaTeX font size:
288 font_sizes[LyXFont::SIZE_TINY] = 5.0;
289 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
290 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
291 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
292 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
293 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
294 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
295 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
296 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
297 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
298 use_scalable_fonts = true;
299 roman_font_name = "-*-times";
300 sans_font_name = "-*-helvetica";
301 typewriter_font_name = "-*-courier";
302 menu_font_name = "-*-helvetica-bold-r";
303 popup_font_name = "-*-helvetica-medium-r";
304 font_norm = "iso8859-1";
305 font_norm_type = OTHER_ENCODING;
307 override_x_deadkeys = true;
309 auto_region_delete = true;
312 check_lastfiles = true;
315 exit_confirmation = true;
316 display_shortcuts = true;
317 // Spellchecker settings:
318 isp_command = "ispell";
319 isp_accept_compound = false;
320 isp_use_input_encoding = false;
321 isp_use_alt_lang = false;
322 isp_use_pers_dict = false;
323 isp_use_esc_chars = false;
328 mark_foreign_language = true;
329 language_package = "\\usepackage{babel}";
330 language_auto_begin = true;
331 language_auto_end = true;
332 language_command_begin = "\\selectlanguage{$$lang}";
333 language_command_end = "\\selectlanguage{$$lang}";
334 default_language = "english";
336 new_ask_filename = false;
339 date_insert_format = "%A, %e %B %Y";
343 linuxdoc_to_lyx_command="none";
345 /// These variables are not stored on disk (perhaps they
346 // should be moved from the LyXRC class).
352 int LyXRC::ReadBindFile(string const & name)
355 string tmp = i18nLibFileSearch("bind", name, "bind");
356 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
357 int result = read(tmp);
359 lyxerr << "Error reading bind file: " << tmp << endl;
365 int LyXRC::read(string const & filename)
368 string bindFile = "cua";
370 LyXLex lexrc(lyxrcTags, lyxrcCount);
371 if (lyxerr.debugging(Debug::PARSER))
372 lexrc.printTable(lyxerr);
374 lexrc.setFile(filename);
375 if (!lexrc.IsOK()) return -2;
377 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
379 while (lexrc.IsOK()) {
380 // By using two switches we take advantage of the compiler
381 // telling us if we have missed a LyXRCTags element in
382 // the second switch.
383 // Note that this also shows a problem with LyXLex since it
384 // helps us avoid taking advantage of the strictness of the
387 int le = lexrc.lex();
389 case LyXLex::LEX_UNDEF:
390 lexrc.printError("Unknown tag `$$Token'");
392 case LyXLex::LEX_FEOF:
396 switch (static_cast<LyXRCTags>(le)) {
397 case RC_INPUT: // Include file
399 string tmp = LibFileSearch(string(),
402 lexrc.printError("Error reading "
403 "included file: "+tmp);
407 case RC_BINDFILE: // RVDK_PATCH_5
409 string tmp(lexrc.GetString());
410 if (bind_file.empty()) {
411 // we only need the name of the first
412 // bind file since that (usually)
413 // includes several others.
422 ui_file = lexrc.GetString();
426 case RC_EXIT_CONFIRMATION:
428 exit_confirmation = lexrc.GetBool();
431 case RC_DISPLAY_SHORTCUTS:
433 display_shortcuts = lexrc.GetBool();
438 use_kbmap = lexrc.GetBool();
441 case RC_KBMAP_PRIMARY:
443 string kmap(lexrc.GetString());
446 } else if (!LibFileSearch("kbd", kmap,
448 primary_kbmap = kmap;
450 lexrc.printError("LyX: Keymap `$$Token' not found");
454 case RC_KBMAP_SECONDARY:
456 string kmap(lexrc.GetString());
459 } else if (!LibFileSearch("kbd", kmap,
461 secondary_kbmap = kmap;
463 lexrc.printError("LyX: Keymap `$$Token' not found");
467 case RC_FONT_ENCODING:
469 fontenc = lexrc.GetString();
474 printer = lexrc.GetString();
477 case RC_PRINT_COMMAND:
479 print_command = lexrc.GetString();
482 case RC_PRINTEVENPAGEFLAG:
484 print_evenpage_flag = lexrc.GetString();
487 case RC_PRINTODDPAGEFLAG:
489 print_oddpage_flag = lexrc.GetString();
492 case RC_PRINTPAGERANGEFLAG:
494 print_pagerange_flag = lexrc.GetString();
497 case RC_PRINTCOPIESFLAG:
499 print_copies_flag = lexrc.GetString();
502 case RC_PRINTCOLLCOPIESFLAG:
504 print_collcopies_flag = lexrc.GetString();
507 case RC_PRINTREVERSEFLAG:
509 print_reverse_flag = lexrc.GetString();
512 case RC_PRINTLANDSCAPEFLAG:
514 print_landscape_flag = lexrc.GetString();
517 case RC_PRINTTOPRINTER:
519 print_to_printer = lexrc.GetString();
522 case RC_PRINT_ADAPTOUTPUT:
524 print_adapt_output = lexrc.GetBool();
529 print_to_file = lexrc.GetString();
532 case RC_PRINTFILEEXTENSION:
534 print_file_extension = lexrc.GetString();
537 case RC_PRINTEXSTRAOPTIONS:
539 print_extra_options = lexrc.GetString();
542 case RC_PRINTSPOOL_COMMAND:
544 print_spool_command = lexrc.GetString();
547 case RC_PRINTSPOOL_PRINTERPREFIX:
549 print_spool_printerprefix = lexrc.GetString();
552 case RC_PRINTPAPERDIMENSIONFLAG:
554 print_paper_dimension_flag = lexrc.GetString();
557 case RC_PRINTPAPERFLAG:
559 print_paper_flag = lexrc.GetString();
562 case RC_CUSTOM_EXPORT_COMMAND:
564 custom_export_command = lexrc.GetString();
567 case RC_CUSTOM_EXPORT_FORMAT:
569 custom_export_format = lexrc.GetString();
572 case RC_LITERATE_EXTENSION:
574 literate_extension = lexrc.GetString();
577 case RC_RELYX_COMMAND:
579 relyx_command = lexrc.GetString();
582 case RC_DEFAULT_PAPERSIZE:
584 string size = lowercase(lexrc.GetString());
585 if (size == "usletter")
587 BufferParams::PAPER_USLETTER;
588 else if (size == "legal")
590 BufferParams::PAPER_LEGALPAPER;
591 else if (size == "executive")
593 BufferParams::PAPER_EXECUTIVEPAPER;
594 else if (size == "a3")
596 BufferParams::PAPER_A3PAPER;
597 else if (size == "a4")
599 BufferParams::PAPER_A4PAPER;
600 else if (size == "a5")
602 BufferParams::PAPER_A5PAPER;
603 else if (size == "b5")
605 BufferParams::PAPER_B5PAPER;
609 case RC_VIEWDVI_PAPEROPTION:
611 view_dvi_paper_option = lexrc.GetString();
613 view_dvi_paper_option = "";
618 ps_command = lexrc.GetString();
621 case RC_CHKTEX_COMMAND:
623 chktex_command = lexrc.GetString();
628 dpi = lexrc.GetInteger();
633 zoom = lexrc.GetInteger();
638 wheel_jump = lexrc.GetInteger();
641 case RC_SCREEN_FONT_SIZES:
643 font_sizes[LyXFont::SIZE_TINY] =
646 font_sizes[LyXFont::SIZE_SCRIPT] =
649 font_sizes[LyXFont::SIZE_FOOTNOTE] =
652 font_sizes[LyXFont::SIZE_SMALL] =
655 font_sizes[LyXFont::SIZE_NORMAL] =
658 font_sizes[LyXFont::SIZE_LARGE] =
661 font_sizes[LyXFont::SIZE_LARGER] =
664 font_sizes[LyXFont::SIZE_LARGEST] =
667 font_sizes[LyXFont::SIZE_HUGE] =
670 font_sizes[LyXFont::SIZE_HUGER] =
674 case RC_SCREEN_FONT_SCALABLE:
676 use_scalable_fonts = lexrc.GetBool();
681 autosave = lexrc.GetInteger();
684 case RC_DOCUMENTPATH:
686 document_path = ExpandPath(lexrc.GetString());
690 case RC_TEMPLATEPATH:
692 template_path = ExpandPath(lexrc.GetString());
697 tempdir_path = ExpandPath(lexrc.GetString());
702 use_tempdir = lexrc.GetBool();
707 lastfiles = ExpandPath(lexrc.GetString());
710 case RC_NUMLASTFILES:
712 num_lastfiles = lexrc.GetInteger();
715 case RC_CHECKLASTFILES:
717 check_lastfiles = lexrc.GetBool();
720 case RC_SCREEN_FONT_ROMAN:
722 roman_font_name = lexrc.GetString();
725 case RC_SCREEN_FONT_SANS:
727 sans_font_name = lexrc.GetString();
730 case RC_SCREEN_FONT_TYPEWRITER:
732 typewriter_font_name = lexrc.GetString();
735 case RC_SCREEN_FONT_MENU:
737 menu_font_name = lexrc.GetString();
740 case RC_SCREEN_FONT_POPUP:
742 popup_font_name = lexrc.GetString();
745 case RC_SCREEN_FONT_ENCODING:
747 font_norm = lexrc.GetString();
748 set_font_norm_type();
752 case RC_SCREEN_FONT_ENCODING_MENU:
754 font_norm_menu = lexrc.GetString();
759 string lyx_name, x11_name;
762 lyx_name = lexrc.GetString();
764 lexrc.printError("Missing color tag.");
769 x11_name = lexrc.GetString();
771 lexrc.printError("Missing color name for color : `$$Token'");
775 if (!lcolor.setColor(lyx_name, x11_name))
776 lyxerr << "Bad lyxrc set_color for "
781 case RC_AUTOREGIONDELETE:
782 // Auto region delete defaults to true
784 auto_region_delete = lexrc.GetBool();
789 // we should not do an explicit binding before
790 // loading a bind file. So, in this case, load
791 // the default bind file.
794 bind_file = bindFile;
796 // !!!chb, dynamic key binding...
800 if (lexrc.lex() == LyXLex::LEX_DATA) {
801 seq = lexrc.GetString();
803 lexrc.printError("Bad key sequence: `$$Token'");
807 if (lexrc.lex() == LyXLex::LEX_DATA) {
808 cmd = lexrc.GetString();
810 lexrc.printError("Bad command: `$$Token'");
814 if ((action = lyxaction.LookupFunc(cmd))>= 0) {
815 if (lyxerr.debugging(Debug::KBMAP)) {
816 lyxerr << "RC_BIND: Sequence `"
817 << seq << "' Command `"
818 << cmd << "' Action `"
819 << action << '\'' << endl;
821 res = toplevel_keymap->bind(seq, action);
824 "Invalid key sequence `"
827 } else {// cmd is the last token read.
829 "Unknown LyX function `$$Token'");
833 case RC_OVERRIDE_X_DEADKEYS:
835 override_x_deadkeys = lexrc.GetBool();
840 lyxpipes = ExpandPath(lexrc.GetString());
843 case RC_CURSOR_FOLLOWS_SCROLLBAR:
845 cursor_follows_scrollbar = lexrc.GetBool();
850 fax_command = lexrc.GetString();
854 fax_program = lexrc.GetString();
858 string s = lexrc.GetString();
862 phone_book = user_lyxdir + s;
865 case RC_ASCIIROFF_COMMAND:
867 ascii_roff_command = lexrc.GetString();
869 case RC_ASCII_LINELEN:
871 ascii_linelen = lexrc.GetInteger();
873 // Spellchecker settings:
874 case RC_SPELL_COMMAND:
876 isp_command = lexrc.GetString();
878 case RC_ACCEPT_COMPOUND:
880 isp_accept_compound = lexrc.GetBool();
884 isp_use_input_encoding = lexrc.GetBool();
886 case RC_USE_ALT_LANG:
888 isp_use_alt_lang = lexrc.GetBool();
890 case RC_USE_PERS_DICT:
892 isp_use_pers_dict = lexrc.GetBool();
894 case RC_USE_ESC_CHARS:
896 isp_use_esc_chars = lexrc.GetBool();
900 isp_alt_lang = lexrc.GetString();
904 isp_pers_dict = lexrc.GetString();
908 isp_esc_chars = lexrc.GetString();
912 make_backup = lexrc.GetBool();
914 case RC_BACKUPDIR_PATH:
916 backupdir_path = ExpandPath(lexrc.GetString());
918 case RC_DATE_INSERT_FORMAT:
920 date_insert_format = lexrc.GetString();
922 case RC_LANGUAGE_PACKAGE:
924 language_package = lexrc.GetString();
926 case RC_LANGUAGE_AUTO_BEGIN:
928 language_auto_begin = lexrc.GetBool();
930 case RC_LANGUAGE_AUTO_END:
932 language_auto_end = lexrc.GetBool();
934 case RC_LANGUAGE_COMMAND_BEGIN:
936 language_command_begin = lexrc.GetString();
938 case RC_LANGUAGE_COMMAND_END:
940 language_command_end = lexrc.GetString();
944 rtl_support = lexrc.GetBool();
948 auto_number = lexrc.GetBool();
950 case RC_MARK_FOREIGN_LANGUAGE:
952 mark_foreign_language = lexrc.GetBool();
956 show_banner = lexrc.GetBool();
958 case RC_LINUXDOC_TO_LYX_COMMAND:
960 linuxdoc_to_lyx_command = lexrc.GetString();
963 case RC_NEW_ASK_FILENAME:
965 new_ask_filename = lexrc.GetBool();
969 string from, to, command, flags;
971 from = lexrc.GetString();
973 to = lexrc.GetString();
975 command = lexrc.GetString();
977 flags = lexrc.GetString();
978 Converter::Add(from, to, command, flags);
983 string format, command;
985 format = lexrc.GetString();
987 command = lexrc.GetString();
988 Formats::SetViewer(format, command);
991 case RC_DEFAULT_LANGUAGE:
993 default_language = lexrc.GetString();
996 case RC_LAST: break; // this is just a dummy
1004 void LyXRC::write(string const & filename) const
1006 ofstream ofs(filename.c_str());
1012 void LyXRC::print() const
1014 if (lyxerr.debugging())
1021 void LyXRC::output(ostream & os) const
1023 os << "### This file is part of\n"
1024 << "### ========================================================\n"
1025 << "### LyX, The Document Processor\n"
1027 << "### Copyright 1995 Matthias Ettrich\n"
1028 << "### Copyright 1995-2000 The LyX Team.\n"
1030 << "### ========================================================\n"
1032 << "# This file is written by LyX, if you want to make your own\n"
1033 << "# modifications you should do them from inside LyX and save\n"
1036 // Why the switch you might ask. It is a trick to ensure that all
1037 // the elements in the LyXRCTags enum is handled. As you can see
1038 // there are no breaks at all. So it is just a huge fall-through.
1039 // The nice thing is that we will get a warning from the compiler
1040 // if we forget an element.
1041 LyXRCTags tag = RC_LAST;
1045 // input/include files are not done here
1047 // bindings is not written to the preferences file.
1049 os << "\\bind_file " << bind_file << "\n";
1055 << "# MISC SECTION ######################################\n"
1058 case RC_SHOW_BANNER:
1059 os << "# Set to false to inhibit the startup banner.\n"
1060 << "\\show_banner " << tostr(show_banner) << "\n";
1062 // bind files are not done here.
1064 os << "\\ui_file \"" << ui_file << "\"\n";
1065 case RC_AUTOREGIONDELETE:
1066 os << "# Set to false to inhibit automatic replacement of\n"
1067 << "# the current selection.\n"
1068 << "\\auto_region_delete " << tostr(auto_region_delete)
1071 os << "# The time interval between auto-saves in seconds.\n"
1072 << "\\autosave " << autosave << "\n";
1073 case RC_EXIT_CONFIRMATION:
1074 os << "# Ask for confirmation before exit if there are\n"
1075 << "# unsaved changed documents.\n"
1076 << "\\exit_confirmation " << tostr(exit_confirmation)
1078 case RC_DISPLAY_SHORTCUTS:
1079 os << "# Display name of the last command executed, with a\n"
1080 << "# list of short-cuts in the minibuffer.\n"
1081 << "\\display_shortcuts " << tostr(display_shortcuts)
1083 case RC_VIEWDVI_PAPEROPTION:
1084 os << "# Options used to specify paper size to the\n"
1085 << "# view_dvi_command\n"
1086 << "\\view_dvi_paper_option \""
1087 << view_dvi_paper_option << "\"\n";
1088 case RC_DEFAULT_PAPERSIZE:
1089 os << "# The default papersize to use.\n"
1090 << "\\default_papersize \"";
1091 switch (default_papersize) {
1092 case BufferParams::PAPER_USLETTER:
1093 os << "usletter"; break;
1094 case BufferParams::PAPER_LEGALPAPER:
1095 os << "legal"; break;
1096 case BufferParams::PAPER_EXECUTIVEPAPER:
1097 os << "executive"; break;
1098 case BufferParams::PAPER_A3PAPER:
1100 case BufferParams::PAPER_A4PAPER:
1102 case BufferParams::PAPER_A5PAPER:
1104 case BufferParams::PAPER_B5PAPER:
1106 case BufferParams::PAPER_DEFAULT: break;
1110 os << "# Program used for interpreting postscript.\n"
1111 << "\\ps_command \"" << ps_command << "\"\n";
1112 case RC_CHKTEX_COMMAND:
1113 os << "\\chktex_command \"" << chktex_command << "\"\n";
1115 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1116 case RC_KBMAP_PRIMARY:
1117 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1118 case RC_KBMAP_SECONDARY:
1119 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1121 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1122 case RC_RELYX_COMMAND:
1123 os << "\\relyx_command \"" << relyx_command << "\"\n";
1124 case RC_DATE_INSERT_FORMAT:
1125 os << "\\date_insert_format \"" << date_insert_format
1130 << "# SCREEN & FONTS SECTION ############################\n"
1134 os << "\\screen_dpi " << dpi << "\n";
1135 case RC_SCREEN_ZOOM:
1136 os << "\\screen_zoom " << zoom << "\n";
1138 os << "\\wheel_jump " << wheel_jump << "\n";
1139 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1140 os << "\\cursor_follows_scrollbar "
1141 << tostr(cursor_follows_scrollbar) << "\n";
1142 case RC_SCREEN_FONT_ROMAN:
1143 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1144 case RC_SCREEN_FONT_SANS:
1145 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1146 case RC_SCREEN_FONT_TYPEWRITER:
1147 os << "\\screen_font_typewriter \""
1148 << typewriter_font_name << "\"\n";
1149 case RC_SCREEN_FONT_SCALABLE:
1150 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1152 case RC_SCREEN_FONT_ENCODING:
1153 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1154 case RC_SCREEN_FONT_POPUP:
1155 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1156 case RC_SCREEN_FONT_MENU:
1157 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1158 case RC_SCREEN_FONT_SIZES:
1159 os.setf(ios::fixed);
1161 os << "\\screen_font_sizes";
1162 os << " " << font_sizes[LyXFont::SIZE_TINY];
1163 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1164 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1165 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1166 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1167 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1168 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1169 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1170 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1171 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1173 //case RC_SET_COLOR:
1174 // color bindings not written to preference file.
1175 // And we want to be warned about that. (Lgb)
1178 << "# PRINTER SECTION ###################################\n"
1182 os << "\\printer \"" << printer << "\"\n";
1183 case RC_PRINT_ADAPTOUTPUT:
1184 os << "\\print_adapt_output " << tostr(print_adapt_output)
1186 case RC_PRINT_COMMAND:
1187 os << "\\print_command \"" << print_command << "\"\n";
1188 case RC_PRINTEXSTRAOPTIONS:
1189 os << "\\print_extra_options \"" << print_extra_options
1191 case RC_PRINTSPOOL_COMMAND:
1192 os << "\\print_spool_command \"" << print_spool_command
1194 case RC_PRINTSPOOL_PRINTERPREFIX:
1195 os << "\\print_spool_printerprefix \""
1196 << print_spool_printerprefix << "\"\n";
1197 case RC_PRINTEVENPAGEFLAG:
1198 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1200 case RC_PRINTODDPAGEFLAG:
1201 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1203 case RC_PRINTREVERSEFLAG:
1204 os << "\\print_reverse_flag \"" << print_reverse_flag
1206 case RC_PRINTLANDSCAPEFLAG:
1207 os << "\\print_landscape_flag \"" << print_landscape_flag
1209 case RC_PRINTPAGERANGEFLAG:
1210 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1212 case RC_PRINTCOPIESFLAG:
1213 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1214 case RC_PRINTCOLLCOPIESFLAG:
1215 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1217 case RC_PRINTPAPERFLAG:
1218 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1219 case RC_PRINTPAPERDIMENSIONFLAG:
1220 os << "\\print_paper_dimension_flag \""
1221 << print_paper_dimension_flag << "\"\n";
1222 case RC_PRINTTOPRINTER:
1223 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1224 case RC_PRINTTOFILE:
1225 os << "\\print_to_file \"" << print_to_file << "\"\n";
1226 case RC_PRINTFILEEXTENSION:
1227 os << "\\print_file_extension \"" << print_file_extension
1231 << "# EXPORT SECTION ####################################\n"
1234 case RC_CUSTOM_EXPORT_COMMAND:
1235 os << "\\custom_export_command \"" << custom_export_command
1237 case RC_CUSTOM_EXPORT_FORMAT:
1238 os << "\\custom_export_format \"" << custom_export_format
1242 << "# TEX SECTION #######################################\n"
1245 case RC_FONT_ENCODING:
1246 os << "\\font_encoding \"" << fontenc << "\"\n";
1249 << "# LINUXDOC SECTION ##################################\n"
1252 case RC_LINUXDOC_TO_LYX_COMMAND:
1253 os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command
1257 << "# FILE SECTION ######################################\n"
1260 case RC_DOCUMENTPATH:
1261 os << "\\document_path \"" << document_path << "\"\n";
1263 os << "\\lastfiles \"" << lastfiles << "\"\n";
1264 case RC_NUMLASTFILES:
1265 os << "\\num_lastfiles " << num_lastfiles << "\n";
1266 case RC_CHECKLASTFILES:
1267 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1268 case RC_TEMPLATEPATH:
1269 os << "\\template_path \"" << template_path << "\"\n";
1270 case RC_TEMPDIRPATH:
1271 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1273 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1274 case RC_ASCII_LINELEN:
1275 os << "\\ascii_linelen " << ascii_linelen << "\n";
1276 case RC_MAKE_BACKUP:
1277 os << "\\make_backup " << tostr(make_backup) << "\n";
1278 case RC_BACKUPDIR_PATH:
1279 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1282 << "# FAX SECTION #######################################\n"
1285 case RC_FAX_COMMAND:
1286 os << "\\fax_command \"" << fax_command << "\"\n";
1288 os << "\\phone_book \"" << phone_book << "\"\n";
1290 os << "\\fax_program \"" << fax_program << "\"\n";
1293 << "# ASCII EXPORT SECTION ##############################\n"
1296 case RC_ASCIIROFF_COMMAND:
1297 os << "\\ascii_roff_command \"" << ascii_roff_command
1301 << "# SPELLCHECKER SECTION ##############################\n"
1304 case RC_SPELL_COMMAND:
1305 os << "\\spell_command \"" << isp_command << "\"\n";
1306 case RC_ACCEPT_COMPOUND:
1307 os << "\\accept_compound " << tostr(isp_accept_compound)
1309 case RC_USE_ALT_LANG:
1310 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1312 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1313 case RC_USE_ESC_CHARS:
1314 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1317 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1318 case RC_USE_PERS_DICT:
1319 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1322 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1323 case RC_USE_INP_ENC:
1324 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1328 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1331 case RC_RTL_SUPPORT:
1332 os << "\\rtl " << tostr(rtl_support) << "\n";
1333 case RC_LANGUAGE_PACKAGE:
1334 os << "\\language_package \"" << language_package << "\"\n";
1335 case RC_LANGUAGE_COMMAND_BEGIN:
1336 os << "\\language_command_begin \"" << language_command_begin
1338 case RC_LANGUAGE_COMMAND_END:
1339 os << "\\language_command_end \"" << language_command_end
1341 case RC_LANGUAGE_AUTO_BEGIN:
1342 os << "\\language_auto_begin "
1343 << tostr(language_auto_begin) << "\n";
1344 case RC_LANGUAGE_AUTO_END:
1345 os << "\\language_auto_end "
1346 << tostr(language_auto_end) << "\n";
1347 case RC_MARK_FOREIGN_LANGUAGE:
1348 os << "\\mark_foreign_language " <<
1349 tostr(mark_foreign_language) << "\n";
1352 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1355 case RC_LITERATE_EXTENSION:
1356 os << "\\literate_extension \"" << literate_extension
1358 case RC_OVERRIDE_X_DEADKEYS:
1359 os << "\\override_x_deadkeys "
1360 << tostr(override_x_deadkeys) << "\n";
1361 case RC_SCREEN_FONT_ENCODING_MENU:
1362 os << "\\screen_font_encoding_menu \"" << font_norm_menu
1364 case RC_AUTO_NUMBER:
1365 os << "\\auto_number " << tostr(auto_number) << "\n";
1366 case RC_NEW_ASK_FILENAME:
1367 os << "\\new_ask_filename " << tostr(new_ask_filename) << "\n";
1368 case RC_DEFAULT_LANGUAGE:
1369 os << "\\default_language " << default_language << "\n";
1374 void LyXRC::set_font_norm_type()
1376 if (font_norm == "iso10646-1")
1377 font_norm_type = ISO_10646_1;
1378 else if (font_norm == "iso8859-6.8x")
1379 font_norm_type = ISO_8859_6_8;
1381 font_norm_type = OTHER_ENCODING;
1384 // The global instance
1387 // The global copy of the system lyxrc entries (everything except preferences)
1388 //LyXRC system_lyxrc;