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.
26 #include "Converter.h"
31 #include "FontEnums.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 { "\\def_file", LyXRC::RC_DEFFILE },
88 { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
89 { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
90 { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
91 { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
92 { "\\document_path", LyXRC::RC_DOCUMENTPATH },
93 { "\\escape_chars", LyXRC::RC_ESC_CHARS },
94 { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
95 { "\\format", LyXRC::RC_FORMAT },
96 { "\\index_command", LyXRC::RC_INDEX_COMMAND },
97 { "\\input", LyXRC::RC_INPUT },
98 { "\\kbmap", LyXRC::RC_KBMAP },
99 { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
100 { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
101 { "\\label_init_length", LyXRC::RC_LABEL_INIT_LENGTH },
102 { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
103 { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
104 { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
105 { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
106 { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
107 { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
108 { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
109 { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
110 { "\\load_session", LyXRC::RC_LOADSESSION },
111 { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
112 { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
113 { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
114 { "\\path_prefix", LyXRC::RC_PATH_PREFIX },
115 { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
116 { "\\plaintext_linelen", LyXRC::RC_PLAINTEXT_LINELEN },
117 { "\\plaintext_roff_command", LyXRC::RC_PLAINTEXT_ROFF_COMMAND },
118 { "\\preview", LyXRC::RC_PREVIEW },
119 { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
120 { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
121 { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
122 { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
123 { "\\print_command", LyXRC::RC_PRINT_COMMAND },
124 { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
125 { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
126 { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
127 { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
128 { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
129 { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
130 { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
131 { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
132 { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
133 { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
134 { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
135 { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
136 { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
137 { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
138 { "\\printer", LyXRC::RC_PRINTER },
139 { "\\rtl", LyXRC::RC_RTL_SUPPORT },
140 { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
141 { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
142 { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
143 { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
144 { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
145 { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
146 { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
147 { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
148 { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
149 { "\\screen_geometry_height", LyXRC::RC_SCREEN_GEOMETRY_HEIGHT },
150 { "\\screen_geometry_width", LyXRC::RC_SCREEN_GEOMETRY_WIDTH },
151 { "\\screen_geometry_xysaved", LyXRC::RC_SCREEN_GEOMETRY_XYSAVED },
152 { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
153 { "\\serverpipe", LyXRC::RC_SERVERPIPE },
154 { "\\set_color", LyXRC::RC_SET_COLOR },
155 { "\\show_banner", LyXRC::RC_SHOW_BANNER },
156 { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
157 { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
158 { "\\template_path", LyXRC::RC_TEMPLATEPATH },
159 { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
160 { "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS },
161 { "\\ui_file", LyXRC::RC_UIFILE },
162 { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
163 { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
164 { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
165 { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
166 { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
167 { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
168 // compatibility with versions older than 1.4.0 only
169 { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
170 { "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB },
171 // compatibility with versions older than 1.4.0 only
172 { "\\use_tempdir", LyXRC::RC_USETEMPDIR },
173 { "\\user_email", LyXRC::RC_USER_EMAIL },
174 { "\\user_name", LyXRC::RC_USER_NAME },
175 { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
176 // compatibility with versions older than 1.4.0 only
177 { "\\viewer" ,LyXRC::RC_VIEWER}
180 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
191 void LyXRC::setDefaults() {
193 def_file = "default";
195 // Get printer from the environment. If fail, use default "",
196 // assuming that everything is set up correctly.
197 printer = getEnv("PRINTER");
198 print_adapt_output = false;
199 print_command = "dvips";
200 print_evenpage_flag = "-B";
201 print_oddpage_flag = "-A";
202 print_pagerange_flag = "-pp";
203 print_copies_flag = "-c";
204 print_collcopies_flag = "-C";
205 print_reverse_flag = "-r";
206 print_landscape_flag = "-t landscape";
207 print_to_printer = "-P";
208 print_to_file = "-o ";
209 print_file_extension = ".ps";
210 print_paper_flag = "-t";
211 print_paper_dimension_flag = "-T";
212 document_path.erase();
213 view_dvi_paper_option.erase();
214 default_papersize = PAPER_DEFAULT;
215 custom_export_format = "ps";
216 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
217 bibtex_command = "bibtex";
219 index_command = "makeindex -c -q";
221 // Because a screen typically is wider than a piece of paper:
225 geometry_xysaved = true;
226 // Default LaTeX font size:
227 font_sizes[FONT_SIZE_TINY] = "5.0";
228 font_sizes[FONT_SIZE_SCRIPT] = "7.0";
229 font_sizes[FONT_SIZE_FOOTNOTE] = "8.0";
230 font_sizes[FONT_SIZE_SMALL] = "9.0";
231 font_sizes[FONT_SIZE_NORMAL] = "10.0";
232 font_sizes[FONT_SIZE_LARGE] = "12.0";
233 font_sizes[FONT_SIZE_LARGER] = "14.4";
234 font_sizes[FONT_SIZE_LARGEST] = "17.26";
235 font_sizes[FONT_SIZE_HUGE] = "20.74";
236 font_sizes[FONT_SIZE_HUGER] = "24.88";
237 use_scalable_fonts = true;
238 roman_font_name = "";
240 typewriter_font_name = "";
242 auto_region_delete = true;
243 auto_reset_options = false;
244 plaintext_linelen = 65;
245 num_lastfiles = maxlastfiles;
246 check_lastfiles = true;
247 use_lastfilepos = true;
248 load_session = false;
250 backupdir_path.erase();
251 display_graphics = graphics::ColorDisplay;
252 // Spellchecker settings:
253 use_spell_lib = true;
254 isp_command = "ispell";
255 isp_accept_compound = false;
256 isp_use_input_encoding = false;
257 isp_use_alt_lang = false;
258 isp_use_pers_dict = false;
259 isp_use_esc_chars = false;
263 mark_foreign_language = true;
264 language_auto_begin = true;
265 language_auto_end = true;
266 language_global_options = true;
267 language_use_babel = true;
268 language_package = "\\usepackage{babel}";
269 language_command_begin = "\\selectlanguage{$$lang}";
270 language_command_local = "\\foreignlanguage{$$lang}{";
271 default_language = "english";
273 windows_style_tex_paths = false;
274 tex_allows_spaces = false;
275 date_insert_format = "%x";
276 cursor_follows_scrollbar = false;
277 dialogs_iconify_with_main = false;
278 label_init_length = 3;
279 preview = PREVIEW_OFF;
280 preview_hashed_labels = false;
281 preview_scale_factor = "0.9";
282 use_converter_cache = true;
283 converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
285 user_name = to_utf8(support::user_name());
287 user_email = to_utf8(support::user_email());
293 void oldFontFormat(string & family, string & foundry)
295 if (family.empty() || family[0] != '-')
297 foundry = token(family, '-', 1);
298 family = token(family, '-', 2);
306 int LyXRC::read(FileName const & filename)
308 Lexer lexrc(lyxrcTags, lyxrcCount);
309 if (lyxerr.debugging(Debug::PARSER))
310 lexrc.printTable(lyxerr);
312 lexrc.setFile(filename);
313 if (!lexrc.isOK()) return -2;
315 LYXERR(Debug::LYXRC) << "Reading '" << filename << "'..." << endl;
321 int LyXRC::read(std::istream & is)
323 Lexer lexrc(lyxrcTags, lyxrcCount);
324 if (lyxerr.debugging(Debug::PARSER))
325 lexrc.printTable(lyxerr);
328 if (!lexrc.isOK()) return -2;
330 LYXERR(Debug::LYXRC) << "Reading istream..." << endl;
336 int LyXRC::read(Lexer & lexrc)
338 if (!lexrc.isOK()) return -2;
340 while (lexrc.isOK()) {
341 // By using two switches we take advantage of the compiler
342 // telling us if we have missed a LyXRCTags element in
343 // the second switch.
344 // Note that this also shows a problem with Lexer since it
345 // helps us avoid taking advantage of the strictness of the
348 int le = lexrc.lex();
350 case Lexer::LEX_UNDEF:
351 lexrc.printError("Unknown tag `$$Token'");
353 case Lexer::LEX_FEOF:
357 switch (static_cast<LyXRCTags>(le)) {
358 case RC_INPUT: // Include file
361 libFileSearch(string(),
364 lexrc.printError("Error reading "
365 "included file: " + tmp.absFilename());
371 bind_file = os::internal_path(lexrc.getString());
377 def_file = os::internal_path(lexrc.getString());
383 ui_file = os::internal_path(lexrc.getString());
387 case RC_AUTORESET_OPTIONS:
389 auto_reset_options = lexrc.getBool();
393 case RC_DISPLAY_GRAPHICS:
395 display_graphics = graphics::displayTranslator().find(lexrc.getString());
399 case RC_TEX_EXPECTS_WINDOWS_PATHS:
401 windows_style_tex_paths = lexrc.getBool();
405 case RC_TEX_ALLOWS_SPACES:
407 tex_allows_spaces = lexrc.getBool();
413 use_kbmap = lexrc.getBool();
417 case RC_KBMAP_PRIMARY:
419 string const kmap(os::internal_path(lexrc.getString()));
422 } else if (!libFileSearch("kbd", kmap,
424 primary_kbmap = kmap;
426 lexrc.printError("LyX: Keymap `$$Token' not found");
431 case RC_KBMAP_SECONDARY:
433 string const kmap(os::internal_path(lexrc.getString()));
436 } else if (!libFileSearch("kbd", kmap,
438 secondary_kbmap = kmap;
440 lexrc.printError("LyX: Keymap `$$Token' not found");
445 case RC_FONT_ENCODING:
447 fontenc = lexrc.getString();
453 printer = lexrc.getString();
457 case RC_PRINT_COMMAND:
459 print_command = lexrc.getString();
463 case RC_PRINTEVENPAGEFLAG:
465 print_evenpage_flag = lexrc.getString();
469 case RC_PRINTODDPAGEFLAG:
471 print_oddpage_flag = lexrc.getString();
475 case RC_PRINTPAGERANGEFLAG:
477 print_pagerange_flag = lexrc.getString();
481 case RC_PRINTCOPIESFLAG:
483 print_copies_flag = lexrc.getString();
487 case RC_PRINTCOLLCOPIESFLAG:
489 print_collcopies_flag = lexrc.getString();
493 case RC_PRINTREVERSEFLAG:
495 print_reverse_flag = lexrc.getString();
499 case RC_PRINTLANDSCAPEFLAG:
501 print_landscape_flag = lexrc.getString();
505 case RC_PRINTTOPRINTER:
507 print_to_printer = lexrc.getString();
511 case RC_PRINT_ADAPTOUTPUT:
513 print_adapt_output = lexrc.getBool();
519 print_to_file = os::internal_path(lexrc.getString());
523 case RC_PRINTFILEEXTENSION:
525 print_file_extension = lexrc.getString();
529 case RC_PRINTEXSTRAOPTIONS:
531 print_extra_options = lexrc.getString();
535 case RC_PRINTSPOOL_COMMAND:
537 print_spool_command = lexrc.getString();
541 case RC_PRINTSPOOL_PRINTERPREFIX:
543 print_spool_printerprefix = lexrc.getString();
547 case RC_PRINTPAPERDIMENSIONFLAG:
549 print_paper_dimension_flag = lexrc.getString();
553 case RC_PRINTPAPERFLAG:
555 print_paper_flag = lexrc.getString();
559 case RC_CUSTOM_EXPORT_COMMAND:
561 custom_export_command = lexrc.getString();
565 case RC_CUSTOM_EXPORT_FORMAT:
567 custom_export_format = lexrc.getString();
571 case RC_DEFAULT_PAPERSIZE:
574 ascii_lowercase(lexrc.getString());
575 if (size == "usletter")
578 else if (size == "legal")
581 else if (size == "executive")
584 else if (size == "a3")
587 else if (size == "a4")
590 else if (size == "a5")
593 else if (size == "b5")
596 else if (size == "default")
602 case RC_VIEWDVI_PAPEROPTION:
604 view_dvi_paper_option = lexrc.getString();
606 view_dvi_paper_option.erase();
610 case RC_CHKTEX_COMMAND:
612 chktex_command = lexrc.getString();
616 case RC_BIBTEX_COMMAND:
618 bibtex_command = lexrc.getString();
622 case RC_INDEX_COMMAND:
624 index_command = lexrc.getString();
630 dpi = lexrc.getInteger();
636 zoom = lexrc.getInteger();
640 case RC_SCREEN_GEOMETRY_HEIGHT:
642 geometry_height = lexrc.getInteger();
646 case RC_SCREEN_GEOMETRY_WIDTH:
648 geometry_width = lexrc.getInteger();
652 case RC_SCREEN_GEOMETRY_XYSAVED:
654 geometry_xysaved = lexrc.getBool();
658 case RC_SCREEN_FONT_SIZES:
660 font_sizes[FONT_SIZE_TINY] =
664 font_sizes[FONT_SIZE_SCRIPT] =
668 font_sizes[FONT_SIZE_FOOTNOTE] =
672 font_sizes[FONT_SIZE_SMALL] =
676 font_sizes[FONT_SIZE_NORMAL] =
680 font_sizes[FONT_SIZE_LARGE] =
684 font_sizes[FONT_SIZE_LARGER] =
688 font_sizes[FONT_SIZE_LARGEST] =
692 font_sizes[FONT_SIZE_HUGE] =
696 font_sizes[FONT_SIZE_HUGER] =
701 case RC_SCREEN_FONT_SCALABLE:
703 use_scalable_fonts = lexrc.getBool();
709 autosave = lexrc.getInteger();
713 case RC_DOCUMENTPATH:
715 document_path = os::internal_path(lexrc.getString());
716 document_path = expandPath(document_path);
720 case RC_TEMPLATEPATH:
722 template_path = os::internal_path(lexrc.getString());
723 template_path = expandPath(template_path);
729 tempdir_path = os::internal_path(lexrc.getString());
730 tempdir_path = expandPath(tempdir_path);
736 lyxerr << "Ignoring obsolete use_tempdir flag." << endl;
740 case RC_USELASTFILEPOS:
742 use_lastfilepos = lexrc.getBool();
748 load_session = lexrc.getBool();
752 case RC_NUMLASTFILES:
754 num_lastfiles = lexrc.getInteger();
758 case RC_CHECKLASTFILES:
760 check_lastfiles = lexrc.getBool();
764 case RC_SCREEN_FONT_ROMAN:
766 roman_font_name = lexrc.getString();
767 oldFontFormat(roman_font_name,
772 case RC_SCREEN_FONT_SANS:
774 sans_font_name = lexrc.getString();
775 oldFontFormat(sans_font_name, sans_font_foundry);
779 case RC_SCREEN_FONT_TYPEWRITER:
781 typewriter_font_name = lexrc.getString();
782 oldFontFormat(typewriter_font_name,
783 typewriter_font_foundry);
787 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
789 roman_font_foundry = lexrc.getString();
793 case RC_SCREEN_FONT_SANS_FOUNDRY:
795 sans_font_foundry = lexrc.getString();
799 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
801 typewriter_font_foundry = lexrc.getString();
807 string lyx_name, x11_name;
810 lyx_name = lexrc.getString();
812 lexrc.printError("Missing color tag.");
817 x11_name = lexrc.getString();
819 lexrc.printError("Missing color name for color: `$$Token'");
823 ColorCode const col =
824 lcolor.getFromLyXName(lyx_name);
825 if (col == Color_none ||
826 col == Color_inherit ||
830 if (!lcolor.setColor(col, x11_name)) {
831 lyxerr << "Bad lyxrc set_color for "
837 case RC_AUTOREGIONDELETE:
838 // Auto region delete defaults to true
840 auto_region_delete = lexrc.getBool();
846 lyxpipes = os::internal_path(lexrc.getString());
847 lyxpipes = expandPath(lyxpipes);
851 case RC_CURSOR_FOLLOWS_SCROLLBAR:
853 cursor_follows_scrollbar = lexrc.getBool();
857 case RC_DIALOGS_ICONIFY_WITH_MAIN:
859 dialogs_iconify_with_main = lexrc.getBool();
863 case RC_PLAINTEXT_ROFF_COMMAND:
865 plaintext_roff_command = lexrc.getString();
868 case RC_PLAINTEXT_LINELEN:
870 plaintext_linelen = lexrc.getInteger();
873 // Spellchecker settings:
874 case RC_USE_SPELL_LIB:
876 use_spell_lib = lexrc.getBool();
879 case RC_SPELL_COMMAND:
881 isp_command = lexrc.getString();
884 case RC_ACCEPT_COMPOUND:
886 isp_accept_compound = lexrc.getBool();
891 isp_use_input_encoding = lexrc.getBool();
894 case RC_USE_ALT_LANG:
896 isp_use_alt_lang = lexrc.getBool();
899 case RC_USE_PERS_DICT:
901 isp_use_pers_dict = lexrc.getBool();
904 case RC_USE_ESC_CHARS:
906 isp_use_esc_chars = lexrc.getBool();
911 isp_alt_lang = lexrc.getString();
916 isp_pers_dict = os::internal_path(lexrc.getString());
921 isp_esc_chars = lexrc.getString();
926 make_backup = lexrc.getBool();
929 case RC_BACKUPDIR_PATH:
931 backupdir_path = os::internal_path(lexrc.getString());
932 backupdir_path = expandPath(backupdir_path);
935 case RC_DATE_INSERT_FORMAT:
937 date_insert_format = lexrc.getString();
940 case RC_LANGUAGE_PACKAGE:
942 language_package = lexrc.getString();
945 case RC_LANGUAGE_AUTO_BEGIN:
947 language_auto_begin = lexrc.getBool();
950 case RC_LANGUAGE_AUTO_END:
952 language_auto_end = lexrc.getBool();
955 case RC_LANGUAGE_GLOBAL_OPTIONS:
957 language_global_options = lexrc.getBool();
960 case RC_LANGUAGE_USE_BABEL:
962 language_use_babel = lexrc.getBool();
965 case RC_LANGUAGE_COMMAND_BEGIN:
967 language_command_begin = lexrc.getString();
970 case RC_LANGUAGE_COMMAND_END:
972 language_command_end = lexrc.getString();
975 case RC_LANGUAGE_COMMAND_LOCAL:
977 language_command_local = lexrc.getString();
982 rtl_support = lexrc.getBool();
987 auto_number = lexrc.getBool();
990 case RC_MARK_FOREIGN_LANGUAGE:
992 mark_foreign_language = lexrc.getBool();
999 fmt = lexrc.getString();
1002 command = lexrc.getString();
1004 setMover(fmt, command);
1008 case RC_CONVERTER: {
1009 string from, to, command, flags;
1011 from = lexrc.getString();
1014 to = lexrc.getString();
1017 command = lexrc.getString();
1020 flags = lexrc.getString();
1022 if (command.empty()) {
1023 theConverters().erase(from, to);
1025 theConverters().add(from, to, command, flags);
1029 // compatibility with versions older than 1.4.0 only
1031 string format, command;
1033 format = lexrc.getString();
1036 command = lexrc.getString();
1038 formats.setViewer(format, command);
1042 string format, extension, prettyname, shortcut;
1044 format = lexrc.getString();
1047 extension = lexrc.getString();
1050 prettyname = lexrc.getString();
1053 shortcut = lexrc.getString();
1055 string viewer, editor;
1057 viewer = lexrc.getString();
1059 editor = lexrc.getString();
1061 // Hack to ensure compatibility with versions older
1063 int le = lexrc.lex();
1064 if (le != Lexer::LEX_FEOF && le != Lexer::LEX_UNDEF) {
1065 flags = lexrc.getString();
1066 if (le != Lexer::LEX_DATA) {
1067 // We have got a known token.
1068 // Therefore this is an old style
1069 // format definition without
1071 lexrc.pushToken(flags);
1075 int flgs = Format::none;
1076 while (!flags.empty()) {
1078 flags = support::split(flags, flag, ',');
1079 if (flag == "document")
1080 flgs |= Format::document;
1081 else if (flag == "vector")
1082 flgs |= Format::vector;
1084 lyxerr << "Ignoring unknown flag `"
1085 << flag << "' for format `"
1086 << format << "'." << endl;
1088 if (prettyname.empty()) {
1089 if (theConverters().formatIsUsed(format)) {
1090 lyxerr << "Can't delete format "
1093 formats.erase(format);
1096 formats.add(format, extension, prettyname,
1097 shortcut, viewer, editor, flgs);
1101 case RC_DEFAULT_LANGUAGE:
1103 default_language = lexrc.getString();
1107 case RC_LABEL_INIT_LENGTH:
1109 label_init_length = lexrc.getInteger();
1113 case RC_SHOW_BANNER:
1115 show_banner = lexrc.getBool();
1121 string const tmp = lexrc.getString();
1122 if (tmp == "true" || tmp == "on")
1123 preview = PREVIEW_ON;
1124 else if (tmp == "no_math")
1125 preview = PREVIEW_NO_MATH;
1127 preview = PREVIEW_OFF;
1128 if (tmp != "false" && tmp != "off")
1129 lyxerr << "Unrecognized "
1131 << tmp << '\n' << endl;
1136 case RC_PREVIEW_HASHED_LABELS:
1138 preview_hashed_labels = lexrc.getBool();
1142 case RC_PREVIEW_SCALE_FACTOR:
1144 preview_scale_factor = lexrc.getString();
1150 user_name = lexrc.getString();
1155 user_email = lexrc.getString();
1158 case RC_PATH_PREFIX:
1160 path_prefix = lexrc.getString();
1163 case RC_USE_CONVERTER_CACHE:
1165 use_converter_cache = lexrc.getBool();
1168 case RC_CONVERTER_CACHE_MAXAGE:
1170 converter_cache_maxage =
1171 convert<unsigned int>(lexrc.getString());
1174 case RC_LAST: break; // this is just a dummy
1178 /// Update converters data-structures
1179 theConverters().update(formats);
1180 theConverters().buildGraph();
1186 void LyXRC::write(FileName const & filename, bool ignore_system_lyxrc) const
1188 ofstream ofs(filename.toFilesystemEncoding().c_str());
1190 write(ofs, ignore_system_lyxrc);
1194 void LyXRC::print() const
1196 if (lyxerr.debugging())
1197 write(lyxerr, false);
1205 typedef std::pair<std::string, SpecialisedMover> Data;
1207 SameMover(Data const & comparison)
1208 : comparison_(comparison) {}
1210 bool operator()(Data const & data) const
1212 return data.first == comparison_.first &&
1213 data.second.command() == comparison_.second.command();
1221 void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) const
1223 LyXRCTags tag = RC_LAST;
1225 if (!name.empty()) {
1226 for (int i = 0; i != lyxrcCount; ++i)
1227 if ("\\" + name == lyxrcTags[i].tag)
1228 tag = static_cast<LyXRCTags>(lyxrcTags[i].code);
1232 os << "### This file is part of\n"
1233 << "### ========================================================\n"
1234 << "### LyX, The Document Processor\n"
1236 << "### Copyright 1995 Matthias Ettrich\n"
1237 << "### Copyright 1995-2007 The LyX Team.\n"
1239 << "### ========================================================\n"
1241 << "# This file is written by LyX, if you want to make your own\n"
1242 << "# modifications you should do them from inside LyX and save\n"
1245 // Why the switch you might ask. It is a trick to ensure that all
1246 // the elements in the LyXRCTags enum is handled. As you can see
1247 // there are no breaks at all. So it is just a huge fall-through.
1248 // The nice thing is that we will get a warning from the compiler
1249 // if we forget an element.
1253 // input/include files are not done here
1255 if (ignore_system_lyxrc ||
1256 bind_file != system_lyxrc.bind_file) {
1257 string const path = os::external_path(bind_file);
1258 os << "\\bind_file \"" << path << "\"\n";
1264 if (ignore_system_lyxrc ||
1265 def_file != system_lyxrc.def_file) {
1266 string const path = os::external_path(def_file);
1267 os << "\\def_file \"" << path << "\"\n";
1276 << "# MISC SECTION ######################################\n"
1278 // bind files are not done here.
1280 case RC_PATH_PREFIX:
1281 if (ignore_system_lyxrc ||
1282 path_prefix != system_lyxrc.path_prefix) {
1283 os << "\\path_prefix \"" << path_prefix << "\"\n";
1288 if (ignore_system_lyxrc ||
1289 ui_file != system_lyxrc.ui_file) {
1290 string const path = os::external_path(ui_file);
1291 os << "\\ui_file \"" << path << "\"\n";
1295 case RC_AUTOREGIONDELETE:
1296 if (ignore_system_lyxrc ||
1297 auto_region_delete != system_lyxrc.auto_region_delete) {
1298 os << "# Set to false to inhibit automatic replacement of\n"
1299 << "# the current selection.\n"
1300 << "\\auto_region_delete " << convert<string>(auto_region_delete)
1305 case RC_AUTORESET_OPTIONS:
1306 if (ignore_system_lyxrc ||
1307 auto_reset_options != system_lyxrc.auto_reset_options) {
1308 os << "# Set to false to inhibit automatic reset of\n"
1309 << "# the class options to defaults on class change.\n"
1310 << "\\auto_reset_options "
1311 << convert<string>(auto_reset_options)
1317 if (ignore_system_lyxrc ||
1318 autosave != system_lyxrc.autosave) {
1319 os << "# The time interval between auto-saves in seconds.\n"
1320 << "\\autosave " << autosave << '\n';
1324 case RC_DISPLAY_GRAPHICS:
1325 if (ignore_system_lyxrc ||
1326 display_graphics != system_lyxrc.display_graphics) {
1327 os << "# Display graphics within LyX\n"
1328 << "# monochrome|grayscale|color|none\n"
1329 << "\\display_graphics "
1330 << graphics::displayTranslator().find(
1331 graphics::DisplayType(display_graphics))
1337 case RC_VIEWDVI_PAPEROPTION:
1338 if (ignore_system_lyxrc ||
1339 view_dvi_paper_option
1340 != system_lyxrc.view_dvi_paper_option) {
1341 os << "# Options used to specify paper size to the\n"
1342 << "# view_dvi_command (e.g. -paper)\n"
1343 << "\\view_dvi_paper_option \""
1344 << view_dvi_paper_option << "\"\n";
1348 case RC_DEFAULT_PAPERSIZE:
1349 if (ignore_system_lyxrc ||
1350 default_papersize != system_lyxrc.default_papersize) {
1351 os << "# The default papersize to use.\n"
1352 << "\\default_papersize \"";
1353 switch (default_papersize) {
1355 os << "default"; break;
1356 case PAPER_USLETTER:
1357 os << "usletter"; break;
1359 os << "legal"; break;
1360 case PAPER_USEXECUTIVE:
1361 os << "executive"; break;
1372 case PAPER_B4: break;
1378 case RC_CHKTEX_COMMAND:
1379 if (ignore_system_lyxrc ||
1380 chktex_command != system_lyxrc.chktex_command) {
1381 os << "\\chktex_command \"" << chktex_command << "\"\n";
1385 case RC_BIBTEX_COMMAND:
1386 if (ignore_system_lyxrc ||
1387 bibtex_command != system_lyxrc.bibtex_command) {
1388 os << "\\bibtex_command \"" << bibtex_command << "\"\n";
1392 case RC_INDEX_COMMAND:
1393 if (ignore_system_lyxrc ||
1394 index_command != system_lyxrc.index_command) {
1395 os << "\\index_command \"" << index_command << "\"\n";
1399 case RC_TEX_EXPECTS_WINDOWS_PATHS:
1400 if (ignore_system_lyxrc ||
1401 windows_style_tex_paths != system_lyxrc.windows_style_tex_paths) {
1402 os << "\\tex_expects_windows_paths "
1403 << convert<string>(windows_style_tex_paths) << '\n';
1407 case RC_TEX_ALLOWS_SPACES:
1408 if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
1409 os << "\\tex_allows_spaces "
1410 << convert<string>(tex_allows_spaces) << '\n';
1415 if (ignore_system_lyxrc ||
1416 use_kbmap != system_lyxrc.use_kbmap) {
1417 os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1421 case RC_KBMAP_PRIMARY:
1422 if (ignore_system_lyxrc ||
1423 primary_kbmap != system_lyxrc.primary_kbmap) {
1424 string const path = os::external_path(primary_kbmap);
1425 os << "\\kbmap_primary \"" << path << "\"\n";
1429 case RC_KBMAP_SECONDARY:
1430 if (ignore_system_lyxrc ||
1431 secondary_kbmap != system_lyxrc.secondary_kbmap) {
1432 string const path = os::external_path(secondary_kbmap);
1433 os << "\\kbmap_secondary \"" << path << "\"\n";
1438 if (ignore_system_lyxrc ||
1439 lyxpipes != system_lyxrc.lyxpipes) {
1440 string const path = os::external_path(lyxpipes);
1441 os << "\\serverpipe \"" << path << "\"\n";
1445 case RC_DATE_INSERT_FORMAT:
1446 if (ignore_system_lyxrc ||
1447 date_insert_format != system_lyxrc.date_insert_format) {
1448 os << "\\date_insert_format \"" << date_insert_format
1453 case RC_LABEL_INIT_LENGTH:
1454 if (ignore_system_lyxrc ||
1455 label_init_length != system_lyxrc.label_init_length) {
1456 os << "\\label_init_length " << label_init_length
1463 os << "\\user_name \"" << user_name << "\"\n";
1468 os << "\\user_email \"" << user_email << "\"\n";
1472 case RC_SHOW_BANNER:
1473 if (ignore_system_lyxrc ||
1474 show_banner != system_lyxrc.show_banner) {
1475 os << "\\show_banner " << convert<string>(show_banner) << '\n';
1481 if (ignore_system_lyxrc ||
1482 preview != system_lyxrc.preview) {
1488 case PREVIEW_NO_MATH:
1495 os << "\\preview " << status << '\n';
1500 case RC_PREVIEW_HASHED_LABELS:
1501 if (ignore_system_lyxrc ||
1502 preview_hashed_labels !=
1503 system_lyxrc.preview_hashed_labels) {
1504 os << "\\preview_hashed_labels "
1505 << convert<string>(preview_hashed_labels) << '\n';
1510 case RC_PREVIEW_SCALE_FACTOR:
1511 if (ignore_system_lyxrc ||
1512 preview_scale_factor != system_lyxrc.preview_scale_factor) {
1513 os << "\\preview_scale_factor "
1514 << preview_scale_factor << '\n';
1519 case RC_USE_CONVERTER_CACHE:
1520 if (ignore_system_lyxrc ||
1521 use_converter_cache != system_lyxrc.use_converter_cache) {
1522 os << "\\use_converter_cache "
1523 << convert<string>(use_converter_cache) << '\n';
1528 case RC_CONVERTER_CACHE_MAXAGE:
1529 if (ignore_system_lyxrc ||
1530 converter_cache_maxage != system_lyxrc.converter_cache_maxage) {
1531 os << "\\converter_cache_maxage "
1532 << converter_cache_maxage << '\n';
1538 << "# SCREEN & FONTS SECTION ############################\n"
1542 if (ignore_system_lyxrc ||
1543 dpi != system_lyxrc.dpi) {
1544 os << "\\screen_dpi " << dpi << '\n';
1548 case RC_SCREEN_ZOOM:
1549 if (ignore_system_lyxrc ||
1550 zoom != system_lyxrc.zoom) {
1551 os << "\\screen_zoom " << zoom << '\n';
1555 case RC_SCREEN_GEOMETRY_HEIGHT:
1556 if (ignore_system_lyxrc ||
1557 geometry_height != system_lyxrc.geometry_height) {
1558 os << "\\screen_geometry_height " << geometry_height
1563 case RC_SCREEN_GEOMETRY_WIDTH:
1564 if (ignore_system_lyxrc ||
1565 geometry_width != system_lyxrc.geometry_width) {
1566 os << "\\screen_geometry_width " << geometry_width
1571 case RC_SCREEN_GEOMETRY_XYSAVED:
1572 if (ignore_system_lyxrc ||
1573 geometry_xysaved != system_lyxrc.geometry_xysaved) {
1574 os << "\\screen_geometry_xysaved " << convert<string>(geometry_xysaved)
1579 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1580 if (ignore_system_lyxrc ||
1581 cursor_follows_scrollbar
1582 != system_lyxrc.cursor_follows_scrollbar) {
1583 os << "\\cursor_follows_scrollbar "
1584 << convert<string>(cursor_follows_scrollbar) << '\n';
1588 case RC_DIALOGS_ICONIFY_WITH_MAIN:
1589 if (ignore_system_lyxrc ||
1590 dialogs_iconify_with_main
1591 != system_lyxrc.dialogs_iconify_with_main) {
1592 os << "\\dialogs_iconify_with_main "
1593 << convert<string>(dialogs_iconify_with_main) << '\n';
1597 case RC_SCREEN_FONT_ROMAN:
1598 if (ignore_system_lyxrc ||
1599 roman_font_name != system_lyxrc.roman_font_name) {
1600 os << "\\screen_font_roman \"" << roman_font_name
1605 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1606 if (ignore_system_lyxrc ||
1607 roman_font_foundry != system_lyxrc.roman_font_foundry) {
1608 os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1613 case RC_SCREEN_FONT_SANS:
1614 if (ignore_system_lyxrc ||
1615 sans_font_name != system_lyxrc.sans_font_name) {
1616 os << "\\screen_font_sans \"" << sans_font_name
1621 case RC_SCREEN_FONT_SANS_FOUNDRY:
1622 if (ignore_system_lyxrc ||
1623 sans_font_foundry != system_lyxrc.sans_font_foundry) {
1624 os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1629 case RC_SCREEN_FONT_TYPEWRITER:
1630 if (ignore_system_lyxrc ||
1631 typewriter_font_name != system_lyxrc.typewriter_font_name) {
1632 os << "\\screen_font_typewriter \""
1633 << typewriter_font_name << "\"\n";
1637 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1638 if (ignore_system_lyxrc ||
1639 typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1640 os << "\\screen_font_typewriter_foundry \""
1641 << typewriter_font_foundry << "\"\n";
1646 case RC_SCREEN_FONT_SCALABLE:
1647 if (ignore_system_lyxrc ||
1648 use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1649 os << "\\screen_font_scalable "
1650 << convert<string>(use_scalable_fonts)
1655 case RC_SCREEN_FONT_SIZES:
1656 if (ignore_system_lyxrc ||
1657 font_sizes[FONT_SIZE_TINY]
1658 != system_lyxrc.font_sizes[FONT_SIZE_TINY] ||
1659 font_sizes[FONT_SIZE_SCRIPT]
1660 != system_lyxrc.font_sizes[FONT_SIZE_SCRIPT] ||
1661 font_sizes[FONT_SIZE_FOOTNOTE]
1662 != system_lyxrc.font_sizes[FONT_SIZE_FOOTNOTE] ||
1663 font_sizes[FONT_SIZE_SMALL]
1664 != system_lyxrc.font_sizes[FONT_SIZE_SMALL] ||
1665 font_sizes[FONT_SIZE_NORMAL]
1666 != system_lyxrc.font_sizes[FONT_SIZE_NORMAL] ||
1667 font_sizes[FONT_SIZE_LARGE]
1668 != system_lyxrc.font_sizes[FONT_SIZE_LARGE] ||
1669 font_sizes[FONT_SIZE_LARGER]
1670 != system_lyxrc.font_sizes[FONT_SIZE_LARGER] ||
1671 font_sizes[FONT_SIZE_LARGEST]
1672 != system_lyxrc.font_sizes[FONT_SIZE_LARGEST] ||
1673 font_sizes[FONT_SIZE_HUGE]
1674 != system_lyxrc.font_sizes[FONT_SIZE_HUGE] ||
1675 font_sizes[FONT_SIZE_HUGER]
1676 != system_lyxrc.font_sizes[FONT_SIZE_HUGER]) {
1677 os.setf(ios::fixed);
1679 os << "\\screen_font_sizes"
1680 << ' ' << font_sizes[FONT_SIZE_TINY]
1681 << ' ' << font_sizes[FONT_SIZE_SCRIPT]
1682 << ' ' << font_sizes[FONT_SIZE_FOOTNOTE]
1683 << ' ' << font_sizes[FONT_SIZE_SMALL]
1684 << ' ' << font_sizes[FONT_SIZE_NORMAL]
1685 << ' ' << font_sizes[FONT_SIZE_LARGE]
1686 << ' ' << font_sizes[FONT_SIZE_LARGER]
1687 << ' ' << font_sizes[FONT_SIZE_LARGEST]
1688 << ' ' << font_sizes[FONT_SIZE_HUGE]
1689 << ' ' << font_sizes[FONT_SIZE_HUGER]
1696 << "# COLOR SECTION ###################################\n"
1700 for (int i = 0; i < Color_ignore; ++i) {
1701 ColorCode lc = static_cast<ColorCode>(i);
1703 string const col(lcolor.getX11Name(lc));
1704 if (ignore_system_lyxrc ||
1705 col != system_lcolor.getX11Name(lc)) {
1706 os << "\\set_color \""
1707 << lcolor.getLyXName(lc) << "\" \""
1715 << "# PRINTER SECTION ###################################\n"
1719 if (ignore_system_lyxrc ||
1720 printer != system_lyxrc.printer) {
1721 os << "\\printer \"" << printer << "\"\n";
1725 case RC_PRINT_ADAPTOUTPUT:
1726 if (ignore_system_lyxrc ||
1727 print_adapt_output != system_lyxrc.print_adapt_output) {
1728 os << "\\print_adapt_output "
1729 << convert<string>(print_adapt_output)
1734 case RC_PRINT_COMMAND:
1735 if (ignore_system_lyxrc ||
1736 print_command != system_lyxrc.print_command) {
1737 os << "\\print_command \"" << print_command << "\"\n";
1741 case RC_PRINTEXSTRAOPTIONS:
1742 if (ignore_system_lyxrc ||
1743 print_extra_options != system_lyxrc.print_extra_options) {
1744 os << "\\print_extra_options \"" << print_extra_options
1749 case RC_PRINTSPOOL_COMMAND:
1750 if (ignore_system_lyxrc ||
1751 print_spool_command != system_lyxrc.print_spool_command) {
1752 os << "\\print_spool_command \"" << print_spool_command
1757 case RC_PRINTSPOOL_PRINTERPREFIX:
1758 if (ignore_system_lyxrc ||
1759 print_spool_printerprefix
1760 != system_lyxrc.print_spool_printerprefix) {
1761 os << "\\print_spool_printerprefix \""
1762 << print_spool_printerprefix << "\"\n";
1766 case RC_PRINTEVENPAGEFLAG:
1767 if (ignore_system_lyxrc ||
1768 print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1769 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1774 case RC_PRINTODDPAGEFLAG:
1775 if (ignore_system_lyxrc ||
1776 print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1777 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1782 case RC_PRINTREVERSEFLAG:
1783 if (ignore_system_lyxrc ||
1784 print_reverse_flag != system_lyxrc.print_reverse_flag) {
1785 os << "\\print_reverse_flag \"" << print_reverse_flag
1790 case RC_PRINTLANDSCAPEFLAG:
1791 if (ignore_system_lyxrc ||
1792 print_landscape_flag != system_lyxrc.print_landscape_flag) {
1793 os << "\\print_landscape_flag \"" << print_landscape_flag
1798 case RC_PRINTPAGERANGEFLAG:
1799 if (ignore_system_lyxrc ||
1800 print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1801 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1806 case RC_PRINTCOPIESFLAG:
1807 if (ignore_system_lyxrc ||
1808 print_copies_flag != system_lyxrc.print_copies_flag) {
1809 os << "\\print_copies_flag \"" << print_copies_flag
1814 case RC_PRINTCOLLCOPIESFLAG:
1815 if (ignore_system_lyxrc ||
1816 print_collcopies_flag
1817 != system_lyxrc.print_collcopies_flag) {
1818 os << "\\print_collcopies_flag \""
1819 << print_collcopies_flag
1824 case RC_PRINTPAPERFLAG:
1825 if (ignore_system_lyxrc ||
1826 print_paper_flag != system_lyxrc.print_paper_flag) {
1827 os << "\\print_paper_flag \"" << print_paper_flag
1832 case RC_PRINTPAPERDIMENSIONFLAG:
1833 if (ignore_system_lyxrc ||
1834 print_paper_dimension_flag
1835 != system_lyxrc.print_paper_dimension_flag) {
1836 os << "\\print_paper_dimension_flag \""
1837 << print_paper_dimension_flag << "\"\n";
1841 case RC_PRINTTOPRINTER:
1842 if (ignore_system_lyxrc ||
1843 print_to_printer != system_lyxrc.print_to_printer) {
1844 os << "\\print_to_printer \"" << print_to_printer
1849 case RC_PRINTTOFILE:
1850 if (ignore_system_lyxrc ||
1851 print_to_file != system_lyxrc.print_to_file) {
1852 string const path = os::external_path(print_to_file);
1853 os << "\\print_to_file \"" << path << "\"\n";
1857 case RC_PRINTFILEEXTENSION:
1858 if (ignore_system_lyxrc ||
1859 print_file_extension != system_lyxrc.print_file_extension) {
1860 os << "\\print_file_extension \""
1861 << print_file_extension
1868 << "# EXPORT SECTION ####################################\n"
1871 case RC_CUSTOM_EXPORT_COMMAND:
1872 if (ignore_system_lyxrc ||
1873 custom_export_command
1874 != system_lyxrc.custom_export_command) {
1875 os << "\\custom_export_command \""
1876 << custom_export_command
1881 case RC_CUSTOM_EXPORT_FORMAT:
1882 if (ignore_system_lyxrc ||
1883 custom_export_format
1884 != system_lyxrc.custom_export_format) {
1885 os << "\\custom_export_format \"" << custom_export_format
1892 << "# TEX SECTION #######################################\n"
1895 case RC_FONT_ENCODING:
1896 if (ignore_system_lyxrc ||
1897 fontenc != system_lyxrc.fontenc) {
1898 os << "\\font_encoding \"" << fontenc << "\"\n";
1904 << "# FILE SECTION ######################################\n"
1907 case RC_DOCUMENTPATH:
1908 if (ignore_system_lyxrc ||
1909 document_path != system_lyxrc.document_path) {
1910 string const path = os::external_path(document_path);
1911 os << "\\document_path \"" << path << "\"\n";
1915 case RC_USELASTFILEPOS:
1916 if (ignore_system_lyxrc ||
1917 use_lastfilepos != system_lyxrc.use_lastfilepos) {
1918 os << "\\use_lastfilepos " << convert<string>(use_lastfilepos)
1923 case RC_LOADSESSION:
1924 if (ignore_system_lyxrc ||
1925 load_session != system_lyxrc.load_session) {
1926 os << "\\load_session " << convert<string>(load_session)
1931 case RC_NUMLASTFILES:
1932 if (ignore_system_lyxrc ||
1933 num_lastfiles != system_lyxrc.num_lastfiles) {
1934 os << "\\num_lastfiles " << num_lastfiles << '\n';
1938 case RC_CHECKLASTFILES:
1939 if (ignore_system_lyxrc ||
1940 check_lastfiles != system_lyxrc.check_lastfiles) {
1941 os << "\\check_lastfiles " << convert<string>(check_lastfiles)
1946 case RC_TEMPLATEPATH:
1947 if (ignore_system_lyxrc ||
1948 template_path != system_lyxrc.template_path) {
1949 string const path = os::external_path(template_path);
1950 os << "\\template_path \"" << path << "\"\n";
1954 case RC_TEMPDIRPATH:
1955 if (ignore_system_lyxrc ||
1956 tempdir_path != system_lyxrc.tempdir_path) {
1957 string const path = os::external_path(tempdir_path);
1958 os << "\\tempdir_path \"" << path << "\"\n";
1966 case RC_PLAINTEXT_LINELEN:
1967 if (ignore_system_lyxrc ||
1968 plaintext_linelen != system_lyxrc.plaintext_linelen) {
1969 os << "\\plaintext_linelen " << plaintext_linelen << '\n';
1973 case RC_MAKE_BACKUP:
1974 if (ignore_system_lyxrc ||
1975 make_backup != system_lyxrc.make_backup) {
1976 os << "\\make_backup " << convert<string>(make_backup) << '\n';
1980 case RC_BACKUPDIR_PATH:
1981 if (ignore_system_lyxrc ||
1982 backupdir_path != system_lyxrc.backupdir_path) {
1983 string const path = os::external_path(backupdir_path);
1984 os << "\\backupdir_path \"" << path << "\"\n";
1990 << "# PLAIN TEXT EXPORT SECTION ##############################\n"
1993 case RC_PLAINTEXT_ROFF_COMMAND:
1994 if (ignore_system_lyxrc ||
1995 plaintext_roff_command != system_lyxrc.plaintext_roff_command) {
1996 os << "\\plaintext_roff_command \"" << plaintext_roff_command
2003 << "# SPELLCHECKER SECTION ##############################\n"
2005 case RC_USE_SPELL_LIB:
2006 if (ignore_system_lyxrc ||
2007 use_spell_lib != system_lyxrc.use_spell_lib) {
2008 os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
2012 case RC_SPELL_COMMAND:
2013 if (ignore_system_lyxrc ||
2014 isp_command != system_lyxrc.isp_command) {
2015 os << "\\spell_command \"" << isp_command << "\"\n";
2019 case RC_ACCEPT_COMPOUND:
2020 if (ignore_system_lyxrc ||
2021 isp_accept_compound != system_lyxrc.isp_accept_compound) {
2022 os << "\\accept_compound " << convert<string>(isp_accept_compound)
2027 case RC_USE_ALT_LANG:
2028 if (ignore_system_lyxrc ||
2029 isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
2030 os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
2036 if (ignore_system_lyxrc ||
2037 isp_alt_lang != system_lyxrc.isp_alt_lang) {
2038 os << "\\alternate_language \"" << isp_alt_lang
2043 case RC_USE_ESC_CHARS:
2044 if (ignore_system_lyxrc ||
2045 isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
2046 os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
2052 if (ignore_system_lyxrc ||
2053 isp_esc_chars != system_lyxrc.isp_esc_chars) {
2054 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
2058 case RC_USE_PERS_DICT:
2059 if (ignore_system_lyxrc ||
2060 isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
2061 os << "\\use_personal_dictionary "
2062 << convert<string>(isp_use_pers_dict)
2068 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
2069 string const path = os::external_path(isp_pers_dict);
2070 os << "\\personal_dictionary \"" << path << "\"\n";
2074 case RC_USE_INP_ENC:
2075 if (ignore_system_lyxrc ||
2076 isp_use_input_encoding
2077 != system_lyxrc.isp_use_input_encoding) {
2078 os << "\\use_input_encoding "
2079 << convert<string>(isp_use_input_encoding)
2086 << "# LANGUAGE SUPPORT SECTION ##########################\n"
2089 case RC_RTL_SUPPORT:
2090 if (ignore_system_lyxrc ||
2091 rtl_support != system_lyxrc.rtl_support) {
2092 os << "\\rtl " << convert<string>(rtl_support) << '\n';
2096 case RC_LANGUAGE_PACKAGE:
2097 if (ignore_system_lyxrc ||
2098 language_package != system_lyxrc.language_package) {
2099 os << "\\language_package \"" << language_package
2104 case RC_LANGUAGE_GLOBAL_OPTIONS:
2105 if (ignore_system_lyxrc ||
2106 language_global_options
2107 != system_lyxrc.language_global_options) {
2108 os << "\\language_global_options \""
2109 << convert<string>(language_global_options)
2114 case RC_LANGUAGE_USE_BABEL:
2115 if (ignore_system_lyxrc ||
2116 language_use_babel != system_lyxrc.language_use_babel) {
2117 os << "\\language_use_babel \""
2118 << convert<string>(language_use_babel)
2123 case RC_LANGUAGE_COMMAND_BEGIN:
2124 if (ignore_system_lyxrc ||
2125 language_command_begin
2126 != system_lyxrc.language_command_begin) {
2127 os << "\\language_command_begin \""
2128 << language_command_begin
2133 case RC_LANGUAGE_COMMAND_END:
2134 if (ignore_system_lyxrc ||
2135 language_command_end
2136 != system_lyxrc.language_command_end) {
2137 os << "\\language_command_end \"" << language_command_end
2142 case RC_LANGUAGE_COMMAND_LOCAL:
2143 if (ignore_system_lyxrc ||
2144 language_command_local
2145 != system_lyxrc.language_command_local) {
2146 os << "\\language_command_local \""
2147 << language_command_local
2152 case RC_LANGUAGE_AUTO_BEGIN:
2153 if (ignore_system_lyxrc ||
2154 language_auto_begin != system_lyxrc.language_auto_begin) {
2155 os << "\\language_auto_begin "
2156 << convert<string>(language_auto_begin) << '\n';
2160 case RC_LANGUAGE_AUTO_END:
2161 if (ignore_system_lyxrc ||
2162 language_auto_end != system_lyxrc.language_auto_end) {
2163 os << "\\language_auto_end "
2164 << convert<string>(language_auto_end) << '\n';
2168 case RC_MARK_FOREIGN_LANGUAGE:
2169 if (ignore_system_lyxrc ||
2170 mark_foreign_language
2171 != system_lyxrc.mark_foreign_language) {
2172 os << "\\mark_foreign_language " <<
2173 convert<string>(mark_foreign_language) << '\n';
2179 << "# 2nd MISC SUPPORT SECTION ##########################\n"
2182 case RC_AUTO_NUMBER:
2183 if (ignore_system_lyxrc ||
2184 auto_number != system_lyxrc.auto_number) {
2185 os << "\\auto_number " << convert<string>(auto_number) << '\n';
2189 case RC_DEFAULT_LANGUAGE:
2190 if (ignore_system_lyxrc ||
2191 default_language != system_lyxrc.default_language) {
2192 os << "\\default_language " << default_language << '\n';
2198 << "# FORMATS SECTION ##########################\n"
2202 // New/modified formats
2203 for (Formats::const_iterator cit = formats.begin();
2204 cit != formats.end(); ++cit) {
2205 Format const * format =
2206 system_formats.getFormat(cit->name());
2208 format->extension() != cit->extension() ||
2209 format->prettyname() != cit->prettyname() ||
2210 format->shortcut() != cit->shortcut() ||
2211 format->viewer() != cit->viewer() ||
2212 format->editor() != cit->editor() ||
2213 format->documentFormat() != cit->documentFormat() ||
2214 format->vectorFormat() != cit->vectorFormat()) {
2215 os << "\\format \"" << cit->name() << "\" \""
2216 << cit->extension() << "\" \""
2217 << cit->prettyname() << "\" \""
2218 << cit->shortcut() << "\" \""
2219 << cit->viewer() << "\" \""
2220 << cit->editor() << "\" \"";
2221 std::vector<string> flags;
2222 if (cit->documentFormat())
2223 flags.push_back("document");
2224 if (cit->vectorFormat())
2225 flags.push_back("vector");
2226 os << support::getStringFromVector(flags);
2231 // Look for deleted formats
2232 for (Formats::const_iterator cit = system_formats.begin();
2233 cit != system_formats.end(); ++cit)
2234 if (!formats.getFormat(cit->name()))
2235 os << "\\format \"" << cit->name()
2236 << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
2245 << "# CONVERTERS SECTION ##########################\n"
2249 // Look for new converters
2250 for (Converters::const_iterator cit = theConverters().begin();
2251 cit != theConverters().end(); ++cit) {
2252 Converter const * converter =
2253 theSystemConverters().getConverter(cit->from,
2256 converter->command != cit->command ||
2257 converter->flags != cit->flags)
2258 os << "\\converter \"" << cit->from << "\" \""
2259 << cit->to << "\" \""
2260 << cit->command << "\" \""
2261 << cit->flags << "\"\n";
2264 // New/modifed converters
2265 for (Converters::const_iterator cit = theSystemConverters().begin();
2266 cit != theSystemConverters().end(); ++cit)
2267 if (!theConverters().getConverter(cit->from, cit->to))
2268 os << "\\converter \"" << cit->from
2269 << "\" \"" << cit->to << "\" \"\" \"\"\n";
2276 << "# COPIERS SECTION ##########################\n"
2279 // Look for new movers
2280 Movers::const_iterator const sysbegin = theSystemMovers().begin();
2281 Movers::const_iterator const sysend = theSystemMovers().end();
2282 Movers::const_iterator it = theMovers().begin();
2283 Movers::const_iterator end = theMovers().end();
2285 for (; it != end; ++it) {
2286 Movers::const_iterator const sysit =
2287 std::find_if(sysbegin, sysend, SameMover(*it));
2288 if (sysit == sysend) {
2289 std::string const & fmt = it->first;
2290 std::string const & command =
2291 it->second.command();
2293 os << "\\copier " << fmt
2294 << " \"" << command << "\"\n";
2300 // We don't actually delete SpecialisedMover(s) from the
2301 // map, just clear their 'command', so there's no need
2302 // to test for anything else.
2310 string const LyXRC::getDescription(LyXRCTags tag)
2315 case RC_ACCEPT_COMPOUND:
2316 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2320 case RC_USE_ALT_LANG:
2321 str = _("Specify an alternate language. The default is to use the language of the document.");
2324 case RC_PLAINTEXT_ROFF_COMMAND:
2325 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.");
2328 case RC_PLAINTEXT_LINELEN:
2329 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.");
2332 case RC_AUTOREGIONDELETE:
2333 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2336 case RC_AUTORESET_OPTIONS:
2337 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2341 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2344 case RC_AUTO_NUMBER:
2347 case RC_BACKUPDIR_PATH:
2348 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.");
2351 case RC_BIBTEX_COMMAND:
2352 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2356 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2359 case RC_CHECKLASTFILES:
2360 str = _("Select to check whether the lastfiles still exist.");
2363 case RC_CHKTEX_COMMAND:
2364 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2373 case RC_CURSOR_FOLLOWS_SCROLLBAR:
2374 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.");
2377 case RC_CUSTOM_EXPORT_COMMAND:
2380 case RC_CUSTOM_EXPORT_FORMAT:
2383 case RC_DATE_INSERT_FORMAT:
2384 //xgettext:no-c-format
2385 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2388 case RC_DEFAULT_LANGUAGE:
2389 str = _("New documents will be assigned this language.");
2392 case RC_DEFAULT_PAPERSIZE:
2393 str = _("Specify the default paper size.");
2396 case RC_DIALOGS_ICONIFY_WITH_MAIN:
2397 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2400 case RC_DISPLAY_GRAPHICS:
2401 str = _("Select how LyX will display any graphics.");
2404 case RC_DOCUMENTPATH:
2405 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2409 case RC_USE_ESC_CHARS:
2410 str = _("Specify additional chars that can be part of a word.");
2413 case RC_FONT_ENCODING:
2414 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2420 case RC_INDEX_COMMAND:
2421 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\".");
2428 case RC_KBMAP_PRIMARY:
2429 case RC_KBMAP_SECONDARY:
2430 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.");
2433 case RC_LABEL_INIT_LENGTH:
2434 str = _("Maximum number of words in the initialization string for a new label");
2437 case RC_LANGUAGE_AUTO_BEGIN:
2438 str = _("Select if a language switching command is needed at the beginning of the document.");
2441 case RC_LANGUAGE_AUTO_END:
2442 str = _("Select if a language switching command is needed at the end of the document.");
2445 case RC_LANGUAGE_COMMAND_BEGIN:
2446 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.");
2449 case RC_LANGUAGE_COMMAND_END:
2450 str = _("The LaTeX command for changing back to the language of the document.");
2453 case RC_LANGUAGE_COMMAND_LOCAL:
2454 str = _("The LaTeX command for local changing of the language.");
2457 case RC_LANGUAGE_GLOBAL_OPTIONS:
2458 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2461 case RC_LANGUAGE_PACKAGE:
2462 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2465 case RC_LANGUAGE_USE_BABEL:
2466 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2469 case RC_USELASTFILEPOS:
2470 str = _("De-select if you do not want LyX to scroll to saved position.");
2473 case RC_LOADSESSION:
2474 str = _("De-select to prevent loading files opened from the last LyX session.");
2477 case RC_MAKE_BACKUP:
2478 str = _("De-select if you don't want LyX to create backup files.");
2481 case RC_MARK_FOREIGN_LANGUAGE:
2482 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2485 case RC_NUMLASTFILES:
2486 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."),
2490 case RC_PATH_PREFIX:
2491 str = _("Specify those directories which should be "
2492 "prepended to the PATH environment variable. "
2493 "Use the OS native format.");
2497 case RC_USE_PERS_DICT:
2498 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2502 str = _("Shows a typeset preview of things such as math");
2505 case RC_PREVIEW_HASHED_LABELS:
2506 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2509 case RC_PREVIEW_SCALE_FACTOR:
2510 str = _("Scale the preview size to suit.");
2513 case RC_PRINTCOLLCOPIESFLAG:
2514 str = _("The option for specifying whether the copies should be collated.");
2517 case RC_PRINTCOPIESFLAG:
2518 str = _("The option for specifying the number of copies to print.");
2522 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2525 case RC_PRINTEVENPAGEFLAG:
2526 str = _("The option to print only even pages.");
2529 case RC_PRINTEXSTRAOPTIONS:
2530 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2533 case RC_PRINTFILEEXTENSION:
2534 str = _("Extension of printer program output file. Usually \".ps\".");
2537 case RC_PRINTLANDSCAPEFLAG:
2538 str = _("The option to print out in landscape.");
2541 case RC_PRINTODDPAGEFLAG:
2542 str = _("The option to print only odd pages.");
2545 case RC_PRINTPAGERANGEFLAG:
2546 str = _("The option for specifying a comma-separated list of pages to print.");
2549 case RC_PRINTPAPERDIMENSIONFLAG:
2550 str = _("Option to specify the dimensions of the print paper.");
2553 case RC_PRINTPAPERFLAG:
2554 str = _("The option to specify paper type.");
2557 case RC_PRINTREVERSEFLAG:
2558 str = _("The option to reverse the order of the pages printed.");
2561 case RC_PRINTSPOOL_COMMAND:
2562 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.");
2565 case RC_PRINTSPOOL_PRINTERPREFIX:
2566 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.");
2569 case RC_PRINTTOFILE:
2570 str = _("Option to pass to the print program to print to a file.");
2573 case RC_PRINTTOPRINTER:
2574 str = _("Option to pass to the print program to print on a specific printer.");
2577 case RC_PRINT_ADAPTOUTPUT:
2578 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2581 case RC_PRINT_COMMAND:
2582 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2585 case RC_RTL_SUPPORT:
2586 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2590 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2593 case RC_SCREEN_FONT_ROMAN:
2594 case RC_SCREEN_FONT_SANS:
2595 case RC_SCREEN_FONT_TYPEWRITER:
2596 str = _("The screen fonts used to display the text while editing.");
2599 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
2600 case RC_SCREEN_FONT_SANS_FOUNDRY:
2601 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2604 case RC_SCREEN_FONT_SCALABLE:
2605 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.");
2608 case RC_SCREEN_FONT_SIZES:
2609 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2612 case RC_SCREEN_ZOOM:
2613 //xgettext:no-c-format
2614 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2617 case RC_SCREEN_GEOMETRY_HEIGHT:
2618 case RC_SCREEN_GEOMETRY_WIDTH:
2619 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).");
2622 case RC_SCREEN_GEOMETRY_XYSAVED:
2623 str = _("Allow session manager to save and restore windows position.");
2627 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2633 case RC_SHOW_BANNER:
2634 str = _("De-select if you don't want the startup banner.");
2637 case RC_SPELL_COMMAND:
2638 str = _("What command runs the spellchecker?");
2641 case RC_TEMPDIRPATH:
2642 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2645 case RC_TEMPLATEPATH:
2646 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2649 case RC_TEX_ALLOWS_SPACES:
2652 case RC_TEX_EXPECTS_WINDOWS_PATHS:
2656 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2668 case RC_USE_INP_ENC:
2669 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.");
2672 case RC_USE_SPELL_LIB:
2675 case RC_VIEWDVI_PAPEROPTION:
2676 _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2691 // The global instance
2694 // The global copy of the system lyxrc entries (everything except preferences)