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"
34 #include "graphics/GraphicsTypes.h"
36 #include "support/convert.h"
37 #include "support/environment.h"
38 #include "support/filetools.h"
39 #include "support/lstrings.h"
40 #include "support/os.h"
41 #include "support/userinfo.h"
46 namespace os = support::os;
48 using support::ascii_lowercase;
49 using support::bformat;
50 using support::expandPath;
51 using support::FileName;
52 using support::getEnv;
53 using support::libFileSearch;
67 // when adding something to this array keep it sorted!
68 keyword_item lyxrcTags[] = {
69 { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
70 { "\\alternate_language", LyXRC::RC_ALT_LANG },
71 { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
72 { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
73 { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
74 { "\\autosave", LyXRC::RC_AUTOSAVE },
75 { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
76 { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
77 { "\\bind_file", LyXRC::RC_BINDFILE },
78 { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
79 { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
80 { "\\converter", LyXRC::RC_CONVERTER },
81 { "\\converter_cache_maxage", LyXRC::RC_CONVERTER_CACHE_MAXAGE },
82 { "\\copier", LyXRC::RC_COPIER },
83 { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
84 { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
85 { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
86 { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
87 { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
88 { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
89 { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
90 { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
91 { "\\document_path", LyXRC::RC_DOCUMENTPATH },
92 { "\\escape_chars", LyXRC::RC_ESC_CHARS },
93 { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
94 { "\\format", LyXRC::RC_FORMAT },
95 { "\\index_command", LyXRC::RC_INDEX_COMMAND },
96 { "\\input", LyXRC::RC_INPUT },
97 { "\\kbmap", LyXRC::RC_KBMAP },
98 { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
99 { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
100 { "\\label_init_length", LyXRC::RC_LABEL_INIT_LENGTH },
101 { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
102 { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
103 { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
104 { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
105 { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
106 { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
107 { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
108 { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
109 { "\\load_session", LyXRC::RC_LOADSESSION },
110 { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
111 { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
112 { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
113 { "\\path_prefix", LyXRC::RC_PATH_PREFIX },
114 { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
115 { "\\plaintext_linelen", LyXRC::RC_PLAINTEXT_LINELEN },
116 { "\\plaintext_roff_command", LyXRC::RC_PLAINTEXT_ROFF_COMMAND },
117 { "\\preview", LyXRC::RC_PREVIEW },
118 { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
119 { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
120 { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
121 { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
122 { "\\print_command", LyXRC::RC_PRINT_COMMAND },
123 { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
124 { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
125 { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
126 { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
127 { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
128 { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
129 { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
130 { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
131 { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
132 { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
133 { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
134 { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
135 { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
136 { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
137 { "\\printer", LyXRC::RC_PRINTER },
138 { "\\rtl", LyXRC::RC_RTL_SUPPORT },
139 { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
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_geometry_height", LyXRC::RC_SCREEN_GEOMETRY_HEIGHT },
149 { "\\screen_geometry_width", LyXRC::RC_SCREEN_GEOMETRY_WIDTH },
150 { "\\screen_geometry_xysaved", LyXRC::RC_SCREEN_GEOMETRY_XYSAVED },
151 { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
152 { "\\serverpipe", LyXRC::RC_SERVERPIPE },
153 { "\\set_color", LyXRC::RC_SET_COLOR },
154 { "\\show_banner", LyXRC::RC_SHOW_BANNER },
155 { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
156 { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
157 { "\\template_path", LyXRC::RC_TEMPLATEPATH },
158 { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
159 { "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS },
160 { "\\ui_file", LyXRC::RC_UIFILE },
161 { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
162 { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
163 { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
164 { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
165 { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
166 { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
167 // compatibility with versions older than 1.4.0 only
168 { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
169 { "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB },
170 // compatibility with versions older than 1.4.0 only
171 { "\\use_tempdir", LyXRC::RC_USETEMPDIR },
172 { "\\user_email", LyXRC::RC_USER_EMAIL },
173 { "\\user_name", LyXRC::RC_USER_NAME },
174 { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
175 // compatibility with versions older than 1.4.0 only
176 { "\\viewer" ,LyXRC::RC_VIEWER}
179 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
190 void LyXRC::setDefaults() {
193 // Get printer from the environment. If fail, use default "",
194 // assuming that everything is set up correctly.
195 printer = getEnv("PRINTER");
196 print_adapt_output = false;
197 print_command = "dvips";
198 print_evenpage_flag = "-B";
199 print_oddpage_flag = "-A";
200 print_pagerange_flag = "-pp";
201 print_copies_flag = "-c";
202 print_collcopies_flag = "-C";
203 print_reverse_flag = "-r";
204 print_landscape_flag = "-t landscape";
205 print_to_printer = "-P";
206 print_to_file = "-o ";
207 print_file_extension = ".ps";
208 print_paper_flag = "-t";
209 print_paper_dimension_flag = "-T";
210 document_path.erase();
211 view_dvi_paper_option.erase();
212 default_papersize = PAPER_DEFAULT;
213 custom_export_format = "ps";
214 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
215 bibtex_command = "bibtex";
217 index_command = "makeindex -c -q";
219 // Because a screen typically is wider than a piece of paper:
223 geometry_xysaved = true;
224 // Default LaTeX font size:
225 font_sizes[Font::SIZE_TINY] = "5.0";
226 font_sizes[Font::SIZE_SCRIPT] = "7.0";
227 font_sizes[Font::SIZE_FOOTNOTE] = "8.0";
228 font_sizes[Font::SIZE_SMALL] = "9.0";
229 font_sizes[Font::SIZE_NORMAL] = "10.0";
230 font_sizes[Font::SIZE_LARGE] = "12.0";
231 font_sizes[Font::SIZE_LARGER] = "14.4";
232 font_sizes[Font::SIZE_LARGEST] = "17.26";
233 font_sizes[Font::SIZE_HUGE] = "20.74";
234 font_sizes[Font::SIZE_HUGER] = "24.88";
235 use_scalable_fonts = true;
236 roman_font_name = "";
238 typewriter_font_name = "";
240 auto_region_delete = true;
241 auto_reset_options = false;
242 plaintext_linelen = 65;
243 num_lastfiles = maxlastfiles;
244 check_lastfiles = true;
245 use_lastfilepos = true;
246 load_session = false;
248 backupdir_path.erase();
249 display_graphics = graphics::ColorDisplay;
250 // Spellchecker settings:
251 use_spell_lib = true;
252 isp_command = "ispell";
253 isp_accept_compound = false;
254 isp_use_input_encoding = false;
255 isp_use_alt_lang = false;
256 isp_use_pers_dict = false;
257 isp_use_esc_chars = false;
261 mark_foreign_language = true;
262 language_auto_begin = true;
263 language_auto_end = true;
264 language_global_options = true;
265 language_use_babel = true;
266 language_package = "\\usepackage{babel}";
267 language_command_begin = "\\selectlanguage{$$lang}";
268 language_command_local = "\\foreignlanguage{$$lang}{";
269 default_language = "english";
271 windows_style_tex_paths = false;
272 tex_allows_spaces = false;
273 date_insert_format = "%x";
274 cursor_follows_scrollbar = false;
275 dialogs_iconify_with_main = false;
276 label_init_length = 3;
277 preview = PREVIEW_OFF;
278 preview_hashed_labels = false;
279 preview_scale_factor = "0.9";
280 use_converter_cache = true;
281 converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
283 user_name = to_utf8(support::user_name());
285 user_email = to_utf8(support::user_email());
291 void oldFontFormat(string & family, string & foundry)
293 if (family.empty() || family[0] != '-')
295 foundry = token(family, '-', 1);
296 family = token(family, '-', 2);
304 int LyXRC::read(FileName const & filename)
306 Lexer lexrc(lyxrcTags, lyxrcCount);
307 if (lyxerr.debugging(Debug::PARSER))
308 lexrc.printTable(lyxerr);
310 lexrc.setFile(filename);
311 if (!lexrc.isOK()) return -2;
313 LYXERR(Debug::LYXRC) << "Reading '" << filename << "'..." << endl;
319 int LyXRC::read(std::istream & is)
321 Lexer lexrc(lyxrcTags, lyxrcCount);
322 if (lyxerr.debugging(Debug::PARSER))
323 lexrc.printTable(lyxerr);
326 if (!lexrc.isOK()) return -2;
328 LYXERR(Debug::LYXRC) << "Reading istream..." << endl;
334 int LyXRC::read(Lexer & lexrc)
336 if (!lexrc.isOK()) return -2;
338 while (lexrc.isOK()) {
339 // By using two switches we take advantage of the compiler
340 // telling us if we have missed a LyXRCTags element in
341 // the second switch.
342 // Note that this also shows a problem with Lexer since it
343 // helps us avoid taking advantage of the strictness of the
346 int le = lexrc.lex();
348 case Lexer::LEX_UNDEF:
349 lexrc.printError("Unknown tag `$$Token'");
351 case Lexer::LEX_FEOF:
355 switch (static_cast<LyXRCTags>(le)) {
356 case RC_INPUT: // Include file
359 libFileSearch(string(),
362 lexrc.printError("Error reading "
363 "included file: " + tmp.absFilename());
369 bind_file = os::internal_path(lexrc.getString());
375 ui_file = os::internal_path(lexrc.getString());
379 case RC_AUTORESET_OPTIONS:
381 auto_reset_options = lexrc.getBool();
385 case RC_DISPLAY_GRAPHICS:
387 display_graphics = graphics::displayTranslator().find(lexrc.getString());
391 case RC_TEX_EXPECTS_WINDOWS_PATHS:
393 windows_style_tex_paths = lexrc.getBool();
397 case RC_TEX_ALLOWS_SPACES:
399 tex_allows_spaces = lexrc.getBool();
405 use_kbmap = lexrc.getBool();
409 case RC_KBMAP_PRIMARY:
411 string const kmap(os::internal_path(lexrc.getString()));
414 } else if (!libFileSearch("kbd", kmap,
416 primary_kbmap = kmap;
418 lexrc.printError("LyX: Keymap `$$Token' not found");
423 case RC_KBMAP_SECONDARY:
425 string const kmap(os::internal_path(lexrc.getString()));
428 } else if (!libFileSearch("kbd", kmap,
430 secondary_kbmap = kmap;
432 lexrc.printError("LyX: Keymap `$$Token' not found");
437 case RC_FONT_ENCODING:
439 fontenc = lexrc.getString();
445 printer = lexrc.getString();
449 case RC_PRINT_COMMAND:
451 print_command = lexrc.getString();
455 case RC_PRINTEVENPAGEFLAG:
457 print_evenpage_flag = lexrc.getString();
461 case RC_PRINTODDPAGEFLAG:
463 print_oddpage_flag = lexrc.getString();
467 case RC_PRINTPAGERANGEFLAG:
469 print_pagerange_flag = lexrc.getString();
473 case RC_PRINTCOPIESFLAG:
475 print_copies_flag = lexrc.getString();
479 case RC_PRINTCOLLCOPIESFLAG:
481 print_collcopies_flag = lexrc.getString();
485 case RC_PRINTREVERSEFLAG:
487 print_reverse_flag = lexrc.getString();
491 case RC_PRINTLANDSCAPEFLAG:
493 print_landscape_flag = lexrc.getString();
497 case RC_PRINTTOPRINTER:
499 print_to_printer = lexrc.getString();
503 case RC_PRINT_ADAPTOUTPUT:
505 print_adapt_output = lexrc.getBool();
511 print_to_file = os::internal_path(lexrc.getString());
515 case RC_PRINTFILEEXTENSION:
517 print_file_extension = lexrc.getString();
521 case RC_PRINTEXSTRAOPTIONS:
523 print_extra_options = lexrc.getString();
527 case RC_PRINTSPOOL_COMMAND:
529 print_spool_command = lexrc.getString();
533 case RC_PRINTSPOOL_PRINTERPREFIX:
535 print_spool_printerprefix = lexrc.getString();
539 case RC_PRINTPAPERDIMENSIONFLAG:
541 print_paper_dimension_flag = lexrc.getString();
545 case RC_PRINTPAPERFLAG:
547 print_paper_flag = lexrc.getString();
551 case RC_CUSTOM_EXPORT_COMMAND:
553 custom_export_command = lexrc.getString();
557 case RC_CUSTOM_EXPORT_FORMAT:
559 custom_export_format = lexrc.getString();
563 case RC_DEFAULT_PAPERSIZE:
566 ascii_lowercase(lexrc.getString());
567 if (size == "usletter")
570 else if (size == "legal")
573 else if (size == "executive")
576 else if (size == "a3")
579 else if (size == "a4")
582 else if (size == "a5")
585 else if (size == "b5")
588 else if (size == "default")
594 case RC_VIEWDVI_PAPEROPTION:
596 view_dvi_paper_option = lexrc.getString();
598 view_dvi_paper_option.erase();
602 case RC_CHKTEX_COMMAND:
604 chktex_command = lexrc.getString();
608 case RC_BIBTEX_COMMAND:
610 bibtex_command = lexrc.getString();
614 case RC_INDEX_COMMAND:
616 index_command = lexrc.getString();
622 dpi = lexrc.getInteger();
628 zoom = lexrc.getInteger();
632 case RC_SCREEN_GEOMETRY_HEIGHT:
634 geometry_height = lexrc.getInteger();
638 case RC_SCREEN_GEOMETRY_WIDTH:
640 geometry_width = lexrc.getInteger();
644 case RC_SCREEN_GEOMETRY_XYSAVED:
646 geometry_xysaved = lexrc.getBool();
650 case RC_SCREEN_FONT_SIZES:
652 font_sizes[Font::SIZE_TINY] =
656 font_sizes[Font::SIZE_SCRIPT] =
660 font_sizes[Font::SIZE_FOOTNOTE] =
664 font_sizes[Font::SIZE_SMALL] =
668 font_sizes[Font::SIZE_NORMAL] =
672 font_sizes[Font::SIZE_LARGE] =
676 font_sizes[Font::SIZE_LARGER] =
680 font_sizes[Font::SIZE_LARGEST] =
684 font_sizes[Font::SIZE_HUGE] =
688 font_sizes[Font::SIZE_HUGER] =
693 case RC_SCREEN_FONT_SCALABLE:
695 use_scalable_fonts = lexrc.getBool();
701 autosave = lexrc.getInteger();
705 case RC_DOCUMENTPATH:
707 document_path = os::internal_path(lexrc.getString());
708 document_path = expandPath(document_path);
712 case RC_TEMPLATEPATH:
714 template_path = os::internal_path(lexrc.getString());
715 template_path = expandPath(template_path);
721 tempdir_path = os::internal_path(lexrc.getString());
722 tempdir_path = expandPath(tempdir_path);
728 lyxerr << "Ignoring obsolete use_tempdir flag." << endl;
732 case RC_USELASTFILEPOS:
734 use_lastfilepos = lexrc.getBool();
740 load_session = lexrc.getBool();
744 case RC_NUMLASTFILES:
746 num_lastfiles = lexrc.getInteger();
750 case RC_CHECKLASTFILES:
752 check_lastfiles = lexrc.getBool();
756 case RC_SCREEN_FONT_ROMAN:
758 roman_font_name = lexrc.getString();
759 oldFontFormat(roman_font_name,
764 case RC_SCREEN_FONT_SANS:
766 sans_font_name = lexrc.getString();
767 oldFontFormat(sans_font_name, sans_font_foundry);
771 case RC_SCREEN_FONT_TYPEWRITER:
773 typewriter_font_name = lexrc.getString();
774 oldFontFormat(typewriter_font_name,
775 typewriter_font_foundry);
779 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
781 roman_font_foundry = lexrc.getString();
785 case RC_SCREEN_FONT_SANS_FOUNDRY:
787 sans_font_foundry = lexrc.getString();
791 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
793 typewriter_font_foundry = lexrc.getString();
799 string lyx_name, x11_name;
802 lyx_name = lexrc.getString();
804 lexrc.printError("Missing color tag.");
809 x11_name = lexrc.getString();
811 lexrc.printError("Missing color name for color: `$$Token'");
815 Color::color const col =
816 lcolor.getFromLyXName(lyx_name);
817 if (col == Color::none ||
818 col == Color::inherit ||
819 col == Color::ignore)
822 if (!lcolor.setColor(col, x11_name)) {
823 lyxerr << "Bad lyxrc set_color for "
829 case RC_AUTOREGIONDELETE:
830 // Auto region delete defaults to true
832 auto_region_delete = lexrc.getBool();
838 lyxpipes = os::internal_path(lexrc.getString());
839 lyxpipes = expandPath(lyxpipes);
843 case RC_CURSOR_FOLLOWS_SCROLLBAR:
845 cursor_follows_scrollbar = lexrc.getBool();
849 case RC_DIALOGS_ICONIFY_WITH_MAIN:
851 dialogs_iconify_with_main = lexrc.getBool();
855 case RC_PLAINTEXT_ROFF_COMMAND:
857 plaintext_roff_command = lexrc.getString();
860 case RC_PLAINTEXT_LINELEN:
862 plaintext_linelen = lexrc.getInteger();
865 // Spellchecker settings:
866 case RC_USE_SPELL_LIB:
868 use_spell_lib = lexrc.getBool();
871 case RC_SPELL_COMMAND:
873 isp_command = lexrc.getString();
876 case RC_ACCEPT_COMPOUND:
878 isp_accept_compound = lexrc.getBool();
883 isp_use_input_encoding = lexrc.getBool();
886 case RC_USE_ALT_LANG:
888 isp_use_alt_lang = lexrc.getBool();
891 case RC_USE_PERS_DICT:
893 isp_use_pers_dict = lexrc.getBool();
896 case RC_USE_ESC_CHARS:
898 isp_use_esc_chars = lexrc.getBool();
903 isp_alt_lang = lexrc.getString();
908 isp_pers_dict = os::internal_path(lexrc.getString());
913 isp_esc_chars = lexrc.getString();
918 make_backup = lexrc.getBool();
921 case RC_BACKUPDIR_PATH:
923 backupdir_path = os::internal_path(lexrc.getString());
924 backupdir_path = expandPath(backupdir_path);
927 case RC_DATE_INSERT_FORMAT:
929 date_insert_format = lexrc.getString();
932 case RC_LANGUAGE_PACKAGE:
934 language_package = lexrc.getString();
937 case RC_LANGUAGE_AUTO_BEGIN:
939 language_auto_begin = lexrc.getBool();
942 case RC_LANGUAGE_AUTO_END:
944 language_auto_end = lexrc.getBool();
947 case RC_LANGUAGE_GLOBAL_OPTIONS:
949 language_global_options = lexrc.getBool();
952 case RC_LANGUAGE_USE_BABEL:
954 language_use_babel = lexrc.getBool();
957 case RC_LANGUAGE_COMMAND_BEGIN:
959 language_command_begin = lexrc.getString();
962 case RC_LANGUAGE_COMMAND_END:
964 language_command_end = lexrc.getString();
967 case RC_LANGUAGE_COMMAND_LOCAL:
969 language_command_local = lexrc.getString();
974 rtl_support = lexrc.getBool();
979 auto_number = lexrc.getBool();
982 case RC_MARK_FOREIGN_LANGUAGE:
984 mark_foreign_language = lexrc.getBool();
991 fmt = lexrc.getString();
994 command = lexrc.getString();
996 setMover(fmt, command);
1000 case RC_CONVERTER: {
1001 string from, to, command, flags;
1003 from = lexrc.getString();
1006 to = lexrc.getString();
1009 command = lexrc.getString();
1012 flags = lexrc.getString();
1014 if (command.empty()) {
1015 theConverters().erase(from, to);
1017 theConverters().add(from, to, command, flags);
1021 // compatibility with versions older than 1.4.0 only
1023 string format, command;
1025 format = lexrc.getString();
1028 command = lexrc.getString();
1030 formats.setViewer(format, command);
1034 string format, extension, prettyname, shortcut;
1036 format = lexrc.getString();
1039 extension = lexrc.getString();
1042 prettyname = lexrc.getString();
1045 shortcut = lexrc.getString();
1047 string viewer, editor;
1049 viewer = lexrc.getString();
1051 editor = lexrc.getString();
1053 // Hack to ensure compatibility with versions older
1055 int le = lexrc.lex();
1056 if (le != Lexer::LEX_FEOF && le != Lexer::LEX_UNDEF) {
1057 flags = lexrc.getString();
1058 if (le != Lexer::LEX_DATA) {
1059 // We have got a known token.
1060 // Therefore this is an old style
1061 // format definition without
1063 lexrc.pushToken(flags);
1067 int flgs = Format::none;
1068 while (!flags.empty()) {
1070 flags = support::split(flags, flag, ',');
1071 if (flag == "document")
1072 flgs |= Format::document;
1073 else if (flag == "vector")
1074 flgs |= Format::vector;
1076 lyxerr << "Ignoring unknown flag `"
1077 << flag << "' for format `"
1078 << format << "'." << endl;
1080 if (prettyname.empty()) {
1081 if (theConverters().formatIsUsed(format)) {
1082 lyxerr << "Can't delete format "
1085 formats.erase(format);
1088 formats.add(format, extension, prettyname,
1089 shortcut, viewer, editor, flgs);
1093 case RC_DEFAULT_LANGUAGE:
1095 default_language = lexrc.getString();
1099 case RC_LABEL_INIT_LENGTH:
1101 label_init_length = lexrc.getInteger();
1105 case RC_SHOW_BANNER:
1107 show_banner = lexrc.getBool();
1113 string const tmp = lexrc.getString();
1114 if (tmp == "true" || tmp == "on")
1115 preview = PREVIEW_ON;
1116 else if (tmp == "no_math")
1117 preview = PREVIEW_NO_MATH;
1119 preview = PREVIEW_OFF;
1120 if (tmp != "false" && tmp != "off")
1121 lyxerr << "Unrecognized "
1123 << tmp << '\n' << endl;
1128 case RC_PREVIEW_HASHED_LABELS:
1130 preview_hashed_labels = lexrc.getBool();
1134 case RC_PREVIEW_SCALE_FACTOR:
1136 preview_scale_factor = lexrc.getString();
1142 user_name = lexrc.getString();
1147 user_email = lexrc.getString();
1150 case RC_PATH_PREFIX:
1152 path_prefix = lexrc.getString();
1155 case RC_USE_CONVERTER_CACHE:
1157 use_converter_cache = lexrc.getBool();
1160 case RC_CONVERTER_CACHE_MAXAGE:
1162 converter_cache_maxage =
1163 convert<unsigned int>(lexrc.getString());
1166 case RC_LAST: break; // this is just a dummy
1170 /// Update converters data-structures
1171 theConverters().update(formats);
1172 theConverters().buildGraph();
1178 void LyXRC::write(FileName const & filename, bool ignore_system_lyxrc) const
1180 ofstream ofs(filename.toFilesystemEncoding().c_str());
1182 write(ofs, ignore_system_lyxrc);
1186 void LyXRC::print() const
1188 if (lyxerr.debugging())
1189 write(lyxerr, false);
1197 typedef std::pair<std::string, SpecialisedMover> Data;
1199 SameMover(Data const & comparison)
1200 : comparison_(comparison) {}
1202 bool operator()(Data const & data) const
1204 return data.first == comparison_.first &&
1205 data.second.command() == comparison_.second.command();
1213 void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
1215 os << "### This file is part of\n"
1216 << "### ========================================================\n"
1217 << "### LyX, The Document Processor\n"
1219 << "### Copyright 1995 Matthias Ettrich\n"
1220 << "### Copyright 1995-2001 The LyX Team.\n"
1222 << "### ========================================================\n"
1224 << "# This file is written by LyX, if you want to make your own\n"
1225 << "# modifications you should do them from inside LyX and save\n"
1228 // Why the switch you might ask. It is a trick to ensure that all
1229 // the elements in the LyXRCTags enum is handled. As you can see
1230 // there are no breaks at all. So it is just a huge fall-through.
1231 // The nice thing is that we will get a warning from the compiler
1232 // if we forget an element.
1233 LyXRCTags tag = RC_LAST;
1237 // input/include files are not done here
1239 if (ignore_system_lyxrc ||
1240 bind_file != system_lyxrc.bind_file) {
1241 string const path = os::external_path(bind_file);
1242 os << "\\bind_file \"" << path << "\"\n";
1248 << "# MISC SECTION ######################################\n"
1251 // bind files are not done here.
1253 case RC_PATH_PREFIX:
1254 if (ignore_system_lyxrc ||
1255 path_prefix != system_lyxrc.path_prefix) {
1256 os << "\\path_prefix \"" << path_prefix << "\"\n";
1260 if (ignore_system_lyxrc ||
1261 ui_file != system_lyxrc.ui_file) {
1262 string const path = os::external_path(ui_file);
1263 os << "\\ui_file \"" << path << "\"\n";
1265 case RC_AUTOREGIONDELETE:
1266 if (ignore_system_lyxrc ||
1267 auto_region_delete != system_lyxrc.auto_region_delete) {
1268 os << "# Set to false to inhibit automatic replacement of\n"
1269 << "# the current selection.\n"
1270 << "\\auto_region_delete " << convert<string>(auto_region_delete)
1273 case RC_AUTORESET_OPTIONS:
1274 if (ignore_system_lyxrc ||
1275 auto_reset_options != system_lyxrc.auto_reset_options) {
1276 os << "# Set to false to inhibit automatic reset of\n"
1277 << "# the class options to defaults on class change.\n"
1278 << "\\auto_reset_options "
1279 << convert<string>(auto_reset_options)
1283 if (ignore_system_lyxrc ||
1284 autosave != system_lyxrc.autosave) {
1285 os << "# The time interval between auto-saves in seconds.\n"
1286 << "\\autosave " << autosave << '\n';
1288 case RC_DISPLAY_GRAPHICS:
1289 if (ignore_system_lyxrc ||
1290 display_graphics != system_lyxrc.display_graphics) {
1291 os << "# Display graphics within LyX\n"
1292 << "# monochrome|grayscale|color|none\n"
1293 << "\\display_graphics "
1294 << graphics::displayTranslator().find(display_graphics)
1298 case RC_VIEWDVI_PAPEROPTION:
1299 if (ignore_system_lyxrc ||
1300 view_dvi_paper_option
1301 != system_lyxrc.view_dvi_paper_option) {
1302 os << "# Options used to specify paper size to the\n"
1303 << "# view_dvi_command (e.g. -paper)\n"
1304 << "\\view_dvi_paper_option \""
1305 << view_dvi_paper_option << "\"\n";
1307 case RC_DEFAULT_PAPERSIZE:
1308 if (ignore_system_lyxrc ||
1309 default_papersize != system_lyxrc.default_papersize) {
1310 os << "# The default papersize to use.\n"
1311 << "\\default_papersize \"";
1312 switch (default_papersize) {
1314 os << "default"; break;
1315 case PAPER_USLETTER:
1316 os << "usletter"; break;
1318 os << "legal"; break;
1319 case PAPER_USEXECUTIVE:
1320 os << "executive"; break;
1331 case PAPER_B4: break;
1335 case RC_CHKTEX_COMMAND:
1336 if (ignore_system_lyxrc ||
1337 chktex_command != system_lyxrc.chktex_command) {
1338 os << "\\chktex_command \"" << chktex_command << "\"\n";
1340 case RC_BIBTEX_COMMAND:
1341 if (ignore_system_lyxrc ||
1342 bibtex_command != system_lyxrc.bibtex_command) {
1343 os << "\\bibtex_command \"" << bibtex_command << "\"\n";
1345 case RC_INDEX_COMMAND:
1346 if (ignore_system_lyxrc ||
1347 index_command != system_lyxrc.index_command) {
1348 os << "\\index_command \"" << index_command << "\"\n";
1350 case RC_TEX_EXPECTS_WINDOWS_PATHS:
1351 if (ignore_system_lyxrc ||
1352 windows_style_tex_paths != system_lyxrc.windows_style_tex_paths) {
1353 os << "\\tex_expects_windows_paths "
1354 << convert<string>(windows_style_tex_paths) << '\n';
1356 case RC_TEX_ALLOWS_SPACES:
1357 if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
1358 os << "\\tex_allows_spaces "
1359 << convert<string>(tex_allows_spaces) << '\n';
1362 if (ignore_system_lyxrc ||
1363 use_kbmap != system_lyxrc.use_kbmap) {
1364 os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1366 case RC_KBMAP_PRIMARY:
1367 if (ignore_system_lyxrc ||
1368 primary_kbmap != system_lyxrc.primary_kbmap) {
1369 string const path = os::external_path(primary_kbmap);
1370 os << "\\kbmap_primary \"" << path << "\"\n";
1372 case RC_KBMAP_SECONDARY:
1373 if (ignore_system_lyxrc ||
1374 secondary_kbmap != system_lyxrc.secondary_kbmap) {
1375 string const path = os::external_path(secondary_kbmap);
1376 os << "\\kbmap_secondary \"" << path << "\"\n";
1379 if (ignore_system_lyxrc ||
1380 lyxpipes != system_lyxrc.lyxpipes) {
1381 string const path = os::external_path(lyxpipes);
1382 os << "\\serverpipe \"" << path << "\"\n";
1384 case RC_DATE_INSERT_FORMAT:
1385 if (ignore_system_lyxrc ||
1386 date_insert_format != system_lyxrc.date_insert_format) {
1387 os << "\\date_insert_format \"" << date_insert_format
1390 case RC_LABEL_INIT_LENGTH:
1391 if (ignore_system_lyxrc ||
1392 label_init_length != system_lyxrc.label_init_length) {
1393 os << "\\label_init_length " << label_init_length
1398 os << "\\user_name \"" << user_name << "\"\n";
1401 os << "\\user_email \"" << user_email << "\"\n";
1403 case RC_SHOW_BANNER:
1404 if (ignore_system_lyxrc ||
1405 show_banner != system_lyxrc.show_banner) {
1406 os << "\\show_banner " << convert<string>(show_banner) << '\n';
1410 if (ignore_system_lyxrc ||
1411 preview != system_lyxrc.preview) {
1417 case PREVIEW_NO_MATH:
1424 os << "\\preview " << status << '\n';
1427 case RC_PREVIEW_HASHED_LABELS:
1428 if (ignore_system_lyxrc ||
1429 preview_hashed_labels !=
1430 system_lyxrc.preview_hashed_labels) {
1431 os << "\\preview_hashed_labels "
1432 << convert<string>(preview_hashed_labels) << '\n';
1435 case RC_PREVIEW_SCALE_FACTOR:
1436 if (ignore_system_lyxrc ||
1437 preview_scale_factor != system_lyxrc.preview_scale_factor) {
1438 os << "\\preview_scale_factor "
1439 << preview_scale_factor << '\n';
1442 case RC_USE_CONVERTER_CACHE:
1443 if (ignore_system_lyxrc ||
1444 use_converter_cache != system_lyxrc.use_converter_cache) {
1445 os << "\\use_converter_cache "
1446 << convert<string>(use_converter_cache) << '\n';
1449 case RC_CONVERTER_CACHE_MAXAGE:
1450 if (ignore_system_lyxrc ||
1451 converter_cache_maxage != system_lyxrc.converter_cache_maxage) {
1452 os << "\\converter_cache_maxage "
1453 << converter_cache_maxage << '\n';
1457 << "# SCREEN & FONTS SECTION ############################\n"
1461 if (ignore_system_lyxrc ||
1462 dpi != system_lyxrc.dpi) {
1463 os << "\\screen_dpi " << dpi << '\n';
1465 case RC_SCREEN_ZOOM:
1466 if (ignore_system_lyxrc ||
1467 zoom != system_lyxrc.zoom) {
1468 os << "\\screen_zoom " << zoom << '\n';
1470 case RC_SCREEN_GEOMETRY_HEIGHT:
1471 if (ignore_system_lyxrc ||
1472 geometry_height != system_lyxrc.geometry_height) {
1473 os << "\\screen_geometry_height " << geometry_height
1476 case RC_SCREEN_GEOMETRY_WIDTH:
1477 if (ignore_system_lyxrc ||
1478 geometry_width != system_lyxrc.geometry_width) {
1479 os << "\\screen_geometry_width " << geometry_width
1482 case RC_SCREEN_GEOMETRY_XYSAVED:
1483 if (ignore_system_lyxrc ||
1484 geometry_xysaved != system_lyxrc.geometry_xysaved) {
1485 os << "\\screen_geometry_xysaved " << convert<string>(geometry_xysaved)
1488 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1489 if (ignore_system_lyxrc ||
1490 cursor_follows_scrollbar
1491 != system_lyxrc.cursor_follows_scrollbar) {
1492 os << "\\cursor_follows_scrollbar "
1493 << convert<string>(cursor_follows_scrollbar) << '\n';
1495 case RC_DIALOGS_ICONIFY_WITH_MAIN:
1496 if (ignore_system_lyxrc ||
1497 dialogs_iconify_with_main
1498 != system_lyxrc.dialogs_iconify_with_main) {
1499 os << "\\dialogs_iconify_with_main "
1500 << convert<string>(dialogs_iconify_with_main) << '\n';
1502 case RC_SCREEN_FONT_ROMAN:
1503 if (ignore_system_lyxrc ||
1504 roman_font_name != system_lyxrc.roman_font_name) {
1505 os << "\\screen_font_roman \"" << roman_font_name
1508 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1509 if (ignore_system_lyxrc ||
1510 roman_font_foundry != system_lyxrc.roman_font_foundry) {
1511 os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1514 case RC_SCREEN_FONT_SANS:
1515 if (ignore_system_lyxrc ||
1516 sans_font_name != system_lyxrc.sans_font_name) {
1517 os << "\\screen_font_sans \"" << sans_font_name
1520 case RC_SCREEN_FONT_SANS_FOUNDRY:
1521 if (ignore_system_lyxrc ||
1522 sans_font_foundry != system_lyxrc.sans_font_foundry) {
1523 os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1526 case RC_SCREEN_FONT_TYPEWRITER:
1527 if (ignore_system_lyxrc ||
1528 typewriter_font_name != system_lyxrc.typewriter_font_name) {
1529 os << "\\screen_font_typewriter \""
1530 << typewriter_font_name << "\"\n";
1532 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1533 if (ignore_system_lyxrc ||
1534 typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1535 os << "\\screen_font_typewriter_foundry \""
1536 << typewriter_font_foundry << "\"\n";
1539 case RC_SCREEN_FONT_SCALABLE:
1540 if (ignore_system_lyxrc ||
1541 use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1542 os << "\\screen_font_scalable "
1543 << convert<string>(use_scalable_fonts)
1546 case RC_SCREEN_FONT_SIZES:
1547 if (ignore_system_lyxrc ||
1548 font_sizes[Font::SIZE_TINY]
1549 != system_lyxrc.font_sizes[Font::SIZE_TINY] ||
1550 font_sizes[Font::SIZE_SCRIPT]
1551 != system_lyxrc.font_sizes[Font::SIZE_SCRIPT] ||
1552 font_sizes[Font::SIZE_FOOTNOTE]
1553 != system_lyxrc.font_sizes[Font::SIZE_FOOTNOTE] ||
1554 font_sizes[Font::SIZE_SMALL]
1555 != system_lyxrc.font_sizes[Font::SIZE_SMALL] ||
1556 font_sizes[Font::SIZE_NORMAL]
1557 != system_lyxrc.font_sizes[Font::SIZE_NORMAL] ||
1558 font_sizes[Font::SIZE_LARGE]
1559 != system_lyxrc.font_sizes[Font::SIZE_LARGE] ||
1560 font_sizes[Font::SIZE_LARGER]
1561 != system_lyxrc.font_sizes[Font::SIZE_LARGER] ||
1562 font_sizes[Font::SIZE_LARGEST]
1563 != system_lyxrc.font_sizes[Font::SIZE_LARGEST] ||
1564 font_sizes[Font::SIZE_HUGE]
1565 != system_lyxrc.font_sizes[Font::SIZE_HUGE] ||
1566 font_sizes[Font::SIZE_HUGER]
1567 != system_lyxrc.font_sizes[Font::SIZE_HUGER]) {
1568 os.setf(ios::fixed);
1570 os << "\\screen_font_sizes"
1571 << ' ' << font_sizes[Font::SIZE_TINY]
1572 << ' ' << font_sizes[Font::SIZE_SCRIPT]
1573 << ' ' << font_sizes[Font::SIZE_FOOTNOTE]
1574 << ' ' << font_sizes[Font::SIZE_SMALL]
1575 << ' ' << font_sizes[Font::SIZE_NORMAL]
1576 << ' ' << font_sizes[Font::SIZE_LARGE]
1577 << ' ' << font_sizes[Font::SIZE_LARGER]
1578 << ' ' << font_sizes[Font::SIZE_LARGEST]
1579 << ' ' << font_sizes[Font::SIZE_HUGE]
1580 << ' ' << font_sizes[Font::SIZE_HUGER]
1585 << "# COLOR SECTION ###################################\n"
1589 for (int i = 0; i < Color::ignore; ++i) {
1590 Color::color lc = static_cast<Color::color>(i);
1592 string const col(lcolor.getX11Name(lc));
1593 if (ignore_system_lyxrc ||
1594 col != system_lcolor.getX11Name(lc)) {
1595 os << "\\set_color \""
1596 << lcolor.getLyXName(lc) << "\" \""
1602 << "# PRINTER SECTION ###################################\n"
1606 if (ignore_system_lyxrc ||
1607 printer != system_lyxrc.printer) {
1608 os << "\\printer \"" << printer << "\"\n";
1610 case RC_PRINT_ADAPTOUTPUT:
1611 if (ignore_system_lyxrc ||
1612 print_adapt_output != system_lyxrc.print_adapt_output) {
1613 os << "\\print_adapt_output "
1614 << convert<string>(print_adapt_output)
1617 case RC_PRINT_COMMAND:
1618 if (ignore_system_lyxrc ||
1619 print_command != system_lyxrc.print_command) {
1620 os << "\\print_command \"" << print_command << "\"\n";
1622 case RC_PRINTEXSTRAOPTIONS:
1623 if (ignore_system_lyxrc ||
1624 print_extra_options != system_lyxrc.print_extra_options) {
1625 os << "\\print_extra_options \"" << print_extra_options
1628 case RC_PRINTSPOOL_COMMAND:
1629 if (ignore_system_lyxrc ||
1630 print_spool_command != system_lyxrc.print_spool_command) {
1631 os << "\\print_spool_command \"" << print_spool_command
1634 case RC_PRINTSPOOL_PRINTERPREFIX:
1635 if (ignore_system_lyxrc ||
1636 print_spool_printerprefix
1637 != system_lyxrc.print_spool_printerprefix) {
1638 os << "\\print_spool_printerprefix \""
1639 << print_spool_printerprefix << "\"\n";
1641 case RC_PRINTEVENPAGEFLAG:
1642 if (ignore_system_lyxrc ||
1643 print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1644 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1647 case RC_PRINTODDPAGEFLAG:
1648 if (ignore_system_lyxrc ||
1649 print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1650 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1653 case RC_PRINTREVERSEFLAG:
1654 if (ignore_system_lyxrc ||
1655 print_reverse_flag != system_lyxrc.print_reverse_flag) {
1656 os << "\\print_reverse_flag \"" << print_reverse_flag
1659 case RC_PRINTLANDSCAPEFLAG:
1660 if (ignore_system_lyxrc ||
1661 print_landscape_flag != system_lyxrc.print_landscape_flag) {
1662 os << "\\print_landscape_flag \"" << print_landscape_flag
1665 case RC_PRINTPAGERANGEFLAG:
1666 if (ignore_system_lyxrc ||
1667 print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1668 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1671 case RC_PRINTCOPIESFLAG:
1672 if (ignore_system_lyxrc ||
1673 print_copies_flag != system_lyxrc.print_copies_flag) {
1674 os << "\\print_copies_flag \"" << print_copies_flag
1677 case RC_PRINTCOLLCOPIESFLAG:
1678 if (ignore_system_lyxrc ||
1679 print_collcopies_flag
1680 != system_lyxrc.print_collcopies_flag) {
1681 os << "\\print_collcopies_flag \""
1682 << print_collcopies_flag
1685 case RC_PRINTPAPERFLAG:
1686 if (ignore_system_lyxrc ||
1687 print_paper_flag != system_lyxrc.print_paper_flag) {
1688 os << "\\print_paper_flag \"" << print_paper_flag
1691 case RC_PRINTPAPERDIMENSIONFLAG:
1692 if (ignore_system_lyxrc ||
1693 print_paper_dimension_flag
1694 != system_lyxrc.print_paper_dimension_flag) {
1695 os << "\\print_paper_dimension_flag \""
1696 << print_paper_dimension_flag << "\"\n";
1698 case RC_PRINTTOPRINTER:
1699 if (ignore_system_lyxrc ||
1700 print_to_printer != system_lyxrc.print_to_printer) {
1701 os << "\\print_to_printer \"" << print_to_printer
1704 case RC_PRINTTOFILE:
1705 if (ignore_system_lyxrc ||
1706 print_to_file != system_lyxrc.print_to_file) {
1707 string const path = os::external_path(print_to_file);
1708 os << "\\print_to_file \"" << path << "\"\n";
1710 case RC_PRINTFILEEXTENSION:
1711 if (ignore_system_lyxrc ||
1712 print_file_extension != system_lyxrc.print_file_extension) {
1713 os << "\\print_file_extension \""
1714 << print_file_extension
1719 << "# EXPORT SECTION ####################################\n"
1722 case RC_CUSTOM_EXPORT_COMMAND:
1723 if (ignore_system_lyxrc ||
1724 custom_export_command
1725 != system_lyxrc.custom_export_command) {
1726 os << "\\custom_export_command \""
1727 << custom_export_command
1730 case RC_CUSTOM_EXPORT_FORMAT:
1731 if (ignore_system_lyxrc ||
1732 custom_export_format
1733 != system_lyxrc.custom_export_format) {
1734 os << "\\custom_export_format \"" << custom_export_format
1739 << "# TEX SECTION #######################################\n"
1742 case RC_FONT_ENCODING:
1743 if (ignore_system_lyxrc ||
1744 fontenc != system_lyxrc.fontenc) {
1745 os << "\\font_encoding \"" << fontenc << "\"\n";
1749 << "# FILE SECTION ######################################\n"
1752 case RC_DOCUMENTPATH:
1753 if (ignore_system_lyxrc ||
1754 document_path != system_lyxrc.document_path) {
1755 string const path = os::external_path(document_path);
1756 os << "\\document_path \"" << path << "\"\n";
1758 case RC_USELASTFILEPOS:
1759 if (ignore_system_lyxrc ||
1760 use_lastfilepos != system_lyxrc.use_lastfilepos) {
1761 os << "\\use_lastfilepos " << convert<string>(use_lastfilepos)
1764 case RC_LOADSESSION:
1765 if (ignore_system_lyxrc ||
1766 load_session != system_lyxrc.load_session) {
1767 os << "\\load_session " << convert<string>(load_session)
1770 case RC_NUMLASTFILES:
1771 if (ignore_system_lyxrc ||
1772 num_lastfiles != system_lyxrc.num_lastfiles) {
1773 os << "\\num_lastfiles " << num_lastfiles << '\n';
1775 case RC_CHECKLASTFILES:
1776 if (ignore_system_lyxrc ||
1777 check_lastfiles != system_lyxrc.check_lastfiles) {
1778 os << "\\check_lastfiles " << convert<string>(check_lastfiles)
1781 case RC_TEMPLATEPATH:
1782 if (ignore_system_lyxrc ||
1783 template_path != system_lyxrc.template_path) {
1784 string const path = os::external_path(template_path);
1785 os << "\\template_path \"" << path << "\"\n";
1787 case RC_TEMPDIRPATH:
1788 if (ignore_system_lyxrc ||
1789 tempdir_path != system_lyxrc.tempdir_path) {
1790 string const path = os::external_path(tempdir_path);
1791 os << "\\tempdir_path \"" << path << "\"\n";
1795 case RC_PLAINTEXT_LINELEN:
1796 if (ignore_system_lyxrc ||
1797 plaintext_linelen != system_lyxrc.plaintext_linelen) {
1798 os << "\\plaintext_linelen " << plaintext_linelen << '\n';
1800 case RC_MAKE_BACKUP:
1801 if (ignore_system_lyxrc ||
1802 make_backup != system_lyxrc.make_backup) {
1803 os << "\\make_backup " << convert<string>(make_backup) << '\n';
1805 case RC_BACKUPDIR_PATH:
1806 if (ignore_system_lyxrc ||
1807 backupdir_path != system_lyxrc.backupdir_path) {
1808 string const path = os::external_path(backupdir_path);
1809 os << "\\backupdir_path \"" << path << "\"\n";
1813 << "# PLAIN TEXT EXPORT SECTION ##############################\n"
1816 case RC_PLAINTEXT_ROFF_COMMAND:
1817 if (ignore_system_lyxrc ||
1818 plaintext_roff_command != system_lyxrc.plaintext_roff_command) {
1819 os << "\\plaintext_roff_command \"" << plaintext_roff_command
1824 << "# SPELLCHECKER SECTION ##############################\n"
1826 case RC_USE_SPELL_LIB:
1827 if (ignore_system_lyxrc ||
1828 use_spell_lib != system_lyxrc.use_spell_lib) {
1829 os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
1831 case RC_SPELL_COMMAND:
1832 if (ignore_system_lyxrc ||
1833 isp_command != system_lyxrc.isp_command) {
1834 os << "\\spell_command \"" << isp_command << "\"\n";
1836 case RC_ACCEPT_COMPOUND:
1837 if (ignore_system_lyxrc ||
1838 isp_accept_compound != system_lyxrc.isp_accept_compound) {
1839 os << "\\accept_compound " << convert<string>(isp_accept_compound)
1842 case RC_USE_ALT_LANG:
1843 if (ignore_system_lyxrc ||
1844 isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
1845 os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
1849 if (ignore_system_lyxrc ||
1850 isp_alt_lang != system_lyxrc.isp_alt_lang) {
1851 os << "\\alternate_language \"" << isp_alt_lang
1854 case RC_USE_ESC_CHARS:
1855 if (ignore_system_lyxrc ||
1856 isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
1857 os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
1861 if (ignore_system_lyxrc ||
1862 isp_esc_chars != system_lyxrc.isp_esc_chars) {
1863 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1865 case RC_USE_PERS_DICT:
1866 if (ignore_system_lyxrc ||
1867 isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
1868 os << "\\use_personal_dictionary "
1869 << convert<string>(isp_use_pers_dict)
1873 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
1874 string const path = os::external_path(isp_pers_dict);
1875 os << "\\personal_dictionary \"" << path << "\"\n";
1877 case RC_USE_INP_ENC:
1878 if (ignore_system_lyxrc ||
1879 isp_use_input_encoding
1880 != system_lyxrc.isp_use_input_encoding) {
1881 os << "\\use_input_encoding "
1882 << convert<string>(isp_use_input_encoding)
1887 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1890 case RC_RTL_SUPPORT:
1891 if (ignore_system_lyxrc ||
1892 rtl_support != system_lyxrc.rtl_support) {
1893 os << "\\rtl " << convert<string>(rtl_support) << '\n';
1895 case RC_LANGUAGE_PACKAGE:
1896 if (ignore_system_lyxrc ||
1897 language_package != system_lyxrc.language_package) {
1898 os << "\\language_package \"" << language_package
1901 case RC_LANGUAGE_GLOBAL_OPTIONS:
1902 if (ignore_system_lyxrc ||
1903 language_global_options
1904 != system_lyxrc.language_global_options) {
1905 os << "\\language_global_options \""
1906 << convert<string>(language_global_options)
1909 case RC_LANGUAGE_USE_BABEL:
1910 if (ignore_system_lyxrc ||
1911 language_use_babel != system_lyxrc.language_use_babel) {
1912 os << "\\language_use_babel \""
1913 << convert<string>(language_use_babel)
1916 case RC_LANGUAGE_COMMAND_BEGIN:
1917 if (ignore_system_lyxrc ||
1918 language_command_begin
1919 != system_lyxrc.language_command_begin) {
1920 os << "\\language_command_begin \""
1921 << language_command_begin
1924 case RC_LANGUAGE_COMMAND_END:
1925 if (ignore_system_lyxrc ||
1926 language_command_end
1927 != system_lyxrc.language_command_end) {
1928 os << "\\language_command_end \"" << language_command_end
1931 case RC_LANGUAGE_COMMAND_LOCAL:
1932 if (ignore_system_lyxrc ||
1933 language_command_local
1934 != system_lyxrc.language_command_local) {
1935 os << "\\language_command_local \""
1936 << language_command_local
1939 case RC_LANGUAGE_AUTO_BEGIN:
1940 if (ignore_system_lyxrc ||
1941 language_auto_begin != system_lyxrc.language_auto_begin) {
1942 os << "\\language_auto_begin "
1943 << convert<string>(language_auto_begin) << '\n';
1945 case RC_LANGUAGE_AUTO_END:
1946 if (ignore_system_lyxrc ||
1947 language_auto_end != system_lyxrc.language_auto_end) {
1948 os << "\\language_auto_end "
1949 << convert<string>(language_auto_end) << '\n';
1951 case RC_MARK_FOREIGN_LANGUAGE:
1952 if (ignore_system_lyxrc ||
1953 mark_foreign_language
1954 != system_lyxrc.mark_foreign_language) {
1955 os << "\\mark_foreign_language " <<
1956 convert<string>(mark_foreign_language) << '\n';
1960 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1963 case RC_AUTO_NUMBER:
1964 if (ignore_system_lyxrc ||
1965 auto_number != system_lyxrc.auto_number) {
1966 os << "\\auto_number " << convert<string>(auto_number) << '\n';
1968 case RC_DEFAULT_LANGUAGE:
1969 if (ignore_system_lyxrc ||
1970 default_language != system_lyxrc.default_language) {
1971 os << "\\default_language " << default_language << '\n';
1975 << "# FORMATS SECTION ##########################\n"
1979 // New/modified formats
1980 for (Formats::const_iterator cit = formats.begin();
1981 cit != formats.end(); ++cit) {
1982 Format const * format =
1983 system_formats.getFormat(cit->name());
1985 format->extension() != cit->extension() ||
1986 format->prettyname() != cit->prettyname() ||
1987 format->shortcut() != cit->shortcut() ||
1988 format->viewer() != cit->viewer() ||
1989 format->editor() != cit->editor() ||
1990 format->documentFormat() != cit->documentFormat() ||
1991 format->vectorFormat() != cit->vectorFormat()) {
1992 os << "\\format \"" << cit->name() << "\" \""
1993 << cit->extension() << "\" \""
1994 << cit->prettyname() << "\" \""
1995 << cit->shortcut() << "\" \""
1996 << cit->viewer() << "\" \""
1997 << cit->editor() << "\" \"";
1998 std::vector<string> flags;
1999 if (cit->documentFormat())
2000 flags.push_back("document");
2001 if (cit->vectorFormat())
2002 flags.push_back("vector");
2003 os << support::getStringFromVector(flags);
2008 // Look for deleted formats
2009 for (Formats::const_iterator cit = system_formats.begin();
2010 cit != system_formats.end(); ++cit)
2011 if (!formats.getFormat(cit->name()))
2012 os << "\\format \"" << cit->name()
2013 << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
2018 << "# CONVERTERS SECTION ##########################\n"
2022 // Look for new converters
2023 for (Converters::const_iterator cit = theConverters().begin();
2024 cit != theConverters().end(); ++cit) {
2025 Converter const * converter =
2026 theSystemConverters().getConverter(cit->from,
2029 converter->command != cit->command ||
2030 converter->flags != cit->flags)
2031 os << "\\converter \"" << cit->from << "\" \""
2032 << cit->to << "\" \""
2033 << cit->command << "\" \""
2034 << cit->flags << "\"\n";
2037 // New/modifed converters
2038 for (Converters::const_iterator cit = theSystemConverters().begin();
2039 cit != theSystemConverters().end(); ++cit)
2040 if (!theConverters().getConverter(cit->from, cit->to))
2041 os << "\\converter \"" << cit->from
2042 << "\" \"" << cit->to << "\" \"\" \"\"\n";
2046 << "# COPIERS SECTION ##########################\n"
2049 // Look for new movers
2050 Movers::const_iterator const sysbegin = theSystemMovers().begin();
2051 Movers::const_iterator const sysend = theSystemMovers().end();
2052 Movers::const_iterator it = theMovers().begin();
2053 Movers::const_iterator end = theMovers().end();
2055 for (; it != end; ++it) {
2056 Movers::const_iterator const sysit =
2057 std::find_if(sysbegin, sysend, SameMover(*it));
2058 if (sysit == sysend) {
2059 std::string const & fmt = it->first;
2060 std::string const & command =
2061 it->second.command();
2063 os << "\\copier " << fmt
2064 << " \"" << command << "\"\n";
2068 // We don't actually delete SpecialisedMover(s) from the
2069 // map, just clear their 'command', so there's no need
2070 // to test for anything else.
2078 string const LyXRC::getDescription(LyXRCTags tag)
2083 case RC_ACCEPT_COMPOUND:
2084 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2088 case RC_USE_ALT_LANG:
2089 str = _("Specify an alternate language. The default is to use the language of the document.");
2092 case RC_PLAINTEXT_ROFF_COMMAND:
2093 str = _("Use to define an external program to render tables in plain text output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"\" is specified, an internal routine is used.");
2096 case RC_PLAINTEXT_LINELEN:
2097 str = _("The maximum line length of exported plain text/LaTeX/SGML files. If set to 0, paragraphs are output in a single line; if the line length is > 0, paragraphs are separated by a blank line.");
2100 case RC_AUTOREGIONDELETE:
2101 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2104 case RC_AUTORESET_OPTIONS:
2105 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2109 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2112 case RC_AUTO_NUMBER:
2115 case RC_BACKUPDIR_PATH:
2116 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.");
2119 case RC_BIBTEX_COMMAND:
2120 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2124 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2127 case RC_CHECKLASTFILES:
2128 str = _("Select to check whether the lastfiles still exist.");
2131 case RC_CHKTEX_COMMAND:
2132 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2141 case RC_CURSOR_FOLLOWS_SCROLLBAR:
2142 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.");
2145 case RC_CUSTOM_EXPORT_COMMAND:
2148 case RC_CUSTOM_EXPORT_FORMAT:
2151 case RC_DATE_INSERT_FORMAT:
2152 //xgettext:no-c-format
2153 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2156 case RC_DEFAULT_LANGUAGE:
2157 str = _("New documents will be assigned this language.");
2160 case RC_DEFAULT_PAPERSIZE:
2161 str = _("Specify the default paper size.");
2164 case RC_DIALOGS_ICONIFY_WITH_MAIN:
2165 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2168 case RC_DISPLAY_GRAPHICS:
2169 str = _("Select how LyX will display any graphics.");
2172 case RC_DOCUMENTPATH:
2173 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2177 case RC_USE_ESC_CHARS:
2178 str = _("Specify additional chars that can be part of a word.");
2181 case RC_FONT_ENCODING:
2182 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2188 case RC_INDEX_COMMAND:
2189 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\".");
2196 case RC_KBMAP_PRIMARY:
2197 case RC_KBMAP_SECONDARY:
2198 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.");
2201 case RC_LABEL_INIT_LENGTH:
2202 str = _("Maximum number of words in the initialization string for a new label");
2205 case RC_LANGUAGE_AUTO_BEGIN:
2206 str = _("Select if a language switching command is needed at the beginning of the document.");
2209 case RC_LANGUAGE_AUTO_END:
2210 str = _("Select if a language switching command is needed at the end of the document.");
2213 case RC_LANGUAGE_COMMAND_BEGIN:
2214 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.");
2217 case RC_LANGUAGE_COMMAND_END:
2218 str = _("The LaTeX command for changing back to the language of the document.");
2221 case RC_LANGUAGE_COMMAND_LOCAL:
2222 str = _("The LaTeX command for local changing of the language.");
2225 case RC_LANGUAGE_GLOBAL_OPTIONS:
2226 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2229 case RC_LANGUAGE_PACKAGE:
2230 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2233 case RC_LANGUAGE_USE_BABEL:
2234 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2237 case RC_USELASTFILEPOS:
2238 str = _("De-select if you do not want LyX to scroll to saved position.");
2241 case RC_LOADSESSION:
2242 str = _("De-select to prevent loading files opened from the last lyx session.");
2245 case RC_MAKE_BACKUP:
2246 str = _("De-select if you don't want LyX to create backup files.");
2249 case RC_MARK_FOREIGN_LANGUAGE:
2250 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2253 case RC_NUMLASTFILES:
2254 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."),
2258 case RC_PATH_PREFIX:
2259 str = _("Specify those directories which should be "
2260 "prepended to the PATH environment variable. "
2261 "Use the OS native format.");
2265 case RC_USE_PERS_DICT:
2266 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2270 str = _("Shows a typeset preview of things such as math");
2273 case RC_PREVIEW_HASHED_LABELS:
2274 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2277 case RC_PREVIEW_SCALE_FACTOR:
2278 str = _("Scale the preview size to suit.");
2281 case RC_PRINTCOLLCOPIESFLAG:
2282 str = _("The option for specifying whether the copies should be collated.");
2285 case RC_PRINTCOPIESFLAG:
2286 str = _("The option for specifying the number of copies to print.");
2290 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2293 case RC_PRINTEVENPAGEFLAG:
2294 str = _("The option to print only even pages.");
2297 case RC_PRINTEXSTRAOPTIONS:
2298 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2301 case RC_PRINTFILEEXTENSION:
2302 str = _("Extension of printer program output file. Usually \".ps\".");
2305 case RC_PRINTLANDSCAPEFLAG:
2306 str = _("The option to print out in landscape.");
2309 case RC_PRINTODDPAGEFLAG:
2310 str = _("The option to print only odd pages.");
2313 case RC_PRINTPAGERANGEFLAG:
2314 str = _("The option for specifying a comma-separated list of pages to print.");
2317 case RC_PRINTPAPERDIMENSIONFLAG:
2318 str = _("Option to specify the dimensions of the print paper.");
2321 case RC_PRINTPAPERFLAG:
2322 str = _("The option to specify paper type.");
2325 case RC_PRINTREVERSEFLAG:
2326 str = _("The option to reverse the order of the pages printed.");
2329 case RC_PRINTSPOOL_COMMAND:
2330 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.");
2333 case RC_PRINTSPOOL_PRINTERPREFIX:
2334 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.");
2337 case RC_PRINTTOFILE:
2338 str = _("Option to pass to the print program to print to a file.");
2341 case RC_PRINTTOPRINTER:
2342 str = _("Option to pass to the print program to print on a specific printer.");
2345 case RC_PRINT_ADAPTOUTPUT:
2346 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2349 case RC_PRINT_COMMAND:
2350 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2353 case RC_RTL_SUPPORT:
2354 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2358 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2361 case RC_SCREEN_FONT_ROMAN:
2362 case RC_SCREEN_FONT_SANS:
2363 case RC_SCREEN_FONT_TYPEWRITER:
2364 str = _("The screen fonts used to display the text while editing.");
2367 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
2368 case RC_SCREEN_FONT_SANS_FOUNDRY:
2369 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2372 case RC_SCREEN_FONT_SCALABLE:
2373 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.");
2376 case RC_SCREEN_FONT_SIZES:
2377 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2380 case RC_SCREEN_ZOOM:
2381 //xgettext:no-c-format
2382 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2385 case RC_SCREEN_GEOMETRY_HEIGHT:
2386 case RC_SCREEN_GEOMETRY_WIDTH:
2387 str = _("Specify geometry of the main view in width x height (values from last session will not be used if non-zero values are specified).");
2390 case RC_SCREEN_GEOMETRY_XYSAVED:
2391 str = _("Allow session manager to save and restore windows position.");
2395 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2401 case RC_SHOW_BANNER:
2402 str = _("De-select if you don't want the startup banner.");
2405 case RC_SPELL_COMMAND:
2406 str = _("What command runs the spellchecker?");
2409 case RC_TEMPDIRPATH:
2410 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2413 case RC_TEMPLATEPATH:
2414 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2417 case RC_TEX_ALLOWS_SPACES:
2420 case RC_TEX_EXPECTS_WINDOWS_PATHS:
2424 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2436 case RC_USE_INP_ENC:
2437 str = _("Specify whether to pass the -T input encoding option to ispell. Enable this if you cannot check the spelling of words containing accented letters. This may not work with all dictionaries.");
2440 case RC_USE_SPELL_LIB:
2443 case RC_VIEWDVI_PAPEROPTION:
2444 _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2459 // The global instance
2462 // The global copy of the system lyxrc entries (everything except preferences)