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.
24 #include "support/debug.h"
26 #include "Converter.h"
28 #include "support/gettext.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"
44 using namespace lyx::support;
48 namespace os = support::os;
52 // when adding something to this array keep it sorted!
53 keyword_item lyxrcTags[] = {
54 { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
55 { "\\allow_geometry_session", LyXRC::RC_GEOMETRY_SESSION },
56 { "\\alternate_language", LyXRC::RC_ALT_LANG },
57 { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
58 { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
59 { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
60 { "\\autosave", LyXRC::RC_AUTOSAVE },
61 { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
62 { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
63 { "\\bind_file", LyXRC::RC_BINDFILE },
64 { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
65 { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
66 { "\\converter", LyXRC::RC_CONVERTER },
67 { "\\converter_cache_maxage", LyXRC::RC_CONVERTER_CACHE_MAXAGE },
68 { "\\copier", LyXRC::RC_COPIER },
69 { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
70 { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
71 { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
72 { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
73 { "\\def_file", LyXRC::RC_DEFFILE },
74 { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
75 { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
76 { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
77 { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
78 { "\\document_path", LyXRC::RC_DOCUMENTPATH },
79 { "\\escape_chars", LyXRC::RC_ESC_CHARS },
80 { "\\example_path", LyXRC::RC_EXAMPLEPATH },
81 { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
82 { "\\format", LyXRC::RC_FORMAT },
83 { "\\index_command", LyXRC::RC_INDEX_COMMAND },
84 { "\\input", LyXRC::RC_INPUT },
85 { "\\kbmap", LyXRC::RC_KBMAP },
86 { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
87 { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
88 { "\\label_init_length", LyXRC::RC_LABEL_INIT_LENGTH },
89 { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
90 { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
91 { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
92 { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
93 { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
94 { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
95 { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
96 { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
97 { "\\load_session", LyXRC::RC_LOADSESSION },
98 { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
99 { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
100 { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
101 { "\\path_prefix", LyXRC::RC_PATH_PREFIX },
102 { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
103 { "\\plaintext_linelen", LyXRC::RC_PLAINTEXT_LINELEN },
104 { "\\plaintext_roff_command", LyXRC::RC_PLAINTEXT_ROFF_COMMAND },
105 { "\\preview", LyXRC::RC_PREVIEW },
106 { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
107 { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
108 { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
109 { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
110 { "\\print_command", LyXRC::RC_PRINT_COMMAND },
111 { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
112 { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
113 { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
114 { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
115 { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
116 { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
117 { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
118 { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
119 { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
120 { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
121 { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
122 { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
123 { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
124 { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
125 { "\\printer", LyXRC::RC_PRINTER },
126 { "\\rtl", LyXRC::RC_RTL_SUPPORT },
127 { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
128 { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
129 { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
130 { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
131 { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
132 { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
133 { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
134 { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
135 { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
136 { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
137 { "\\serverpipe", LyXRC::RC_SERVERPIPE },
138 { "\\set_color", LyXRC::RC_SET_COLOR },
139 { "\\show_banner", LyXRC::RC_SHOW_BANNER },
140 { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
141 { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
142 { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
143 { "\\template_path", LyXRC::RC_TEMPLATEPATH },
144 { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
145 { "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS },
146 { "\\ui_file", LyXRC::RC_UIFILE },
147 { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
148 { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
149 { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
150 { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
151 { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
152 { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
153 { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE },
154 // compatibility with versions older than 1.4.0 only
155 { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
156 { "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB },
157 // compatibility with versions older than 1.4.0 only
158 { "\\use_tempdir", LyXRC::RC_USETEMPDIR },
159 { "\\user_email", LyXRC::RC_USER_EMAIL },
160 { "\\user_name", LyXRC::RC_USER_NAME },
161 { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
162 // compatibility with versions older than 1.4.0 only
163 { "\\viewer", LyXRC::RC_VIEWER}
166 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
177 void LyXRC::setDefaults() {
179 def_file = "default";
181 // Get printer from the environment. If fail, use default "",
182 // assuming that everything is set up correctly.
183 printer = getEnv("PRINTER");
184 print_adapt_output = false;
185 print_command = "dvips";
186 print_evenpage_flag = "-B";
187 print_oddpage_flag = "-A";
188 print_pagerange_flag = "-pp";
189 print_copies_flag = "-c";
190 print_collcopies_flag = "-C";
191 print_reverse_flag = "-r";
192 print_landscape_flag = "-t landscape";
193 print_to_printer = "-P";
194 print_to_file = "-o ";
195 print_file_extension = ".ps";
196 print_paper_flag = "-t";
197 print_paper_dimension_flag = "-T";
198 document_path.erase();
199 view_dvi_paper_option.erase();
200 default_papersize = PAPER_DEFAULT;
201 custom_export_format = "ps";
202 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
203 bibtex_command = "bibtex";
205 index_command = "makeindex -c -q";
207 // Because a screen typically is wider than a piece of paper:
209 allow_geometry_session = true;
210 // Default LaTeX font size:
211 font_sizes[FONT_SIZE_TINY] = "5.0";
212 font_sizes[FONT_SIZE_SCRIPT] = "7.0";
213 font_sizes[FONT_SIZE_FOOTNOTE] = "8.0";
214 font_sizes[FONT_SIZE_SMALL] = "9.0";
215 font_sizes[FONT_SIZE_NORMAL] = "10.0";
216 font_sizes[FONT_SIZE_LARGE] = "12.0";
217 font_sizes[FONT_SIZE_LARGER] = "14.4";
218 font_sizes[FONT_SIZE_LARGEST] = "17.26";
219 font_sizes[FONT_SIZE_HUGE] = "20.74";
220 font_sizes[FONT_SIZE_HUGER] = "24.88";
221 use_scalable_fonts = true;
222 roman_font_name = "";
224 typewriter_font_name = "";
226 auto_region_delete = true;
227 auto_reset_options = false;
228 plaintext_linelen = 65;
229 num_lastfiles = maxlastfiles;
230 check_lastfiles = true;
231 use_lastfilepos = true;
232 load_session = false;
234 backupdir_path.erase();
235 display_graphics = graphics::ColorDisplay;
236 // Spellchecker settings:
237 use_spell_lib = true;
238 isp_command = "ispell";
239 isp_accept_compound = false;
240 isp_use_input_encoding = false;
241 isp_use_alt_lang = false;
242 isp_use_pers_dict = false;
243 isp_use_esc_chars = false;
247 mark_foreign_language = true;
248 language_auto_begin = true;
249 language_auto_end = true;
250 language_global_options = true;
251 language_use_babel = true;
252 language_package = "\\usepackage{babel}";
253 language_command_begin = "\\selectlanguage{$$lang}";
254 language_command_local = "\\foreignlanguage{$$lang}{";
255 sort_layouts = false;
256 default_language = "english";
258 windows_style_tex_paths = false;
259 tex_allows_spaces = false;
260 date_insert_format = "%x";
261 cursor_follows_scrollbar = false;
262 dialogs_iconify_with_main = false;
263 label_init_length = 3;
264 preview = PREVIEW_OFF;
265 preview_hashed_labels = false;
266 preview_scale_factor = "0.9";
267 use_converter_cache = true;
268 use_pixmap_cache = false;
269 converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
271 user_name = to_utf8(support::user_name());
273 user_email = to_utf8(support::user_email());
279 void oldFontFormat(string & family, string & foundry)
281 if (family.empty() || family[0] != '-')
283 foundry = token(family, '-', 1);
284 family = token(family, '-', 2);
292 int LyXRC::read(FileName const & filename)
294 Lexer lexrc(lyxrcTags, lyxrcCount);
295 if (lyxerr.debugging(Debug::PARSER))
296 lexrc.printTable(lyxerr);
298 lexrc.setFile(filename);
299 if (!lexrc.isOK()) return -2;
301 LYXERR(Debug::LYXRC, "Reading '" << filename << "'...");
307 int LyXRC::read(istream & is)
309 Lexer lexrc(lyxrcTags, lyxrcCount);
310 if (lyxerr.debugging(Debug::PARSER))
311 lexrc.printTable(lyxerr);
314 if (!lexrc.isOK()) return -2;
316 LYXERR(Debug::LYXRC, "Reading istream...");
322 int LyXRC::read(Lexer & lexrc)
324 if (!lexrc.isOK()) return -2;
326 while (lexrc.isOK()) {
327 // By using two switches we take advantage of the compiler
328 // telling us if we have missed a LyXRCTags element in
329 // the second switch.
330 // Note that this also shows a problem with Lexer since it
331 // helps us avoid taking advantage of the strictness of the
334 int le = lexrc.lex();
336 case Lexer::LEX_UNDEF:
337 lexrc.printError("Unknown tag `$$Token'");
339 case Lexer::LEX_FEOF:
343 switch (static_cast<LyXRCTags>(le)) {
344 case RC_INPUT: // Include file
347 libFileSearch(string(),
350 lexrc.printError("Error reading "
351 "included file: " + tmp.absFilename());
357 bind_file = os::internal_path(lexrc.getString());
363 def_file = os::internal_path(lexrc.getString());
369 ui_file = os::internal_path(lexrc.getString());
373 case RC_AUTORESET_OPTIONS:
375 auto_reset_options = lexrc.getBool();
379 case RC_DISPLAY_GRAPHICS:
381 display_graphics = graphics::displayTranslator().find(lexrc.getString());
385 case RC_TEX_EXPECTS_WINDOWS_PATHS:
387 windows_style_tex_paths = lexrc.getBool();
391 case RC_TEX_ALLOWS_SPACES:
393 tex_allows_spaces = lexrc.getBool();
399 use_kbmap = lexrc.getBool();
403 case RC_KBMAP_PRIMARY:
405 string const kmap(os::internal_path(lexrc.getString()));
408 } else if (!libFileSearch("kbd", kmap,
410 primary_kbmap = kmap;
412 lexrc.printError("LyX: Keymap `$$Token' not found");
417 case RC_KBMAP_SECONDARY:
419 string const kmap(os::internal_path(lexrc.getString()));
422 } else if (!libFileSearch("kbd", kmap,
424 secondary_kbmap = kmap;
426 lexrc.printError("LyX: Keymap `$$Token' not found");
431 case RC_FONT_ENCODING:
433 fontenc = lexrc.getString();
439 printer = lexrc.getString();
443 case RC_PRINT_COMMAND:
445 print_command = lexrc.getString();
449 case RC_PRINTEVENPAGEFLAG:
451 print_evenpage_flag = lexrc.getString();
455 case RC_PRINTODDPAGEFLAG:
457 print_oddpage_flag = lexrc.getString();
461 case RC_PRINTPAGERANGEFLAG:
463 print_pagerange_flag = lexrc.getString();
467 case RC_PRINTCOPIESFLAG:
469 print_copies_flag = lexrc.getString();
473 case RC_PRINTCOLLCOPIESFLAG:
475 print_collcopies_flag = lexrc.getString();
479 case RC_PRINTREVERSEFLAG:
481 print_reverse_flag = lexrc.getString();
485 case RC_PRINTLANDSCAPEFLAG:
487 print_landscape_flag = lexrc.getString();
491 case RC_PRINTTOPRINTER:
493 print_to_printer = lexrc.getString();
497 case RC_PRINT_ADAPTOUTPUT:
499 print_adapt_output = lexrc.getBool();
505 print_to_file = os::internal_path(lexrc.getString());
509 case RC_PRINTFILEEXTENSION:
511 print_file_extension = lexrc.getString();
515 case RC_PRINTEXSTRAOPTIONS:
517 print_extra_options = lexrc.getString();
521 case RC_PRINTSPOOL_COMMAND:
523 print_spool_command = lexrc.getString();
527 case RC_PRINTSPOOL_PRINTERPREFIX:
529 print_spool_printerprefix = lexrc.getString();
533 case RC_PRINTPAPERDIMENSIONFLAG:
535 print_paper_dimension_flag = lexrc.getString();
539 case RC_PRINTPAPERFLAG:
541 print_paper_flag = lexrc.getString();
545 case RC_CUSTOM_EXPORT_COMMAND:
547 custom_export_command = lexrc.getString();
551 case RC_CUSTOM_EXPORT_FORMAT:
553 custom_export_format = lexrc.getString();
557 case RC_DEFAULT_PAPERSIZE:
560 ascii_lowercase(lexrc.getString());
561 if (size == "usletter")
564 else if (size == "legal")
567 else if (size == "executive")
570 else if (size == "a3")
573 else if (size == "a4")
576 else if (size == "a5")
579 else if (size == "b5")
582 else if (size == "default")
588 case RC_VIEWDVI_PAPEROPTION:
590 view_dvi_paper_option = lexrc.getString();
592 view_dvi_paper_option.erase();
596 case RC_CHKTEX_COMMAND:
598 chktex_command = lexrc.getString();
602 case RC_BIBTEX_COMMAND:
604 bibtex_command = lexrc.getString();
608 case RC_INDEX_COMMAND:
610 index_command = lexrc.getString();
616 dpi = lexrc.getInteger();
622 zoom = lexrc.getInteger();
626 case RC_GEOMETRY_SESSION:
628 allow_geometry_session = lexrc.getBool();
632 case RC_SCREEN_FONT_SIZES:
634 font_sizes[FONT_SIZE_TINY] =
638 font_sizes[FONT_SIZE_SCRIPT] =
642 font_sizes[FONT_SIZE_FOOTNOTE] =
646 font_sizes[FONT_SIZE_SMALL] =
650 font_sizes[FONT_SIZE_NORMAL] =
654 font_sizes[FONT_SIZE_LARGE] =
658 font_sizes[FONT_SIZE_LARGER] =
662 font_sizes[FONT_SIZE_LARGEST] =
666 font_sizes[FONT_SIZE_HUGE] =
670 font_sizes[FONT_SIZE_HUGER] =
675 case RC_SCREEN_FONT_SCALABLE:
677 use_scalable_fonts = lexrc.getBool();
683 autosave = lexrc.getInteger();
687 case RC_DOCUMENTPATH:
689 document_path = os::internal_path(lexrc.getString());
690 document_path = expandPath(document_path);
696 example_path = os::internal_path(lexrc.getString());
697 example_path = expandPath(example_path);
701 case RC_TEMPLATEPATH:
703 template_path = os::internal_path(lexrc.getString());
704 template_path = expandPath(template_path);
710 tempdir_path = os::internal_path(lexrc.getString());
711 tempdir_path = expandPath(tempdir_path);
717 lyxerr << "Ignoring obsolete use_tempdir flag." << endl;
721 case RC_USELASTFILEPOS:
723 use_lastfilepos = lexrc.getBool();
729 load_session = lexrc.getBool();
733 case RC_NUMLASTFILES:
735 num_lastfiles = lexrc.getInteger();
739 case RC_CHECKLASTFILES:
741 check_lastfiles = lexrc.getBool();
745 case RC_SCREEN_FONT_ROMAN:
747 roman_font_name = lexrc.getString();
748 oldFontFormat(roman_font_name,
753 case RC_SCREEN_FONT_SANS:
755 sans_font_name = lexrc.getString();
756 oldFontFormat(sans_font_name, sans_font_foundry);
760 case RC_SCREEN_FONT_TYPEWRITER:
762 typewriter_font_name = lexrc.getString();
763 oldFontFormat(typewriter_font_name,
764 typewriter_font_foundry);
768 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
770 roman_font_foundry = lexrc.getString();
774 case RC_SCREEN_FONT_SANS_FOUNDRY:
776 sans_font_foundry = lexrc.getString();
780 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
782 typewriter_font_foundry = lexrc.getString();
788 string lyx_name, x11_name;
791 lyx_name = lexrc.getString();
793 lexrc.printError("Missing color tag.");
798 x11_name = lexrc.getString();
800 lexrc.printError("Missing color name for color: `$$Token'");
804 ColorCode const col =
805 lcolor.getFromLyXName(lyx_name);
806 if (col == Color_none ||
807 col == Color_inherit ||
811 if (!lcolor.setColor(col, x11_name)) {
812 lyxerr << "Bad lyxrc set_color for "
818 case RC_AUTOREGIONDELETE:
819 // Auto region delete defaults to true
821 auto_region_delete = lexrc.getBool();
827 lyxpipes = os::internal_path(lexrc.getString());
828 lyxpipes = expandPath(lyxpipes);
832 case RC_CURSOR_FOLLOWS_SCROLLBAR:
834 cursor_follows_scrollbar = lexrc.getBool();
838 case RC_DIALOGS_ICONIFY_WITH_MAIN:
840 dialogs_iconify_with_main = lexrc.getBool();
844 case RC_PLAINTEXT_ROFF_COMMAND:
846 plaintext_roff_command = lexrc.getString();
849 case RC_PLAINTEXT_LINELEN:
851 plaintext_linelen = lexrc.getInteger();
854 // Spellchecker settings:
855 case RC_USE_SPELL_LIB:
857 use_spell_lib = lexrc.getBool();
860 case RC_SPELL_COMMAND:
862 isp_command = lexrc.getString();
865 case RC_ACCEPT_COMPOUND:
867 isp_accept_compound = lexrc.getBool();
872 isp_use_input_encoding = lexrc.getBool();
875 case RC_USE_ALT_LANG:
877 isp_use_alt_lang = lexrc.getBool();
880 case RC_USE_PERS_DICT:
882 isp_use_pers_dict = lexrc.getBool();
885 case RC_USE_PIXMAP_CACHE:
887 use_pixmap_cache = lexrc.getBool();
890 case RC_USE_ESC_CHARS:
892 isp_use_esc_chars = lexrc.getBool();
897 isp_alt_lang = lexrc.getString();
902 isp_pers_dict = os::internal_path(lexrc.getString());
907 isp_esc_chars = lexrc.getString();
912 make_backup = lexrc.getBool();
915 case RC_BACKUPDIR_PATH:
917 backupdir_path = os::internal_path(lexrc.getString());
918 backupdir_path = expandPath(backupdir_path);
921 case RC_DATE_INSERT_FORMAT:
923 date_insert_format = lexrc.getString();
926 case RC_LANGUAGE_PACKAGE:
928 language_package = lexrc.getString();
931 case RC_LANGUAGE_AUTO_BEGIN:
933 language_auto_begin = lexrc.getBool();
936 case RC_LANGUAGE_AUTO_END:
938 language_auto_end = lexrc.getBool();
941 case RC_LANGUAGE_GLOBAL_OPTIONS:
943 language_global_options = lexrc.getBool();
946 case RC_LANGUAGE_USE_BABEL:
948 language_use_babel = lexrc.getBool();
951 case RC_LANGUAGE_COMMAND_BEGIN:
953 language_command_begin = lexrc.getString();
956 case RC_LANGUAGE_COMMAND_END:
958 language_command_end = lexrc.getString();
961 case RC_LANGUAGE_COMMAND_LOCAL:
963 language_command_local = lexrc.getString();
968 rtl_support = lexrc.getBool();
973 auto_number = lexrc.getBool();
976 case RC_MARK_FOREIGN_LANGUAGE:
978 mark_foreign_language = lexrc.getBool();
985 fmt = lexrc.getString();
988 command = lexrc.getString();
990 setMover(fmt, command);
995 string from, to, command, flags;
997 from = lexrc.getString();
1000 to = lexrc.getString();
1003 command = lexrc.getString();
1006 flags = lexrc.getString();
1008 if (command.empty()) {
1009 theConverters().erase(from, to);
1011 theConverters().add(from, to, command, flags);
1015 // compatibility with versions older than 1.4.0 only
1017 string format, command;
1019 format = lexrc.getString();
1022 command = lexrc.getString();
1024 formats.setViewer(format, command);
1028 string format, extension, prettyname, shortcut;
1030 format = lexrc.getString();
1033 extension = lexrc.getString();
1036 prettyname = lexrc.getString();
1039 shortcut = lexrc.getString();
1041 string viewer, editor;
1043 viewer = lexrc.getString();
1045 editor = lexrc.getString();
1047 // Hack to ensure compatibility with versions older
1049 int le = lexrc.lex();
1050 if (le != Lexer::LEX_FEOF && le != Lexer::LEX_UNDEF) {
1051 flags = lexrc.getString();
1052 if (le != Lexer::LEX_DATA) {
1053 // We have got a known token.
1054 // Therefore this is an old style
1055 // format definition without
1057 lexrc.pushToken(flags);
1061 int flgs = Format::none;
1062 while (!flags.empty()) {
1064 flags = split(flags, flag, ',');
1065 if (flag == "document")
1066 flgs |= Format::document;
1067 else if (flag == "vector")
1068 flgs |= Format::vector;
1070 lyxerr << "Ignoring unknown flag `"
1071 << flag << "' for format `"
1072 << format << "'." << endl;
1074 if (prettyname.empty()) {
1075 if (theConverters().formatIsUsed(format)) {
1076 lyxerr << "Can't delete format "
1079 formats.erase(format);
1082 formats.add(format, extension, prettyname,
1083 shortcut, viewer, editor, flgs);
1087 case RC_DEFAULT_LANGUAGE:
1089 default_language = lexrc.getString();
1093 case RC_LABEL_INIT_LENGTH:
1095 label_init_length = lexrc.getInteger();
1099 case RC_SHOW_BANNER:
1101 show_banner = lexrc.getBool();
1107 string const tmp = lexrc.getString();
1108 if (tmp == "true" || tmp == "on")
1109 preview = PREVIEW_ON;
1110 else if (tmp == "no_math")
1111 preview = PREVIEW_NO_MATH;
1113 preview = PREVIEW_OFF;
1114 if (tmp != "false" && tmp != "off")
1115 lyxerr << "Unrecognized "
1117 << tmp << '\n' << endl;
1122 case RC_PREVIEW_HASHED_LABELS:
1124 preview_hashed_labels = lexrc.getBool();
1128 case RC_PREVIEW_SCALE_FACTOR:
1130 preview_scale_factor = lexrc.getString();
1136 user_name = lexrc.getString();
1141 user_email = lexrc.getString();
1144 case RC_PATH_PREFIX:
1146 path_prefix = lexrc.getString();
1149 case RC_USE_CONVERTER_CACHE:
1151 use_converter_cache = lexrc.getBool();
1154 case RC_CONVERTER_CACHE_MAXAGE:
1156 converter_cache_maxage =
1157 convert<unsigned int>(lexrc.getString());
1160 case RC_SORT_LAYOUTS:
1162 sort_layouts = lexrc.getBool();
1165 case RC_LAST: break; // this is just a dummy
1169 /// Update converters data-structures
1170 theConverters().update(formats);
1171 theConverters().buildGraph();
1177 void LyXRC::write(FileName const & filename, bool ignore_system_lyxrc) const
1179 ofstream ofs(filename.toFilesystemEncoding().c_str());
1181 write(ofs, ignore_system_lyxrc);
1185 void LyXRC::print() const
1187 if (lyxerr.debugging())
1188 write(lyxerr, false);
1196 typedef pair<string, SpecialisedMover> Data;
1198 SameMover(Data const & comparison)
1199 : comparison_(comparison) {}
1201 bool operator()(Data const & data) const
1203 return data.first == comparison_.first &&
1204 data.second.command() == comparison_.second.command();
1212 void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) const
1214 LyXRCTags tag = RC_LAST;
1216 if (!name.empty()) {
1217 for (int i = 0; i != lyxrcCount; ++i)
1218 if ("\\" + name == lyxrcTags[i].tag)
1219 tag = static_cast<LyXRCTags>(lyxrcTags[i].code);
1223 os << "### This file is part of\n"
1224 << "### ========================================================\n"
1225 << "### LyX, The Document Processor\n"
1227 << "### Copyright 1995 Matthias Ettrich\n"
1228 << "### Copyright 1995-2007 The LyX Team.\n"
1230 << "### ========================================================\n"
1232 << "# This file is written by LyX, if you want to make your own\n"
1233 << "# modifications you should do them from inside LyX and save\n"
1236 // Why the switch you might ask. It is a trick to ensure that all
1237 // the elements in the LyXRCTags enum is handled. As you can see
1238 // there are no breaks at all. So it is just a huge fall-through.
1239 // The nice thing is that we will get a warning from the compiler
1240 // if we forget an element.
1244 // input/include files are not done here
1246 if (ignore_system_lyxrc ||
1247 bind_file != system_lyxrc.bind_file) {
1248 string const path = os::external_path(bind_file);
1249 os << "\\bind_file \"" << path << "\"\n";
1255 if (ignore_system_lyxrc ||
1256 def_file != system_lyxrc.def_file) {
1257 string const path = os::external_path(def_file);
1258 os << "\\def_file \"" << path << "\"\n";
1267 << "# MISC SECTION ######################################\n"
1269 // bind files are not done here.
1271 case RC_PATH_PREFIX:
1272 if (ignore_system_lyxrc ||
1273 path_prefix != system_lyxrc.path_prefix) {
1274 os << "\\path_prefix \"" << path_prefix << "\"\n";
1279 if (ignore_system_lyxrc ||
1280 ui_file != system_lyxrc.ui_file) {
1281 string const path = os::external_path(ui_file);
1282 os << "\\ui_file \"" << path << "\"\n";
1286 case RC_AUTOREGIONDELETE:
1287 if (ignore_system_lyxrc ||
1288 auto_region_delete != system_lyxrc.auto_region_delete) {
1289 os << "# Set to false to inhibit automatic replacement of\n"
1290 << "# the current selection.\n"
1291 << "\\auto_region_delete " << convert<string>(auto_region_delete)
1296 case RC_AUTORESET_OPTIONS:
1297 if (ignore_system_lyxrc ||
1298 auto_reset_options != system_lyxrc.auto_reset_options) {
1299 os << "# Set to false to inhibit automatic reset of\n"
1300 << "# the class options to defaults on class change.\n"
1301 << "\\auto_reset_options "
1302 << convert<string>(auto_reset_options)
1308 if (ignore_system_lyxrc ||
1309 autosave != system_lyxrc.autosave) {
1310 os << "# The time interval between auto-saves in seconds.\n"
1311 << "\\autosave " << autosave << '\n';
1315 case RC_DISPLAY_GRAPHICS:
1316 if (ignore_system_lyxrc ||
1317 display_graphics != system_lyxrc.display_graphics) {
1318 os << "# Display graphics within LyX\n"
1319 << "# monochrome|grayscale|color|none\n"
1320 << "\\display_graphics "
1321 << graphics::displayTranslator().find(
1322 graphics::DisplayType(display_graphics))
1327 case RC_SORT_LAYOUTS:
1328 if (ignore_system_lyxrc ||
1329 sort_layouts != system_lyxrc.sort_layouts) {
1330 os << "# Sort layouts alphabetically.\n"
1331 << "\\sort_layouts " << convert<string>(sort_layouts) << '\n';
1335 case RC_VIEWDVI_PAPEROPTION:
1336 if (ignore_system_lyxrc ||
1337 view_dvi_paper_option
1338 != system_lyxrc.view_dvi_paper_option) {
1339 os << "# Options used to specify paper size to the\n"
1340 << "# view_dvi_command (e.g. -paper)\n"
1341 << "\\view_dvi_paper_option \""
1342 << view_dvi_paper_option << "\"\n";
1346 case RC_DEFAULT_PAPERSIZE:
1347 if (ignore_system_lyxrc ||
1348 default_papersize != system_lyxrc.default_papersize) {
1349 os << "# The default papersize to use.\n"
1350 << "\\default_papersize \"";
1351 switch (default_papersize) {
1353 os << "default"; break;
1354 case PAPER_USLETTER:
1355 os << "usletter"; break;
1357 os << "legal"; break;
1358 case PAPER_USEXECUTIVE:
1359 os << "executive"; break;
1370 case PAPER_B4: break;
1376 case RC_CHKTEX_COMMAND:
1377 if (ignore_system_lyxrc ||
1378 chktex_command != system_lyxrc.chktex_command) {
1379 os << "\\chktex_command \"" << chktex_command << "\"\n";
1383 case RC_BIBTEX_COMMAND:
1384 if (ignore_system_lyxrc ||
1385 bibtex_command != system_lyxrc.bibtex_command) {
1386 os << "\\bibtex_command \"" << bibtex_command << "\"\n";
1390 case RC_INDEX_COMMAND:
1391 if (ignore_system_lyxrc ||
1392 index_command != system_lyxrc.index_command) {
1393 os << "\\index_command \"" << index_command << "\"\n";
1397 case RC_TEX_EXPECTS_WINDOWS_PATHS:
1398 if (ignore_system_lyxrc ||
1399 windows_style_tex_paths != system_lyxrc.windows_style_tex_paths) {
1400 os << "\\tex_expects_windows_paths "
1401 << convert<string>(windows_style_tex_paths) << '\n';
1405 case RC_TEX_ALLOWS_SPACES:
1406 if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
1407 os << "\\tex_allows_spaces "
1408 << convert<string>(tex_allows_spaces) << '\n';
1413 if (ignore_system_lyxrc ||
1414 use_kbmap != system_lyxrc.use_kbmap) {
1415 os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1419 case RC_KBMAP_PRIMARY:
1420 if (ignore_system_lyxrc ||
1421 primary_kbmap != system_lyxrc.primary_kbmap) {
1422 string const path = os::external_path(primary_kbmap);
1423 os << "\\kbmap_primary \"" << path << "\"\n";
1427 case RC_KBMAP_SECONDARY:
1428 if (ignore_system_lyxrc ||
1429 secondary_kbmap != system_lyxrc.secondary_kbmap) {
1430 string const path = os::external_path(secondary_kbmap);
1431 os << "\\kbmap_secondary \"" << path << "\"\n";
1436 if (ignore_system_lyxrc ||
1437 lyxpipes != system_lyxrc.lyxpipes) {
1438 string const path = os::external_path(lyxpipes);
1439 os << "\\serverpipe \"" << path << "\"\n";
1443 case RC_DATE_INSERT_FORMAT:
1444 if (ignore_system_lyxrc ||
1445 date_insert_format != system_lyxrc.date_insert_format) {
1446 os << "\\date_insert_format \"" << date_insert_format
1451 case RC_LABEL_INIT_LENGTH:
1452 if (ignore_system_lyxrc ||
1453 label_init_length != system_lyxrc.label_init_length) {
1454 os << "\\label_init_length " << label_init_length
1461 os << "\\user_name \"" << user_name << "\"\n";
1466 os << "\\user_email \"" << user_email << "\"\n";
1470 case RC_SHOW_BANNER:
1471 if (ignore_system_lyxrc ||
1472 show_banner != system_lyxrc.show_banner) {
1473 os << "\\show_banner " << convert<string>(show_banner) << '\n';
1479 if (ignore_system_lyxrc ||
1480 preview != system_lyxrc.preview) {
1486 case PREVIEW_NO_MATH:
1493 os << "\\preview " << status << '\n';
1498 case RC_PREVIEW_HASHED_LABELS:
1499 if (ignore_system_lyxrc ||
1500 preview_hashed_labels !=
1501 system_lyxrc.preview_hashed_labels) {
1502 os << "\\preview_hashed_labels "
1503 << convert<string>(preview_hashed_labels) << '\n';
1508 case RC_PREVIEW_SCALE_FACTOR:
1509 if (ignore_system_lyxrc ||
1510 preview_scale_factor != system_lyxrc.preview_scale_factor) {
1511 os << "\\preview_scale_factor "
1512 << preview_scale_factor << '\n';
1517 case RC_USE_CONVERTER_CACHE:
1518 if (ignore_system_lyxrc ||
1519 use_converter_cache != system_lyxrc.use_converter_cache) {
1520 os << "\\use_converter_cache "
1521 << convert<string>(use_converter_cache) << '\n';
1526 case RC_CONVERTER_CACHE_MAXAGE:
1527 if (ignore_system_lyxrc ||
1528 converter_cache_maxage != system_lyxrc.converter_cache_maxage) {
1529 os << "\\converter_cache_maxage "
1530 << converter_cache_maxage << '\n';
1536 << "# SCREEN & FONTS SECTION ############################\n"
1540 if (ignore_system_lyxrc ||
1541 dpi != system_lyxrc.dpi) {
1542 os << "\\screen_dpi " << dpi << '\n';
1546 case RC_SCREEN_ZOOM:
1547 if (ignore_system_lyxrc ||
1548 zoom != system_lyxrc.zoom) {
1549 os << "\\screen_zoom " << zoom << '\n';
1553 case RC_GEOMETRY_SESSION:
1554 if (ignore_system_lyxrc ||
1555 allow_geometry_session != system_lyxrc.allow_geometry_session) {
1556 os << "\\allow_geometry_session " << convert<string>(allow_geometry_session)
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 ColorCode lc = static_cast<ColorCode>(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_EXAMPLEPATH:
1929 if (ignore_system_lyxrc ||
1930 example_path != system_lyxrc.example_path) {
1931 string const path = os::external_path(example_path);
1932 os << "\\example_path \"" << path << "\"\n";
1936 case RC_TEMPLATEPATH:
1937 if (ignore_system_lyxrc ||
1938 template_path != system_lyxrc.template_path) {
1939 string const path = os::external_path(template_path);
1940 os << "\\template_path \"" << path << "\"\n";
1944 case RC_TEMPDIRPATH:
1945 if (ignore_system_lyxrc ||
1946 tempdir_path != system_lyxrc.tempdir_path) {
1947 string const path = os::external_path(tempdir_path);
1948 os << "\\tempdir_path \"" << path << "\"\n";
1956 case RC_PLAINTEXT_LINELEN:
1957 if (ignore_system_lyxrc ||
1958 plaintext_linelen != system_lyxrc.plaintext_linelen) {
1959 os << "\\plaintext_linelen " << plaintext_linelen << '\n';
1963 case RC_MAKE_BACKUP:
1964 if (ignore_system_lyxrc ||
1965 make_backup != system_lyxrc.make_backup) {
1966 os << "\\make_backup " << convert<string>(make_backup) << '\n';
1970 case RC_BACKUPDIR_PATH:
1971 if (ignore_system_lyxrc ||
1972 backupdir_path != system_lyxrc.backupdir_path) {
1973 string const path = os::external_path(backupdir_path);
1974 os << "\\backupdir_path \"" << path << "\"\n";
1980 << "# PLAIN TEXT EXPORT SECTION ##############################\n"
1983 case RC_PLAINTEXT_ROFF_COMMAND:
1984 if (ignore_system_lyxrc ||
1985 plaintext_roff_command != system_lyxrc.plaintext_roff_command) {
1986 os << "\\plaintext_roff_command \"" << plaintext_roff_command
1993 << "# SPELLCHECKER SECTION ##############################\n"
1995 case RC_USE_SPELL_LIB:
1996 if (ignore_system_lyxrc ||
1997 use_spell_lib != system_lyxrc.use_spell_lib) {
1998 os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
2002 case RC_SPELL_COMMAND:
2003 if (ignore_system_lyxrc ||
2004 isp_command != system_lyxrc.isp_command) {
2005 os << "\\spell_command \"" << isp_command << "\"\n";
2009 case RC_ACCEPT_COMPOUND:
2010 if (ignore_system_lyxrc ||
2011 isp_accept_compound != system_lyxrc.isp_accept_compound) {
2012 os << "\\accept_compound " << convert<string>(isp_accept_compound)
2017 case RC_USE_ALT_LANG:
2018 if (ignore_system_lyxrc ||
2019 isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
2020 os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
2026 if (ignore_system_lyxrc ||
2027 isp_alt_lang != system_lyxrc.isp_alt_lang) {
2028 os << "\\alternate_language \"" << isp_alt_lang
2033 case RC_USE_ESC_CHARS:
2034 if (ignore_system_lyxrc ||
2035 isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
2036 os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
2042 if (ignore_system_lyxrc ||
2043 isp_esc_chars != system_lyxrc.isp_esc_chars) {
2044 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
2048 case RC_USE_PERS_DICT:
2049 if (ignore_system_lyxrc ||
2050 isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
2051 os << "\\use_personal_dictionary "
2052 << convert<string>(isp_use_pers_dict)
2057 case RC_USE_PIXMAP_CACHE:
2058 if (ignore_system_lyxrc ||
2059 use_pixmap_cache != system_lyxrc.use_pixmap_cache) {
2060 os << "\\use_pixmap_cache "
2061 << convert<string>(use_pixmap_cache)
2065 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
2066 string const path = os::external_path(isp_pers_dict);
2067 os << "\\personal_dictionary \"" << path << "\"\n";
2071 case RC_USE_INP_ENC:
2072 if (ignore_system_lyxrc ||
2073 isp_use_input_encoding
2074 != system_lyxrc.isp_use_input_encoding) {
2075 os << "\\use_input_encoding "
2076 << convert<string>(isp_use_input_encoding)
2083 << "# LANGUAGE SUPPORT SECTION ##########################\n"
2086 case RC_RTL_SUPPORT:
2087 if (ignore_system_lyxrc ||
2088 rtl_support != system_lyxrc.rtl_support) {
2089 os << "\\rtl " << convert<string>(rtl_support) << '\n';
2093 case RC_LANGUAGE_PACKAGE:
2094 if (ignore_system_lyxrc ||
2095 language_package != system_lyxrc.language_package) {
2096 os << "\\language_package \"" << language_package
2101 case RC_LANGUAGE_GLOBAL_OPTIONS:
2102 if (ignore_system_lyxrc ||
2103 language_global_options
2104 != system_lyxrc.language_global_options) {
2105 os << "\\language_global_options \""
2106 << convert<string>(language_global_options)
2111 case RC_LANGUAGE_USE_BABEL:
2112 if (ignore_system_lyxrc ||
2113 language_use_babel != system_lyxrc.language_use_babel) {
2114 os << "\\language_use_babel \""
2115 << convert<string>(language_use_babel)
2120 case RC_LANGUAGE_COMMAND_BEGIN:
2121 if (ignore_system_lyxrc ||
2122 language_command_begin
2123 != system_lyxrc.language_command_begin) {
2124 os << "\\language_command_begin \""
2125 << language_command_begin
2130 case RC_LANGUAGE_COMMAND_END:
2131 if (ignore_system_lyxrc ||
2132 language_command_end
2133 != system_lyxrc.language_command_end) {
2134 os << "\\language_command_end \"" << language_command_end
2139 case RC_LANGUAGE_COMMAND_LOCAL:
2140 if (ignore_system_lyxrc ||
2141 language_command_local
2142 != system_lyxrc.language_command_local) {
2143 os << "\\language_command_local \""
2144 << language_command_local
2149 case RC_LANGUAGE_AUTO_BEGIN:
2150 if (ignore_system_lyxrc ||
2151 language_auto_begin != system_lyxrc.language_auto_begin) {
2152 os << "\\language_auto_begin "
2153 << convert<string>(language_auto_begin) << '\n';
2157 case RC_LANGUAGE_AUTO_END:
2158 if (ignore_system_lyxrc ||
2159 language_auto_end != system_lyxrc.language_auto_end) {
2160 os << "\\language_auto_end "
2161 << convert<string>(language_auto_end) << '\n';
2165 case RC_MARK_FOREIGN_LANGUAGE:
2166 if (ignore_system_lyxrc ||
2167 mark_foreign_language
2168 != system_lyxrc.mark_foreign_language) {
2169 os << "\\mark_foreign_language " <<
2170 convert<string>(mark_foreign_language) << '\n';
2176 << "# 2nd MISC SUPPORT SECTION ##########################\n"
2179 case RC_AUTO_NUMBER:
2180 if (ignore_system_lyxrc ||
2181 auto_number != system_lyxrc.auto_number) {
2182 os << "\\auto_number " << convert<string>(auto_number) << '\n';
2186 case RC_DEFAULT_LANGUAGE:
2187 if (ignore_system_lyxrc ||
2188 default_language != system_lyxrc.default_language) {
2189 os << "\\default_language " << default_language << '\n';
2195 << "# FORMATS SECTION ##########################\n"
2199 // New/modified formats
2200 for (Formats::const_iterator cit = formats.begin();
2201 cit != formats.end(); ++cit) {
2202 Format const * format =
2203 system_formats.getFormat(cit->name());
2205 format->extension() != cit->extension() ||
2206 format->prettyname() != cit->prettyname() ||
2207 format->shortcut() != cit->shortcut() ||
2208 format->viewer() != cit->viewer() ||
2209 format->editor() != cit->editor() ||
2210 format->documentFormat() != cit->documentFormat() ||
2211 format->vectorFormat() != cit->vectorFormat()) {
2212 os << "\\format \"" << cit->name() << "\" \""
2213 << cit->extension() << "\" \""
2214 << cit->prettyname() << "\" \""
2215 << cit->shortcut() << "\" \""
2216 << cit->viewer() << "\" \""
2217 << cit->editor() << "\" \"";
2218 vector<string> flags;
2219 if (cit->documentFormat())
2220 flags.push_back("document");
2221 if (cit->vectorFormat())
2222 flags.push_back("vector");
2223 os << getStringFromVector(flags);
2228 // Look for deleted formats
2229 for (Formats::const_iterator cit = system_formats.begin();
2230 cit != system_formats.end(); ++cit)
2231 if (!formats.getFormat(cit->name()))
2232 os << "\\format \"" << cit->name()
2233 << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
2242 << "# CONVERTERS SECTION ##########################\n"
2246 // Look for new converters
2247 for (Converters::const_iterator cit = theConverters().begin();
2248 cit != theConverters().end(); ++cit) {
2249 Converter const * converter =
2250 theSystemConverters().getConverter(cit->from,
2253 converter->command != cit->command ||
2254 converter->flags != cit->flags)
2255 os << "\\converter \"" << cit->from << "\" \""
2256 << cit->to << "\" \""
2257 << cit->command << "\" \""
2258 << cit->flags << "\"\n";
2261 // New/modifed converters
2262 for (Converters::const_iterator cit = theSystemConverters().begin();
2263 cit != theSystemConverters().end(); ++cit)
2264 if (!theConverters().getConverter(cit->from, cit->to))
2265 os << "\\converter \"" << cit->from
2266 << "\" \"" << cit->to << "\" \"\" \"\"\n";
2273 << "# COPIERS SECTION ##########################\n"
2276 // Look for new movers
2277 Movers::const_iterator const sysbegin = theSystemMovers().begin();
2278 Movers::const_iterator const sysend = theSystemMovers().end();
2279 Movers::const_iterator it = theMovers().begin();
2280 Movers::const_iterator end = theMovers().end();
2282 for (; it != end; ++it) {
2283 Movers::const_iterator const sysit =
2284 find_if(sysbegin, sysend, SameMover(*it));
2285 if (sysit == sysend) {
2286 string const & fmt = it->first;
2287 string const & command =
2288 it->second.command();
2290 os << "\\copier " << fmt
2291 << " \"" << command << "\"\n";
2297 // We don't actually delete SpecialisedMover(s) from the
2298 // map, just clear their 'command', so there's no need
2299 // to test for anything else.
2307 string const LyXRC::getDescription(LyXRCTags tag)
2312 case RC_ACCEPT_COMPOUND:
2313 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2317 case RC_USE_ALT_LANG:
2318 str = _("Specify an alternate language. The default is to use the language of the document.");
2321 case RC_PLAINTEXT_ROFF_COMMAND:
2322 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.");
2325 case RC_PLAINTEXT_LINELEN:
2326 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.");
2329 case RC_AUTOREGIONDELETE:
2330 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2333 case RC_AUTORESET_OPTIONS:
2334 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2338 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2341 case RC_AUTO_NUMBER:
2344 case RC_BACKUPDIR_PATH:
2345 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.");
2348 case RC_BIBTEX_COMMAND:
2349 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2353 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2356 case RC_CHECKLASTFILES:
2357 str = _("Select to check whether the lastfiles still exist.");
2360 case RC_CHKTEX_COMMAND:
2361 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2370 case RC_CURSOR_FOLLOWS_SCROLLBAR:
2371 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.");
2374 case RC_CUSTOM_EXPORT_COMMAND:
2377 case RC_CUSTOM_EXPORT_FORMAT:
2380 case RC_DATE_INSERT_FORMAT:
2381 //xgettext:no-c-format
2382 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2386 str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories.");
2389 case RC_DEFAULT_LANGUAGE:
2390 str = _("New documents will be assigned this language.");
2393 case RC_DEFAULT_PAPERSIZE:
2394 str = _("Specify the default paper size.");
2397 case RC_DIALOGS_ICONIFY_WITH_MAIN:
2398 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2401 case RC_DISPLAY_GRAPHICS:
2402 str = _("Select how LyX will display any graphics.");
2405 case RC_DOCUMENTPATH:
2406 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2410 case RC_USE_ESC_CHARS:
2411 str = _("Specify additional chars that can be part of a word.");
2414 case RC_EXAMPLEPATH:
2415 str = _("The path that LyX will set when offering to choose an example. An empty value selects the directory LyX was started from.");
2418 case RC_FONT_ENCODING:
2419 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2425 case RC_INDEX_COMMAND:
2426 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\".");
2433 case RC_KBMAP_PRIMARY:
2434 case RC_KBMAP_SECONDARY:
2435 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.");
2438 case RC_LABEL_INIT_LENGTH:
2439 str = _("Maximum number of words in the initialization string for a new label");
2442 case RC_LANGUAGE_AUTO_BEGIN:
2443 str = _("Select if a language switching command is needed at the beginning of the document.");
2446 case RC_LANGUAGE_AUTO_END:
2447 str = _("Select if a language switching command is needed at the end of the document.");
2450 case RC_LANGUAGE_COMMAND_BEGIN:
2451 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.");
2454 case RC_LANGUAGE_COMMAND_END:
2455 str = _("The LaTeX command for changing back to the language of the document.");
2458 case RC_LANGUAGE_COMMAND_LOCAL:
2459 str = _("The LaTeX command for local changing of the language.");
2462 case RC_LANGUAGE_GLOBAL_OPTIONS:
2463 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2466 case RC_LANGUAGE_PACKAGE:
2467 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2470 case RC_LANGUAGE_USE_BABEL:
2471 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2474 case RC_USELASTFILEPOS:
2475 str = _("De-select if you do not want LyX to scroll to saved position.");
2478 case RC_LOADSESSION:
2479 str = _("De-select to prevent loading files opened from the last LyX session.");
2482 case RC_MAKE_BACKUP:
2483 str = _("De-select if you don't want LyX to create backup files.");
2486 case RC_MARK_FOREIGN_LANGUAGE:
2487 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2490 case RC_NUMLASTFILES:
2491 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."),
2495 case RC_PATH_PREFIX:
2496 str = _("Specify those directories which should be "
2497 "prepended to the PATH environment variable. "
2498 "Use the OS native format.");
2502 case RC_USE_PERS_DICT:
2503 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2507 str = _("Shows a typeset preview of things such as math");
2510 case RC_PREVIEW_HASHED_LABELS:
2511 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2514 case RC_PREVIEW_SCALE_FACTOR:
2515 str = _("Scale the preview size to suit.");
2518 case RC_PRINTCOLLCOPIESFLAG:
2519 str = _("The option for specifying whether the copies should be collated.");
2522 case RC_PRINTCOPIESFLAG:
2523 str = _("The option for specifying the number of copies to print.");
2527 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2530 case RC_PRINTEVENPAGEFLAG:
2531 str = _("The option to print only even pages.");
2534 case RC_PRINTEXSTRAOPTIONS:
2535 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2538 case RC_PRINTFILEEXTENSION:
2539 str = _("Extension of printer program output file. Usually \".ps\".");
2542 case RC_PRINTLANDSCAPEFLAG:
2543 str = _("The option to print out in landscape.");
2546 case RC_PRINTODDPAGEFLAG:
2547 str = _("The option to print only odd pages.");
2550 case RC_PRINTPAGERANGEFLAG:
2551 str = _("The option for specifying a comma-separated list of pages to print.");
2554 case RC_PRINTPAPERDIMENSIONFLAG:
2555 str = _("Option to specify the dimensions of the print paper.");
2558 case RC_PRINTPAPERFLAG:
2559 str = _("The option to specify paper type.");
2562 case RC_PRINTREVERSEFLAG:
2563 str = _("The option to reverse the order of the pages printed.");
2566 case RC_PRINTSPOOL_COMMAND:
2567 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.");
2570 case RC_PRINTSPOOL_PRINTERPREFIX:
2571 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.");
2574 case RC_PRINTTOFILE:
2575 str = _("Option to pass to the print program to print to a file.");
2578 case RC_PRINTTOPRINTER:
2579 str = _("Option to pass to the print program to print on a specific printer.");
2582 case RC_PRINT_ADAPTOUTPUT:
2583 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2586 case RC_PRINT_COMMAND:
2587 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2590 case RC_RTL_SUPPORT:
2591 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2595 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2598 case RC_SCREEN_FONT_ROMAN:
2599 case RC_SCREEN_FONT_SANS:
2600 case RC_SCREEN_FONT_TYPEWRITER:
2601 str = _("The screen fonts used to display the text while editing.");
2604 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
2605 case RC_SCREEN_FONT_SANS_FOUNDRY:
2606 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2609 case RC_SCREEN_FONT_SCALABLE:
2610 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.");
2613 case RC_SCREEN_FONT_SIZES:
2614 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2617 case RC_SCREEN_ZOOM:
2618 //xgettext:no-c-format
2619 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2622 case RC_GEOMETRY_SESSION:
2623 str = _("Allow session manager to save and restore windows geometry.");
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_PIXMAP_CACHE:
2673 str = _("Enable the pixmap cache that might improve performance on Mac and Windows.");
2676 case RC_USE_SPELL_LIB:
2679 case RC_VIEWDVI_PAPEROPTION:
2680 _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2695 // The global instance
2698 // The global copy of the system lyxrc entries (everything except preferences)