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, string const & name) const
1215 LyXRCTags tag = RC_LAST;
1217 if (!name.empty()) {
1218 for (size_t i = 0; i < lyxrcCount; ++i)
1219 if ("\\" + name == lyxrcTags[i].tag)
1220 tag = static_cast<LyXRCTags>(lyxrcTags[i].code);
1224 os << "### This file is part of\n"
1225 << "### ========================================================\n"
1226 << "### LyX, The Document Processor\n"
1228 << "### Copyright 1995 Matthias Ettrich\n"
1229 << "### Copyright 1995-2001 The LyX Team.\n"
1231 << "### ========================================================\n"
1233 << "# This file is written by LyX, if you want to make your own\n"
1234 << "# modifications you should do them from inside LyX and save\n"
1237 // Why the switch you might ask. It is a trick to ensure that all
1238 // the elements in the LyXRCTags enum is handled. As you can see
1239 // there are no breaks at all. So it is just a huge fall-through.
1240 // The nice thing is that we will get a warning from the compiler
1241 // if we forget an element.
1245 // input/include files are not done here
1247 if (ignore_system_lyxrc ||
1248 bind_file != system_lyxrc.bind_file) {
1249 string const path = os::external_path(bind_file);
1250 os << "\\bind_file \"" << path << "\"\n";
1259 << "# MISC SECTION ######################################\n"
1261 // bind files are not done here.
1263 case RC_PATH_PREFIX:
1264 if (ignore_system_lyxrc ||
1265 path_prefix != system_lyxrc.path_prefix) {
1266 os << "\\path_prefix \"" << path_prefix << "\"\n";
1271 if (ignore_system_lyxrc ||
1272 ui_file != system_lyxrc.ui_file) {
1273 string const path = os::external_path(ui_file);
1274 os << "\\ui_file \"" << path << "\"\n";
1278 case RC_AUTOREGIONDELETE:
1279 if (ignore_system_lyxrc ||
1280 auto_region_delete != system_lyxrc.auto_region_delete) {
1281 os << "# Set to false to inhibit automatic replacement of\n"
1282 << "# the current selection.\n"
1283 << "\\auto_region_delete " << convert<string>(auto_region_delete)
1288 case RC_AUTORESET_OPTIONS:
1289 if (ignore_system_lyxrc ||
1290 auto_reset_options != system_lyxrc.auto_reset_options) {
1291 os << "# Set to false to inhibit automatic reset of\n"
1292 << "# the class options to defaults on class change.\n"
1293 << "\\auto_reset_options "
1294 << convert<string>(auto_reset_options)
1300 if (ignore_system_lyxrc ||
1301 autosave != system_lyxrc.autosave) {
1302 os << "# The time interval between auto-saves in seconds.\n"
1303 << "\\autosave " << autosave << '\n';
1307 case RC_DISPLAY_GRAPHICS:
1308 if (ignore_system_lyxrc ||
1309 display_graphics != system_lyxrc.display_graphics) {
1310 os << "# Display graphics within LyX\n"
1311 << "# monochrome|grayscale|color|none\n"
1312 << "\\display_graphics "
1313 << graphics::displayTranslator().find(display_graphics)
1319 case RC_VIEWDVI_PAPEROPTION:
1320 if (ignore_system_lyxrc ||
1321 view_dvi_paper_option
1322 != system_lyxrc.view_dvi_paper_option) {
1323 os << "# Options used to specify paper size to the\n"
1324 << "# view_dvi_command (e.g. -paper)\n"
1325 << "\\view_dvi_paper_option \""
1326 << view_dvi_paper_option << "\"\n";
1330 case RC_DEFAULT_PAPERSIZE:
1331 if (ignore_system_lyxrc ||
1332 default_papersize != system_lyxrc.default_papersize) {
1333 os << "# The default papersize to use.\n"
1334 << "\\default_papersize \"";
1335 switch (default_papersize) {
1337 os << "default"; break;
1338 case PAPER_USLETTER:
1339 os << "usletter"; break;
1341 os << "legal"; break;
1342 case PAPER_USEXECUTIVE:
1343 os << "executive"; break;
1354 case PAPER_B4: break;
1360 case RC_CHKTEX_COMMAND:
1361 if (ignore_system_lyxrc ||
1362 chktex_command != system_lyxrc.chktex_command) {
1363 os << "\\chktex_command \"" << chktex_command << "\"\n";
1367 case RC_BIBTEX_COMMAND:
1368 if (ignore_system_lyxrc ||
1369 bibtex_command != system_lyxrc.bibtex_command) {
1370 os << "\\bibtex_command \"" << bibtex_command << "\"\n";
1374 case RC_INDEX_COMMAND:
1375 if (ignore_system_lyxrc ||
1376 index_command != system_lyxrc.index_command) {
1377 os << "\\index_command \"" << index_command << "\"\n";
1381 case RC_TEX_EXPECTS_WINDOWS_PATHS:
1382 if (ignore_system_lyxrc ||
1383 windows_style_tex_paths != system_lyxrc.windows_style_tex_paths) {
1384 os << "\\tex_expects_windows_paths "
1385 << convert<string>(windows_style_tex_paths) << '\n';
1389 case RC_TEX_ALLOWS_SPACES:
1390 if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
1391 os << "\\tex_allows_spaces "
1392 << convert<string>(tex_allows_spaces) << '\n';
1397 if (ignore_system_lyxrc ||
1398 use_kbmap != system_lyxrc.use_kbmap) {
1399 os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1403 case RC_KBMAP_PRIMARY:
1404 if (ignore_system_lyxrc ||
1405 primary_kbmap != system_lyxrc.primary_kbmap) {
1406 string const path = os::external_path(primary_kbmap);
1407 os << "\\kbmap_primary \"" << path << "\"\n";
1411 case RC_KBMAP_SECONDARY:
1412 if (ignore_system_lyxrc ||
1413 secondary_kbmap != system_lyxrc.secondary_kbmap) {
1414 string const path = os::external_path(secondary_kbmap);
1415 os << "\\kbmap_secondary \"" << path << "\"\n";
1420 if (ignore_system_lyxrc ||
1421 lyxpipes != system_lyxrc.lyxpipes) {
1422 string const path = os::external_path(lyxpipes);
1423 os << "\\serverpipe \"" << path << "\"\n";
1427 case RC_DATE_INSERT_FORMAT:
1428 if (ignore_system_lyxrc ||
1429 date_insert_format != system_lyxrc.date_insert_format) {
1430 os << "\\date_insert_format \"" << date_insert_format
1435 case RC_LABEL_INIT_LENGTH:
1436 if (ignore_system_lyxrc ||
1437 label_init_length != system_lyxrc.label_init_length) {
1438 os << "\\label_init_length " << label_init_length
1445 os << "\\user_name \"" << user_name << "\"\n";
1450 os << "\\user_email \"" << user_email << "\"\n";
1454 case RC_SHOW_BANNER:
1455 if (ignore_system_lyxrc ||
1456 show_banner != system_lyxrc.show_banner) {
1457 os << "\\show_banner " << convert<string>(show_banner) << '\n';
1463 if (ignore_system_lyxrc ||
1464 preview != system_lyxrc.preview) {
1470 case PREVIEW_NO_MATH:
1477 os << "\\preview " << status << '\n';
1482 case RC_PREVIEW_HASHED_LABELS:
1483 if (ignore_system_lyxrc ||
1484 preview_hashed_labels !=
1485 system_lyxrc.preview_hashed_labels) {
1486 os << "\\preview_hashed_labels "
1487 << convert<string>(preview_hashed_labels) << '\n';
1492 case RC_PREVIEW_SCALE_FACTOR:
1493 if (ignore_system_lyxrc ||
1494 preview_scale_factor != system_lyxrc.preview_scale_factor) {
1495 os << "\\preview_scale_factor "
1496 << preview_scale_factor << '\n';
1501 case RC_USE_CONVERTER_CACHE:
1502 if (ignore_system_lyxrc ||
1503 use_converter_cache != system_lyxrc.use_converter_cache) {
1504 os << "\\use_converter_cache "
1505 << convert<string>(use_converter_cache) << '\n';
1510 case RC_CONVERTER_CACHE_MAXAGE:
1511 if (ignore_system_lyxrc ||
1512 converter_cache_maxage != system_lyxrc.converter_cache_maxage) {
1513 os << "\\converter_cache_maxage "
1514 << converter_cache_maxage << '\n';
1520 << "# SCREEN & FONTS SECTION ############################\n"
1524 if (ignore_system_lyxrc ||
1525 dpi != system_lyxrc.dpi) {
1526 os << "\\screen_dpi " << dpi << '\n';
1530 case RC_SCREEN_ZOOM:
1531 if (ignore_system_lyxrc ||
1532 zoom != system_lyxrc.zoom) {
1533 os << "\\screen_zoom " << zoom << '\n';
1537 case RC_SCREEN_GEOMETRY_HEIGHT:
1538 if (ignore_system_lyxrc ||
1539 geometry_height != system_lyxrc.geometry_height) {
1540 os << "\\screen_geometry_height " << geometry_height
1545 case RC_SCREEN_GEOMETRY_WIDTH:
1546 if (ignore_system_lyxrc ||
1547 geometry_width != system_lyxrc.geometry_width) {
1548 os << "\\screen_geometry_width " << geometry_width
1553 case RC_SCREEN_GEOMETRY_XYSAVED:
1554 if (ignore_system_lyxrc ||
1555 geometry_xysaved != system_lyxrc.geometry_xysaved) {
1556 os << "\\screen_geometry_xysaved " << convert<string>(geometry_xysaved)
1561 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1562 if (ignore_system_lyxrc ||
1563 cursor_follows_scrollbar
1564 != system_lyxrc.cursor_follows_scrollbar) {
1565 os << "\\cursor_follows_scrollbar "
1566 << convert<string>(cursor_follows_scrollbar) << '\n';
1570 case RC_DIALOGS_ICONIFY_WITH_MAIN:
1571 if (ignore_system_lyxrc ||
1572 dialogs_iconify_with_main
1573 != system_lyxrc.dialogs_iconify_with_main) {
1574 os << "\\dialogs_iconify_with_main "
1575 << convert<string>(dialogs_iconify_with_main) << '\n';
1579 case RC_SCREEN_FONT_ROMAN:
1580 if (ignore_system_lyxrc ||
1581 roman_font_name != system_lyxrc.roman_font_name) {
1582 os << "\\screen_font_roman \"" << roman_font_name
1587 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1588 if (ignore_system_lyxrc ||
1589 roman_font_foundry != system_lyxrc.roman_font_foundry) {
1590 os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1595 case RC_SCREEN_FONT_SANS:
1596 if (ignore_system_lyxrc ||
1597 sans_font_name != system_lyxrc.sans_font_name) {
1598 os << "\\screen_font_sans \"" << sans_font_name
1603 case RC_SCREEN_FONT_SANS_FOUNDRY:
1604 if (ignore_system_lyxrc ||
1605 sans_font_foundry != system_lyxrc.sans_font_foundry) {
1606 os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1611 case RC_SCREEN_FONT_TYPEWRITER:
1612 if (ignore_system_lyxrc ||
1613 typewriter_font_name != system_lyxrc.typewriter_font_name) {
1614 os << "\\screen_font_typewriter \""
1615 << typewriter_font_name << "\"\n";
1619 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1620 if (ignore_system_lyxrc ||
1621 typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1622 os << "\\screen_font_typewriter_foundry \""
1623 << typewriter_font_foundry << "\"\n";
1628 case RC_SCREEN_FONT_SCALABLE:
1629 if (ignore_system_lyxrc ||
1630 use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1631 os << "\\screen_font_scalable "
1632 << convert<string>(use_scalable_fonts)
1637 case RC_SCREEN_FONT_SIZES:
1638 if (ignore_system_lyxrc ||
1639 font_sizes[Font::SIZE_TINY]
1640 != system_lyxrc.font_sizes[Font::SIZE_TINY] ||
1641 font_sizes[Font::SIZE_SCRIPT]
1642 != system_lyxrc.font_sizes[Font::SIZE_SCRIPT] ||
1643 font_sizes[Font::SIZE_FOOTNOTE]
1644 != system_lyxrc.font_sizes[Font::SIZE_FOOTNOTE] ||
1645 font_sizes[Font::SIZE_SMALL]
1646 != system_lyxrc.font_sizes[Font::SIZE_SMALL] ||
1647 font_sizes[Font::SIZE_NORMAL]
1648 != system_lyxrc.font_sizes[Font::SIZE_NORMAL] ||
1649 font_sizes[Font::SIZE_LARGE]
1650 != system_lyxrc.font_sizes[Font::SIZE_LARGE] ||
1651 font_sizes[Font::SIZE_LARGER]
1652 != system_lyxrc.font_sizes[Font::SIZE_LARGER] ||
1653 font_sizes[Font::SIZE_LARGEST]
1654 != system_lyxrc.font_sizes[Font::SIZE_LARGEST] ||
1655 font_sizes[Font::SIZE_HUGE]
1656 != system_lyxrc.font_sizes[Font::SIZE_HUGE] ||
1657 font_sizes[Font::SIZE_HUGER]
1658 != system_lyxrc.font_sizes[Font::SIZE_HUGER]) {
1659 os.setf(ios::fixed);
1661 os << "\\screen_font_sizes"
1662 << ' ' << font_sizes[Font::SIZE_TINY]
1663 << ' ' << font_sizes[Font::SIZE_SCRIPT]
1664 << ' ' << font_sizes[Font::SIZE_FOOTNOTE]
1665 << ' ' << font_sizes[Font::SIZE_SMALL]
1666 << ' ' << font_sizes[Font::SIZE_NORMAL]
1667 << ' ' << font_sizes[Font::SIZE_LARGE]
1668 << ' ' << font_sizes[Font::SIZE_LARGER]
1669 << ' ' << font_sizes[Font::SIZE_LARGEST]
1670 << ' ' << font_sizes[Font::SIZE_HUGE]
1671 << ' ' << font_sizes[Font::SIZE_HUGER]
1678 << "# COLOR SECTION ###################################\n"
1682 for (int i = 0; i < Color::ignore; ++i) {
1683 Color::color lc = static_cast<Color::color>(i);
1685 string const col(lcolor.getX11Name(lc));
1686 if (ignore_system_lyxrc ||
1687 col != system_lcolor.getX11Name(lc)) {
1688 os << "\\set_color \""
1689 << lcolor.getLyXName(lc) << "\" \""
1697 << "# PRINTER SECTION ###################################\n"
1701 if (ignore_system_lyxrc ||
1702 printer != system_lyxrc.printer) {
1703 os << "\\printer \"" << printer << "\"\n";
1707 case RC_PRINT_ADAPTOUTPUT:
1708 if (ignore_system_lyxrc ||
1709 print_adapt_output != system_lyxrc.print_adapt_output) {
1710 os << "\\print_adapt_output "
1711 << convert<string>(print_adapt_output)
1716 case RC_PRINT_COMMAND:
1717 if (ignore_system_lyxrc ||
1718 print_command != system_lyxrc.print_command) {
1719 os << "\\print_command \"" << print_command << "\"\n";
1723 case RC_PRINTEXSTRAOPTIONS:
1724 if (ignore_system_lyxrc ||
1725 print_extra_options != system_lyxrc.print_extra_options) {
1726 os << "\\print_extra_options \"" << print_extra_options
1731 case RC_PRINTSPOOL_COMMAND:
1732 if (ignore_system_lyxrc ||
1733 print_spool_command != system_lyxrc.print_spool_command) {
1734 os << "\\print_spool_command \"" << print_spool_command
1739 case RC_PRINTSPOOL_PRINTERPREFIX:
1740 if (ignore_system_lyxrc ||
1741 print_spool_printerprefix
1742 != system_lyxrc.print_spool_printerprefix) {
1743 os << "\\print_spool_printerprefix \""
1744 << print_spool_printerprefix << "\"\n";
1748 case RC_PRINTEVENPAGEFLAG:
1749 if (ignore_system_lyxrc ||
1750 print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1751 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1756 case RC_PRINTODDPAGEFLAG:
1757 if (ignore_system_lyxrc ||
1758 print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1759 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1764 case RC_PRINTREVERSEFLAG:
1765 if (ignore_system_lyxrc ||
1766 print_reverse_flag != system_lyxrc.print_reverse_flag) {
1767 os << "\\print_reverse_flag \"" << print_reverse_flag
1772 case RC_PRINTLANDSCAPEFLAG:
1773 if (ignore_system_lyxrc ||
1774 print_landscape_flag != system_lyxrc.print_landscape_flag) {
1775 os << "\\print_landscape_flag \"" << print_landscape_flag
1780 case RC_PRINTPAGERANGEFLAG:
1781 if (ignore_system_lyxrc ||
1782 print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1783 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1788 case RC_PRINTCOPIESFLAG:
1789 if (ignore_system_lyxrc ||
1790 print_copies_flag != system_lyxrc.print_copies_flag) {
1791 os << "\\print_copies_flag \"" << print_copies_flag
1796 case RC_PRINTCOLLCOPIESFLAG:
1797 if (ignore_system_lyxrc ||
1798 print_collcopies_flag
1799 != system_lyxrc.print_collcopies_flag) {
1800 os << "\\print_collcopies_flag \""
1801 << print_collcopies_flag
1806 case RC_PRINTPAPERFLAG:
1807 if (ignore_system_lyxrc ||
1808 print_paper_flag != system_lyxrc.print_paper_flag) {
1809 os << "\\print_paper_flag \"" << print_paper_flag
1814 case RC_PRINTPAPERDIMENSIONFLAG:
1815 if (ignore_system_lyxrc ||
1816 print_paper_dimension_flag
1817 != system_lyxrc.print_paper_dimension_flag) {
1818 os << "\\print_paper_dimension_flag \""
1819 << print_paper_dimension_flag << "\"\n";
1823 case RC_PRINTTOPRINTER:
1824 if (ignore_system_lyxrc ||
1825 print_to_printer != system_lyxrc.print_to_printer) {
1826 os << "\\print_to_printer \"" << print_to_printer
1831 case RC_PRINTTOFILE:
1832 if (ignore_system_lyxrc ||
1833 print_to_file != system_lyxrc.print_to_file) {
1834 string const path = os::external_path(print_to_file);
1835 os << "\\print_to_file \"" << path << "\"\n";
1839 case RC_PRINTFILEEXTENSION:
1840 if (ignore_system_lyxrc ||
1841 print_file_extension != system_lyxrc.print_file_extension) {
1842 os << "\\print_file_extension \""
1843 << print_file_extension
1850 << "# EXPORT SECTION ####################################\n"
1853 case RC_CUSTOM_EXPORT_COMMAND:
1854 if (ignore_system_lyxrc ||
1855 custom_export_command
1856 != system_lyxrc.custom_export_command) {
1857 os << "\\custom_export_command \""
1858 << custom_export_command
1863 case RC_CUSTOM_EXPORT_FORMAT:
1864 if (ignore_system_lyxrc ||
1865 custom_export_format
1866 != system_lyxrc.custom_export_format) {
1867 os << "\\custom_export_format \"" << custom_export_format
1874 << "# TEX SECTION #######################################\n"
1877 case RC_FONT_ENCODING:
1878 if (ignore_system_lyxrc ||
1879 fontenc != system_lyxrc.fontenc) {
1880 os << "\\font_encoding \"" << fontenc << "\"\n";
1886 << "# FILE SECTION ######################################\n"
1889 case RC_DOCUMENTPATH:
1890 if (ignore_system_lyxrc ||
1891 document_path != system_lyxrc.document_path) {
1892 string const path = os::external_path(document_path);
1893 os << "\\document_path \"" << path << "\"\n";
1897 case RC_USELASTFILEPOS:
1898 if (ignore_system_lyxrc ||
1899 use_lastfilepos != system_lyxrc.use_lastfilepos) {
1900 os << "\\use_lastfilepos " << convert<string>(use_lastfilepos)
1905 case RC_LOADSESSION:
1906 if (ignore_system_lyxrc ||
1907 load_session != system_lyxrc.load_session) {
1908 os << "\\load_session " << convert<string>(load_session)
1913 case RC_NUMLASTFILES:
1914 if (ignore_system_lyxrc ||
1915 num_lastfiles != system_lyxrc.num_lastfiles) {
1916 os << "\\num_lastfiles " << num_lastfiles << '\n';
1920 case RC_CHECKLASTFILES:
1921 if (ignore_system_lyxrc ||
1922 check_lastfiles != system_lyxrc.check_lastfiles) {
1923 os << "\\check_lastfiles " << convert<string>(check_lastfiles)
1928 case RC_TEMPLATEPATH:
1929 if (ignore_system_lyxrc ||
1930 template_path != system_lyxrc.template_path) {
1931 string const path = os::external_path(template_path);
1932 os << "\\template_path \"" << path << "\"\n";
1936 case RC_TEMPDIRPATH:
1937 if (ignore_system_lyxrc ||
1938 tempdir_path != system_lyxrc.tempdir_path) {
1939 string const path = os::external_path(tempdir_path);
1940 os << "\\tempdir_path \"" << path << "\"\n";
1948 case RC_PLAINTEXT_LINELEN:
1949 if (ignore_system_lyxrc ||
1950 plaintext_linelen != system_lyxrc.plaintext_linelen) {
1951 os << "\\plaintext_linelen " << plaintext_linelen << '\n';
1955 case RC_MAKE_BACKUP:
1956 if (ignore_system_lyxrc ||
1957 make_backup != system_lyxrc.make_backup) {
1958 os << "\\make_backup " << convert<string>(make_backup) << '\n';
1962 case RC_BACKUPDIR_PATH:
1963 if (ignore_system_lyxrc ||
1964 backupdir_path != system_lyxrc.backupdir_path) {
1965 string const path = os::external_path(backupdir_path);
1966 os << "\\backupdir_path \"" << path << "\"\n";
1972 << "# PLAIN TEXT EXPORT SECTION ##############################\n"
1975 case RC_PLAINTEXT_ROFF_COMMAND:
1976 if (ignore_system_lyxrc ||
1977 plaintext_roff_command != system_lyxrc.plaintext_roff_command) {
1978 os << "\\plaintext_roff_command \"" << plaintext_roff_command
1985 << "# SPELLCHECKER SECTION ##############################\n"
1987 case RC_USE_SPELL_LIB:
1988 if (ignore_system_lyxrc ||
1989 use_spell_lib != system_lyxrc.use_spell_lib) {
1990 os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
1994 case RC_SPELL_COMMAND:
1995 if (ignore_system_lyxrc ||
1996 isp_command != system_lyxrc.isp_command) {
1997 os << "\\spell_command \"" << isp_command << "\"\n";
2001 case RC_ACCEPT_COMPOUND:
2002 if (ignore_system_lyxrc ||
2003 isp_accept_compound != system_lyxrc.isp_accept_compound) {
2004 os << "\\accept_compound " << convert<string>(isp_accept_compound)
2009 case RC_USE_ALT_LANG:
2010 if (ignore_system_lyxrc ||
2011 isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
2012 os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
2018 if (ignore_system_lyxrc ||
2019 isp_alt_lang != system_lyxrc.isp_alt_lang) {
2020 os << "\\alternate_language \"" << isp_alt_lang
2025 case RC_USE_ESC_CHARS:
2026 if (ignore_system_lyxrc ||
2027 isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
2028 os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
2034 if (ignore_system_lyxrc ||
2035 isp_esc_chars != system_lyxrc.isp_esc_chars) {
2036 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
2040 case RC_USE_PERS_DICT:
2041 if (ignore_system_lyxrc ||
2042 isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
2043 os << "\\use_personal_dictionary "
2044 << convert<string>(isp_use_pers_dict)
2050 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
2051 string const path = os::external_path(isp_pers_dict);
2052 os << "\\personal_dictionary \"" << path << "\"\n";
2056 case RC_USE_INP_ENC:
2057 if (ignore_system_lyxrc ||
2058 isp_use_input_encoding
2059 != system_lyxrc.isp_use_input_encoding) {
2060 os << "\\use_input_encoding "
2061 << convert<string>(isp_use_input_encoding)
2068 << "# LANGUAGE SUPPORT SECTION ##########################\n"
2071 case RC_RTL_SUPPORT:
2072 if (ignore_system_lyxrc ||
2073 rtl_support != system_lyxrc.rtl_support) {
2074 os << "\\rtl " << convert<string>(rtl_support) << '\n';
2078 case RC_LANGUAGE_PACKAGE:
2079 if (ignore_system_lyxrc ||
2080 language_package != system_lyxrc.language_package) {
2081 os << "\\language_package \"" << language_package
2086 case RC_LANGUAGE_GLOBAL_OPTIONS:
2087 if (ignore_system_lyxrc ||
2088 language_global_options
2089 != system_lyxrc.language_global_options) {
2090 os << "\\language_global_options \""
2091 << convert<string>(language_global_options)
2096 case RC_LANGUAGE_USE_BABEL:
2097 if (ignore_system_lyxrc ||
2098 language_use_babel != system_lyxrc.language_use_babel) {
2099 os << "\\language_use_babel \""
2100 << convert<string>(language_use_babel)
2105 case RC_LANGUAGE_COMMAND_BEGIN:
2106 if (ignore_system_lyxrc ||
2107 language_command_begin
2108 != system_lyxrc.language_command_begin) {
2109 os << "\\language_command_begin \""
2110 << language_command_begin
2115 case RC_LANGUAGE_COMMAND_END:
2116 if (ignore_system_lyxrc ||
2117 language_command_end
2118 != system_lyxrc.language_command_end) {
2119 os << "\\language_command_end \"" << language_command_end
2124 case RC_LANGUAGE_COMMAND_LOCAL:
2125 if (ignore_system_lyxrc ||
2126 language_command_local
2127 != system_lyxrc.language_command_local) {
2128 os << "\\language_command_local \""
2129 << language_command_local
2134 case RC_LANGUAGE_AUTO_BEGIN:
2135 if (ignore_system_lyxrc ||
2136 language_auto_begin != system_lyxrc.language_auto_begin) {
2137 os << "\\language_auto_begin "
2138 << convert<string>(language_auto_begin) << '\n';
2142 case RC_LANGUAGE_AUTO_END:
2143 if (ignore_system_lyxrc ||
2144 language_auto_end != system_lyxrc.language_auto_end) {
2145 os << "\\language_auto_end "
2146 << convert<string>(language_auto_end) << '\n';
2150 case RC_MARK_FOREIGN_LANGUAGE:
2151 if (ignore_system_lyxrc ||
2152 mark_foreign_language
2153 != system_lyxrc.mark_foreign_language) {
2154 os << "\\mark_foreign_language " <<
2155 convert<string>(mark_foreign_language) << '\n';
2161 << "# 2nd MISC SUPPORT SECTION ##########################\n"
2164 case RC_AUTO_NUMBER:
2165 if (ignore_system_lyxrc ||
2166 auto_number != system_lyxrc.auto_number) {
2167 os << "\\auto_number " << convert<string>(auto_number) << '\n';
2171 case RC_DEFAULT_LANGUAGE:
2172 if (ignore_system_lyxrc ||
2173 default_language != system_lyxrc.default_language) {
2174 os << "\\default_language " << default_language << '\n';
2180 << "# FORMATS SECTION ##########################\n"
2184 // New/modified formats
2185 for (Formats::const_iterator cit = formats.begin();
2186 cit != formats.end(); ++cit) {
2187 Format const * format =
2188 system_formats.getFormat(cit->name());
2190 format->extension() != cit->extension() ||
2191 format->prettyname() != cit->prettyname() ||
2192 format->shortcut() != cit->shortcut() ||
2193 format->viewer() != cit->viewer() ||
2194 format->editor() != cit->editor() ||
2195 format->documentFormat() != cit->documentFormat() ||
2196 format->vectorFormat() != cit->vectorFormat()) {
2197 os << "\\format \"" << cit->name() << "\" \""
2198 << cit->extension() << "\" \""
2199 << cit->prettyname() << "\" \""
2200 << cit->shortcut() << "\" \""
2201 << cit->viewer() << "\" \""
2202 << cit->editor() << "\" \"";
2203 std::vector<string> flags;
2204 if (cit->documentFormat())
2205 flags.push_back("document");
2206 if (cit->vectorFormat())
2207 flags.push_back("vector");
2208 os << support::getStringFromVector(flags);
2213 // Look for deleted formats
2214 for (Formats::const_iterator cit = system_formats.begin();
2215 cit != system_formats.end(); ++cit)
2216 if (!formats.getFormat(cit->name()))
2217 os << "\\format \"" << cit->name()
2218 << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
2227 << "# CONVERTERS SECTION ##########################\n"
2231 // Look for new converters
2232 for (Converters::const_iterator cit = theConverters().begin();
2233 cit != theConverters().end(); ++cit) {
2234 Converter const * converter =
2235 theSystemConverters().getConverter(cit->from,
2238 converter->command != cit->command ||
2239 converter->flags != cit->flags)
2240 os << "\\converter \"" << cit->from << "\" \""
2241 << cit->to << "\" \""
2242 << cit->command << "\" \""
2243 << cit->flags << "\"\n";
2246 // New/modifed converters
2247 for (Converters::const_iterator cit = theSystemConverters().begin();
2248 cit != theSystemConverters().end(); ++cit)
2249 if (!theConverters().getConverter(cit->from, cit->to))
2250 os << "\\converter \"" << cit->from
2251 << "\" \"" << cit->to << "\" \"\" \"\"\n";
2258 << "# COPIERS SECTION ##########################\n"
2261 // Look for new movers
2262 Movers::const_iterator const sysbegin = theSystemMovers().begin();
2263 Movers::const_iterator const sysend = theSystemMovers().end();
2264 Movers::const_iterator it = theMovers().begin();
2265 Movers::const_iterator end = theMovers().end();
2267 for (; it != end; ++it) {
2268 Movers::const_iterator const sysit =
2269 std::find_if(sysbegin, sysend, SameMover(*it));
2270 if (sysit == sysend) {
2271 std::string const & fmt = it->first;
2272 std::string const & command =
2273 it->second.command();
2275 os << "\\copier " << fmt
2276 << " \"" << command << "\"\n";
2282 // We don't actually delete SpecialisedMover(s) from the
2283 // map, just clear their 'command', so there's no need
2284 // to test for anything else.
2292 string const LyXRC::getDescription(LyXRCTags tag)
2297 case RC_ACCEPT_COMPOUND:
2298 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2302 case RC_USE_ALT_LANG:
2303 str = _("Specify an alternate language. The default is to use the language of the document.");
2306 case RC_PLAINTEXT_ROFF_COMMAND:
2307 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.");
2310 case RC_PLAINTEXT_LINELEN:
2311 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.");
2314 case RC_AUTOREGIONDELETE:
2315 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2318 case RC_AUTORESET_OPTIONS:
2319 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2323 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2326 case RC_AUTO_NUMBER:
2329 case RC_BACKUPDIR_PATH:
2330 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.");
2333 case RC_BIBTEX_COMMAND:
2334 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2338 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2341 case RC_CHECKLASTFILES:
2342 str = _("Select to check whether the lastfiles still exist.");
2345 case RC_CHKTEX_COMMAND:
2346 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2355 case RC_CURSOR_FOLLOWS_SCROLLBAR:
2356 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.");
2359 case RC_CUSTOM_EXPORT_COMMAND:
2362 case RC_CUSTOM_EXPORT_FORMAT:
2365 case RC_DATE_INSERT_FORMAT:
2366 //xgettext:no-c-format
2367 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2370 case RC_DEFAULT_LANGUAGE:
2371 str = _("New documents will be assigned this language.");
2374 case RC_DEFAULT_PAPERSIZE:
2375 str = _("Specify the default paper size.");
2378 case RC_DIALOGS_ICONIFY_WITH_MAIN:
2379 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2382 case RC_DISPLAY_GRAPHICS:
2383 str = _("Select how LyX will display any graphics.");
2386 case RC_DOCUMENTPATH:
2387 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2391 case RC_USE_ESC_CHARS:
2392 str = _("Specify additional chars that can be part of a word.");
2395 case RC_FONT_ENCODING:
2396 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2402 case RC_INDEX_COMMAND:
2403 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\".");
2410 case RC_KBMAP_PRIMARY:
2411 case RC_KBMAP_SECONDARY:
2412 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.");
2415 case RC_LABEL_INIT_LENGTH:
2416 str = _("Maximum number of words in the initialization string for a new label");
2419 case RC_LANGUAGE_AUTO_BEGIN:
2420 str = _("Select if a language switching command is needed at the beginning of the document.");
2423 case RC_LANGUAGE_AUTO_END:
2424 str = _("Select if a language switching command is needed at the end of the document.");
2427 case RC_LANGUAGE_COMMAND_BEGIN:
2428 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.");
2431 case RC_LANGUAGE_COMMAND_END:
2432 str = _("The LaTeX command for changing back to the language of the document.");
2435 case RC_LANGUAGE_COMMAND_LOCAL:
2436 str = _("The LaTeX command for local changing of the language.");
2439 case RC_LANGUAGE_GLOBAL_OPTIONS:
2440 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2443 case RC_LANGUAGE_PACKAGE:
2444 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2447 case RC_LANGUAGE_USE_BABEL:
2448 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2451 case RC_USELASTFILEPOS:
2452 str = _("De-select if you do not want LyX to scroll to saved position.");
2455 case RC_LOADSESSION:
2456 str = _("De-select to prevent loading files opened from the last LyX session.");
2459 case RC_MAKE_BACKUP:
2460 str = _("De-select if you don't want LyX to create backup files.");
2463 case RC_MARK_FOREIGN_LANGUAGE:
2464 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2467 case RC_NUMLASTFILES:
2468 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."),
2472 case RC_PATH_PREFIX:
2473 str = _("Specify those directories which should be "
2474 "prepended to the PATH environment variable. "
2475 "Use the OS native format.");
2479 case RC_USE_PERS_DICT:
2480 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2484 str = _("Shows a typeset preview of things such as math");
2487 case RC_PREVIEW_HASHED_LABELS:
2488 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2491 case RC_PREVIEW_SCALE_FACTOR:
2492 str = _("Scale the preview size to suit.");
2495 case RC_PRINTCOLLCOPIESFLAG:
2496 str = _("The option for specifying whether the copies should be collated.");
2499 case RC_PRINTCOPIESFLAG:
2500 str = _("The option for specifying the number of copies to print.");
2504 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2507 case RC_PRINTEVENPAGEFLAG:
2508 str = _("The option to print only even pages.");
2511 case RC_PRINTEXSTRAOPTIONS:
2512 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2515 case RC_PRINTFILEEXTENSION:
2516 str = _("Extension of printer program output file. Usually \".ps\".");
2519 case RC_PRINTLANDSCAPEFLAG:
2520 str = _("The option to print out in landscape.");
2523 case RC_PRINTODDPAGEFLAG:
2524 str = _("The option to print only odd pages.");
2527 case RC_PRINTPAGERANGEFLAG:
2528 str = _("The option for specifying a comma-separated list of pages to print.");
2531 case RC_PRINTPAPERDIMENSIONFLAG:
2532 str = _("Option to specify the dimensions of the print paper.");
2535 case RC_PRINTPAPERFLAG:
2536 str = _("The option to specify paper type.");
2539 case RC_PRINTREVERSEFLAG:
2540 str = _("The option to reverse the order of the pages printed.");
2543 case RC_PRINTSPOOL_COMMAND:
2544 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.");
2547 case RC_PRINTSPOOL_PRINTERPREFIX:
2548 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.");
2551 case RC_PRINTTOFILE:
2552 str = _("Option to pass to the print program to print to a file.");
2555 case RC_PRINTTOPRINTER:
2556 str = _("Option to pass to the print program to print on a specific printer.");
2559 case RC_PRINT_ADAPTOUTPUT:
2560 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2563 case RC_PRINT_COMMAND:
2564 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2567 case RC_RTL_SUPPORT:
2568 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2572 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2575 case RC_SCREEN_FONT_ROMAN:
2576 case RC_SCREEN_FONT_SANS:
2577 case RC_SCREEN_FONT_TYPEWRITER:
2578 str = _("The screen fonts used to display the text while editing.");
2581 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
2582 case RC_SCREEN_FONT_SANS_FOUNDRY:
2583 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2586 case RC_SCREEN_FONT_SCALABLE:
2587 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.");
2590 case RC_SCREEN_FONT_SIZES:
2591 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2594 case RC_SCREEN_ZOOM:
2595 //xgettext:no-c-format
2596 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2599 case RC_SCREEN_GEOMETRY_HEIGHT:
2600 case RC_SCREEN_GEOMETRY_WIDTH:
2601 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).");
2604 case RC_SCREEN_GEOMETRY_XYSAVED:
2605 str = _("Allow session manager to save and restore windows position.");
2609 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2615 case RC_SHOW_BANNER:
2616 str = _("De-select if you don't want the startup banner.");
2619 case RC_SPELL_COMMAND:
2620 str = _("What command runs the spellchecker?");
2623 case RC_TEMPDIRPATH:
2624 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2627 case RC_TEMPLATEPATH:
2628 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2631 case RC_TEX_ALLOWS_SPACES:
2634 case RC_TEX_EXPECTS_WINDOWS_PATHS:
2638 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2650 case RC_USE_INP_ENC:
2651 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.");
2654 case RC_USE_SPELL_LIB:
2657 case RC_VIEWDVI_PAPEROPTION:
2658 _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2673 // The global instance
2676 // The global copy of the system lyxrc entries (everything except preferences)