3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Jean-Marc Lasgouttes
8 * \author Angus Leeming
10 * \author André Pönitz
14 * Full author contact details are available in file CREDITS.
25 #include "converter.h"
28 #include "lastfiles.h"
34 #include "graphics/GraphicsTypes.h"
36 #include "support/filetools.h"
37 #include "support/lstrings.h"
38 #include "support/tostr.h"
39 #include "support/userinfo.h"
41 using lyx::support::ascii_lowercase;
42 using lyx::support::bformat;
43 using lyx::support::ExpandPath;
44 using lyx::support::GetEnv;
45 using lyx::support::LibFileSearch;
46 using lyx::support::token;
59 // when adding something to this array keep it sorted!
60 keyword_item lyxrcTags[] = {
61 { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
62 { "\\alternate_language", LyXRC::RC_ALT_LANG },
63 { "\\ascii_linelen", LyXRC::RC_ASCII_LINELEN },
64 { "\\ascii_roff_command", LyXRC::RC_ASCIIROFF_COMMAND },
65 { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
66 { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
67 { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
68 { "\\autosave", LyXRC::RC_AUTOSAVE },
69 { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
70 { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
71 { "\\bind_file", LyXRC::RC_BINDFILE },
72 { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
73 { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
74 { "\\converter", LyXRC::RC_CONVERTER },
75 { "\\copier", LyXRC::RC_COPIER },
76 { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
77 { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
78 { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
79 { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
80 { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
81 { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
82 { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
83 { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
84 { "\\document_path", LyXRC::RC_DOCUMENTPATH },
85 { "\\escape_chars", LyXRC::RC_ESC_CHARS },
86 { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
87 { "\\format", LyXRC::RC_FORMAT },
88 { "\\index_command", LyXRC::RC_INDEX_COMMAND },
89 { "\\input", LyXRC::RC_INPUT },
90 { "\\kbmap", LyXRC::RC_KBMAP },
91 { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
92 { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
93 { "\\label_init_length", LyXRC::RC_LABEL_INIT_LENGTH },
94 { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
95 { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
96 { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
97 { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
98 { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
99 { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
100 { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
101 { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
102 { "\\lastfiles", LyXRC::RC_LASTFILES },
103 { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
104 { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
105 { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
106 { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
107 { "\\popup_bold_font", LyXRC::RC_POPUP_BOLD_FONT },
108 { "\\popup_font_encoding", LyXRC::RC_POPUP_FONT_ENCODING },
109 { "\\popup_normal_font", LyXRC::RC_POPUP_NORMAL_FONT },
110 { "\\preview", LyXRC::RC_PREVIEW },
111 { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
112 { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
113 { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
114 { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
115 { "\\print_command", LyXRC::RC_PRINT_COMMAND },
116 { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
117 { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
118 { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
119 { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
120 { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
121 { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
122 { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
123 { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
124 { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
125 { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
126 { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
127 { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
128 { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
129 { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
130 { "\\printer", LyXRC::RC_PRINTER },
131 { "\\rtl", LyXRC::RC_RTL_SUPPORT },
132 { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
133 { "\\screen_font_encoding", LyXRC::RC_SCREEN_FONT_ENCODING },
134 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
135 { "\\screen_font_encoding_menu", LyXRC::RC_POPUP_FONT_ENCODING },
136 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
137 { "\\screen_font_menu", LyXRC::RC_POPUP_BOLD_FONT },
138 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
139 { "\\screen_font_popup", LyXRC::RC_POPUP_NORMAL_FONT },
140 { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
141 { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
142 { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
143 { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
144 { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
145 { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
146 { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
147 { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
148 { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
149 { "\\serverpipe", LyXRC::RC_SERVERPIPE },
150 { "\\set_color", LyXRC::RC_SET_COLOR },
151 { "\\show_banner", LyXRC::RC_SHOW_BANNER },
152 { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
153 { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
154 { "\\template_path", LyXRC::RC_TEMPLATEPATH },
155 { "\\ui_file", LyXRC::RC_UIFILE },
156 { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
157 { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
158 { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
159 { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
160 // compatibility with versions older than 1.4.0 only
161 { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
162 { "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB },
163 // compatibility with versions older than 1.4.0 only
164 { "\\use_tempdir", LyXRC::RC_USETEMPDIR },
165 { "\\user_email", LyXRC::RC_USER_EMAIL },
166 { "\\user_name", LyXRC::RC_USER_NAME },
167 { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
168 // compatibility with versions older than 1.4.0 only
169 { "\\viewer" ,LyXRC::RC_VIEWER},
170 { "\\wheel_jump", LyXRC::RC_WHEEL_JUMP }
173 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
184 void LyXRC::setDefaults() {
187 // Get printer from the environment. If fail, use default "",
188 // assuming that everything is set up correctly.
189 printer = GetEnv("PRINTER");
190 print_adapt_output = false;
191 print_command = "dvips";
192 print_evenpage_flag = "-B";
193 print_oddpage_flag = "-A";
194 print_pagerange_flag = "-pp";
195 print_copies_flag = "-c";
196 print_collcopies_flag = "-C";
197 print_reverse_flag = "-r";
198 print_landscape_flag = "-t landscape";
199 print_to_printer = "-P";
200 print_to_file = "-o ";
201 print_file_extension = ".ps";
202 print_paper_flag = "-t";
203 print_paper_dimension_flag = "-T";
204 document_path.erase();
205 tempdir_path = "/tmp";
206 view_dvi_paper_option.erase();
207 default_papersize = PAPER_USLETTER;
208 custom_export_format = "ps";
209 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
210 bibtex_command = "bibtex";
212 index_command = "makeindex -c -q";
214 // Because a screen typically is wider than a piece of paper:
217 // Default LaTeX font size:
218 font_sizes[LyXFont::SIZE_TINY] = 5.0;
219 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
220 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
221 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
222 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
223 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
224 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
225 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
226 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
227 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
228 use_scalable_fonts = true;
229 roman_font_name = "";
231 typewriter_font_name = "";
232 popup_bold_font = "-*-helvetica-bold-r";
233 popup_normal_font = "-*-helvetica-medium-r";
234 font_norm = "iso8859-1";
235 font_norm_type = ISO_8859_1;
236 popup_font_encoding.erase();
238 auto_region_delete = true;
239 auto_reset_options = false;
241 num_lastfiles = maxlastfiles;
242 check_lastfiles = true;
244 backupdir_path.erase();
245 display_graphics = lyx::graphics::ColorDisplay;
246 // Spellchecker settings:
247 use_spell_lib = true;
248 isp_command = "ispell";
249 isp_accept_compound = false;
250 isp_use_input_encoding = false;
251 isp_use_alt_lang = false;
252 isp_use_pers_dict = false;
253 isp_use_esc_chars = false;
257 mark_foreign_language = true;
258 language_auto_begin = true;
259 language_auto_end = true;
260 language_global_options = true;
261 language_use_babel = true;
262 language_package = "\\usepackage{babel}";
263 language_command_begin = "\\selectlanguage{$$lang}";
264 language_command_local = "\\foreignlanguage{$$lang}{";
265 default_language = "english";
269 date_insert_format = "%A, %e %B %Y";
270 cursor_follows_scrollbar = false;
271 dialogs_iconify_with_main = false;
272 label_init_length = 3;
273 preview = PREVIEW_OFF;
274 preview_hashed_labels = false;
275 preview_scale_factor = 0.9;
277 user_name = lyx::support::user_name();
279 user_email = lyx::support::user_email();
285 void oldFontFormat(string & family, string & foundry)
287 if (family.empty() || family[0] != '-')
289 foundry = token(family, '-', 1);
290 family = token(family, '-', 2);
298 int LyXRC::read(string const & filename)
300 LyXLex lexrc(lyxrcTags, lyxrcCount);
301 if (lyxerr.debugging(Debug::PARSER))
302 lexrc.printTable(lyxerr);
304 lexrc.setFile(filename);
305 if (!lexrc.isOK()) return -2;
307 lyxerr[Debug::LYXRC] << "Reading '" << filename << "'..." << endl;
313 int LyXRC::read(std::istream & is)
315 LyXLex lexrc(lyxrcTags, lyxrcCount);
316 if (lyxerr.debugging(Debug::PARSER))
317 lexrc.printTable(lyxerr);
320 if (!lexrc.isOK()) return -2;
322 lyxerr[Debug::LYXRC] << "Reading istream..." << endl;
328 int LyXRC::read(LyXLex & lexrc)
330 if (!lexrc.isOK()) return -2;
332 while (lexrc.isOK()) {
333 // By using two switches we take advantage of the compiler
334 // telling us if we have missed a LyXRCTags element in
335 // the second switch.
336 // Note that this also shows a problem with LyXLex since it
337 // helps us avoid taking advantage of the strictness of the
340 int le = lexrc.lex();
342 case LyXLex::LEX_UNDEF:
343 lexrc.printError("Unknown tag `$$Token'");
345 case LyXLex::LEX_FEOF:
349 switch (static_cast<LyXRCTags>(le)) {
350 case RC_INPUT: // Include file
353 LibFileSearch(string(),
356 lexrc.printError("Error reading "
357 "included file: "+tmp);
361 case RC_BINDFILE: // RVDK_PATCH_5
363 bind_file = lexrc.getString();
369 ui_file = lexrc.getString();
373 case RC_AUTORESET_OPTIONS:
375 auto_reset_options = lexrc.getBool();
379 case RC_DISPLAY_GRAPHICS:
381 display_graphics = lyx::graphics::displayTranslator().find(lexrc.getString());
387 use_kbmap = lexrc.getBool();
391 case RC_KBMAP_PRIMARY:
393 string const kmap(lexrc.getString());
396 } else if (!LibFileSearch("kbd", kmap,
398 primary_kbmap = kmap;
400 lexrc.printError("LyX: Keymap `$$Token' not found");
405 case RC_KBMAP_SECONDARY:
407 string const kmap(lexrc.getString());
410 } else if (!LibFileSearch("kbd", kmap,
412 secondary_kbmap = kmap;
414 lexrc.printError("LyX: Keymap `$$Token' not found");
419 case RC_FONT_ENCODING:
421 fontenc = lexrc.getString();
427 printer = lexrc.getString();
431 case RC_PRINT_COMMAND:
433 print_command = lexrc.getString();
437 case RC_PRINTEVENPAGEFLAG:
439 print_evenpage_flag = lexrc.getString();
443 case RC_PRINTODDPAGEFLAG:
445 print_oddpage_flag = lexrc.getString();
449 case RC_PRINTPAGERANGEFLAG:
451 print_pagerange_flag = lexrc.getString();
455 case RC_PRINTCOPIESFLAG:
457 print_copies_flag = lexrc.getString();
461 case RC_PRINTCOLLCOPIESFLAG:
463 print_collcopies_flag = lexrc.getString();
467 case RC_PRINTREVERSEFLAG:
469 print_reverse_flag = lexrc.getString();
473 case RC_PRINTLANDSCAPEFLAG:
475 print_landscape_flag = lexrc.getString();
479 case RC_PRINTTOPRINTER:
481 print_to_printer = lexrc.getString();
485 case RC_PRINT_ADAPTOUTPUT:
487 print_adapt_output = lexrc.getBool();
493 print_to_file = lexrc.getString();
497 case RC_PRINTFILEEXTENSION:
499 print_file_extension = lexrc.getString();
503 case RC_PRINTEXSTRAOPTIONS:
505 print_extra_options = lexrc.getString();
509 case RC_PRINTSPOOL_COMMAND:
511 print_spool_command = lexrc.getString();
515 case RC_PRINTSPOOL_PRINTERPREFIX:
517 print_spool_printerprefix = lexrc.getString();
521 case RC_PRINTPAPERDIMENSIONFLAG:
523 print_paper_dimension_flag = lexrc.getString();
527 case RC_PRINTPAPERFLAG:
529 print_paper_flag = lexrc.getString();
533 case RC_CUSTOM_EXPORT_COMMAND:
535 custom_export_command = lexrc.getString();
539 case RC_CUSTOM_EXPORT_FORMAT:
541 custom_export_format = lexrc.getString();
545 case RC_DEFAULT_PAPERSIZE:
548 ascii_lowercase(lexrc.getString());
549 if (size == "usletter")
552 else if (size == "legal")
555 else if (size == "executive")
557 PAPER_EXECUTIVEPAPER;
558 else if (size == "a3")
561 else if (size == "a4")
564 else if (size == "a5")
567 else if (size == "b5")
573 case RC_VIEWDVI_PAPEROPTION:
575 view_dvi_paper_option = lexrc.getString();
577 view_dvi_paper_option.erase();
581 case RC_CHKTEX_COMMAND:
583 chktex_command = lexrc.getString();
587 case RC_BIBTEX_COMMAND:
589 bibtex_command = lexrc.getString();
593 case RC_INDEX_COMMAND:
595 index_command = lexrc.getString();
601 dpi = lexrc.getInteger();
607 zoom = lexrc.getInteger();
613 wheel_jump = lexrc.getInteger();
617 case RC_SCREEN_FONT_SIZES:
619 font_sizes[LyXFont::SIZE_TINY] =
623 font_sizes[LyXFont::SIZE_SCRIPT] =
627 font_sizes[LyXFont::SIZE_FOOTNOTE] =
631 font_sizes[LyXFont::SIZE_SMALL] =
635 font_sizes[LyXFont::SIZE_NORMAL] =
639 font_sizes[LyXFont::SIZE_LARGE] =
643 font_sizes[LyXFont::SIZE_LARGER] =
647 font_sizes[LyXFont::SIZE_LARGEST] =
651 font_sizes[LyXFont::SIZE_HUGE] =
655 font_sizes[LyXFont::SIZE_HUGER] =
660 case RC_SCREEN_FONT_SCALABLE:
662 use_scalable_fonts = lexrc.getBool();
668 autosave = lexrc.getInteger();
672 case RC_DOCUMENTPATH:
674 document_path = ExpandPath(lexrc.getString());
678 case RC_TEMPLATEPATH:
680 template_path = ExpandPath(lexrc.getString());
686 tempdir_path = ExpandPath(lexrc.getString());
692 lyxerr << "Ignoring obsolete use_tempdir flag." << endl;
698 lastfiles = ExpandPath(lexrc.getString());
702 case RC_NUMLASTFILES:
704 num_lastfiles = lexrc.getInteger();
708 case RC_CHECKLASTFILES:
710 check_lastfiles = lexrc.getBool();
714 case RC_SCREEN_FONT_ROMAN:
716 roman_font_name = lexrc.getString();
717 oldFontFormat(roman_font_name,
722 case RC_SCREEN_FONT_SANS:
724 sans_font_name = lexrc.getString();
725 oldFontFormat(sans_font_name, sans_font_foundry);
729 case RC_SCREEN_FONT_TYPEWRITER:
731 typewriter_font_name = lexrc.getString();
732 oldFontFormat(typewriter_font_name,
733 typewriter_font_foundry);
737 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
739 roman_font_foundry = lexrc.getString();
743 case RC_SCREEN_FONT_SANS_FOUNDRY:
745 sans_font_foundry = lexrc.getString();
749 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
751 typewriter_font_foundry = lexrc.getString();
755 case RC_SCREEN_FONT_ENCODING:
757 font_norm = lexrc.getString();
758 set_font_norm_type();
762 case RC_POPUP_BOLD_FONT:
764 popup_bold_font = lexrc.getString();
768 case RC_POPUP_NORMAL_FONT:
770 popup_normal_font = lexrc.getString();
774 case RC_POPUP_FONT_ENCODING:
776 popup_font_encoding = lexrc.getString();
782 string lyx_name, x11_name;
785 lyx_name = lexrc.getString();
787 lexrc.printError("Missing color tag.");
792 x11_name = lexrc.getString();
794 lexrc.printError("Missing color name for color: `$$Token'");
798 LColor::color const col =
799 lcolor.getFromLyXName(lyx_name);
800 if (col == LColor::none ||
801 col == LColor::inherit ||
802 col == LColor::ignore)
805 if (!lcolor.setColor(col, x11_name)) {
806 lyxerr << "Bad lyxrc set_color for "
812 case RC_AUTOREGIONDELETE:
813 // Auto region delete defaults to true
815 auto_region_delete = lexrc.getBool();
821 lyxpipes = ExpandPath(lexrc.getString());
825 case RC_CURSOR_FOLLOWS_SCROLLBAR:
827 cursor_follows_scrollbar = lexrc.getBool();
831 case RC_DIALOGS_ICONIFY_WITH_MAIN:
833 dialogs_iconify_with_main = lexrc.getBool();
837 case RC_ASCIIROFF_COMMAND:
839 ascii_roff_command = lexrc.getString();
842 case RC_ASCII_LINELEN:
844 ascii_linelen = lexrc.getInteger();
847 // Spellchecker settings:
848 case RC_USE_SPELL_LIB:
850 use_spell_lib = lexrc.getBool();
853 case RC_SPELL_COMMAND:
855 isp_command = lexrc.getString();
858 case RC_ACCEPT_COMPOUND:
860 isp_accept_compound = lexrc.getBool();
865 isp_use_input_encoding = lexrc.getBool();
868 case RC_USE_ALT_LANG:
870 isp_use_alt_lang = lexrc.getBool();
873 case RC_USE_PERS_DICT:
875 isp_use_pers_dict = lexrc.getBool();
878 case RC_USE_ESC_CHARS:
880 isp_use_esc_chars = lexrc.getBool();
885 isp_alt_lang = lexrc.getString();
890 isp_pers_dict = lexrc.getString();
895 isp_esc_chars = lexrc.getString();
900 make_backup = lexrc.getBool();
903 case RC_BACKUPDIR_PATH:
905 backupdir_path = ExpandPath(lexrc.getString());
908 case RC_DATE_INSERT_FORMAT:
910 date_insert_format = lexrc.getString();
913 case RC_LANGUAGE_PACKAGE:
915 language_package = lexrc.getString();
918 case RC_LANGUAGE_AUTO_BEGIN:
920 language_auto_begin = lexrc.getBool();
923 case RC_LANGUAGE_AUTO_END:
925 language_auto_end = lexrc.getBool();
928 case RC_LANGUAGE_GLOBAL_OPTIONS:
930 language_global_options = lexrc.getBool();
933 case RC_LANGUAGE_USE_BABEL:
935 language_use_babel = lexrc.getBool();
938 case RC_LANGUAGE_COMMAND_BEGIN:
940 language_command_begin = lexrc.getString();
943 case RC_LANGUAGE_COMMAND_END:
945 language_command_end = lexrc.getString();
948 case RC_LANGUAGE_COMMAND_LOCAL:
950 language_command_local = lexrc.getString();
955 rtl_support = lexrc.getBool();
960 auto_number = lexrc.getBool();
963 case RC_MARK_FOREIGN_LANGUAGE:
965 mark_foreign_language = lexrc.getBool();
972 fmt = lexrc.getString();
975 command = lexrc.getString();
977 movers.set(fmt, command);
982 string from, to, command, flags;
984 from = lexrc.getString();
987 to = lexrc.getString();
990 command = lexrc.getString();
993 flags = lexrc.getString();
996 || token(command, ' ', 0) == "none") {
997 converters.erase(from, to);
999 converters.add(from, to, command, flags);
1003 // compatibility with versions older than 1.4.0 only
1005 string format, command;
1007 format = lexrc.getString();
1010 command = lexrc.getString();
1011 if (token(command, ' ', 0) == "none")
1014 formats.setViewer(format, command);
1018 string format, extension, prettyname, shortcut;
1020 format = lexrc.getString();
1023 extension = lexrc.getString();
1026 prettyname = lexrc.getString();
1029 shortcut = lexrc.getString();
1031 string viewer, editor;
1032 // Hack to ensure compatibility with versions older
1034 int le = lexrc.lex();
1035 if (le != LyXLex::LEX_FEOF && le != LyXLex::LEX_UNDEF) {
1036 viewer = lexrc.getString();
1037 if (le == LyXLex::LEX_DATA) {
1038 if (token(viewer, ' ', 0) == "none")
1041 editor = lexrc.getString();
1042 if (token(editor, ' ', 0) == "none")
1046 // We have got a known token.
1047 // Therefore this is an old style
1048 // format definition without
1049 // viewer and editor.
1050 lexrc.pushToken(viewer);
1054 if (prettyname.empty()) {
1055 if (converters.formatIsUsed(format)) {
1056 lyxerr << "Can't delete format "
1059 formats.erase(format);
1062 formats.add(format, extension, prettyname,
1063 shortcut, viewer, editor);
1067 case RC_DEFAULT_LANGUAGE:
1069 default_language = lexrc.getString();
1073 case RC_LABEL_INIT_LENGTH:
1075 label_init_length = lexrc.getInteger();
1079 case RC_SHOW_BANNER:
1081 show_banner = lexrc.getBool();
1087 string const tmp = lexrc.getString();
1088 if (tmp == "true" || tmp == "on")
1089 preview = PREVIEW_ON;
1090 else if (tmp == "no_math")
1091 preview = PREVIEW_NO_MATH;
1093 preview = PREVIEW_OFF;
1094 if (tmp != "false" && tmp != "off")
1095 lyxerr << "Unrecognized "
1097 << tmp << '\n' << endl;
1102 case RC_PREVIEW_HASHED_LABELS:
1104 preview_hashed_labels = lexrc.getBool();
1108 case RC_PREVIEW_SCALE_FACTOR:
1110 preview_scale_factor = lexrc.getFloat();
1116 user_name = lexrc.getString();
1121 user_email = lexrc.getString();
1124 case RC_LAST: break; // this is just a dummy
1128 /// Update converters data-structures
1129 converters.update(formats);
1130 converters.buildGraph();
1136 void LyXRC::write(string const & filename, bool ignore_system_lyxrc) const
1138 ofstream ofs(filename.c_str());
1140 write(ofs, ignore_system_lyxrc);
1144 void LyXRC::print() const
1146 if (lyxerr.debugging())
1147 write(lyxerr, false);
1154 typedef std::pair<std::string, SpecialisedMover> Data;
1156 SameMover(Data const & comparison)
1157 : comparison_(comparison) {}
1159 bool operator()(Data const & data) const
1161 return data.first == comparison_.first &&
1162 data.second.command() == comparison_.second.command();
1170 void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
1172 os << "### This file is part of\n"
1173 << "### ========================================================\n"
1174 << "### LyX, The Document Processor\n"
1176 << "### Copyright 1995 Matthias Ettrich\n"
1177 << "### Copyright 1995-2001 The LyX Team.\n"
1179 << "### ========================================================\n"
1181 << "# This file is written by LyX, if you want to make your own\n"
1182 << "# modifications you should do them from inside LyX and save\n"
1185 // Why the switch you might ask. It is a trick to ensure that all
1186 // the elements in the LyXRCTags enum is handled. As you can see
1187 // there are no breaks at all. So it is just a huge fall-through.
1188 // The nice thing is that we will get a warning from the compiler
1189 // if we forget an element.
1190 LyXRCTags tag = RC_LAST;
1194 // input/include files are not done here
1196 if (ignore_system_lyxrc ||
1197 bind_file != system_lyxrc.bind_file) {
1198 os << "\\bind_file " << bind_file << "\n";
1204 << "# MISC SECTION ######################################\n"
1207 // bind files are not done here.
1209 if (ignore_system_lyxrc ||
1210 ui_file != system_lyxrc.ui_file) {
1211 os << "\\ui_file \"" << ui_file << "\"\n";
1213 case RC_AUTOREGIONDELETE:
1214 if (ignore_system_lyxrc ||
1215 auto_region_delete != system_lyxrc.auto_region_delete) {
1216 os << "# Set to false to inhibit automatic replacement of\n"
1217 << "# the current selection.\n"
1218 << "\\auto_region_delete " << tostr(auto_region_delete)
1221 case RC_AUTORESET_OPTIONS:
1222 if (ignore_system_lyxrc ||
1223 auto_reset_options != system_lyxrc.auto_reset_options) {
1224 os << "# Set to false to inhibit automatic reset of\n"
1225 << "# the class options to defaults on class change.\n"
1226 << "\\auto_reset_options " << tostr(auto_reset_options)
1230 if (ignore_system_lyxrc ||
1231 autosave != system_lyxrc.autosave) {
1232 os << "# The time interval between auto-saves in seconds.\n"
1233 << "\\autosave " << autosave << '\n';
1235 case RC_DISPLAY_GRAPHICS:
1236 if (ignore_system_lyxrc ||
1237 display_graphics != system_lyxrc.display_graphics) {
1238 os << "# Display graphics within LyX\n"
1239 << "# monochrome|grayscale|color|none\n"
1240 << "\\display_graphics "
1241 << lyx::graphics::displayTranslator().find(display_graphics)
1245 case RC_VIEWDVI_PAPEROPTION:
1246 if (ignore_system_lyxrc ||
1247 view_dvi_paper_option
1248 != system_lyxrc.view_dvi_paper_option) {
1249 os << "# Options used to specify paper size to the\n"
1250 << "# view_dvi_command (e.g. -paper)\n"
1251 << "\\view_dvi_paper_option \""
1252 << view_dvi_paper_option << "\"\n";
1254 case RC_DEFAULT_PAPERSIZE:
1255 if (ignore_system_lyxrc ||
1256 default_papersize != system_lyxrc.default_papersize) {
1257 os << "# The default papersize to use.\n"
1258 << "\\default_papersize \"";
1259 switch (default_papersize) {
1260 case PAPER_USLETTER:
1261 os << "usletter"; break;
1262 case PAPER_LEGALPAPER:
1263 os << "legal"; break;
1264 case PAPER_EXECUTIVEPAPER:
1265 os << "executive"; break;
1274 case PAPER_DEFAULT: break;
1278 case RC_CHKTEX_COMMAND:
1279 if (ignore_system_lyxrc ||
1280 chktex_command != system_lyxrc.chktex_command) {
1281 os << "\\chktex_command \"" << chktex_command << "\"\n";
1283 case RC_BIBTEX_COMMAND:
1284 if (ignore_system_lyxrc ||
1285 bibtex_command != system_lyxrc.bibtex_command) {
1286 os << "\\bibtex_command \"" << bibtex_command << "\"\n";
1288 case RC_INDEX_COMMAND:
1289 if (ignore_system_lyxrc ||
1290 index_command != system_lyxrc.index_command) {
1291 os << "\\index_command \"" << index_command << "\"\n";
1294 if (ignore_system_lyxrc ||
1295 use_kbmap != system_lyxrc.use_kbmap) {
1296 os << "\\kbmap " << tostr(use_kbmap) << '\n';
1298 case RC_KBMAP_PRIMARY:
1299 if (ignore_system_lyxrc ||
1300 primary_kbmap != system_lyxrc.primary_kbmap) {
1301 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1303 case RC_KBMAP_SECONDARY:
1304 if (ignore_system_lyxrc ||
1305 secondary_kbmap != system_lyxrc.secondary_kbmap) {
1306 os << "\\kbmap_secondary \"" << secondary_kbmap
1310 if (ignore_system_lyxrc ||
1311 lyxpipes != system_lyxrc.lyxpipes) {
1312 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1314 case RC_DATE_INSERT_FORMAT:
1315 if (ignore_system_lyxrc ||
1316 date_insert_format != system_lyxrc.date_insert_format) {
1317 os << "\\date_insert_format \"" << date_insert_format
1320 case RC_LABEL_INIT_LENGTH:
1321 if (ignore_system_lyxrc ||
1322 label_init_length != system_lyxrc.label_init_length) {
1323 os << "\\label_init_length " << label_init_length
1328 os << "\\user_name \"" << user_name << "\"\n";
1331 os << "\\user_email \"" << user_email << "\"\n";
1333 case RC_SHOW_BANNER:
1334 if (ignore_system_lyxrc ||
1335 show_banner != system_lyxrc.show_banner) {
1336 os << "\\show_banner " << tostr(show_banner) << '\n';
1340 if (ignore_system_lyxrc ||
1341 preview != system_lyxrc.preview) {
1347 case PREVIEW_NO_MATH:
1354 os << "\\preview " << status << '\n';
1357 case RC_PREVIEW_HASHED_LABELS:
1358 if (ignore_system_lyxrc ||
1359 preview_hashed_labels !=
1360 system_lyxrc.preview_hashed_labels) {
1361 os << "\\preview_hashed_labels "
1362 << tostr(preview_hashed_labels) << '\n';
1365 case RC_PREVIEW_SCALE_FACTOR:
1366 if (ignore_system_lyxrc ||
1367 preview_scale_factor != system_lyxrc.preview_scale_factor) {
1368 os << "\\preview_scale_factor "
1369 << preview_scale_factor << '\n';
1373 << "# SCREEN & FONTS SECTION ############################\n"
1376 case RC_POPUP_NORMAL_FONT:
1377 if (ignore_system_lyxrc ||
1378 popup_normal_font != system_lyxrc.popup_normal_font) {
1379 os << "\\popup_normal_font \"" << popup_normal_font
1382 case RC_POPUP_BOLD_FONT:
1383 if (ignore_system_lyxrc ||
1384 popup_bold_font != system_lyxrc.popup_bold_font) {
1385 os << "\\popup_bold_font \"" << popup_bold_font
1388 case RC_POPUP_FONT_ENCODING:
1389 if (ignore_system_lyxrc ||
1390 popup_font_encoding != system_lyxrc.popup_font_encoding) {
1391 os << "\\popup_font_encoding \"" << popup_font_encoding
1395 if (ignore_system_lyxrc ||
1396 dpi != system_lyxrc.dpi) {
1397 os << "\\screen_dpi " << dpi << '\n';
1399 case RC_SCREEN_ZOOM:
1400 if (ignore_system_lyxrc ||
1401 zoom != system_lyxrc.zoom) {
1402 os << "\\screen_zoom " << zoom << '\n';
1405 if (ignore_system_lyxrc ||
1406 wheel_jump != system_lyxrc.wheel_jump) {
1407 os << "\\wheel_jump " << wheel_jump << '\n';
1409 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1410 if (ignore_system_lyxrc ||
1411 cursor_follows_scrollbar
1412 != system_lyxrc.cursor_follows_scrollbar) {
1413 os << "\\cursor_follows_scrollbar "
1414 << tostr(cursor_follows_scrollbar) << '\n';
1416 case RC_DIALOGS_ICONIFY_WITH_MAIN:
1417 if (ignore_system_lyxrc ||
1418 dialogs_iconify_with_main
1419 != system_lyxrc.dialogs_iconify_with_main) {
1420 os << "\\dialogs_iconify_with_main "
1421 << tostr(dialogs_iconify_with_main) << '\n';
1423 case RC_SCREEN_FONT_ROMAN:
1424 if (ignore_system_lyxrc ||
1425 roman_font_name != system_lyxrc.roman_font_name) {
1426 os << "\\screen_font_roman \"" << roman_font_name
1429 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1430 if (ignore_system_lyxrc ||
1431 roman_font_foundry != system_lyxrc.roman_font_foundry) {
1432 os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1435 case RC_SCREEN_FONT_SANS:
1436 if (ignore_system_lyxrc ||
1437 sans_font_name != system_lyxrc.sans_font_name) {
1438 os << "\\screen_font_sans \"" << sans_font_name
1441 case RC_SCREEN_FONT_SANS_FOUNDRY:
1442 if (ignore_system_lyxrc ||
1443 sans_font_foundry != system_lyxrc.sans_font_foundry) {
1444 os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1447 case RC_SCREEN_FONT_TYPEWRITER:
1448 if (ignore_system_lyxrc ||
1449 typewriter_font_name != system_lyxrc.typewriter_font_name) {
1450 os << "\\screen_font_typewriter \""
1451 << typewriter_font_name << "\"\n";
1453 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1454 if (ignore_system_lyxrc ||
1455 typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1456 os << "\\screen_font_typewriter_foundry \""
1457 << typewriter_font_foundry << "\"\n";
1460 case RC_SCREEN_FONT_SCALABLE:
1461 if (ignore_system_lyxrc ||
1462 use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1463 os << "\\screen_font_scalable "
1464 << tostr(use_scalable_fonts)
1467 case RC_SCREEN_FONT_ENCODING:
1468 if (ignore_system_lyxrc ||
1469 font_norm != system_lyxrc.font_norm) {
1470 os << "\\screen_font_encoding \"" << font_norm
1473 case RC_SCREEN_FONT_SIZES:
1474 if (ignore_system_lyxrc ||
1475 font_sizes[LyXFont::SIZE_TINY]
1476 != system_lyxrc.font_sizes[LyXFont::SIZE_TINY] ||
1477 font_sizes[LyXFont::SIZE_SCRIPT]
1478 != system_lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] ||
1479 font_sizes[LyXFont::SIZE_FOOTNOTE]
1480 != system_lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] ||
1481 font_sizes[LyXFont::SIZE_SMALL]
1482 != system_lyxrc.font_sizes[LyXFont::SIZE_SMALL] ||
1483 font_sizes[LyXFont::SIZE_NORMAL]
1484 != system_lyxrc.font_sizes[LyXFont::SIZE_NORMAL] ||
1485 font_sizes[LyXFont::SIZE_LARGE]
1486 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGE] ||
1487 font_sizes[LyXFont::SIZE_LARGER]
1488 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGER] ||
1489 font_sizes[LyXFont::SIZE_LARGEST]
1490 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGEST] ||
1491 font_sizes[LyXFont::SIZE_HUGE]
1492 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGE] ||
1493 font_sizes[LyXFont::SIZE_HUGER]
1494 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGER]) {
1495 os.setf(ios::fixed);
1497 os << "\\screen_font_sizes"
1498 << ' ' << font_sizes[LyXFont::SIZE_TINY]
1499 << ' ' << font_sizes[LyXFont::SIZE_SCRIPT]
1500 << ' ' << font_sizes[LyXFont::SIZE_FOOTNOTE]
1501 << ' ' << font_sizes[LyXFont::SIZE_SMALL]
1502 << ' ' << font_sizes[LyXFont::SIZE_NORMAL]
1503 << ' ' << font_sizes[LyXFont::SIZE_LARGE]
1504 << ' ' << font_sizes[LyXFont::SIZE_LARGER]
1505 << ' ' << font_sizes[LyXFont::SIZE_LARGEST]
1506 << ' ' << font_sizes[LyXFont::SIZE_HUGE]
1507 << ' ' << font_sizes[LyXFont::SIZE_HUGER]
1512 << "# COLOR SECTION ###################################\n"
1516 for (int i = 0; i < LColor::ignore; ++i) {
1517 LColor::color lc = static_cast<LColor::color>(i);
1519 string const col(lcolor.getX11Name(lc));
1520 if (ignore_system_lyxrc ||
1521 col != system_lcolor.getX11Name(lc)) {
1522 os << "\\set_color \""
1523 << lcolor.getLyXName(lc) << "\" \""
1529 << "# PRINTER SECTION ###################################\n"
1533 if (ignore_system_lyxrc ||
1534 printer != system_lyxrc.printer) {
1535 os << "\\printer \"" << printer << "\"\n";
1537 case RC_PRINT_ADAPTOUTPUT:
1538 if (ignore_system_lyxrc ||
1539 print_adapt_output != system_lyxrc.print_adapt_output) {
1540 os << "\\print_adapt_output "
1541 << tostr(print_adapt_output)
1544 case RC_PRINT_COMMAND:
1545 if (ignore_system_lyxrc ||
1546 print_command != system_lyxrc.print_command) {
1547 os << "\\print_command \"" << print_command << "\"\n";
1549 case RC_PRINTEXSTRAOPTIONS:
1550 if (ignore_system_lyxrc ||
1551 print_extra_options != system_lyxrc.print_extra_options) {
1552 os << "\\print_extra_options \"" << print_extra_options
1555 case RC_PRINTSPOOL_COMMAND:
1556 if (ignore_system_lyxrc ||
1557 print_spool_command != system_lyxrc.print_spool_command) {
1558 os << "\\print_spool_command \"" << print_spool_command
1561 case RC_PRINTSPOOL_PRINTERPREFIX:
1562 if (ignore_system_lyxrc ||
1563 print_spool_printerprefix
1564 != system_lyxrc.print_spool_printerprefix) {
1565 os << "\\print_spool_printerprefix \""
1566 << print_spool_printerprefix << "\"\n";
1568 case RC_PRINTEVENPAGEFLAG:
1569 if (ignore_system_lyxrc ||
1570 print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1571 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1574 case RC_PRINTODDPAGEFLAG:
1575 if (ignore_system_lyxrc ||
1576 print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1577 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1580 case RC_PRINTREVERSEFLAG:
1581 if (ignore_system_lyxrc ||
1582 print_reverse_flag != system_lyxrc.print_reverse_flag) {
1583 os << "\\print_reverse_flag \"" << print_reverse_flag
1586 case RC_PRINTLANDSCAPEFLAG:
1587 if (ignore_system_lyxrc ||
1588 print_landscape_flag != system_lyxrc.print_landscape_flag) {
1589 os << "\\print_landscape_flag \"" << print_landscape_flag
1592 case RC_PRINTPAGERANGEFLAG:
1593 if (ignore_system_lyxrc ||
1594 print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1595 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1598 case RC_PRINTCOPIESFLAG:
1599 if (ignore_system_lyxrc ||
1600 print_copies_flag != system_lyxrc.print_copies_flag) {
1601 os << "\\print_copies_flag \"" << print_copies_flag
1604 case RC_PRINTCOLLCOPIESFLAG:
1605 if (ignore_system_lyxrc ||
1606 print_collcopies_flag
1607 != system_lyxrc.print_collcopies_flag) {
1608 os << "\\print_collcopies_flag \""
1609 << print_collcopies_flag
1612 case RC_PRINTPAPERFLAG:
1613 if (ignore_system_lyxrc ||
1614 print_paper_flag != system_lyxrc.print_paper_flag) {
1615 os << "\\print_paper_flag \"" << print_paper_flag
1618 case RC_PRINTPAPERDIMENSIONFLAG:
1619 if (ignore_system_lyxrc ||
1620 print_paper_dimension_flag
1621 != system_lyxrc.print_paper_dimension_flag) {
1622 os << "\\print_paper_dimension_flag \""
1623 << print_paper_dimension_flag << "\"\n";
1625 case RC_PRINTTOPRINTER:
1626 if (ignore_system_lyxrc ||
1627 print_to_printer != system_lyxrc.print_to_printer) {
1628 os << "\\print_to_printer \"" << print_to_printer
1631 case RC_PRINTTOFILE:
1632 if (ignore_system_lyxrc ||
1633 print_to_file != system_lyxrc.print_to_file) {
1634 os << "\\print_to_file \"" << print_to_file << "\"\n";
1636 case RC_PRINTFILEEXTENSION:
1637 if (ignore_system_lyxrc ||
1638 print_file_extension != system_lyxrc.print_file_extension) {
1639 os << "\\print_file_extension \""
1640 << print_file_extension
1645 << "# EXPORT SECTION ####################################\n"
1648 case RC_CUSTOM_EXPORT_COMMAND:
1649 if (ignore_system_lyxrc ||
1650 custom_export_command
1651 != system_lyxrc.custom_export_command) {
1652 os << "\\custom_export_command \""
1653 << custom_export_command
1656 case RC_CUSTOM_EXPORT_FORMAT:
1657 if (ignore_system_lyxrc ||
1658 custom_export_format
1659 != system_lyxrc.custom_export_format) {
1660 os << "\\custom_export_format \"" << custom_export_format
1665 << "# TEX SECTION #######################################\n"
1668 case RC_FONT_ENCODING:
1669 if (ignore_system_lyxrc ||
1670 fontenc != system_lyxrc.fontenc) {
1671 os << "\\font_encoding \"" << fontenc << "\"\n";
1675 << "# FILE SECTION ######################################\n"
1678 case RC_DOCUMENTPATH:
1679 if (ignore_system_lyxrc ||
1680 document_path != system_lyxrc.document_path) {
1681 os << "\\document_path \"" << document_path << "\"\n";
1684 if (ignore_system_lyxrc ||
1685 lastfiles != system_lyxrc.lastfiles) {
1686 os << "\\lastfiles \"" << lastfiles << "\"\n";
1688 case RC_NUMLASTFILES:
1689 if (ignore_system_lyxrc ||
1690 num_lastfiles != system_lyxrc.num_lastfiles) {
1691 os << "\\num_lastfiles " << num_lastfiles << '\n';
1693 case RC_CHECKLASTFILES:
1694 if (ignore_system_lyxrc ||
1695 check_lastfiles != system_lyxrc.check_lastfiles) {
1696 os << "\\check_lastfiles " << tostr(check_lastfiles)
1699 case RC_TEMPLATEPATH:
1700 if (ignore_system_lyxrc ||
1701 template_path != system_lyxrc.template_path) {
1702 os << "\\template_path \"" << template_path << "\"\n";
1704 case RC_TEMPDIRPATH:
1705 if (ignore_system_lyxrc ||
1706 tempdir_path != system_lyxrc.tempdir_path) {
1707 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1711 case RC_ASCII_LINELEN:
1712 if (ignore_system_lyxrc ||
1713 ascii_linelen != system_lyxrc.ascii_linelen) {
1714 os << "\\ascii_linelen " << ascii_linelen << '\n';
1716 case RC_MAKE_BACKUP:
1717 if (ignore_system_lyxrc ||
1718 make_backup != system_lyxrc.make_backup) {
1719 os << "\\make_backup " << tostr(make_backup) << '\n';
1721 case RC_BACKUPDIR_PATH:
1722 if (ignore_system_lyxrc ||
1723 backupdir_path != system_lyxrc.backupdir_path) {
1724 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1728 << "# ASCII EXPORT SECTION ##############################\n"
1731 case RC_ASCIIROFF_COMMAND:
1732 if (ignore_system_lyxrc ||
1733 ascii_roff_command != system_lyxrc.ascii_roff_command) {
1734 os << "\\ascii_roff_command \"" << ascii_roff_command
1739 << "# SPELLCHECKER SECTION ##############################\n"
1741 case RC_USE_SPELL_LIB:
1742 if (ignore_system_lyxrc ||
1743 use_spell_lib != system_lyxrc.use_spell_lib) {
1744 os << "\\use_spell_lib " << tostr(use_spell_lib) << '\n';
1746 case RC_SPELL_COMMAND:
1747 if (ignore_system_lyxrc ||
1748 isp_command != system_lyxrc.isp_command) {
1749 os << "\\spell_command \"" << isp_command << "\"\n";
1751 case RC_ACCEPT_COMPOUND:
1752 if (ignore_system_lyxrc ||
1753 isp_accept_compound != system_lyxrc.isp_accept_compound) {
1754 os << "\\accept_compound " << tostr(isp_accept_compound)
1757 case RC_USE_ALT_LANG:
1758 if (ignore_system_lyxrc ||
1759 isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
1760 os << "\\use_alt_language " << tostr(isp_use_alt_lang)
1764 if (ignore_system_lyxrc ||
1765 isp_alt_lang != system_lyxrc.isp_alt_lang) {
1766 os << "\\alternate_language \"" << isp_alt_lang
1769 case RC_USE_ESC_CHARS:
1770 if (ignore_system_lyxrc ||
1771 isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
1772 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1776 if (ignore_system_lyxrc ||
1777 isp_esc_chars != system_lyxrc.isp_esc_chars) {
1778 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1780 case RC_USE_PERS_DICT:
1781 if (ignore_system_lyxrc ||
1782 isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
1783 os << "\\use_personal_dictionary "
1784 << tostr(isp_use_pers_dict)
1788 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
1789 os << "\\personal_dictionary \"" << isp_pers_dict
1792 case RC_USE_INP_ENC:
1793 if (ignore_system_lyxrc ||
1794 isp_use_input_encoding
1795 != system_lyxrc.isp_use_input_encoding) {
1796 os << "\\use_input_encoding "
1797 << tostr(isp_use_input_encoding)
1802 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1805 case RC_RTL_SUPPORT:
1806 if (ignore_system_lyxrc ||
1807 rtl_support != system_lyxrc.rtl_support) {
1808 os << "\\rtl " << tostr(rtl_support) << '\n';
1810 case RC_LANGUAGE_PACKAGE:
1811 if (ignore_system_lyxrc ||
1812 language_package != system_lyxrc.language_package) {
1813 os << "\\language_package \"" << language_package
1816 case RC_LANGUAGE_GLOBAL_OPTIONS:
1817 if (ignore_system_lyxrc ||
1818 language_global_options
1819 != system_lyxrc.language_global_options) {
1820 os << "\\language_global_options \""
1821 << tostr(language_global_options)
1824 case RC_LANGUAGE_USE_BABEL:
1825 if (ignore_system_lyxrc ||
1826 language_use_babel != system_lyxrc.language_use_babel) {
1827 os << "\\language_use_babel \""
1828 << tostr(language_use_babel)
1831 case RC_LANGUAGE_COMMAND_BEGIN:
1832 if (ignore_system_lyxrc ||
1833 language_command_begin
1834 != system_lyxrc.language_command_begin) {
1835 os << "\\language_command_begin \""
1836 << language_command_begin
1839 case RC_LANGUAGE_COMMAND_END:
1840 if (ignore_system_lyxrc ||
1841 language_command_end
1842 != system_lyxrc.language_command_end) {
1843 os << "\\language_command_end \"" << language_command_end
1846 case RC_LANGUAGE_COMMAND_LOCAL:
1847 if (ignore_system_lyxrc ||
1848 language_command_local
1849 != system_lyxrc.language_command_local) {
1850 os << "\\language_command_local \""
1851 << language_command_local
1854 case RC_LANGUAGE_AUTO_BEGIN:
1855 if (ignore_system_lyxrc ||
1856 language_auto_begin != system_lyxrc.language_auto_begin) {
1857 os << "\\language_auto_begin "
1858 << tostr(language_auto_begin) << '\n';
1860 case RC_LANGUAGE_AUTO_END:
1861 if (ignore_system_lyxrc ||
1862 language_auto_end != system_lyxrc.language_auto_end) {
1863 os << "\\language_auto_end "
1864 << tostr(language_auto_end) << '\n';
1866 case RC_MARK_FOREIGN_LANGUAGE:
1867 if (ignore_system_lyxrc ||
1868 mark_foreign_language
1869 != system_lyxrc.mark_foreign_language) {
1870 os << "\\mark_foreign_language " <<
1871 tostr(mark_foreign_language) << '\n';
1875 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1878 case RC_AUTO_NUMBER:
1879 if (ignore_system_lyxrc ||
1880 auto_number != system_lyxrc.auto_number) {
1881 os << "\\auto_number " << tostr(auto_number) << '\n';
1883 case RC_DEFAULT_LANGUAGE:
1884 if (ignore_system_lyxrc ||
1885 default_language != system_lyxrc.default_language) {
1886 os << "\\default_language " << default_language << '\n';
1890 << "# FORMATS SECTION ##########################\n"
1894 // New/modifed formats
1895 for (Formats::const_iterator cit = formats.begin();
1896 cit != formats.end(); ++cit) {
1897 Format const * format =
1898 system_formats.getFormat(cit->name());
1900 format->extension() != cit->extension() ||
1901 format->prettyname() != cit->prettyname() ||
1902 format->shortcut() != cit->shortcut() ||
1903 format->viewer() != cit->viewer() ||
1904 format->editor() != cit->editor())
1905 os << "\\format \"" << cit->name() << "\" \""
1906 << cit->extension() << "\" \""
1907 << cit->prettyname() << "\" \""
1908 << cit->shortcut() << "\" \""
1909 << cit->viewer() << "\" \""
1910 << cit->editor() << "\"\n";
1913 // Look for deleted formats
1914 for (Formats::const_iterator cit = system_formats.begin();
1915 cit != system_formats.end(); ++cit)
1916 if (!formats.getFormat(cit->name()))
1917 os << "\\format \"" << cit->name()
1918 << "\" \"\" \"\" \"\" \"\" \"\"\n";
1923 << "# CONVERTERS SECTION ##########################\n"
1927 // Look for new converters
1928 for (Converters::const_iterator cit = converters.begin();
1929 cit != converters.end(); ++cit) {
1930 Converter const * converter =
1931 system_converters.getConverter(cit->from,
1934 converter->command != cit->command ||
1935 converter->flags != cit->flags)
1936 os << "\\converter \"" << cit->from << "\" \""
1937 << cit->to << "\" \""
1938 << cit->command << "\" \""
1939 << cit->flags << "\"\n";
1942 // New/modifed converters
1943 for (Converters::const_iterator cit = system_converters.begin();
1944 cit != system_converters.end(); ++cit)
1945 if (!converters.getConverter(cit->from, cit->to))
1946 os << "\\converter \"" << cit->from
1947 << "\" \"" << cit->to << "\" \"\" \"\"\n";
1951 << "# COPIERS SECTION ##########################\n"
1954 // Look for new movers
1955 Movers::iterator const sysbegin = system_movers.begin();
1956 Movers::iterator const sysend = system_movers.end();
1958 for (Movers::iterator it = movers.begin(), end = movers.end();
1960 Movers::iterator const sysit =
1961 std::find_if(sysbegin, sysend, SameMover(*it));
1962 if (sysit == sysend) {
1963 std::string const & fmt = it->first;
1964 std::string const & command =
1965 it->second.command();
1967 os << "\\copier " << fmt
1968 << " \"" << command << "\"\n";
1972 // We don't actually delete SpecialisedMover(s) from the
1973 // map, just clear their 'command', so there's no need
1974 // to test for anything else.
1980 void LyXRC::set_font_norm_type()
1982 if (font_norm == "iso10646-1")
1983 font_norm_type = ISO_10646_1;
1984 else if (font_norm == "iso8859-1")
1985 font_norm_type = ISO_8859_1;
1986 else if (font_norm == "iso8859-3")
1987 font_norm_type = ISO_8859_3;
1988 else if (font_norm == "iso8859-4")
1989 font_norm_type = ISO_8859_4;
1990 else if (font_norm == "iso8859-6.8x")
1991 font_norm_type = ISO_8859_6_8;
1992 else if (font_norm == "iso8859-9")
1993 font_norm_type = ISO_8859_9;
1994 else if (font_norm == "iso8859-15")
1995 font_norm_type = ISO_8859_15;
1997 font_norm_type = OTHER_ENCODING;
2001 string const LyXRC::getDescription(LyXRCTags tag)
2006 case RC_FONT_ENCODING:
2007 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2011 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2014 case RC_PRINT_COMMAND:
2015 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2018 case RC_PRINTEVENPAGEFLAG:
2019 str = _("The option to print only even pages.");
2022 case RC_PRINTODDPAGEFLAG:
2023 str = _("The option to print only odd pages.");
2026 case RC_PRINTPAGERANGEFLAG:
2027 str = _("The option for specifying a comma-separated list of pages to print.");
2030 case RC_PRINTCOPIESFLAG:
2031 str = _("The option for specifying the number of copies to print.");
2034 case RC_PRINTCOLLCOPIESFLAG:
2035 str = _("The option for specifying whether the copies should be collated.");
2038 case RC_PRINTREVERSEFLAG:
2039 str = _("The option to reverse the order of the pages printed.");
2042 case RC_PRINTLANDSCAPEFLAG:
2043 str = _("The option to print out in landscape.");
2046 case RC_PRINTPAPERFLAG:
2047 str = _("The option to specify paper type.");
2050 case RC_PRINTPAPERDIMENSIONFLAG:
2051 str = _("Option to specify the dimensions of the print paper.");
2054 case RC_PRINTTOPRINTER:
2055 str = _("Option to pass to the print program to print on a specific printer.");
2058 case RC_PRINT_ADAPTOUTPUT:
2059 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2062 case RC_PRINTTOFILE:
2063 str = _("Option to pass to the print program to print to a file.");
2066 case RC_PRINTFILEEXTENSION:
2067 str = _("Extension of printer program output file. Usually \".ps\".");
2070 case RC_PRINTEXSTRAOPTIONS:
2071 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2074 case RC_PRINTSPOOL_COMMAND:
2075 str = _("When set, this printer option automatically prints to a file and then calls a separate print spooling program on that file with the given name and arguments.");
2078 case RC_PRINTSPOOL_PRINTERPREFIX:
2079 str = _("If you specify a printer name in the print dialog, the following argument is prepended along with the printer name after the spool command.");
2083 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2086 case RC_SCREEN_ZOOM:
2087 //xgettext:no-c-format
2088 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2091 case RC_SCREEN_FONT_SIZES:
2092 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2095 case RC_SCREEN_FONT_ROMAN:
2096 case RC_SCREEN_FONT_SANS:
2097 case RC_SCREEN_FONT_TYPEWRITER:
2098 str = _("The screen fonts used to display the text while editing.");
2101 case RC_POPUP_BOLD_FONT:
2102 str = _("The bold font in the dialogs.");
2105 case RC_POPUP_NORMAL_FONT:
2106 str = _("The normal font in the dialogs.");
2109 case RC_SCREEN_FONT_ENCODING:
2110 str = _("The encoding for the screen fonts.");
2113 case RC_POPUP_FONT_ENCODING:
2114 str = _("The encoding for the menu/popups fonts.");
2121 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2124 case RC_DOCUMENTPATH:
2125 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2128 case RC_TEMPLATEPATH:
2129 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2132 case RC_TEMPDIRPATH:
2133 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2137 str = _("The file where the last-files information should be stored.");
2140 case RC_AUTOREGIONDELETE:
2141 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2144 case RC_AUTORESET_OPTIONS:
2145 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2149 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2153 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2157 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2161 case RC_KBMAP_PRIMARY:
2162 case RC_KBMAP_SECONDARY:
2163 str = _("Use this to set the correct mapping file for your keyboard. You'll need this if you for instance want to type German documents on an American keyboard.");
2166 case RC_ASCIIROFF_COMMAND:
2167 str = _("Use to define an external program to render tables in the ASCII output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"none\" is specified, an internal routine is used.");
2170 case RC_ASCII_LINELEN:
2171 str = _("This is the maximum line length of an exported ASCII file (LaTeX, SGML or plain text).");
2174 case RC_NUMLASTFILES:
2175 str = bformat(_("Maximal number of lastfiles. Up to %1$s can appear in the file menu."), tostr(maxlastfiles));
2178 case RC_CHECKLASTFILES:
2179 str = _("Select to check whether the lastfiles still exist.");
2182 case RC_VIEWDVI_PAPEROPTION:
2183 str = _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2186 case RC_DEFAULT_PAPERSIZE:
2187 str = _("Specify the default paper size.");
2190 case RC_ACCEPT_COMPOUND:
2191 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2194 case RC_SPELL_COMMAND:
2195 str = _("What command runs the spell checker?");
2198 case RC_USE_INP_ENC:
2199 str = _("Specify whether to pass the -T input encoding option to ispell. Enable this if you can't spellcheck words with international letters in them. This may not work with all dictionaries.");
2202 case RC_USE_ALT_LANG:
2204 str = _("Specify an alternate language. The default is to use the language of the document.");
2207 case RC_USE_PERS_DICT:
2209 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2212 case RC_USE_ESC_CHARS:
2214 str = _("Specify additional chars that can be part of a word.");
2217 case RC_SCREEN_FONT_SCALABLE:
2218 str = _("Allow bitmap fonts to be resized. If you are using a bitmap font, selecting this option may make some fonts look blocky in LyX. Deselecting this option makes LyX use the nearest bitmap font size available, instead of scaling.");
2221 case RC_CHKTEX_COMMAND:
2222 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2225 case RC_BIBTEX_COMMAND:
2226 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2229 case RC_INDEX_COMMAND:
2230 str = _("Define the options of makeindex (cf. man makeindex) or select an alternative compiler. E.g., using xindy/make-rules, the command string would be \"makeindex.sh -m $$lang\".");
2233 case RC_CURSOR_FOLLOWS_SCROLLBAR:
2234 str = _("LyX normally doesn't update the cursor position if you move the scrollbar. Set to true if you'd prefer to always have the cursor on screen.");
2237 case RC_DIALOGS_ICONIFY_WITH_MAIN:
2238 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2241 case RC_DISPLAY_GRAPHICS:
2242 str = _("Select how LyX will display any graphics.");
2245 case RC_MAKE_BACKUP:
2246 str = _("De-select if you don't want LyX to create backup files.");
2249 case RC_BACKUPDIR_PATH:
2250 str = _("The path for storing backup files. If it is an empty string, LyX will store the backup file in the same directory as the original file.");
2253 case RC_RTL_SUPPORT:
2254 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2257 case RC_MARK_FOREIGN_LANGUAGE:
2258 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2261 case RC_LANGUAGE_PACKAGE:
2262 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2265 case RC_LANGUAGE_GLOBAL_OPTIONS:
2266 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2269 case RC_LANGUAGE_USE_BABEL:
2270 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2273 case RC_LANGUAGE_AUTO_BEGIN:
2274 str = _("Select if a language switching command is needed at the beginning of the document.");
2277 case RC_LANGUAGE_AUTO_END:
2278 str = _("Select if a language switching command is needed at the end of the document.");
2281 case RC_LANGUAGE_COMMAND_BEGIN:
2282 str = _("The LaTeX command for changing from the language of the document to another language. E.g. \\selectlanguage{$$lang} where $$lang is substituted by the name of the second language.");
2285 case RC_LANGUAGE_COMMAND_END:
2286 str = _("The LaTeX command for changing back to the language of the document.");
2289 case RC_LANGUAGE_COMMAND_LOCAL:
2290 str = _("The LaTeX command for local changing of the language.");
2293 case RC_DATE_INSERT_FORMAT:
2294 //xgettext:no-c-format
2295 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2298 case RC_SHOW_BANNER:
2299 str = _("De-select if you don't want the startup banner.");
2303 str = _("The number of lines that are scrolled by mice with wheels or five button mice.");
2315 case RC_DEFAULT_LANGUAGE:
2316 str = _("New documents will be assigned this language.");
2319 case RC_LABEL_INIT_LENGTH:
2320 str = _("Maximum number of words in the initialization string for a new label");
2324 str = _("Shows a typeset preview of things such as math");
2327 case RC_PREVIEW_HASHED_LABELS:
2328 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2331 case RC_PREVIEW_SCALE_FACTOR:
2332 str = _("Scale the preview size to suit.");
2342 // The global instance
2345 // The global copy of the system lyxrc entries (everything except preferences)