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 LyXAction lyxaction;
46 extern kb_keymap * toplevel_keymap;
55 RC_PRINTPAGERANGEFLAG,
57 RC_PRINTCOLLCOPIESFLAG,
59 RC_PRINTLANDSCAPEFLAG,
63 RC_PRINTFILEEXTENSION,
64 RC_PRINTEXSTRAOPTIONS,
65 RC_PRINTSPOOL_COMMAND,
66 RC_PRINTSPOOL_PRINTERPREFIX,
68 RC_PRINTPAPERDIMENSIONFLAG,
69 RC_CUSTOM_EXPORT_COMMAND,
70 RC_CUSTOM_EXPORT_FORMAT,
76 RC_SCREEN_FONT_TYPEWRITER,
79 RC_SCREEN_FONT_ENCODING,
80 RC_SCREEN_FONT_ENCODING_MENU,
90 RC_OVERRIDE_X_DEADKEYS,
101 RC_ASCIIROFF_COMMAND,
105 RC_VIEWDVI_PAPEROPTION,
106 RC_DEFAULT_PAPERSIZE,
114 RC_SCREEN_FONT_SCALABLE,
119 RC_CURSOR_FOLLOWS_SCROLLBAR,
120 RC_EXIT_CONFIRMATION,
121 RC_DISPLAY_SHORTCUTS,
126 RC_MARK_FOREIGN_LANGUAGE,
128 RC_LANGUAGE_AUTO_BEGIN,
129 RC_LANGUAGE_AUTO_END,
130 RC_LANGUAGE_COMMAND_BEGIN,
131 RC_LANGUAGE_COMMAND_END,
132 RC_DATE_INSERT_FORMAT,
145 keyword_item lyxrcTags[] = {
146 { "\\accept_compound", RC_ACCEPT_COMPOUND },
147 { "\\alternate_language", RC_ALT_LANG },
148 { "\\ascii_linelen", RC_ASCII_LINELEN },
149 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
150 { "\\auto_number", RC_AUTO_NUMBER },
151 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
152 { "\\autosave", RC_AUTOSAVE },
153 { "\\backupdir_path", RC_BACKUPDIR_PATH },
154 { "\\bind", RC_BIND },
155 { "\\bind_file", RC_BINDFILE },
156 { "\\check_lastfiles", RC_CHECKLASTFILES },
157 { "\\chktex_command", RC_CHKTEX_COMMAND },
158 { "\\converter", RC_CONVERTER },
159 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
160 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
161 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
162 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
163 { "\\default_language", RC_DEFAULT_LANGUAGE },
164 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
165 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
166 { "\\document_path", RC_DOCUMENTPATH },
167 { "\\escape_chars", RC_ESC_CHARS },
168 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
169 { "\\fax_command", RC_FAX_COMMAND },
170 { "\\fax_program", RC_FAXPROGRAM },
171 { "\\font_encoding", RC_FONT_ENCODING },
172 { "\\format", RC_FORMAT },
173 { "\\input", RC_INPUT },
174 { "\\kbmap", RC_KBMAP },
175 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
176 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
177 { "\\language_auto_begin", RC_LANGUAGE_AUTO_BEGIN },
178 { "\\language_auto_end", RC_LANGUAGE_AUTO_END },
179 { "\\language_command_begin", RC_LANGUAGE_COMMAND_BEGIN },
180 { "\\language_command_end", RC_LANGUAGE_COMMAND_END },
181 { "\\language_package", RC_LANGUAGE_PACKAGE },
182 { "\\lastfiles", RC_LASTFILES },
183 { "\\make_backup", RC_MAKE_BACKUP },
184 { "\\mark_foreign_language", RC_MARK_FOREIGN_LANGUAGE },
185 { "\\new_ask_filename", RC_NEW_ASK_FILENAME },
186 { "\\num_lastfiles", RC_NUMLASTFILES },
187 { "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
188 { "\\personal_dictionary", RC_PERS_DICT },
189 { "\\phone_book", RC_PHONEBOOK },
190 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
191 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
192 { "\\print_command", RC_PRINT_COMMAND },
193 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
194 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
195 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
196 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
197 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
198 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
199 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
200 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
201 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
202 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
203 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
204 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
205 { "\\print_to_file", RC_PRINTTOFILE },
206 { "\\print_to_printer", RC_PRINTTOPRINTER },
207 { "\\printer", RC_PRINTER },
208 { "\\ps_command", RC_PS_COMMAND },
209 { "\\rtl", RC_RTL_SUPPORT },
210 { "\\screen_dpi", RC_SCREEN_DPI },
211 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
212 { "\\screen_font_encoding_menu", RC_SCREEN_FONT_ENCODING_MENU },
213 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
214 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
215 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
216 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
217 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
218 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
219 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
220 { "\\screen_zoom", RC_SCREEN_ZOOM },
221 { "\\serverpipe", RC_SERVERPIPE },
222 { "\\set_color", RC_SET_COLOR },
223 { "\\show_banner", RC_SHOW_BANNER },
224 { "\\spell_command", RC_SPELL_COMMAND },
225 { "\\tempdir_path", RC_TEMPDIRPATH },
226 { "\\template_path", RC_TEMPLATEPATH },
227 { "\\ui_file", RC_UIFILE },
228 { "\\use_alt_language", RC_USE_ALT_LANG },
229 { "\\use_escape_chars", RC_USE_ESC_CHARS },
230 { "\\use_input_encoding", RC_USE_INP_ENC },
231 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
232 { "\\use_tempdir", RC_USETEMPDIR },
233 { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
234 { "\\viewer" ,RC_VIEWER},
235 { "\\wheel_jump", RC_WHEEL_JUMP }
238 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
239 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
248 void LyXRC::setDefaults() {
250 // Get printer from the environment. If fail, use default "",
251 // assuming that everything is set up correctly.
252 printer = GetEnv("PRINTER");
253 print_adapt_output = false;
254 print_command = "dvips";
255 print_evenpage_flag = "-B";
256 print_oddpage_flag = "-A";
257 print_pagerange_flag = "-pp";
258 print_copies_flag = "-c";
259 print_collcopies_flag = "-C";
260 print_reverse_flag = "-r";
261 print_landscape_flag = "-t landscape";
262 print_to_printer = "-P";
263 print_to_file = "-o ";
264 print_file_extension = ".ps";
265 print_paper_flag = "-t";
266 print_paper_dimension_flag = "-T";
267 document_path = GetEnvPath("HOME");
268 tempdir_path = "/tmp";
271 view_dvi_paper_option = "-paper";
272 default_papersize = BufferParams::PAPER_USLETTER;
273 custom_export_format = "ps";
274 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
277 // Because a screen typically is wider than a piece of paper:
280 // Default LaTeX font size:
281 font_sizes[LyXFont::SIZE_TINY] = 5.0;
282 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
283 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
284 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
285 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
286 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
287 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
288 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
289 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
290 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
291 use_scalable_fonts = true;
292 roman_font_name = "-*-times";
293 sans_font_name = "-*-helvetica";
294 typewriter_font_name = "-*-courier";
295 menu_font_name = "-*-helvetica-bold-r";
296 popup_font_name = "-*-helvetica-medium-r";
297 font_norm = "iso8859-1";
298 font_norm_type = OTHER_ENCODING;
300 override_x_deadkeys = true;
302 auto_region_delete = true;
305 check_lastfiles = true;
308 exit_confirmation = true;
309 display_shortcuts = true;
310 // Spellchecker settings:
311 isp_command = "ispell";
312 isp_accept_compound = false;
313 isp_use_input_encoding = false;
314 isp_use_alt_lang = false;
315 isp_use_pers_dict = false;
316 isp_use_esc_chars = false;
321 mark_foreign_language = true;
322 language_package = "\\usepackage{babel}";
323 language_auto_begin = true;
324 language_auto_end = true;
325 language_command_begin = "\\selectlanguage{$$lang}";
326 language_command_end = "\\selectlanguage{$$lang}";
327 default_language = "english";
329 new_ask_filename = false;
332 date_insert_format = "%A, %e %B %Y";
334 cursor_follows_scrollbar = false;
336 /// These variables are not stored on disk (perhaps they
337 // should be moved from the LyXRC class).
343 int LyXRC::ReadBindFile(string const & name)
346 string tmp = i18nLibFileSearch("bind", name, "bind");
347 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
348 int result = read(tmp);
350 lyxerr << "Error reading bind file: " << tmp << endl;
356 int LyXRC::read(string const & filename)
359 string bindFile = "cua";
361 LyXLex lexrc(lyxrcTags, lyxrcCount);
362 if (lyxerr.debugging(Debug::PARSER))
363 lexrc.printTable(lyxerr);
365 lexrc.setFile(filename);
366 if (!lexrc.IsOK()) return -2;
368 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
370 while (lexrc.IsOK()) {
371 // By using two switches we take advantage of the compiler
372 // telling us if we have missed a LyXRCTags element in
373 // the second switch.
374 // Note that this also shows a problem with LyXLex since it
375 // helps us avoid taking advantage of the strictness of the
378 int le = lexrc.lex();
380 case LyXLex::LEX_UNDEF:
381 lexrc.printError("Unknown tag `$$Token'");
383 case LyXLex::LEX_FEOF:
387 switch (static_cast<LyXRCTags>(le)) {
388 case RC_INPUT: // Include file
390 string tmp = LibFileSearch(string(),
393 lexrc.printError("Error reading "
394 "included file: "+tmp);
398 case RC_BINDFILE: // RVDK_PATCH_5
400 string tmp(lexrc.GetString());
401 if (bind_file.empty()) {
402 // we only need the name of the first
403 // bind file since that (usually)
404 // includes several others.
413 ui_file = lexrc.GetString();
417 case RC_EXIT_CONFIRMATION:
419 exit_confirmation = lexrc.GetBool();
422 case RC_DISPLAY_SHORTCUTS:
424 display_shortcuts = lexrc.GetBool();
429 use_kbmap = lexrc.GetBool();
432 case RC_KBMAP_PRIMARY:
434 string kmap(lexrc.GetString());
437 } else if (!LibFileSearch("kbd", kmap,
439 primary_kbmap = kmap;
441 lexrc.printError("LyX: Keymap `$$Token' not found");
445 case RC_KBMAP_SECONDARY:
447 string kmap(lexrc.GetString());
450 } else if (!LibFileSearch("kbd", kmap,
452 secondary_kbmap = kmap;
454 lexrc.printError("LyX: Keymap `$$Token' not found");
458 case RC_FONT_ENCODING:
460 fontenc = lexrc.GetString();
465 printer = lexrc.GetString();
468 case RC_PRINT_COMMAND:
470 print_command = lexrc.GetString();
473 case RC_PRINTEVENPAGEFLAG:
475 print_evenpage_flag = lexrc.GetString();
478 case RC_PRINTODDPAGEFLAG:
480 print_oddpage_flag = lexrc.GetString();
483 case RC_PRINTPAGERANGEFLAG:
485 print_pagerange_flag = lexrc.GetString();
488 case RC_PRINTCOPIESFLAG:
490 print_copies_flag = lexrc.GetString();
493 case RC_PRINTCOLLCOPIESFLAG:
495 print_collcopies_flag = lexrc.GetString();
498 case RC_PRINTREVERSEFLAG:
500 print_reverse_flag = lexrc.GetString();
503 case RC_PRINTLANDSCAPEFLAG:
505 print_landscape_flag = lexrc.GetString();
508 case RC_PRINTTOPRINTER:
510 print_to_printer = lexrc.GetString();
513 case RC_PRINT_ADAPTOUTPUT:
515 print_adapt_output = lexrc.GetBool();
520 print_to_file = lexrc.GetString();
523 case RC_PRINTFILEEXTENSION:
525 print_file_extension = lexrc.GetString();
528 case RC_PRINTEXSTRAOPTIONS:
530 print_extra_options = lexrc.GetString();
533 case RC_PRINTSPOOL_COMMAND:
535 print_spool_command = lexrc.GetString();
538 case RC_PRINTSPOOL_PRINTERPREFIX:
540 print_spool_printerprefix = lexrc.GetString();
543 case RC_PRINTPAPERDIMENSIONFLAG:
545 print_paper_dimension_flag = lexrc.GetString();
548 case RC_PRINTPAPERFLAG:
550 print_paper_flag = lexrc.GetString();
553 case RC_CUSTOM_EXPORT_COMMAND:
555 custom_export_command = lexrc.GetString();
558 case RC_CUSTOM_EXPORT_FORMAT:
560 custom_export_format = lexrc.GetString();
563 case RC_DEFAULT_PAPERSIZE:
565 string size = lowercase(lexrc.GetString());
566 if (size == "usletter")
568 BufferParams::PAPER_USLETTER;
569 else if (size == "legal")
571 BufferParams::PAPER_LEGALPAPER;
572 else if (size == "executive")
574 BufferParams::PAPER_EXECUTIVEPAPER;
575 else if (size == "a3")
577 BufferParams::PAPER_A3PAPER;
578 else if (size == "a4")
580 BufferParams::PAPER_A4PAPER;
581 else if (size == "a5")
583 BufferParams::PAPER_A5PAPER;
584 else if (size == "b5")
586 BufferParams::PAPER_B5PAPER;
590 case RC_VIEWDVI_PAPEROPTION:
592 view_dvi_paper_option = lexrc.GetString();
594 view_dvi_paper_option = "";
599 ps_command = lexrc.GetString();
602 case RC_CHKTEX_COMMAND:
604 chktex_command = lexrc.GetString();
609 dpi = lexrc.GetInteger();
614 zoom = lexrc.GetInteger();
619 wheel_jump = lexrc.GetInteger();
622 case RC_SCREEN_FONT_SIZES:
624 font_sizes[LyXFont::SIZE_TINY] =
627 font_sizes[LyXFont::SIZE_SCRIPT] =
630 font_sizes[LyXFont::SIZE_FOOTNOTE] =
633 font_sizes[LyXFont::SIZE_SMALL] =
636 font_sizes[LyXFont::SIZE_NORMAL] =
639 font_sizes[LyXFont::SIZE_LARGE] =
642 font_sizes[LyXFont::SIZE_LARGER] =
645 font_sizes[LyXFont::SIZE_LARGEST] =
648 font_sizes[LyXFont::SIZE_HUGE] =
651 font_sizes[LyXFont::SIZE_HUGER] =
655 case RC_SCREEN_FONT_SCALABLE:
657 use_scalable_fonts = lexrc.GetBool();
662 autosave = lexrc.GetInteger();
665 case RC_DOCUMENTPATH:
667 document_path = ExpandPath(lexrc.GetString());
671 case RC_TEMPLATEPATH:
673 template_path = ExpandPath(lexrc.GetString());
678 tempdir_path = ExpandPath(lexrc.GetString());
683 use_tempdir = lexrc.GetBool();
688 lastfiles = ExpandPath(lexrc.GetString());
691 case RC_NUMLASTFILES:
693 num_lastfiles = lexrc.GetInteger();
696 case RC_CHECKLASTFILES:
698 check_lastfiles = lexrc.GetBool();
701 case RC_SCREEN_FONT_ROMAN:
703 roman_font_name = lexrc.GetString();
706 case RC_SCREEN_FONT_SANS:
708 sans_font_name = lexrc.GetString();
711 case RC_SCREEN_FONT_TYPEWRITER:
713 typewriter_font_name = lexrc.GetString();
716 case RC_SCREEN_FONT_MENU:
718 menu_font_name = lexrc.GetString();
721 case RC_SCREEN_FONT_POPUP:
723 popup_font_name = lexrc.GetString();
726 case RC_SCREEN_FONT_ENCODING:
728 font_norm = lexrc.GetString();
729 set_font_norm_type();
733 case RC_SCREEN_FONT_ENCODING_MENU:
735 font_norm_menu = lexrc.GetString();
740 string lyx_name, x11_name;
743 lyx_name = lexrc.GetString();
745 lexrc.printError("Missing color tag.");
750 x11_name = lexrc.GetString();
752 lexrc.printError("Missing color name for color : `$$Token'");
756 if (!lcolor.setColor(lyx_name, x11_name))
757 lyxerr << "Bad lyxrc set_color for "
762 case RC_AUTOREGIONDELETE:
763 // Auto region delete defaults to true
765 auto_region_delete = lexrc.GetBool();
770 // we should not do an explicit binding before
771 // loading a bind file. So, in this case, load
772 // the default bind file.
775 bind_file = bindFile;
777 // !!!chb, dynamic key binding...
781 if (lexrc.lex() == LyXLex::LEX_DATA) {
782 seq = lexrc.GetString();
784 lexrc.printError("Bad key sequence: `$$Token'");
788 if (lexrc.lex() == LyXLex::LEX_DATA) {
789 cmd = lexrc.GetString();
791 lexrc.printError("Bad command: `$$Token'");
795 if ((action = lyxaction.LookupFunc(cmd))>= 0) {
796 if (lyxerr.debugging(Debug::KBMAP)) {
797 lyxerr << "RC_BIND: Sequence `"
798 << seq << "' Command `"
799 << cmd << "' Action `"
800 << action << '\'' << endl;
802 res = toplevel_keymap->bind(seq, action);
805 "Invalid key sequence `"
808 } else {// cmd is the last token read.
810 "Unknown LyX function `$$Token'");
814 case RC_OVERRIDE_X_DEADKEYS:
816 override_x_deadkeys = lexrc.GetBool();
821 lyxpipes = ExpandPath(lexrc.GetString());
824 case RC_CURSOR_FOLLOWS_SCROLLBAR:
826 cursor_follows_scrollbar = lexrc.GetBool();
831 fax_command = lexrc.GetString();
835 fax_program = lexrc.GetString();
839 string s = lexrc.GetString();
843 phone_book = user_lyxdir + s;
846 case RC_ASCIIROFF_COMMAND:
848 ascii_roff_command = lexrc.GetString();
850 case RC_ASCII_LINELEN:
852 ascii_linelen = lexrc.GetInteger();
854 // Spellchecker settings:
855 case RC_SPELL_COMMAND:
857 isp_command = lexrc.GetString();
859 case RC_ACCEPT_COMPOUND:
861 isp_accept_compound = lexrc.GetBool();
865 isp_use_input_encoding = lexrc.GetBool();
867 case RC_USE_ALT_LANG:
869 isp_use_alt_lang = lexrc.GetBool();
871 case RC_USE_PERS_DICT:
873 isp_use_pers_dict = lexrc.GetBool();
875 case RC_USE_ESC_CHARS:
877 isp_use_esc_chars = lexrc.GetBool();
881 isp_alt_lang = lexrc.GetString();
885 isp_pers_dict = lexrc.GetString();
889 isp_esc_chars = lexrc.GetString();
893 make_backup = lexrc.GetBool();
895 case RC_BACKUPDIR_PATH:
897 backupdir_path = ExpandPath(lexrc.GetString());
899 case RC_DATE_INSERT_FORMAT:
901 date_insert_format = lexrc.GetString();
903 case RC_LANGUAGE_PACKAGE:
905 language_package = lexrc.GetString();
907 case RC_LANGUAGE_AUTO_BEGIN:
909 language_auto_begin = lexrc.GetBool();
911 case RC_LANGUAGE_AUTO_END:
913 language_auto_end = lexrc.GetBool();
915 case RC_LANGUAGE_COMMAND_BEGIN:
917 language_command_begin = lexrc.GetString();
919 case RC_LANGUAGE_COMMAND_END:
921 language_command_end = lexrc.GetString();
925 rtl_support = lexrc.GetBool();
929 auto_number = lexrc.GetBool();
931 case RC_MARK_FOREIGN_LANGUAGE:
933 mark_foreign_language = lexrc.GetBool();
937 show_banner = lexrc.GetBool();
940 case RC_NEW_ASK_FILENAME:
942 new_ask_filename = lexrc.GetBool();
945 string from, to, command, flags;
947 from = lexrc.GetString();
949 to = lexrc.GetString();
951 command = lexrc.GetString();
953 flags = lexrc.GetString();
954 Converter::Add(from, to, command, flags);
958 string format, command;
960 format = lexrc.GetString();
962 command = lexrc.GetString();
963 Formats::SetViewer(format, command);
967 string format, extension, prettyname, shortcut;
969 format = lexrc.GetString();
971 extension = lexrc.GetString();
973 prettyname = lexrc.GetString();
975 shortcut = lexrc.GetString();
976 Formats::Add(format, extension, prettyname, shortcut);
979 case RC_DEFAULT_LANGUAGE:
981 default_language = lexrc.GetString();
984 case RC_LAST: break; // this is just a dummy
992 void LyXRC::write(string const & filename) const
994 ofstream ofs(filename.c_str());
1000 void LyXRC::print() const
1002 if (lyxerr.debugging())
1009 void LyXRC::output(ostream & os) const
1011 os << "### This file is part of\n"
1012 << "### ========================================================\n"
1013 << "### LyX, The Document Processor\n"
1015 << "### Copyright 1995 Matthias Ettrich\n"
1016 << "### Copyright 1995-2000 The LyX Team.\n"
1018 << "### ========================================================\n"
1020 << "# This file is written by LyX, if you want to make your own\n"
1021 << "# modifications you should do them from inside LyX and save\n"
1024 // Why the switch you might ask. It is a trick to ensure that all
1025 // the elements in the LyXRCTags enum is handled. As you can see
1026 // there are no breaks at all. So it is just a huge fall-through.
1027 // The nice thing is that we will get a warning from the compiler
1028 // if we forget an element.
1029 LyXRCTags tag = RC_LAST;
1033 // input/include files are not done here
1035 // bindings is not written to the preferences file.
1037 if (bind_file != system_lyxrc.bind_file) {
1038 os << "\\bind_file " << bind_file << "\n";
1044 << "# MISC SECTION ######################################\n"
1047 case RC_SHOW_BANNER:
1048 if (show_banner != system_lyxrc.show_banner) {
1049 os << "# Set to false to inhibit the startup banner.\n"
1050 << "\\show_banner " << tostr(show_banner) << "\n";
1052 // bind files are not done here.
1054 if (ui_file != system_lyxrc.ui_file) {
1055 os << "\\ui_file \"" << ui_file << "\"\n";
1057 case RC_AUTOREGIONDELETE:
1058 if (auto_region_delete != system_lyxrc.auto_region_delete) {
1059 os << "# Set to false to inhibit automatic replacement of\n"
1060 << "# the current selection.\n"
1061 << "\\auto_region_delete " << tostr(auto_region_delete)
1065 if (autosave != system_lyxrc.autosave) {
1066 os << "# The time interval between auto-saves in seconds.\n"
1067 << "\\autosave " << autosave << "\n";
1069 case RC_EXIT_CONFIRMATION:
1070 if (exit_confirmation != system_lyxrc.exit_confirmation) {
1071 os << "# Ask for confirmation before exit if there are\n"
1072 << "# unsaved changed documents.\n"
1073 << "\\exit_confirmation " << tostr(exit_confirmation)
1076 case RC_DISPLAY_SHORTCUTS:
1077 if (display_shortcuts != system_lyxrc.display_shortcuts) {
1078 os << "# Display name of the last command executed,\n"
1079 << "# with a list of short-cuts in the minibuffer.\n"
1080 << "\\display_shortcuts " << tostr(display_shortcuts)
1083 case RC_VIEWDVI_PAPEROPTION:
1084 if (view_dvi_paper_option
1085 != system_lyxrc.view_dvi_paper_option) {
1086 os << "# Options used to specify paper size to the\n"
1087 << "# view_dvi_command\n"
1088 << "\\view_dvi_paper_option \""
1089 << view_dvi_paper_option << "\"\n";
1091 case RC_DEFAULT_PAPERSIZE:
1092 if (default_papersize != system_lyxrc.default_papersize) {
1093 os << "# The default papersize to use.\n"
1094 << "\\default_papersize \"";
1095 switch (default_papersize) {
1096 case BufferParams::PAPER_USLETTER:
1097 os << "usletter"; break;
1098 case BufferParams::PAPER_LEGALPAPER:
1099 os << "legal"; break;
1100 case BufferParams::PAPER_EXECUTIVEPAPER:
1101 os << "executive"; break;
1102 case BufferParams::PAPER_A3PAPER:
1104 case BufferParams::PAPER_A4PAPER:
1106 case BufferParams::PAPER_A5PAPER:
1108 case BufferParams::PAPER_B5PAPER:
1110 case BufferParams::PAPER_DEFAULT: break;
1115 if (ps_command != system_lyxrc.ps_command) {
1116 os << "# Program used for interpreting postscript.\n"
1117 << "\\ps_command \"" << ps_command << "\"\n";
1119 case RC_CHKTEX_COMMAND:
1120 if (chktex_command != system_lyxrc.chktex_command) {
1121 os << "\\chktex_command \"" << chktex_command << "\"\n";
1124 if (use_kbmap != system_lyxrc.use_kbmap) {
1125 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1127 case RC_KBMAP_PRIMARY:
1128 if (primary_kbmap != system_lyxrc.primary_kbmap) {
1129 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1131 case RC_KBMAP_SECONDARY:
1132 if (secondary_kbmap != system_lyxrc.secondary_kbmap) {
1133 os << "\\kbmap_secondary \"" << secondary_kbmap
1137 if (lyxpipes != system_lyxrc.lyxpipes) {
1138 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1140 case RC_DATE_INSERT_FORMAT:
1141 if (date_insert_format != system_lyxrc.date_insert_format) {
1142 os << "\\date_insert_format \"" << date_insert_format
1147 << "# SCREEN & FONTS SECTION ############################\n"
1151 if (dpi != system_lyxrc.dpi) {
1152 os << "\\screen_dpi " << dpi << "\n";
1154 case RC_SCREEN_ZOOM:
1155 if (zoom != system_lyxrc.zoom) {
1156 os << "\\screen_zoom " << zoom << "\n";
1159 if (wheel_jump != system_lyxrc.wheel_jump) {
1160 os << "\\wheel_jump " << wheel_jump << "\n";
1162 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1163 if (cursor_follows_scrollbar
1164 != system_lyxrc.cursor_follows_scrollbar) {
1165 os << "\\cursor_follows_scrollbar "
1166 << tostr(cursor_follows_scrollbar) << "\n";
1168 case RC_SCREEN_FONT_ROMAN:
1169 if (roman_font_name != system_lyxrc.roman_font_name) {
1170 os << "\\screen_font_roman \"" << roman_font_name
1173 case RC_SCREEN_FONT_SANS:
1174 if (sans_font_name != system_lyxrc.sans_font_name) {
1175 os << "\\screen_font_sans \"" << sans_font_name
1178 case RC_SCREEN_FONT_TYPEWRITER:
1179 if (typewriter_font_name != system_lyxrc.typewriter_font_name) {
1180 os << "\\screen_font_typewriter \""
1181 << typewriter_font_name << "\"\n";
1183 case RC_SCREEN_FONT_SCALABLE:
1184 if (use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1185 os << "\\screen_font_scalable "
1186 << tostr(use_scalable_fonts)
1189 case RC_SCREEN_FONT_ENCODING:
1190 if (font_norm != system_lyxrc.font_norm) {
1191 os << "\\screen_font_encoding \"" << font_norm
1194 case RC_SCREEN_FONT_POPUP:
1195 if (popup_font_name != system_lyxrc.popup_font_name) {
1196 os << "\\screen_font_popup \"" << popup_font_name
1199 case RC_SCREEN_FONT_MENU:
1200 if (menu_font_name != system_lyxrc.menu_font_name) {
1201 os << "\\screen_font_menu \"" << menu_font_name
1204 case RC_SCREEN_FONT_SIZES:
1205 if (font_sizes[LyXFont::SIZE_TINY]
1206 != system_lyxrc.font_sizes[LyXFont::SIZE_TINY] ||
1207 font_sizes[LyXFont::SIZE_SCRIPT]
1208 != system_lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] ||
1209 font_sizes[LyXFont::SIZE_FOOTNOTE]
1210 != system_lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] ||
1211 font_sizes[LyXFont::SIZE_SMALL]
1212 != system_lyxrc.font_sizes[LyXFont::SIZE_SMALL] ||
1213 font_sizes[LyXFont::SIZE_NORMAL]
1214 != system_lyxrc.font_sizes[LyXFont::SIZE_NORMAL] ||
1215 font_sizes[LyXFont::SIZE_LARGE]
1216 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGE] ||
1217 font_sizes[LyXFont::SIZE_LARGER]
1218 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGER] ||
1219 font_sizes[LyXFont::SIZE_LARGEST]
1220 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGEST] ||
1221 font_sizes[LyXFont::SIZE_HUGE]
1222 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGE] ||
1223 font_sizes[LyXFont::SIZE_HUGER]
1224 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGER]) {
1225 os.setf(ios::fixed);
1227 os << "\\screen_font_sizes";
1228 os << " " << font_sizes[LyXFont::SIZE_TINY];
1229 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1230 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1231 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1232 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1233 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1234 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1235 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1236 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1237 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1241 //case RC_SET_COLOR:
1242 // color bindings not written to preference file.
1243 // And we want to be warned about that. (Lgb)
1246 << "# PRINTER SECTION ###################################\n"
1250 if (printer != system_lyxrc.printer) {
1251 os << "\\printer \"" << printer << "\"\n";
1253 case RC_PRINT_ADAPTOUTPUT:
1254 if (print_adapt_output != system_lyxrc.print_adapt_output) {
1255 os << "\\print_adapt_output "
1256 << tostr(print_adapt_output)
1259 case RC_PRINT_COMMAND:
1260 if (print_command != system_lyxrc.print_command) {
1261 os << "\\print_command \"" << print_command << "\"\n";
1263 case RC_PRINTEXSTRAOPTIONS:
1264 if (print_extra_options != system_lyxrc.print_extra_options) {
1265 os << "\\print_extra_options \"" << print_extra_options
1268 case RC_PRINTSPOOL_COMMAND:
1269 if (print_spool_command != system_lyxrc.print_spool_command) {
1270 os << "\\print_spool_command \"" << print_spool_command
1273 case RC_PRINTSPOOL_PRINTERPREFIX:
1274 if (print_spool_printerprefix
1275 != system_lyxrc.print_spool_printerprefix) {
1276 os << "\\print_spool_printerprefix \""
1277 << print_spool_printerprefix << "\"\n";
1279 case RC_PRINTEVENPAGEFLAG:
1280 if (print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1281 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1284 case RC_PRINTODDPAGEFLAG:
1285 if (print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1286 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1289 case RC_PRINTREVERSEFLAG:
1290 if (print_reverse_flag != system_lyxrc.print_reverse_flag) {
1291 os << "\\print_reverse_flag \"" << print_reverse_flag
1294 case RC_PRINTLANDSCAPEFLAG:
1295 if (print_landscape_flag != system_lyxrc.print_landscape_flag) {
1296 os << "\\print_landscape_flag \"" << print_landscape_flag
1299 case RC_PRINTPAGERANGEFLAG:
1300 if (print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1301 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1304 case RC_PRINTCOPIESFLAG:
1305 if (print_copies_flag != system_lyxrc.print_copies_flag) {
1306 os << "\\print_copies_flag \"" << print_copies_flag
1309 case RC_PRINTCOLLCOPIESFLAG:
1310 if (print_collcopies_flag
1311 != system_lyxrc.print_collcopies_flag) {
1312 os << "\\print_collcopies_flag \""
1313 << print_collcopies_flag
1316 case RC_PRINTPAPERFLAG:
1317 if (print_paper_flag != system_lyxrc.print_paper_flag) {
1318 os << "\\print_paper_flag \"" << print_paper_flag
1321 case RC_PRINTPAPERDIMENSIONFLAG:
1322 if (print_paper_dimension_flag
1323 != system_lyxrc.print_paper_dimension_flag) {
1324 os << "\\print_paper_dimension_flag \""
1325 << print_paper_dimension_flag << "\"\n";
1327 case RC_PRINTTOPRINTER:
1328 if (print_to_printer != system_lyxrc.print_to_printer) {
1329 os << "\\print_to_printer \"" << print_to_printer
1332 case RC_PRINTTOFILE:
1333 if (print_to_file != system_lyxrc.print_to_file) {
1334 os << "\\print_to_file \"" << print_to_file << "\"\n";
1336 case RC_PRINTFILEEXTENSION:
1337 if (print_file_extension != system_lyxrc.print_file_extension) {
1338 os << "\\print_file_extension \""
1339 << print_file_extension
1344 << "# EXPORT SECTION ####################################\n"
1347 case RC_CUSTOM_EXPORT_COMMAND:
1348 if (custom_export_command
1349 != system_lyxrc.custom_export_command) {
1350 os << "\\custom_export_command \""
1351 << custom_export_command
1354 case RC_CUSTOM_EXPORT_FORMAT:
1355 if (custom_export_format
1356 != system_lyxrc.custom_export_format) {
1357 os << "\\custom_export_format \"" << custom_export_format
1362 << "# TEX SECTION #######################################\n"
1365 case RC_FONT_ENCODING:
1366 if (fontenc != system_lyxrc.fontenc) {
1367 os << "\\font_encoding \"" << fontenc << "\"\n";
1371 << "# FILE SECTION ######################################\n"
1374 case RC_DOCUMENTPATH:
1375 if (document_path != system_lyxrc.document_path) {
1376 os << "\\document_path \"" << document_path << "\"\n";
1379 if (lastfiles != system_lyxrc.lastfiles) {
1380 os << "\\lastfiles \"" << lastfiles << "\"\n";
1382 case RC_NUMLASTFILES:
1383 if (num_lastfiles != system_lyxrc.num_lastfiles) {
1384 os << "\\num_lastfiles " << num_lastfiles << "\n";
1386 case RC_CHECKLASTFILES:
1387 if (check_lastfiles != system_lyxrc.check_lastfiles) {
1388 os << "\\check_lastfiles " << tostr(check_lastfiles)
1391 case RC_TEMPLATEPATH:
1392 if (template_path != system_lyxrc.template_path) {
1393 os << "\\template_path \"" << template_path << "\"\n";
1395 case RC_TEMPDIRPATH:
1396 if (tempdir_path != system_lyxrc.tempdir_path) {
1397 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1400 if (use_tempdir != system_lyxrc.use_tempdir) {
1401 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1403 case RC_ASCII_LINELEN:
1404 if (ascii_linelen != system_lyxrc.ascii_linelen) {
1405 os << "\\ascii_linelen " << ascii_linelen << "\n";
1407 case RC_MAKE_BACKUP:
1408 if (make_backup != system_lyxrc.make_backup) {
1409 os << "\\make_backup " << tostr(make_backup) << "\n";
1411 case RC_BACKUPDIR_PATH:
1412 if (backupdir_path != system_lyxrc.backupdir_path) {
1413 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1417 << "# FAX SECTION #######################################\n"
1420 case RC_FAX_COMMAND:
1421 if (fax_command != system_lyxrc.fax_command) {
1422 os << "\\fax_command \"" << fax_command << "\"\n";
1425 if (phone_book != system_lyxrc.phone_book) {
1426 os << "\\phone_book \"" << phone_book << "\"\n";
1429 if (fax_program != system_lyxrc.fax_program) {
1430 os << "\\fax_program \"" << fax_program << "\"\n";
1434 << "# ASCII EXPORT SECTION ##############################\n"
1437 case RC_ASCIIROFF_COMMAND:
1438 if (ascii_roff_command != system_lyxrc.ascii_roff_command) {
1439 os << "\\ascii_roff_command \"" << ascii_roff_command
1444 << "# SPELLCHECKER SECTION ##############################\n"
1447 case RC_SPELL_COMMAND:
1448 if (isp_command != system_lyxrc.isp_command) {
1449 os << "\\spell_command \"" << isp_command << "\"\n";
1451 case RC_ACCEPT_COMPOUND:
1452 if (isp_accept_compound != system_lyxrc.isp_accept_compound) {
1453 os << "\\accept_compound " << tostr(isp_accept_compound)
1456 case RC_USE_ALT_LANG:
1457 if (isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
1458 os << "\\use_alt_language " << tostr(isp_use_alt_lang)
1462 if (isp_alt_lang != system_lyxrc.isp_alt_lang) {
1463 os << "\\alternate_language \"" << isp_alt_lang
1466 case RC_USE_ESC_CHARS:
1467 if (isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
1468 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1472 if (isp_esc_chars != system_lyxrc.isp_esc_chars) {
1473 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1475 case RC_USE_PERS_DICT:
1476 if (isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
1477 os << "\\use_personal_dictionary "
1478 << tostr(isp_use_pers_dict)
1482 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
1483 os << "\\personal_dictionary \"" << isp_pers_dict
1486 case RC_USE_INP_ENC:
1487 if (isp_use_input_encoding
1488 != system_lyxrc.isp_use_input_encoding) {
1489 os << "\\use_input_encoding "
1490 << tostr(isp_use_input_encoding)
1495 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1498 case RC_RTL_SUPPORT:
1499 if (rtl_support != system_lyxrc.rtl_support) {
1500 os << "\\rtl " << tostr(rtl_support) << "\n";
1502 case RC_LANGUAGE_PACKAGE:
1503 if (language_package != system_lyxrc.language_package) {
1504 os << "\\language_package \"" << language_package
1507 case RC_LANGUAGE_COMMAND_BEGIN:
1508 if (language_command_begin
1509 != system_lyxrc.language_command_begin) {
1510 os << "\\language_command_begin \""
1511 << language_command_begin
1514 case RC_LANGUAGE_COMMAND_END:
1515 if (language_command_end
1516 != system_lyxrc.language_command_end) {
1517 os << "\\language_command_end \"" << language_command_end
1520 case RC_LANGUAGE_AUTO_BEGIN:
1521 if (language_auto_begin != system_lyxrc.language_auto_begin) {
1522 os << "\\language_auto_begin "
1523 << tostr(language_auto_begin) << "\n";
1525 case RC_LANGUAGE_AUTO_END:
1526 if (language_auto_end != system_lyxrc.language_auto_end) {
1527 os << "\\language_auto_end "
1528 << tostr(language_auto_end) << "\n";
1530 case RC_MARK_FOREIGN_LANGUAGE:
1531 if (mark_foreign_language
1532 != system_lyxrc.mark_foreign_language) {
1533 os << "\\mark_foreign_language " <<
1534 tostr(mark_foreign_language) << "\n";
1538 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1541 case RC_OVERRIDE_X_DEADKEYS:
1542 if (override_x_deadkeys != system_lyxrc.override_x_deadkeys) {
1543 os << "\\override_x_deadkeys "
1544 << tostr(override_x_deadkeys) << "\n";
1546 case RC_SCREEN_FONT_ENCODING_MENU:
1547 if (font_norm_menu != system_lyxrc.font_norm_menu) {
1548 os << "\\screen_font_encoding_menu \"" << font_norm_menu
1551 case RC_AUTO_NUMBER:
1552 if (auto_number != system_lyxrc.auto_number) {
1553 os << "\\auto_number " << tostr(auto_number) << "\n";
1555 case RC_NEW_ASK_FILENAME:
1556 if (new_ask_filename != system_lyxrc.new_ask_filename) {
1557 os << "\\new_ask_filename " << tostr(new_ask_filename)
1560 case RC_DEFAULT_LANGUAGE:
1561 if (default_language != system_lyxrc.default_language) {
1562 os << "\\default_language " << default_language << "\n";
1568 void LyXRC::set_font_norm_type()
1570 if (font_norm == "iso10646-1")
1571 font_norm_type = ISO_10646_1;
1572 else if (font_norm == "iso8859-6.8x")
1573 font_norm_type = ISO_8859_6_8;
1575 font_norm_type = OTHER_ENCODING;
1578 // The global instance
1581 // The global copy of the system lyxrc entries (everything except preferences)