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.getString();
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 " << convert<string>(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 "
1227 << convert<string>(auto_reset_options)
1231 if (ignore_system_lyxrc ||
1232 autosave != system_lyxrc.autosave) {
1233 os << "# The time interval between auto-saves in seconds.\n"
1234 << "\\autosave " << autosave << '\n';
1236 case RC_DISPLAY_GRAPHICS:
1237 if (ignore_system_lyxrc ||
1238 display_graphics != system_lyxrc.display_graphics) {
1239 os << "# Display graphics within LyX\n"
1240 << "# monochrome|grayscale|color|none\n"
1241 << "\\display_graphics "
1242 << lyx::graphics::displayTranslator().find(display_graphics)
1246 case RC_VIEWDVI_PAPEROPTION:
1247 if (ignore_system_lyxrc ||
1248 view_dvi_paper_option
1249 != system_lyxrc.view_dvi_paper_option) {
1250 os << "# Options used to specify paper size to the\n"
1251 << "# view_dvi_command (e.g. -paper)\n"
1252 << "\\view_dvi_paper_option \""
1253 << view_dvi_paper_option << "\"\n";
1255 case RC_DEFAULT_PAPERSIZE:
1256 if (ignore_system_lyxrc ||
1257 default_papersize != system_lyxrc.default_papersize) {
1258 os << "# The default papersize to use.\n"
1259 << "\\default_papersize \"";
1260 switch (default_papersize) {
1261 case PAPER_USLETTER:
1262 os << "usletter"; break;
1263 case PAPER_LEGALPAPER:
1264 os << "legal"; break;
1265 case PAPER_EXECUTIVEPAPER:
1266 os << "executive"; break;
1275 case PAPER_DEFAULT: break;
1279 case RC_CHKTEX_COMMAND:
1280 if (ignore_system_lyxrc ||
1281 chktex_command != system_lyxrc.chktex_command) {
1282 os << "\\chktex_command \"" << chktex_command << "\"\n";
1284 case RC_BIBTEX_COMMAND:
1285 if (ignore_system_lyxrc ||
1286 bibtex_command != system_lyxrc.bibtex_command) {
1287 os << "\\bibtex_command \"" << bibtex_command << "\"\n";
1289 case RC_INDEX_COMMAND:
1290 if (ignore_system_lyxrc ||
1291 index_command != system_lyxrc.index_command) {
1292 os << "\\index_command \"" << index_command << "\"\n";
1295 if (ignore_system_lyxrc ||
1296 use_kbmap != system_lyxrc.use_kbmap) {
1297 os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1299 case RC_KBMAP_PRIMARY:
1300 if (ignore_system_lyxrc ||
1301 primary_kbmap != system_lyxrc.primary_kbmap) {
1302 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1304 case RC_KBMAP_SECONDARY:
1305 if (ignore_system_lyxrc ||
1306 secondary_kbmap != system_lyxrc.secondary_kbmap) {
1307 os << "\\kbmap_secondary \"" << secondary_kbmap
1311 if (ignore_system_lyxrc ||
1312 lyxpipes != system_lyxrc.lyxpipes) {
1313 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1315 case RC_DATE_INSERT_FORMAT:
1316 if (ignore_system_lyxrc ||
1317 date_insert_format != system_lyxrc.date_insert_format) {
1318 os << "\\date_insert_format \"" << date_insert_format
1321 case RC_LABEL_INIT_LENGTH:
1322 if (ignore_system_lyxrc ||
1323 label_init_length != system_lyxrc.label_init_length) {
1324 os << "\\label_init_length " << label_init_length
1329 os << "\\user_name \"" << user_name << "\"\n";
1332 os << "\\user_email \"" << user_email << "\"\n";
1334 case RC_SHOW_BANNER:
1335 if (ignore_system_lyxrc ||
1336 show_banner != system_lyxrc.show_banner) {
1337 os << "\\show_banner " << convert<string>(show_banner) << '\n';
1341 if (ignore_system_lyxrc ||
1342 preview != system_lyxrc.preview) {
1348 case PREVIEW_NO_MATH:
1355 os << "\\preview " << status << '\n';
1358 case RC_PREVIEW_HASHED_LABELS:
1359 if (ignore_system_lyxrc ||
1360 preview_hashed_labels !=
1361 system_lyxrc.preview_hashed_labels) {
1362 os << "\\preview_hashed_labels "
1363 << convert<string>(preview_hashed_labels) << '\n';
1366 case RC_PREVIEW_SCALE_FACTOR:
1367 if (ignore_system_lyxrc ||
1368 preview_scale_factor != system_lyxrc.preview_scale_factor) {
1369 os << "\\preview_scale_factor "
1370 << preview_scale_factor << '\n';
1374 << "# SCREEN & FONTS SECTION ############################\n"
1377 case RC_POPUP_NORMAL_FONT:
1378 if (ignore_system_lyxrc ||
1379 popup_normal_font != system_lyxrc.popup_normal_font) {
1380 os << "\\popup_normal_font \"" << popup_normal_font
1383 case RC_POPUP_BOLD_FONT:
1384 if (ignore_system_lyxrc ||
1385 popup_bold_font != system_lyxrc.popup_bold_font) {
1386 os << "\\popup_bold_font \"" << popup_bold_font
1389 case RC_POPUP_FONT_ENCODING:
1390 if (ignore_system_lyxrc ||
1391 popup_font_encoding != system_lyxrc.popup_font_encoding) {
1392 os << "\\popup_font_encoding \"" << popup_font_encoding
1396 if (ignore_system_lyxrc ||
1397 dpi != system_lyxrc.dpi) {
1398 os << "\\screen_dpi " << dpi << '\n';
1400 case RC_SCREEN_ZOOM:
1401 if (ignore_system_lyxrc ||
1402 zoom != system_lyxrc.zoom) {
1403 os << "\\screen_zoom " << zoom << '\n';
1406 if (ignore_system_lyxrc ||
1407 wheel_jump != system_lyxrc.wheel_jump) {
1408 os << "\\wheel_jump " << wheel_jump << '\n';
1410 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1411 if (ignore_system_lyxrc ||
1412 cursor_follows_scrollbar
1413 != system_lyxrc.cursor_follows_scrollbar) {
1414 os << "\\cursor_follows_scrollbar "
1415 << convert<string>(cursor_follows_scrollbar) << '\n';
1417 case RC_DIALOGS_ICONIFY_WITH_MAIN:
1418 if (ignore_system_lyxrc ||
1419 dialogs_iconify_with_main
1420 != system_lyxrc.dialogs_iconify_with_main) {
1421 os << "\\dialogs_iconify_with_main "
1422 << convert<string>(dialogs_iconify_with_main) << '\n';
1424 case RC_SCREEN_FONT_ROMAN:
1425 if (ignore_system_lyxrc ||
1426 roman_font_name != system_lyxrc.roman_font_name) {
1427 os << "\\screen_font_roman \"" << roman_font_name
1430 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1431 if (ignore_system_lyxrc ||
1432 roman_font_foundry != system_lyxrc.roman_font_foundry) {
1433 os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1436 case RC_SCREEN_FONT_SANS:
1437 if (ignore_system_lyxrc ||
1438 sans_font_name != system_lyxrc.sans_font_name) {
1439 os << "\\screen_font_sans \"" << sans_font_name
1442 case RC_SCREEN_FONT_SANS_FOUNDRY:
1443 if (ignore_system_lyxrc ||
1444 sans_font_foundry != system_lyxrc.sans_font_foundry) {
1445 os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1448 case RC_SCREEN_FONT_TYPEWRITER:
1449 if (ignore_system_lyxrc ||
1450 typewriter_font_name != system_lyxrc.typewriter_font_name) {
1451 os << "\\screen_font_typewriter \""
1452 << typewriter_font_name << "\"\n";
1454 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1455 if (ignore_system_lyxrc ||
1456 typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1457 os << "\\screen_font_typewriter_foundry \""
1458 << typewriter_font_foundry << "\"\n";
1461 case RC_SCREEN_FONT_SCALABLE:
1462 if (ignore_system_lyxrc ||
1463 use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1464 os << "\\screen_font_scalable "
1465 << convert<string>(use_scalable_fonts)
1468 case RC_SCREEN_FONT_ENCODING:
1469 if (ignore_system_lyxrc ||
1470 font_norm != system_lyxrc.font_norm) {
1471 os << "\\screen_font_encoding \"" << font_norm
1474 case RC_SCREEN_FONT_SIZES:
1475 if (ignore_system_lyxrc ||
1476 font_sizes[LyXFont::SIZE_TINY]
1477 != system_lyxrc.font_sizes[LyXFont::SIZE_TINY] ||
1478 font_sizes[LyXFont::SIZE_SCRIPT]
1479 != system_lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] ||
1480 font_sizes[LyXFont::SIZE_FOOTNOTE]
1481 != system_lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] ||
1482 font_sizes[LyXFont::SIZE_SMALL]
1483 != system_lyxrc.font_sizes[LyXFont::SIZE_SMALL] ||
1484 font_sizes[LyXFont::SIZE_NORMAL]
1485 != system_lyxrc.font_sizes[LyXFont::SIZE_NORMAL] ||
1486 font_sizes[LyXFont::SIZE_LARGE]
1487 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGE] ||
1488 font_sizes[LyXFont::SIZE_LARGER]
1489 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGER] ||
1490 font_sizes[LyXFont::SIZE_LARGEST]
1491 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGEST] ||
1492 font_sizes[LyXFont::SIZE_HUGE]
1493 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGE] ||
1494 font_sizes[LyXFont::SIZE_HUGER]
1495 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGER]) {
1496 os.setf(ios::fixed);
1498 os << "\\screen_font_sizes"
1499 << ' ' << font_sizes[LyXFont::SIZE_TINY]
1500 << ' ' << font_sizes[LyXFont::SIZE_SCRIPT]
1501 << ' ' << font_sizes[LyXFont::SIZE_FOOTNOTE]
1502 << ' ' << font_sizes[LyXFont::SIZE_SMALL]
1503 << ' ' << font_sizes[LyXFont::SIZE_NORMAL]
1504 << ' ' << font_sizes[LyXFont::SIZE_LARGE]
1505 << ' ' << font_sizes[LyXFont::SIZE_LARGER]
1506 << ' ' << font_sizes[LyXFont::SIZE_LARGEST]
1507 << ' ' << font_sizes[LyXFont::SIZE_HUGE]
1508 << ' ' << font_sizes[LyXFont::SIZE_HUGER]
1513 << "# COLOR SECTION ###################################\n"
1517 for (int i = 0; i < LColor::ignore; ++i) {
1518 LColor::color lc = static_cast<LColor::color>(i);
1520 string const col(lcolor.getX11Name(lc));
1521 if (ignore_system_lyxrc ||
1522 col != system_lcolor.getX11Name(lc)) {
1523 os << "\\set_color \""
1524 << lcolor.getLyXName(lc) << "\" \""
1530 << "# PRINTER SECTION ###################################\n"
1534 if (ignore_system_lyxrc ||
1535 printer != system_lyxrc.printer) {
1536 os << "\\printer \"" << printer << "\"\n";
1538 case RC_PRINT_ADAPTOUTPUT:
1539 if (ignore_system_lyxrc ||
1540 print_adapt_output != system_lyxrc.print_adapt_output) {
1541 os << "\\print_adapt_output "
1542 << convert<string>(print_adapt_output)
1545 case RC_PRINT_COMMAND:
1546 if (ignore_system_lyxrc ||
1547 print_command != system_lyxrc.print_command) {
1548 os << "\\print_command \"" << print_command << "\"\n";
1550 case RC_PRINTEXSTRAOPTIONS:
1551 if (ignore_system_lyxrc ||
1552 print_extra_options != system_lyxrc.print_extra_options) {
1553 os << "\\print_extra_options \"" << print_extra_options
1556 case RC_PRINTSPOOL_COMMAND:
1557 if (ignore_system_lyxrc ||
1558 print_spool_command != system_lyxrc.print_spool_command) {
1559 os << "\\print_spool_command \"" << print_spool_command
1562 case RC_PRINTSPOOL_PRINTERPREFIX:
1563 if (ignore_system_lyxrc ||
1564 print_spool_printerprefix
1565 != system_lyxrc.print_spool_printerprefix) {
1566 os << "\\print_spool_printerprefix \""
1567 << print_spool_printerprefix << "\"\n";
1569 case RC_PRINTEVENPAGEFLAG:
1570 if (ignore_system_lyxrc ||
1571 print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1572 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1575 case RC_PRINTODDPAGEFLAG:
1576 if (ignore_system_lyxrc ||
1577 print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1578 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1581 case RC_PRINTREVERSEFLAG:
1582 if (ignore_system_lyxrc ||
1583 print_reverse_flag != system_lyxrc.print_reverse_flag) {
1584 os << "\\print_reverse_flag \"" << print_reverse_flag
1587 case RC_PRINTLANDSCAPEFLAG:
1588 if (ignore_system_lyxrc ||
1589 print_landscape_flag != system_lyxrc.print_landscape_flag) {
1590 os << "\\print_landscape_flag \"" << print_landscape_flag
1593 case RC_PRINTPAGERANGEFLAG:
1594 if (ignore_system_lyxrc ||
1595 print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1596 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1599 case RC_PRINTCOPIESFLAG:
1600 if (ignore_system_lyxrc ||
1601 print_copies_flag != system_lyxrc.print_copies_flag) {
1602 os << "\\print_copies_flag \"" << print_copies_flag
1605 case RC_PRINTCOLLCOPIESFLAG:
1606 if (ignore_system_lyxrc ||
1607 print_collcopies_flag
1608 != system_lyxrc.print_collcopies_flag) {
1609 os << "\\print_collcopies_flag \""
1610 << print_collcopies_flag
1613 case RC_PRINTPAPERFLAG:
1614 if (ignore_system_lyxrc ||
1615 print_paper_flag != system_lyxrc.print_paper_flag) {
1616 os << "\\print_paper_flag \"" << print_paper_flag
1619 case RC_PRINTPAPERDIMENSIONFLAG:
1620 if (ignore_system_lyxrc ||
1621 print_paper_dimension_flag
1622 != system_lyxrc.print_paper_dimension_flag) {
1623 os << "\\print_paper_dimension_flag \""
1624 << print_paper_dimension_flag << "\"\n";
1626 case RC_PRINTTOPRINTER:
1627 if (ignore_system_lyxrc ||
1628 print_to_printer != system_lyxrc.print_to_printer) {
1629 os << "\\print_to_printer \"" << print_to_printer
1632 case RC_PRINTTOFILE:
1633 if (ignore_system_lyxrc ||
1634 print_to_file != system_lyxrc.print_to_file) {
1635 os << "\\print_to_file \"" << print_to_file << "\"\n";
1637 case RC_PRINTFILEEXTENSION:
1638 if (ignore_system_lyxrc ||
1639 print_file_extension != system_lyxrc.print_file_extension) {
1640 os << "\\print_file_extension \""
1641 << print_file_extension
1646 << "# EXPORT SECTION ####################################\n"
1649 case RC_CUSTOM_EXPORT_COMMAND:
1650 if (ignore_system_lyxrc ||
1651 custom_export_command
1652 != system_lyxrc.custom_export_command) {
1653 os << "\\custom_export_command \""
1654 << custom_export_command
1657 case RC_CUSTOM_EXPORT_FORMAT:
1658 if (ignore_system_lyxrc ||
1659 custom_export_format
1660 != system_lyxrc.custom_export_format) {
1661 os << "\\custom_export_format \"" << custom_export_format
1666 << "# TEX SECTION #######################################\n"
1669 case RC_FONT_ENCODING:
1670 if (ignore_system_lyxrc ||
1671 fontenc != system_lyxrc.fontenc) {
1672 os << "\\font_encoding \"" << fontenc << "\"\n";
1676 << "# FILE SECTION ######################################\n"
1679 case RC_DOCUMENTPATH:
1680 if (ignore_system_lyxrc ||
1681 document_path != system_lyxrc.document_path) {
1682 os << "\\document_path \"" << document_path << "\"\n";
1685 if (ignore_system_lyxrc ||
1686 lastfiles != system_lyxrc.lastfiles) {
1687 os << "\\lastfiles \"" << lastfiles << "\"\n";
1689 case RC_NUMLASTFILES:
1690 if (ignore_system_lyxrc ||
1691 num_lastfiles != system_lyxrc.num_lastfiles) {
1692 os << "\\num_lastfiles " << num_lastfiles << '\n';
1694 case RC_CHECKLASTFILES:
1695 if (ignore_system_lyxrc ||
1696 check_lastfiles != system_lyxrc.check_lastfiles) {
1697 os << "\\check_lastfiles " << convert<string>(check_lastfiles)
1700 case RC_TEMPLATEPATH:
1701 if (ignore_system_lyxrc ||
1702 template_path != system_lyxrc.template_path) {
1703 os << "\\template_path \"" << template_path << "\"\n";
1705 case RC_TEMPDIRPATH:
1706 if (ignore_system_lyxrc ||
1707 tempdir_path != system_lyxrc.tempdir_path) {
1708 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1712 case RC_ASCII_LINELEN:
1713 if (ignore_system_lyxrc ||
1714 ascii_linelen != system_lyxrc.ascii_linelen) {
1715 os << "\\ascii_linelen " << ascii_linelen << '\n';
1717 case RC_MAKE_BACKUP:
1718 if (ignore_system_lyxrc ||
1719 make_backup != system_lyxrc.make_backup) {
1720 os << "\\make_backup " << convert<string>(make_backup) << '\n';
1722 case RC_BACKUPDIR_PATH:
1723 if (ignore_system_lyxrc ||
1724 backupdir_path != system_lyxrc.backupdir_path) {
1725 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1729 << "# ASCII EXPORT SECTION ##############################\n"
1732 case RC_ASCIIROFF_COMMAND:
1733 if (ignore_system_lyxrc ||
1734 ascii_roff_command != system_lyxrc.ascii_roff_command) {
1735 os << "\\ascii_roff_command \"" << ascii_roff_command
1740 << "# SPELLCHECKER SECTION ##############################\n"
1742 case RC_USE_SPELL_LIB:
1743 if (ignore_system_lyxrc ||
1744 use_spell_lib != system_lyxrc.use_spell_lib) {
1745 os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
1747 case RC_SPELL_COMMAND:
1748 if (ignore_system_lyxrc ||
1749 isp_command != system_lyxrc.isp_command) {
1750 os << "\\spell_command \"" << isp_command << "\"\n";
1752 case RC_ACCEPT_COMPOUND:
1753 if (ignore_system_lyxrc ||
1754 isp_accept_compound != system_lyxrc.isp_accept_compound) {
1755 os << "\\accept_compound " << convert<string>(isp_accept_compound)
1758 case RC_USE_ALT_LANG:
1759 if (ignore_system_lyxrc ||
1760 isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
1761 os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
1765 if (ignore_system_lyxrc ||
1766 isp_alt_lang != system_lyxrc.isp_alt_lang) {
1767 os << "\\alternate_language \"" << isp_alt_lang
1770 case RC_USE_ESC_CHARS:
1771 if (ignore_system_lyxrc ||
1772 isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
1773 os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
1777 if (ignore_system_lyxrc ||
1778 isp_esc_chars != system_lyxrc.isp_esc_chars) {
1779 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1781 case RC_USE_PERS_DICT:
1782 if (ignore_system_lyxrc ||
1783 isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
1784 os << "\\use_personal_dictionary "
1785 << convert<string>(isp_use_pers_dict)
1789 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
1790 os << "\\personal_dictionary \"" << isp_pers_dict
1793 case RC_USE_INP_ENC:
1794 if (ignore_system_lyxrc ||
1795 isp_use_input_encoding
1796 != system_lyxrc.isp_use_input_encoding) {
1797 os << "\\use_input_encoding "
1798 << convert<string>(isp_use_input_encoding)
1803 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1806 case RC_RTL_SUPPORT:
1807 if (ignore_system_lyxrc ||
1808 rtl_support != system_lyxrc.rtl_support) {
1809 os << "\\rtl " << convert<string>(rtl_support) << '\n';
1811 case RC_LANGUAGE_PACKAGE:
1812 if (ignore_system_lyxrc ||
1813 language_package != system_lyxrc.language_package) {
1814 os << "\\language_package \"" << language_package
1817 case RC_LANGUAGE_GLOBAL_OPTIONS:
1818 if (ignore_system_lyxrc ||
1819 language_global_options
1820 != system_lyxrc.language_global_options) {
1821 os << "\\language_global_options \""
1822 << convert<string>(language_global_options)
1825 case RC_LANGUAGE_USE_BABEL:
1826 if (ignore_system_lyxrc ||
1827 language_use_babel != system_lyxrc.language_use_babel) {
1828 os << "\\language_use_babel \""
1829 << convert<string>(language_use_babel)
1832 case RC_LANGUAGE_COMMAND_BEGIN:
1833 if (ignore_system_lyxrc ||
1834 language_command_begin
1835 != system_lyxrc.language_command_begin) {
1836 os << "\\language_command_begin \""
1837 << language_command_begin
1840 case RC_LANGUAGE_COMMAND_END:
1841 if (ignore_system_lyxrc ||
1842 language_command_end
1843 != system_lyxrc.language_command_end) {
1844 os << "\\language_command_end \"" << language_command_end
1847 case RC_LANGUAGE_COMMAND_LOCAL:
1848 if (ignore_system_lyxrc ||
1849 language_command_local
1850 != system_lyxrc.language_command_local) {
1851 os << "\\language_command_local \""
1852 << language_command_local
1855 case RC_LANGUAGE_AUTO_BEGIN:
1856 if (ignore_system_lyxrc ||
1857 language_auto_begin != system_lyxrc.language_auto_begin) {
1858 os << "\\language_auto_begin "
1859 << convert<string>(language_auto_begin) << '\n';
1861 case RC_LANGUAGE_AUTO_END:
1862 if (ignore_system_lyxrc ||
1863 language_auto_end != system_lyxrc.language_auto_end) {
1864 os << "\\language_auto_end "
1865 << convert<string>(language_auto_end) << '\n';
1867 case RC_MARK_FOREIGN_LANGUAGE:
1868 if (ignore_system_lyxrc ||
1869 mark_foreign_language
1870 != system_lyxrc.mark_foreign_language) {
1871 os << "\\mark_foreign_language " <<
1872 convert<string>(mark_foreign_language) << '\n';
1876 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1879 case RC_AUTO_NUMBER:
1880 if (ignore_system_lyxrc ||
1881 auto_number != system_lyxrc.auto_number) {
1882 os << "\\auto_number " << convert<string>(auto_number) << '\n';
1884 case RC_DEFAULT_LANGUAGE:
1885 if (ignore_system_lyxrc ||
1886 default_language != system_lyxrc.default_language) {
1887 os << "\\default_language " << default_language << '\n';
1891 << "# FORMATS SECTION ##########################\n"
1895 // New/modifed formats
1896 for (Formats::const_iterator cit = formats.begin();
1897 cit != formats.end(); ++cit) {
1898 Format const * format =
1899 system_formats.getFormat(cit->name());
1901 format->extension() != cit->extension() ||
1902 format->prettyname() != cit->prettyname() ||
1903 format->shortcut() != cit->shortcut() ||
1904 format->viewer() != cit->viewer() ||
1905 format->editor() != cit->editor())
1906 os << "\\format \"" << cit->name() << "\" \""
1907 << cit->extension() << "\" \""
1908 << cit->prettyname() << "\" \""
1909 << cit->shortcut() << "\" \""
1910 << cit->viewer() << "\" \""
1911 << cit->editor() << "\"\n";
1914 // Look for deleted formats
1915 for (Formats::const_iterator cit = system_formats.begin();
1916 cit != system_formats.end(); ++cit)
1917 if (!formats.getFormat(cit->name()))
1918 os << "\\format \"" << cit->name()
1919 << "\" \"\" \"\" \"\" \"\" \"\"\n";
1924 << "# CONVERTERS SECTION ##########################\n"
1928 // Look for new converters
1929 for (Converters::const_iterator cit = converters.begin();
1930 cit != converters.end(); ++cit) {
1931 Converter const * converter =
1932 system_converters.getConverter(cit->from,
1935 converter->command != cit->command ||
1936 converter->flags != cit->flags)
1937 os << "\\converter \"" << cit->from << "\" \""
1938 << cit->to << "\" \""
1939 << cit->command << "\" \""
1940 << cit->flags << "\"\n";
1943 // New/modifed converters
1944 for (Converters::const_iterator cit = system_converters.begin();
1945 cit != system_converters.end(); ++cit)
1946 if (!converters.getConverter(cit->from, cit->to))
1947 os << "\\converter \"" << cit->from
1948 << "\" \"" << cit->to << "\" \"\" \"\"\n";
1952 << "# COPIERS SECTION ##########################\n"
1955 // Look for new movers
1956 Movers::iterator const sysbegin = system_movers.begin();
1957 Movers::iterator const sysend = system_movers.end();
1959 for (Movers::iterator it = movers.begin(), end = movers.end();
1961 Movers::iterator const sysit =
1962 std::find_if(sysbegin, sysend, SameMover(*it));
1963 if (sysit == sysend) {
1964 std::string const & fmt = it->first;
1965 std::string const & command =
1966 it->second.command();
1968 os << "\\copier " << fmt
1969 << " \"" << command << "\"\n";
1973 // We don't actually delete SpecialisedMover(s) from the
1974 // map, just clear their 'command', so there's no need
1975 // to test for anything else.
1981 void LyXRC::set_font_norm_type()
1983 if (font_norm == "iso10646-1")
1984 font_norm_type = ISO_10646_1;
1985 else if (font_norm == "iso8859-1")
1986 font_norm_type = ISO_8859_1;
1987 else if (font_norm == "iso8859-3")
1988 font_norm_type = ISO_8859_3;
1989 else if (font_norm == "iso8859-4")
1990 font_norm_type = ISO_8859_4;
1991 else if (font_norm == "iso8859-6.8x")
1992 font_norm_type = ISO_8859_6_8;
1993 else if (font_norm == "iso8859-9")
1994 font_norm_type = ISO_8859_9;
1995 else if (font_norm == "iso8859-15")
1996 font_norm_type = ISO_8859_15;
1998 font_norm_type = OTHER_ENCODING;
2002 string const LyXRC::getDescription(LyXRCTags tag)
2007 case RC_FONT_ENCODING:
2008 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2012 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2015 case RC_PRINT_COMMAND:
2016 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2019 case RC_PRINTEVENPAGEFLAG:
2020 str = _("The option to print only even pages.");
2023 case RC_PRINTODDPAGEFLAG:
2024 str = _("The option to print only odd pages.");
2027 case RC_PRINTPAGERANGEFLAG:
2028 str = _("The option for specifying a comma-separated list of pages to print.");
2031 case RC_PRINTCOPIESFLAG:
2032 str = _("The option for specifying the number of copies to print.");
2035 case RC_PRINTCOLLCOPIESFLAG:
2036 str = _("The option for specifying whether the copies should be collated.");
2039 case RC_PRINTREVERSEFLAG:
2040 str = _("The option to reverse the order of the pages printed.");
2043 case RC_PRINTLANDSCAPEFLAG:
2044 str = _("The option to print out in landscape.");
2047 case RC_PRINTPAPERFLAG:
2048 str = _("The option to specify paper type.");
2051 case RC_PRINTPAPERDIMENSIONFLAG:
2052 str = _("Option to specify the dimensions of the print paper.");
2055 case RC_PRINTTOPRINTER:
2056 str = _("Option to pass to the print program to print on a specific printer.");
2059 case RC_PRINT_ADAPTOUTPUT:
2060 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2063 case RC_PRINTTOFILE:
2064 str = _("Option to pass to the print program to print to a file.");
2067 case RC_PRINTFILEEXTENSION:
2068 str = _("Extension of printer program output file. Usually \".ps\".");
2071 case RC_PRINTEXSTRAOPTIONS:
2072 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2075 case RC_PRINTSPOOL_COMMAND:
2076 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.");
2079 case RC_PRINTSPOOL_PRINTERPREFIX:
2080 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.");
2084 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2087 case RC_SCREEN_ZOOM:
2088 //xgettext:no-c-format
2089 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2092 case RC_SCREEN_FONT_SIZES:
2093 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2096 case RC_SCREEN_FONT_ROMAN:
2097 case RC_SCREEN_FONT_SANS:
2098 case RC_SCREEN_FONT_TYPEWRITER:
2099 str = _("The screen fonts used to display the text while editing.");
2102 case RC_POPUP_BOLD_FONT:
2103 str = _("The bold font in the dialogs.");
2106 case RC_POPUP_NORMAL_FONT:
2107 str = _("The normal font in the dialogs.");
2110 case RC_SCREEN_FONT_ENCODING:
2111 str = _("The encoding for the screen fonts.");
2114 case RC_POPUP_FONT_ENCODING:
2115 str = _("The encoding for the menu/popups fonts.");
2122 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2125 case RC_DOCUMENTPATH:
2126 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2129 case RC_TEMPLATEPATH:
2130 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2133 case RC_TEMPDIRPATH:
2134 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2138 str = _("The file where the last-files information should be stored.");
2141 case RC_AUTOREGIONDELETE:
2142 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2145 case RC_AUTORESET_OPTIONS:
2146 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2150 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2154 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2158 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2162 case RC_KBMAP_PRIMARY:
2163 case RC_KBMAP_SECONDARY:
2164 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.");
2167 case RC_ASCIIROFF_COMMAND:
2168 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.");
2171 case RC_ASCII_LINELEN:
2172 str = _("This is the maximum line length of an exported ASCII file (LaTeX, SGML or plain text).");
2175 case RC_NUMLASTFILES:
2176 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."), maxlastfiles);
2179 case RC_CHECKLASTFILES:
2180 str = _("Select to check whether the lastfiles still exist.");
2183 case RC_VIEWDVI_PAPEROPTION:
2184 str = _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2187 case RC_DEFAULT_PAPERSIZE:
2188 str = _("Specify the default paper size.");
2191 case RC_ACCEPT_COMPOUND:
2192 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2195 case RC_SPELL_COMMAND:
2196 str = _("What command runs the spell checker?");
2199 case RC_USE_INP_ENC:
2200 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.");
2203 case RC_USE_ALT_LANG:
2205 str = _("Specify an alternate language. The default is to use the language of the document.");
2208 case RC_USE_PERS_DICT:
2210 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2213 case RC_USE_ESC_CHARS:
2215 str = _("Specify additional chars that can be part of a word.");
2218 case RC_SCREEN_FONT_SCALABLE:
2219 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.");
2222 case RC_CHKTEX_COMMAND:
2223 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2226 case RC_BIBTEX_COMMAND:
2227 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2230 case RC_INDEX_COMMAND:
2231 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\".");
2234 case RC_CURSOR_FOLLOWS_SCROLLBAR:
2235 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.");
2238 case RC_DIALOGS_ICONIFY_WITH_MAIN:
2239 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2242 case RC_DISPLAY_GRAPHICS:
2243 str = _("Select how LyX will display any graphics.");
2246 case RC_MAKE_BACKUP:
2247 str = _("De-select if you don't want LyX to create backup files.");
2250 case RC_BACKUPDIR_PATH:
2251 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.");
2254 case RC_RTL_SUPPORT:
2255 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2258 case RC_MARK_FOREIGN_LANGUAGE:
2259 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2262 case RC_LANGUAGE_PACKAGE:
2263 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2266 case RC_LANGUAGE_GLOBAL_OPTIONS:
2267 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2270 case RC_LANGUAGE_USE_BABEL:
2271 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2274 case RC_LANGUAGE_AUTO_BEGIN:
2275 str = _("Select if a language switching command is needed at the beginning of the document.");
2278 case RC_LANGUAGE_AUTO_END:
2279 str = _("Select if a language switching command is needed at the end of the document.");
2282 case RC_LANGUAGE_COMMAND_BEGIN:
2283 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.");
2286 case RC_LANGUAGE_COMMAND_END:
2287 str = _("The LaTeX command for changing back to the language of the document.");
2290 case RC_LANGUAGE_COMMAND_LOCAL:
2291 str = _("The LaTeX command for local changing of the language.");
2294 case RC_DATE_INSERT_FORMAT:
2295 //xgettext:no-c-format
2296 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2299 case RC_SHOW_BANNER:
2300 str = _("De-select if you don't want the startup banner.");
2304 str = _("The number of lines that are scrolled by mice with wheels or five button mice.");
2316 case RC_DEFAULT_LANGUAGE:
2317 str = _("New documents will be assigned this language.");
2320 case RC_LABEL_INIT_LENGTH:
2321 str = _("Maximum number of words in the initialization string for a new label");
2325 str = _("Shows a typeset preview of things such as math");
2328 case RC_PREVIEW_HASHED_LABELS:
2329 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2332 case RC_PREVIEW_SCALE_FACTOR:
2333 str = _("Scale the preview size to suit.");
2343 // The global instance
2346 // The global copy of the system lyxrc entries (everything except preferences)