3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Jean-Marc Lasgouttes
8 * \author Angus Leeming
10 * \author André Pönitz
14 * Full author contact details are available in file CREDITS.
25 #include "converter.h"
28 #include "lastfiles.h"
34 #include "graphics/GraphicsTypes.h"
36 #include "support/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"
43 namespace os = lyx::support::os;
45 using lyx::support::ascii_lowercase;
46 using lyx::support::bformat;
47 using lyx::support::ExpandPath;
48 using lyx::support::getEnv;
49 using lyx::support::LibFileSearch;
50 using lyx::support::token;
63 // when adding something to this array keep it sorted!
64 keyword_item lyxrcTags[] = {
65 { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
66 { "\\alternate_language", LyXRC::RC_ALT_LANG },
67 { "\\ascii_linelen", LyXRC::RC_ASCII_LINELEN },
68 { "\\ascii_roff_command", LyXRC::RC_ASCIIROFF_COMMAND },
69 { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
70 { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
71 { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
72 { "\\autosave", LyXRC::RC_AUTOSAVE },
73 { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
74 { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
75 { "\\bind_file", LyXRC::RC_BINDFILE },
76 { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
77 { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
78 { "\\converter", LyXRC::RC_CONVERTER },
79 { "\\copier", LyXRC::RC_COPIER },
80 { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
81 { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
82 { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
83 { "\\cygwin_path_fix_needed", LyXRC::RC_CYGWIN_PATH_FIX },
84 { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
85 { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
86 { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
87 { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
88 { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
89 { "\\document_path", LyXRC::RC_DOCUMENTPATH },
90 { "\\escape_chars", LyXRC::RC_ESC_CHARS },
91 { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
92 { "\\format", LyXRC::RC_FORMAT },
93 { "\\index_command", LyXRC::RC_INDEX_COMMAND },
94 { "\\input", LyXRC::RC_INPUT },
95 { "\\kbmap", LyXRC::RC_KBMAP },
96 { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
97 { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
98 { "\\label_init_length", LyXRC::RC_LABEL_INIT_LENGTH },
99 { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
100 { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
101 { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
102 { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
103 { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
104 { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
105 { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
106 { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
107 { "\\lastfiles", LyXRC::RC_LASTFILES },
108 { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
109 { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
110 { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
111 { "\\path_prefix", LyXRC::RC_PATH_PREFIX },
112 { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
113 { "\\popup_bold_font", LyXRC::RC_POPUP_BOLD_FONT },
114 { "\\popup_font_encoding", LyXRC::RC_POPUP_FONT_ENCODING },
115 { "\\popup_normal_font", LyXRC::RC_POPUP_NORMAL_FONT },
116 { "\\preview", LyXRC::RC_PREVIEW },
117 { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
118 { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
119 { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
120 { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
121 { "\\print_command", LyXRC::RC_PRINT_COMMAND },
122 { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
123 { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
124 { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
125 { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
126 { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
127 { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
128 { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
129 { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
130 { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
131 { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
132 { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
133 { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
134 { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
135 { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
136 { "\\printer", LyXRC::RC_PRINTER },
137 { "\\rtl", LyXRC::RC_RTL_SUPPORT },
138 { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
139 { "\\screen_font_encoding", LyXRC::RC_SCREEN_FONT_ENCODING },
140 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
141 { "\\screen_font_encoding_menu", LyXRC::RC_POPUP_FONT_ENCODING },
142 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
143 { "\\screen_font_menu", LyXRC::RC_POPUP_BOLD_FONT },
144 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
145 { "\\screen_font_popup", LyXRC::RC_POPUP_NORMAL_FONT },
146 { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
147 { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
148 { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
149 { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
150 { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
151 { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
152 { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
153 { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
154 { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
155 { "\\serverpipe", LyXRC::RC_SERVERPIPE },
156 { "\\set_color", LyXRC::RC_SET_COLOR },
157 { "\\show_banner", LyXRC::RC_SHOW_BANNER },
158 { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
159 { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
160 { "\\template_path", LyXRC::RC_TEMPLATEPATH },
161 { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
162 { "\\ui_file", LyXRC::RC_UIFILE },
163 { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
164 { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
165 { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
166 { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
167 // compatibility with versions older than 1.4.0 only
168 { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
169 { "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB },
170 // compatibility with versions older than 1.4.0 only
171 { "\\use_tempdir", LyXRC::RC_USETEMPDIR },
172 { "\\user_email", LyXRC::RC_USER_EMAIL },
173 { "\\user_name", LyXRC::RC_USER_NAME },
174 { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
175 // compatibility with versions older than 1.4.0 only
176 { "\\viewer" ,LyXRC::RC_VIEWER},
177 { "\\wheel_jump", LyXRC::RC_WHEEL_JUMP }
180 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
191 void LyXRC::setDefaults() {
194 // Get printer from the environment. If fail, use default "",
195 // assuming that everything is set up correctly.
196 printer = getEnv("PRINTER");
197 print_adapt_output = false;
198 print_command = "dvips";
199 print_evenpage_flag = "-B";
200 print_oddpage_flag = "-A";
201 print_pagerange_flag = "-pp";
202 print_copies_flag = "-c";
203 print_collcopies_flag = "-C";
204 print_reverse_flag = "-r";
205 print_landscape_flag = "-t landscape";
206 print_to_printer = "-P";
207 print_to_file = "-o ";
208 print_file_extension = ".ps";
209 print_paper_flag = "-t";
210 print_paper_dimension_flag = "-T";
211 document_path.erase();
212 tempdir_path = "/tmp";
213 view_dvi_paper_option.erase();
214 default_papersize = PAPER_USLETTER;
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:
224 // Default LaTeX font size:
225 font_sizes[LyXFont::SIZE_TINY] = "5.0";
226 font_sizes[LyXFont::SIZE_SCRIPT] = "7.0";
227 font_sizes[LyXFont::SIZE_FOOTNOTE] = "8.0";
228 font_sizes[LyXFont::SIZE_SMALL] = "9.0";
229 font_sizes[LyXFont::SIZE_NORMAL] = "10.0";
230 font_sizes[LyXFont::SIZE_LARGE] = "12.0";
231 font_sizes[LyXFont::SIZE_LARGER] = "14.4";
232 font_sizes[LyXFont::SIZE_LARGEST] = "17.26";
233 font_sizes[LyXFont::SIZE_HUGE] = "20.74";
234 font_sizes[LyXFont::SIZE_HUGER] = "24.88";
235 use_scalable_fonts = true;
236 roman_font_name = "";
238 typewriter_font_name = "";
239 popup_bold_font = "-*-helvetica-bold-r";
240 popup_normal_font = "-*-helvetica-medium-r";
241 font_norm = "iso8859-1";
242 font_norm_type = ISO_8859_1;
243 popup_font_encoding.erase();
245 auto_region_delete = true;
246 auto_reset_options = false;
248 num_lastfiles = maxlastfiles;
249 check_lastfiles = true;
251 backupdir_path.erase();
252 display_graphics = lyx::graphics::ColorDisplay;
253 // Spellchecker settings:
254 use_spell_lib = true;
255 isp_command = "ispell";
256 isp_accept_compound = false;
257 isp_use_input_encoding = false;
258 isp_use_alt_lang = false;
259 isp_use_pers_dict = false;
260 isp_use_esc_chars = false;
264 mark_foreign_language = true;
265 language_auto_begin = true;
266 language_auto_end = true;
267 language_global_options = true;
268 language_use_babel = true;
269 language_package = "\\usepackage{babel}";
270 language_command_begin = "\\selectlanguage{$$lang}";
271 language_command_local = "\\foreignlanguage{$$lang}{";
272 default_language = "english";
274 cygwin_path_fix = false;
275 tex_allows_spaces = false;
276 date_insert_format = "%A, %e %B %Y";
277 cursor_follows_scrollbar = false;
278 dialogs_iconify_with_main = false;
279 label_init_length = 3;
280 preview = PREVIEW_OFF;
281 preview_hashed_labels = false;
282 preview_scale_factor = "0.9";
284 user_name = lyx::support::user_name();
286 user_email = lyx::support::user_email();
292 void oldFontFormat(string & family, string & foundry)
294 if (family.empty() || family[0] != '-')
296 foundry = token(family, '-', 1);
297 family = token(family, '-', 2);
305 int LyXRC::read(string const & filename)
307 LyXLex lexrc(lyxrcTags, lyxrcCount);
308 if (lyxerr.debugging(Debug::PARSER))
309 lexrc.printTable(lyxerr);
311 lexrc.setFile(filename);
312 if (!lexrc.isOK()) return -2;
314 lyxerr[Debug::LYXRC] << "Reading '" << filename << "'..." << endl;
320 int LyXRC::read(std::istream & is)
322 LyXLex lexrc(lyxrcTags, lyxrcCount);
323 if (lyxerr.debugging(Debug::PARSER))
324 lexrc.printTable(lyxerr);
327 if (!lexrc.isOK()) return -2;
329 lyxerr[Debug::LYXRC] << "Reading istream..." << endl;
335 int LyXRC::read(LyXLex & lexrc)
337 if (!lexrc.isOK()) return -2;
339 while (lexrc.isOK()) {
340 // By using two switches we take advantage of the compiler
341 // telling us if we have missed a LyXRCTags element in
342 // the second switch.
343 // Note that this also shows a problem with LyXLex since it
344 // helps us avoid taking advantage of the strictness of the
347 int le = lexrc.lex();
349 case LyXLex::LEX_UNDEF:
350 lexrc.printError("Unknown tag `$$Token'");
352 case LyXLex::LEX_FEOF:
356 switch (static_cast<LyXRCTags>(le)) {
357 case RC_INPUT: // Include file
360 LibFileSearch(string(),
363 lexrc.printError("Error reading "
364 "included file: "+tmp);
370 bind_file = os::internal_path(lexrc.getString());
376 ui_file = os::internal_path(lexrc.getString());
380 case RC_AUTORESET_OPTIONS:
382 auto_reset_options = lexrc.getBool();
386 case RC_DISPLAY_GRAPHICS:
388 display_graphics = lyx::graphics::displayTranslator().find(lexrc.getString());
392 case RC_CYGWIN_PATH_FIX:
394 cygwin_path_fix = lexrc.getBool();
398 case RC_TEX_ALLOWS_SPACES:
400 tex_allows_spaces = lexrc.getBool();
406 use_kbmap = lexrc.getBool();
410 case RC_KBMAP_PRIMARY:
412 string const kmap(os::internal_path(lexrc.getString()));
415 } else if (!LibFileSearch("kbd", kmap,
417 primary_kbmap = kmap;
419 lexrc.printError("LyX: Keymap `$$Token' not found");
424 case RC_KBMAP_SECONDARY:
426 string const kmap(os::internal_path(lexrc.getString()));
429 } else if (!LibFileSearch("kbd", kmap,
431 secondary_kbmap = kmap;
433 lexrc.printError("LyX: Keymap `$$Token' not found");
438 case RC_FONT_ENCODING:
440 fontenc = lexrc.getString();
446 printer = lexrc.getString();
450 case RC_PRINT_COMMAND:
452 print_command = lexrc.getString();
456 case RC_PRINTEVENPAGEFLAG:
458 print_evenpage_flag = lexrc.getString();
462 case RC_PRINTODDPAGEFLAG:
464 print_oddpage_flag = lexrc.getString();
468 case RC_PRINTPAGERANGEFLAG:
470 print_pagerange_flag = lexrc.getString();
474 case RC_PRINTCOPIESFLAG:
476 print_copies_flag = lexrc.getString();
480 case RC_PRINTCOLLCOPIESFLAG:
482 print_collcopies_flag = lexrc.getString();
486 case RC_PRINTREVERSEFLAG:
488 print_reverse_flag = lexrc.getString();
492 case RC_PRINTLANDSCAPEFLAG:
494 print_landscape_flag = lexrc.getString();
498 case RC_PRINTTOPRINTER:
500 print_to_printer = lexrc.getString();
504 case RC_PRINT_ADAPTOUTPUT:
506 print_adapt_output = lexrc.getBool();
512 print_to_file = os::internal_path(lexrc.getString());
516 case RC_PRINTFILEEXTENSION:
518 print_file_extension = lexrc.getString();
522 case RC_PRINTEXSTRAOPTIONS:
524 print_extra_options = lexrc.getString();
528 case RC_PRINTSPOOL_COMMAND:
530 print_spool_command = lexrc.getString();
534 case RC_PRINTSPOOL_PRINTERPREFIX:
536 print_spool_printerprefix = lexrc.getString();
540 case RC_PRINTPAPERDIMENSIONFLAG:
542 print_paper_dimension_flag = lexrc.getString();
546 case RC_PRINTPAPERFLAG:
548 print_paper_flag = lexrc.getString();
552 case RC_CUSTOM_EXPORT_COMMAND:
554 custom_export_command = lexrc.getString();
558 case RC_CUSTOM_EXPORT_FORMAT:
560 custom_export_format = lexrc.getString();
564 case RC_DEFAULT_PAPERSIZE:
567 ascii_lowercase(lexrc.getString());
568 if (size == "usletter")
571 else if (size == "legal")
574 else if (size == "executive")
576 PAPER_EXECUTIVEPAPER;
577 else if (size == "a3")
580 else if (size == "a4")
583 else if (size == "a5")
586 else if (size == "b5")
592 case RC_VIEWDVI_PAPEROPTION:
594 view_dvi_paper_option = lexrc.getString();
596 view_dvi_paper_option.erase();
600 case RC_CHKTEX_COMMAND:
602 chktex_command = lexrc.getString();
606 case RC_BIBTEX_COMMAND:
608 bibtex_command = lexrc.getString();
612 case RC_INDEX_COMMAND:
614 index_command = lexrc.getString();
620 dpi = lexrc.getInteger();
626 zoom = lexrc.getInteger();
632 wheel_jump = lexrc.getInteger();
636 case RC_SCREEN_FONT_SIZES:
638 font_sizes[LyXFont::SIZE_TINY] =
642 font_sizes[LyXFont::SIZE_SCRIPT] =
646 font_sizes[LyXFont::SIZE_FOOTNOTE] =
650 font_sizes[LyXFont::SIZE_SMALL] =
654 font_sizes[LyXFont::SIZE_NORMAL] =
658 font_sizes[LyXFont::SIZE_LARGE] =
662 font_sizes[LyXFont::SIZE_LARGER] =
666 font_sizes[LyXFont::SIZE_LARGEST] =
670 font_sizes[LyXFont::SIZE_HUGE] =
674 font_sizes[LyXFont::SIZE_HUGER] =
679 case RC_SCREEN_FONT_SCALABLE:
681 use_scalable_fonts = lexrc.getBool();
687 autosave = lexrc.getInteger();
691 case RC_DOCUMENTPATH:
693 document_path = os::internal_path(lexrc.getString());
694 document_path = ExpandPath(document_path);
698 case RC_TEMPLATEPATH:
700 template_path = os::internal_path(lexrc.getString());
701 template_path = ExpandPath(template_path);
707 tempdir_path = os::internal_path(lexrc.getString());
708 tempdir_path = ExpandPath(tempdir_path);
714 lyxerr << "Ignoring obsolete use_tempdir flag." << endl;
720 lastfiles = ExpandPath(os::internal_path(lexrc.getString()));
724 case RC_NUMLASTFILES:
726 num_lastfiles = lexrc.getInteger();
730 case RC_CHECKLASTFILES:
732 check_lastfiles = lexrc.getBool();
736 case RC_SCREEN_FONT_ROMAN:
738 roman_font_name = lexrc.getString();
739 oldFontFormat(roman_font_name,
744 case RC_SCREEN_FONT_SANS:
746 sans_font_name = lexrc.getString();
747 oldFontFormat(sans_font_name, sans_font_foundry);
751 case RC_SCREEN_FONT_TYPEWRITER:
753 typewriter_font_name = lexrc.getString();
754 oldFontFormat(typewriter_font_name,
755 typewriter_font_foundry);
759 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
761 roman_font_foundry = lexrc.getString();
765 case RC_SCREEN_FONT_SANS_FOUNDRY:
767 sans_font_foundry = lexrc.getString();
771 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
773 typewriter_font_foundry = lexrc.getString();
777 case RC_SCREEN_FONT_ENCODING:
779 font_norm = lexrc.getString();
780 set_font_norm_type();
784 case RC_POPUP_BOLD_FONT:
786 popup_bold_font = lexrc.getString();
790 case RC_POPUP_NORMAL_FONT:
792 popup_normal_font = lexrc.getString();
796 case RC_POPUP_FONT_ENCODING:
798 popup_font_encoding = lexrc.getString();
804 string lyx_name, x11_name;
807 lyx_name = lexrc.getString();
809 lexrc.printError("Missing color tag.");
814 x11_name = lexrc.getString();
816 lexrc.printError("Missing color name for color: `$$Token'");
820 LColor::color const col =
821 lcolor.getFromLyXName(lyx_name);
822 if (col == LColor::none ||
823 col == LColor::inherit ||
824 col == LColor::ignore)
827 if (!lcolor.setColor(col, x11_name)) {
828 lyxerr << "Bad lyxrc set_color for "
834 case RC_AUTOREGIONDELETE:
835 // Auto region delete defaults to true
837 auto_region_delete = lexrc.getBool();
843 lyxpipes = os::internal_path(lexrc.getString());
844 lyxpipes = ExpandPath(lyxpipes);
848 case RC_CURSOR_FOLLOWS_SCROLLBAR:
850 cursor_follows_scrollbar = lexrc.getBool();
854 case RC_DIALOGS_ICONIFY_WITH_MAIN:
856 dialogs_iconify_with_main = lexrc.getBool();
860 case RC_ASCIIROFF_COMMAND:
862 ascii_roff_command = lexrc.getString();
865 case RC_ASCII_LINELEN:
867 ascii_linelen = lexrc.getInteger();
870 // Spellchecker settings:
871 case RC_USE_SPELL_LIB:
873 use_spell_lib = lexrc.getBool();
876 case RC_SPELL_COMMAND:
878 isp_command = lexrc.getString();
881 case RC_ACCEPT_COMPOUND:
883 isp_accept_compound = lexrc.getBool();
888 isp_use_input_encoding = lexrc.getBool();
891 case RC_USE_ALT_LANG:
893 isp_use_alt_lang = lexrc.getBool();
896 case RC_USE_PERS_DICT:
898 isp_use_pers_dict = lexrc.getBool();
901 case RC_USE_ESC_CHARS:
903 isp_use_esc_chars = lexrc.getBool();
908 isp_alt_lang = lexrc.getString();
913 isp_pers_dict = os::internal_path(lexrc.getString());
918 isp_esc_chars = lexrc.getString();
923 make_backup = lexrc.getBool();
926 case RC_BACKUPDIR_PATH:
928 backupdir_path = os::internal_path(lexrc.getString());
929 backupdir_path = ExpandPath(backupdir_path);
932 case RC_DATE_INSERT_FORMAT:
934 date_insert_format = lexrc.getString();
937 case RC_LANGUAGE_PACKAGE:
939 language_package = lexrc.getString();
942 case RC_LANGUAGE_AUTO_BEGIN:
944 language_auto_begin = lexrc.getBool();
947 case RC_LANGUAGE_AUTO_END:
949 language_auto_end = lexrc.getBool();
952 case RC_LANGUAGE_GLOBAL_OPTIONS:
954 language_global_options = lexrc.getBool();
957 case RC_LANGUAGE_USE_BABEL:
959 language_use_babel = lexrc.getBool();
962 case RC_LANGUAGE_COMMAND_BEGIN:
964 language_command_begin = lexrc.getString();
967 case RC_LANGUAGE_COMMAND_END:
969 language_command_end = lexrc.getString();
972 case RC_LANGUAGE_COMMAND_LOCAL:
974 language_command_local = lexrc.getString();
979 rtl_support = lexrc.getBool();
984 auto_number = lexrc.getBool();
987 case RC_MARK_FOREIGN_LANGUAGE:
989 mark_foreign_language = lexrc.getBool();
996 fmt = lexrc.getString();
999 command = lexrc.getString();
1001 movers.set(fmt, command);
1005 case RC_CONVERTER: {
1006 string from, to, command, flags;
1008 from = lexrc.getString();
1011 to = lexrc.getString();
1014 command = lexrc.getString();
1017 flags = lexrc.getString();
1020 || token(command, ' ', 0) == "none") {
1021 converters.erase(from, to);
1023 converters.add(from, to, command, flags);
1027 // compatibility with versions older than 1.4.0 only
1029 string format, command;
1031 format = lexrc.getString();
1034 command = lexrc.getString();
1035 if (token(command, ' ', 0) == "none")
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;
1056 // Hack to ensure compatibility with versions older
1058 int le = lexrc.lex();
1059 if (le != LyXLex::LEX_FEOF && le != LyXLex::LEX_UNDEF) {
1060 viewer = lexrc.getString();
1061 if (le == LyXLex::LEX_DATA) {
1062 if (token(viewer, ' ', 0) == "none")
1065 editor = lexrc.getString();
1066 if (token(editor, ' ', 0) == "none")
1070 // We have got a known token.
1071 // Therefore this is an old style
1072 // format definition without
1073 // viewer and editor.
1074 lexrc.pushToken(viewer);
1078 if (prettyname.empty()) {
1079 if (converters.formatIsUsed(format)) {
1080 lyxerr << "Can't delete format "
1083 formats.erase(format);
1086 formats.add(format, extension, prettyname,
1087 shortcut, viewer, editor);
1091 case RC_DEFAULT_LANGUAGE:
1093 default_language = lexrc.getString();
1097 case RC_LABEL_INIT_LENGTH:
1099 label_init_length = lexrc.getInteger();
1103 case RC_SHOW_BANNER:
1105 show_banner = lexrc.getBool();
1111 string const tmp = lexrc.getString();
1112 if (tmp == "true" || tmp == "on")
1113 preview = PREVIEW_ON;
1114 else if (tmp == "no_math")
1115 preview = PREVIEW_NO_MATH;
1117 preview = PREVIEW_OFF;
1118 if (tmp != "false" && tmp != "off")
1119 lyxerr << "Unrecognized "
1121 << tmp << '\n' << endl;
1126 case RC_PREVIEW_HASHED_LABELS:
1128 preview_hashed_labels = lexrc.getBool();
1132 case RC_PREVIEW_SCALE_FACTOR:
1134 preview_scale_factor = lexrc.getString();
1140 user_name = lexrc.getString();
1145 user_email = lexrc.getString();
1148 case RC_PATH_PREFIX:
1150 path_prefix = lexrc.getString();
1153 case RC_LAST: break; // this is just a dummy
1157 /// Update converters data-structures
1158 converters.update(formats);
1159 converters.buildGraph();
1165 void LyXRC::write(string const & filename, bool ignore_system_lyxrc) const
1167 ofstream ofs(filename.c_str());
1169 write(ofs, ignore_system_lyxrc);
1173 void LyXRC::print() const
1175 if (lyxerr.debugging())
1176 write(lyxerr, false);
1184 typedef std::pair<std::string, SpecialisedMover> Data;
1186 SameMover(Data const & comparison)
1187 : comparison_(comparison) {}
1189 bool operator()(Data const & data) const
1191 return data.first == comparison_.first &&
1192 data.second.command() == comparison_.second.command();
1200 void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
1202 os << "### This file is part of\n"
1203 << "### ========================================================\n"
1204 << "### LyX, The Document Processor\n"
1206 << "### Copyright 1995 Matthias Ettrich\n"
1207 << "### Copyright 1995-2001 The LyX Team.\n"
1209 << "### ========================================================\n"
1211 << "# This file is written by LyX, if you want to make your own\n"
1212 << "# modifications you should do them from inside LyX and save\n"
1215 // Why the switch you might ask. It is a trick to ensure that all
1216 // the elements in the LyXRCTags enum is handled. As you can see
1217 // there are no breaks at all. So it is just a huge fall-through.
1218 // The nice thing is that we will get a warning from the compiler
1219 // if we forget an element.
1220 LyXRCTags tag = RC_LAST;
1224 // input/include files are not done here
1226 if (ignore_system_lyxrc ||
1227 bind_file != system_lyxrc.bind_file) {
1228 string const path = os::external_path(bind_file);
1229 os << "\\bind_file \"" << path << "\"\n";
1235 << "# MISC SECTION ######################################\n"
1238 // bind files are not done here.
1240 case RC_PATH_PREFIX:
1241 if (ignore_system_lyxrc ||
1242 path_prefix != system_lyxrc.path_prefix) {
1243 os << "\\path_prefix \"" << path_prefix << "\"\n";
1247 if (ignore_system_lyxrc ||
1248 ui_file != system_lyxrc.ui_file) {
1249 string const path = os::external_path(ui_file);
1250 os << "\\ui_file \"" << path << "\"\n";
1252 case RC_AUTOREGIONDELETE:
1253 if (ignore_system_lyxrc ||
1254 auto_region_delete != system_lyxrc.auto_region_delete) {
1255 os << "# Set to false to inhibit automatic replacement of\n"
1256 << "# the current selection.\n"
1257 << "\\auto_region_delete " << convert<string>(auto_region_delete)
1260 case RC_AUTORESET_OPTIONS:
1261 if (ignore_system_lyxrc ||
1262 auto_reset_options != system_lyxrc.auto_reset_options) {
1263 os << "# Set to false to inhibit automatic reset of\n"
1264 << "# the class options to defaults on class change.\n"
1265 << "\\auto_reset_options "
1266 << convert<string>(auto_reset_options)
1270 if (ignore_system_lyxrc ||
1271 autosave != system_lyxrc.autosave) {
1272 os << "# The time interval between auto-saves in seconds.\n"
1273 << "\\autosave " << autosave << '\n';
1275 case RC_DISPLAY_GRAPHICS:
1276 if (ignore_system_lyxrc ||
1277 display_graphics != system_lyxrc.display_graphics) {
1278 os << "# Display graphics within LyX\n"
1279 << "# monochrome|grayscale|color|none\n"
1280 << "\\display_graphics "
1281 << lyx::graphics::displayTranslator().find(display_graphics)
1285 case RC_VIEWDVI_PAPEROPTION:
1286 if (ignore_system_lyxrc ||
1287 view_dvi_paper_option
1288 != system_lyxrc.view_dvi_paper_option) {
1289 os << "# Options used to specify paper size to the\n"
1290 << "# view_dvi_command (e.g. -paper)\n"
1291 << "\\view_dvi_paper_option \""
1292 << view_dvi_paper_option << "\"\n";
1294 case RC_DEFAULT_PAPERSIZE:
1295 if (ignore_system_lyxrc ||
1296 default_papersize != system_lyxrc.default_papersize) {
1297 os << "# The default papersize to use.\n"
1298 << "\\default_papersize \"";
1299 switch (default_papersize) {
1300 case PAPER_USLETTER:
1301 os << "usletter"; break;
1302 case PAPER_LEGALPAPER:
1303 os << "legal"; break;
1304 case PAPER_EXECUTIVEPAPER:
1305 os << "executive"; break;
1314 case PAPER_DEFAULT: break;
1318 case RC_CHKTEX_COMMAND:
1319 if (ignore_system_lyxrc ||
1320 chktex_command != system_lyxrc.chktex_command) {
1321 os << "\\chktex_command \"" << chktex_command << "\"\n";
1323 case RC_BIBTEX_COMMAND:
1324 if (ignore_system_lyxrc ||
1325 bibtex_command != system_lyxrc.bibtex_command) {
1326 os << "\\bibtex_command \"" << bibtex_command << "\"\n";
1328 case RC_INDEX_COMMAND:
1329 if (ignore_system_lyxrc ||
1330 index_command != system_lyxrc.index_command) {
1331 os << "\\index_command \"" << index_command << "\"\n";
1333 case RC_CYGWIN_PATH_FIX:
1334 if (ignore_system_lyxrc ||
1335 cygwin_path_fix != system_lyxrc.cygwin_path_fix) {
1336 os << "\\cygwin_path_fix_needed "
1337 << convert<string>(cygwin_path_fix) << '\n';
1339 case RC_TEX_ALLOWS_SPACES:
1340 if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
1341 os << "\\tex_allows_spaces "
1342 << convert<string>(tex_allows_spaces) << '\n';
1345 if (ignore_system_lyxrc ||
1346 use_kbmap != system_lyxrc.use_kbmap) {
1347 os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1349 case RC_KBMAP_PRIMARY:
1350 if (ignore_system_lyxrc ||
1351 primary_kbmap != system_lyxrc.primary_kbmap) {
1352 string const path = os::external_path(primary_kbmap);
1353 os << "\\kbmap_primary \"" << path << "\"\n";
1355 case RC_KBMAP_SECONDARY:
1356 if (ignore_system_lyxrc ||
1357 secondary_kbmap != system_lyxrc.secondary_kbmap) {
1358 string const path = os::external_path(secondary_kbmap);
1359 os << "\\kbmap_secondary \"" << path << "\"\n";
1362 if (ignore_system_lyxrc ||
1363 lyxpipes != system_lyxrc.lyxpipes) {
1364 string const path = os::external_path(lyxpipes);
1365 os << "\\serverpipe \"" << path << "\"\n";
1367 case RC_DATE_INSERT_FORMAT:
1368 if (ignore_system_lyxrc ||
1369 date_insert_format != system_lyxrc.date_insert_format) {
1370 os << "\\date_insert_format \"" << date_insert_format
1373 case RC_LABEL_INIT_LENGTH:
1374 if (ignore_system_lyxrc ||
1375 label_init_length != system_lyxrc.label_init_length) {
1376 os << "\\label_init_length " << label_init_length
1381 os << "\\user_name \"" << user_name << "\"\n";
1384 os << "\\user_email \"" << user_email << "\"\n";
1386 case RC_SHOW_BANNER:
1387 if (ignore_system_lyxrc ||
1388 show_banner != system_lyxrc.show_banner) {
1389 os << "\\show_banner " << convert<string>(show_banner) << '\n';
1393 if (ignore_system_lyxrc ||
1394 preview != system_lyxrc.preview) {
1400 case PREVIEW_NO_MATH:
1407 os << "\\preview " << status << '\n';
1410 case RC_PREVIEW_HASHED_LABELS:
1411 if (ignore_system_lyxrc ||
1412 preview_hashed_labels !=
1413 system_lyxrc.preview_hashed_labels) {
1414 os << "\\preview_hashed_labels "
1415 << convert<string>(preview_hashed_labels) << '\n';
1418 case RC_PREVIEW_SCALE_FACTOR:
1419 if (ignore_system_lyxrc ||
1420 preview_scale_factor != system_lyxrc.preview_scale_factor) {
1421 os << "\\preview_scale_factor "
1422 << preview_scale_factor << '\n';
1426 << "# SCREEN & FONTS SECTION ############################\n"
1429 case RC_POPUP_NORMAL_FONT:
1430 if (ignore_system_lyxrc ||
1431 popup_normal_font != system_lyxrc.popup_normal_font) {
1432 os << "\\popup_normal_font \"" << popup_normal_font
1435 case RC_POPUP_BOLD_FONT:
1436 if (ignore_system_lyxrc ||
1437 popup_bold_font != system_lyxrc.popup_bold_font) {
1438 os << "\\popup_bold_font \"" << popup_bold_font
1441 case RC_POPUP_FONT_ENCODING:
1442 if (ignore_system_lyxrc ||
1443 popup_font_encoding != system_lyxrc.popup_font_encoding) {
1444 os << "\\popup_font_encoding \"" << popup_font_encoding
1448 if (ignore_system_lyxrc ||
1449 dpi != system_lyxrc.dpi) {
1450 os << "\\screen_dpi " << dpi << '\n';
1452 case RC_SCREEN_ZOOM:
1453 if (ignore_system_lyxrc ||
1454 zoom != system_lyxrc.zoom) {
1455 os << "\\screen_zoom " << zoom << '\n';
1458 if (ignore_system_lyxrc ||
1459 wheel_jump != system_lyxrc.wheel_jump) {
1460 os << "\\wheel_jump " << wheel_jump << '\n';
1462 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1463 if (ignore_system_lyxrc ||
1464 cursor_follows_scrollbar
1465 != system_lyxrc.cursor_follows_scrollbar) {
1466 os << "\\cursor_follows_scrollbar "
1467 << convert<string>(cursor_follows_scrollbar) << '\n';
1469 case RC_DIALOGS_ICONIFY_WITH_MAIN:
1470 if (ignore_system_lyxrc ||
1471 dialogs_iconify_with_main
1472 != system_lyxrc.dialogs_iconify_with_main) {
1473 os << "\\dialogs_iconify_with_main "
1474 << convert<string>(dialogs_iconify_with_main) << '\n';
1476 case RC_SCREEN_FONT_ROMAN:
1477 if (ignore_system_lyxrc ||
1478 roman_font_name != system_lyxrc.roman_font_name) {
1479 os << "\\screen_font_roman \"" << roman_font_name
1482 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1483 if (ignore_system_lyxrc ||
1484 roman_font_foundry != system_lyxrc.roman_font_foundry) {
1485 os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1488 case RC_SCREEN_FONT_SANS:
1489 if (ignore_system_lyxrc ||
1490 sans_font_name != system_lyxrc.sans_font_name) {
1491 os << "\\screen_font_sans \"" << sans_font_name
1494 case RC_SCREEN_FONT_SANS_FOUNDRY:
1495 if (ignore_system_lyxrc ||
1496 sans_font_foundry != system_lyxrc.sans_font_foundry) {
1497 os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1500 case RC_SCREEN_FONT_TYPEWRITER:
1501 if (ignore_system_lyxrc ||
1502 typewriter_font_name != system_lyxrc.typewriter_font_name) {
1503 os << "\\screen_font_typewriter \""
1504 << typewriter_font_name << "\"\n";
1506 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1507 if (ignore_system_lyxrc ||
1508 typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1509 os << "\\screen_font_typewriter_foundry \""
1510 << typewriter_font_foundry << "\"\n";
1513 case RC_SCREEN_FONT_SCALABLE:
1514 if (ignore_system_lyxrc ||
1515 use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1516 os << "\\screen_font_scalable "
1517 << convert<string>(use_scalable_fonts)
1520 case RC_SCREEN_FONT_ENCODING:
1521 if (ignore_system_lyxrc ||
1522 font_norm != system_lyxrc.font_norm) {
1523 os << "\\screen_font_encoding \"" << font_norm
1526 case RC_SCREEN_FONT_SIZES:
1527 if (ignore_system_lyxrc ||
1528 font_sizes[LyXFont::SIZE_TINY]
1529 != system_lyxrc.font_sizes[LyXFont::SIZE_TINY] ||
1530 font_sizes[LyXFont::SIZE_SCRIPT]
1531 != system_lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] ||
1532 font_sizes[LyXFont::SIZE_FOOTNOTE]
1533 != system_lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] ||
1534 font_sizes[LyXFont::SIZE_SMALL]
1535 != system_lyxrc.font_sizes[LyXFont::SIZE_SMALL] ||
1536 font_sizes[LyXFont::SIZE_NORMAL]
1537 != system_lyxrc.font_sizes[LyXFont::SIZE_NORMAL] ||
1538 font_sizes[LyXFont::SIZE_LARGE]
1539 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGE] ||
1540 font_sizes[LyXFont::SIZE_LARGER]
1541 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGER] ||
1542 font_sizes[LyXFont::SIZE_LARGEST]
1543 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGEST] ||
1544 font_sizes[LyXFont::SIZE_HUGE]
1545 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGE] ||
1546 font_sizes[LyXFont::SIZE_HUGER]
1547 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGER]) {
1548 os.setf(ios::fixed);
1550 os << "\\screen_font_sizes"
1551 << ' ' << font_sizes[LyXFont::SIZE_TINY]
1552 << ' ' << font_sizes[LyXFont::SIZE_SCRIPT]
1553 << ' ' << font_sizes[LyXFont::SIZE_FOOTNOTE]
1554 << ' ' << font_sizes[LyXFont::SIZE_SMALL]
1555 << ' ' << font_sizes[LyXFont::SIZE_NORMAL]
1556 << ' ' << font_sizes[LyXFont::SIZE_LARGE]
1557 << ' ' << font_sizes[LyXFont::SIZE_LARGER]
1558 << ' ' << font_sizes[LyXFont::SIZE_LARGEST]
1559 << ' ' << font_sizes[LyXFont::SIZE_HUGE]
1560 << ' ' << font_sizes[LyXFont::SIZE_HUGER]
1565 << "# COLOR SECTION ###################################\n"
1569 for (int i = 0; i < LColor::ignore; ++i) {
1570 LColor::color lc = static_cast<LColor::color>(i);
1572 string const col(lcolor.getX11Name(lc));
1573 if (ignore_system_lyxrc ||
1574 col != system_lcolor.getX11Name(lc)) {
1575 os << "\\set_color \""
1576 << lcolor.getLyXName(lc) << "\" \""
1582 << "# PRINTER SECTION ###################################\n"
1586 if (ignore_system_lyxrc ||
1587 printer != system_lyxrc.printer) {
1588 os << "\\printer \"" << printer << "\"\n";
1590 case RC_PRINT_ADAPTOUTPUT:
1591 if (ignore_system_lyxrc ||
1592 print_adapt_output != system_lyxrc.print_adapt_output) {
1593 os << "\\print_adapt_output "
1594 << convert<string>(print_adapt_output)
1597 case RC_PRINT_COMMAND:
1598 if (ignore_system_lyxrc ||
1599 print_command != system_lyxrc.print_command) {
1600 os << "\\print_command \"" << print_command << "\"\n";
1602 case RC_PRINTEXSTRAOPTIONS:
1603 if (ignore_system_lyxrc ||
1604 print_extra_options != system_lyxrc.print_extra_options) {
1605 os << "\\print_extra_options \"" << print_extra_options
1608 case RC_PRINTSPOOL_COMMAND:
1609 if (ignore_system_lyxrc ||
1610 print_spool_command != system_lyxrc.print_spool_command) {
1611 os << "\\print_spool_command \"" << print_spool_command
1614 case RC_PRINTSPOOL_PRINTERPREFIX:
1615 if (ignore_system_lyxrc ||
1616 print_spool_printerprefix
1617 != system_lyxrc.print_spool_printerprefix) {
1618 os << "\\print_spool_printerprefix \""
1619 << print_spool_printerprefix << "\"\n";
1621 case RC_PRINTEVENPAGEFLAG:
1622 if (ignore_system_lyxrc ||
1623 print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1624 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1627 case RC_PRINTODDPAGEFLAG:
1628 if (ignore_system_lyxrc ||
1629 print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1630 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1633 case RC_PRINTREVERSEFLAG:
1634 if (ignore_system_lyxrc ||
1635 print_reverse_flag != system_lyxrc.print_reverse_flag) {
1636 os << "\\print_reverse_flag \"" << print_reverse_flag
1639 case RC_PRINTLANDSCAPEFLAG:
1640 if (ignore_system_lyxrc ||
1641 print_landscape_flag != system_lyxrc.print_landscape_flag) {
1642 os << "\\print_landscape_flag \"" << print_landscape_flag
1645 case RC_PRINTPAGERANGEFLAG:
1646 if (ignore_system_lyxrc ||
1647 print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1648 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1651 case RC_PRINTCOPIESFLAG:
1652 if (ignore_system_lyxrc ||
1653 print_copies_flag != system_lyxrc.print_copies_flag) {
1654 os << "\\print_copies_flag \"" << print_copies_flag
1657 case RC_PRINTCOLLCOPIESFLAG:
1658 if (ignore_system_lyxrc ||
1659 print_collcopies_flag
1660 != system_lyxrc.print_collcopies_flag) {
1661 os << "\\print_collcopies_flag \""
1662 << print_collcopies_flag
1665 case RC_PRINTPAPERFLAG:
1666 if (ignore_system_lyxrc ||
1667 print_paper_flag != system_lyxrc.print_paper_flag) {
1668 os << "\\print_paper_flag \"" << print_paper_flag
1671 case RC_PRINTPAPERDIMENSIONFLAG:
1672 if (ignore_system_lyxrc ||
1673 print_paper_dimension_flag
1674 != system_lyxrc.print_paper_dimension_flag) {
1675 os << "\\print_paper_dimension_flag \""
1676 << print_paper_dimension_flag << "\"\n";
1678 case RC_PRINTTOPRINTER:
1679 if (ignore_system_lyxrc ||
1680 print_to_printer != system_lyxrc.print_to_printer) {
1681 os << "\\print_to_printer \"" << print_to_printer
1684 case RC_PRINTTOFILE:
1685 if (ignore_system_lyxrc ||
1686 print_to_file != system_lyxrc.print_to_file) {
1687 string const path = os::external_path(print_to_file);
1688 os << "\\print_to_file \"" << path << "\"\n";
1690 case RC_PRINTFILEEXTENSION:
1691 if (ignore_system_lyxrc ||
1692 print_file_extension != system_lyxrc.print_file_extension) {
1693 os << "\\print_file_extension \""
1694 << print_file_extension
1699 << "# EXPORT SECTION ####################################\n"
1702 case RC_CUSTOM_EXPORT_COMMAND:
1703 if (ignore_system_lyxrc ||
1704 custom_export_command
1705 != system_lyxrc.custom_export_command) {
1706 os << "\\custom_export_command \""
1707 << custom_export_command
1710 case RC_CUSTOM_EXPORT_FORMAT:
1711 if (ignore_system_lyxrc ||
1712 custom_export_format
1713 != system_lyxrc.custom_export_format) {
1714 os << "\\custom_export_format \"" << custom_export_format
1719 << "# TEX SECTION #######################################\n"
1722 case RC_FONT_ENCODING:
1723 if (ignore_system_lyxrc ||
1724 fontenc != system_lyxrc.fontenc) {
1725 os << "\\font_encoding \"" << fontenc << "\"\n";
1729 << "# FILE SECTION ######################################\n"
1732 case RC_DOCUMENTPATH:
1733 if (ignore_system_lyxrc ||
1734 document_path != system_lyxrc.document_path) {
1735 string const path = os::external_path(document_path);
1736 os << "\\document_path \"" << path << "\"\n";
1739 if (ignore_system_lyxrc ||
1740 lastfiles != system_lyxrc.lastfiles) {
1741 string const path = os::external_path(lastfiles);
1742 os << "\\lastfiles \"" << path << "\"\n";
1744 case RC_NUMLASTFILES:
1745 if (ignore_system_lyxrc ||
1746 num_lastfiles != system_lyxrc.num_lastfiles) {
1747 os << "\\num_lastfiles " << num_lastfiles << '\n';
1749 case RC_CHECKLASTFILES:
1750 if (ignore_system_lyxrc ||
1751 check_lastfiles != system_lyxrc.check_lastfiles) {
1752 os << "\\check_lastfiles " << convert<string>(check_lastfiles)
1755 case RC_TEMPLATEPATH:
1756 if (ignore_system_lyxrc ||
1757 template_path != system_lyxrc.template_path) {
1758 string const path = os::external_path(template_path);
1759 os << "\\template_path \"" << path << "\"\n";
1761 case RC_TEMPDIRPATH:
1762 if (ignore_system_lyxrc ||
1763 tempdir_path != system_lyxrc.tempdir_path) {
1764 string const path = os::external_path(tempdir_path);
1765 os << "\\tempdir_path \"" << path << "\"\n";
1769 case RC_ASCII_LINELEN:
1770 if (ignore_system_lyxrc ||
1771 ascii_linelen != system_lyxrc.ascii_linelen) {
1772 os << "\\ascii_linelen " << ascii_linelen << '\n';
1774 case RC_MAKE_BACKUP:
1775 if (ignore_system_lyxrc ||
1776 make_backup != system_lyxrc.make_backup) {
1777 os << "\\make_backup " << convert<string>(make_backup) << '\n';
1779 case RC_BACKUPDIR_PATH:
1780 if (ignore_system_lyxrc ||
1781 backupdir_path != system_lyxrc.backupdir_path) {
1782 string const path = os::external_path(backupdir_path);
1783 os << "\\backupdir_path \"" << path << "\"\n";
1787 << "# ASCII EXPORT SECTION ##############################\n"
1790 case RC_ASCIIROFF_COMMAND:
1791 if (ignore_system_lyxrc ||
1792 ascii_roff_command != system_lyxrc.ascii_roff_command) {
1793 os << "\\ascii_roff_command \"" << ascii_roff_command
1798 << "# SPELLCHECKER SECTION ##############################\n"
1800 case RC_USE_SPELL_LIB:
1801 if (ignore_system_lyxrc ||
1802 use_spell_lib != system_lyxrc.use_spell_lib) {
1803 os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
1805 case RC_SPELL_COMMAND:
1806 if (ignore_system_lyxrc ||
1807 isp_command != system_lyxrc.isp_command) {
1808 os << "\\spell_command \"" << isp_command << "\"\n";
1810 case RC_ACCEPT_COMPOUND:
1811 if (ignore_system_lyxrc ||
1812 isp_accept_compound != system_lyxrc.isp_accept_compound) {
1813 os << "\\accept_compound " << convert<string>(isp_accept_compound)
1816 case RC_USE_ALT_LANG:
1817 if (ignore_system_lyxrc ||
1818 isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
1819 os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
1823 if (ignore_system_lyxrc ||
1824 isp_alt_lang != system_lyxrc.isp_alt_lang) {
1825 os << "\\alternate_language \"" << isp_alt_lang
1828 case RC_USE_ESC_CHARS:
1829 if (ignore_system_lyxrc ||
1830 isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
1831 os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
1835 if (ignore_system_lyxrc ||
1836 isp_esc_chars != system_lyxrc.isp_esc_chars) {
1837 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1839 case RC_USE_PERS_DICT:
1840 if (ignore_system_lyxrc ||
1841 isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
1842 os << "\\use_personal_dictionary "
1843 << convert<string>(isp_use_pers_dict)
1847 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
1848 string const path = os::external_path(isp_pers_dict);
1849 os << "\\personal_dictionary \"" << path << "\"\n";
1851 case RC_USE_INP_ENC:
1852 if (ignore_system_lyxrc ||
1853 isp_use_input_encoding
1854 != system_lyxrc.isp_use_input_encoding) {
1855 os << "\\use_input_encoding "
1856 << convert<string>(isp_use_input_encoding)
1861 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1864 case RC_RTL_SUPPORT:
1865 if (ignore_system_lyxrc ||
1866 rtl_support != system_lyxrc.rtl_support) {
1867 os << "\\rtl " << convert<string>(rtl_support) << '\n';
1869 case RC_LANGUAGE_PACKAGE:
1870 if (ignore_system_lyxrc ||
1871 language_package != system_lyxrc.language_package) {
1872 os << "\\language_package \"" << language_package
1875 case RC_LANGUAGE_GLOBAL_OPTIONS:
1876 if (ignore_system_lyxrc ||
1877 language_global_options
1878 != system_lyxrc.language_global_options) {
1879 os << "\\language_global_options \""
1880 << convert<string>(language_global_options)
1883 case RC_LANGUAGE_USE_BABEL:
1884 if (ignore_system_lyxrc ||
1885 language_use_babel != system_lyxrc.language_use_babel) {
1886 os << "\\language_use_babel \""
1887 << convert<string>(language_use_babel)
1890 case RC_LANGUAGE_COMMAND_BEGIN:
1891 if (ignore_system_lyxrc ||
1892 language_command_begin
1893 != system_lyxrc.language_command_begin) {
1894 os << "\\language_command_begin \""
1895 << language_command_begin
1898 case RC_LANGUAGE_COMMAND_END:
1899 if (ignore_system_lyxrc ||
1900 language_command_end
1901 != system_lyxrc.language_command_end) {
1902 os << "\\language_command_end \"" << language_command_end
1905 case RC_LANGUAGE_COMMAND_LOCAL:
1906 if (ignore_system_lyxrc ||
1907 language_command_local
1908 != system_lyxrc.language_command_local) {
1909 os << "\\language_command_local \""
1910 << language_command_local
1913 case RC_LANGUAGE_AUTO_BEGIN:
1914 if (ignore_system_lyxrc ||
1915 language_auto_begin != system_lyxrc.language_auto_begin) {
1916 os << "\\language_auto_begin "
1917 << convert<string>(language_auto_begin) << '\n';
1919 case RC_LANGUAGE_AUTO_END:
1920 if (ignore_system_lyxrc ||
1921 language_auto_end != system_lyxrc.language_auto_end) {
1922 os << "\\language_auto_end "
1923 << convert<string>(language_auto_end) << '\n';
1925 case RC_MARK_FOREIGN_LANGUAGE:
1926 if (ignore_system_lyxrc ||
1927 mark_foreign_language
1928 != system_lyxrc.mark_foreign_language) {
1929 os << "\\mark_foreign_language " <<
1930 convert<string>(mark_foreign_language) << '\n';
1934 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1937 case RC_AUTO_NUMBER:
1938 if (ignore_system_lyxrc ||
1939 auto_number != system_lyxrc.auto_number) {
1940 os << "\\auto_number " << convert<string>(auto_number) << '\n';
1942 case RC_DEFAULT_LANGUAGE:
1943 if (ignore_system_lyxrc ||
1944 default_language != system_lyxrc.default_language) {
1945 os << "\\default_language " << default_language << '\n';
1949 << "# FORMATS SECTION ##########################\n"
1953 // New/modifed formats
1954 for (Formats::const_iterator cit = formats.begin();
1955 cit != formats.end(); ++cit) {
1956 Format const * format =
1957 system_formats.getFormat(cit->name());
1959 format->extension() != cit->extension() ||
1960 format->prettyname() != cit->prettyname() ||
1961 format->shortcut() != cit->shortcut() ||
1962 format->viewer() != cit->viewer() ||
1963 format->editor() != cit->editor())
1964 os << "\\format \"" << cit->name() << "\" \""
1965 << cit->extension() << "\" \""
1966 << cit->prettyname() << "\" \""
1967 << cit->shortcut() << "\" \""
1968 << cit->viewer() << "\" \""
1969 << cit->editor() << "\"\n";
1972 // Look for deleted formats
1973 for (Formats::const_iterator cit = system_formats.begin();
1974 cit != system_formats.end(); ++cit)
1975 if (!formats.getFormat(cit->name()))
1976 os << "\\format \"" << cit->name()
1977 << "\" \"\" \"\" \"\" \"\" \"\"\n";
1982 << "# CONVERTERS SECTION ##########################\n"
1986 // Look for new converters
1987 for (Converters::const_iterator cit = converters.begin();
1988 cit != converters.end(); ++cit) {
1989 Converter const * converter =
1990 system_converters.getConverter(cit->from,
1993 converter->command != cit->command ||
1994 converter->flags != cit->flags)
1995 os << "\\converter \"" << cit->from << "\" \""
1996 << cit->to << "\" \""
1997 << cit->command << "\" \""
1998 << cit->flags << "\"\n";
2001 // New/modifed converters
2002 for (Converters::const_iterator cit = system_converters.begin();
2003 cit != system_converters.end(); ++cit)
2004 if (!converters.getConverter(cit->from, cit->to))
2005 os << "\\converter \"" << cit->from
2006 << "\" \"" << cit->to << "\" \"\" \"\"\n";
2010 << "# COPIERS SECTION ##########################\n"
2013 // Look for new movers
2014 Movers::iterator const sysbegin = system_movers.begin();
2015 Movers::iterator const sysend = system_movers.end();
2017 for (Movers::iterator it = movers.begin(), end = movers.end();
2019 Movers::iterator const sysit =
2020 std::find_if(sysbegin, sysend, SameMover(*it));
2021 if (sysit == sysend) {
2022 std::string const & fmt = it->first;
2023 std::string const & command =
2024 it->second.command();
2026 os << "\\copier " << fmt
2027 << " \"" << command << "\"\n";
2031 // We don't actually delete SpecialisedMover(s) from the
2032 // map, just clear their 'command', so there's no need
2033 // to test for anything else.
2039 void LyXRC::set_font_norm_type()
2041 if (font_norm == "iso10646-1")
2042 font_norm_type = ISO_10646_1;
2043 else if (font_norm == "iso8859-1")
2044 font_norm_type = ISO_8859_1;
2045 else if (font_norm == "iso8859-3")
2046 font_norm_type = ISO_8859_3;
2047 else if (font_norm == "iso8859-4")
2048 font_norm_type = ISO_8859_4;
2049 else if (font_norm == "iso8859-6.8x")
2050 font_norm_type = ISO_8859_6_8;
2051 else if (font_norm == "iso8859-9")
2052 font_norm_type = ISO_8859_9;
2053 else if (font_norm == "iso8859-15")
2054 font_norm_type = ISO_8859_15;
2056 font_norm_type = OTHER_ENCODING;
2060 string const LyXRC::getDescription(LyXRCTags tag)
2065 case RC_ACCEPT_COMPOUND:
2066 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2070 case RC_USE_ALT_LANG:
2071 str = _("Specify an alternate language. The default is to use the language of the document.");
2074 case RC_ASCIIROFF_COMMAND:
2075 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 \"none\" is specified, an internal routine is used.");
2078 case RC_ASCII_LINELEN:
2079 str = _("This is the maximum line length of an exported text file (LaTeX, SGML or plain text).");
2082 case RC_AUTOREGIONDELETE:
2083 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2086 case RC_AUTORESET_OPTIONS:
2087 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2091 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2094 case RC_AUTO_NUMBER:
2097 case RC_BACKUPDIR_PATH:
2098 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.");
2101 case RC_BIBTEX_COMMAND:
2102 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2106 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2109 case RC_CHECKLASTFILES:
2110 str = _("Select to check whether the lastfiles still exist.");
2113 case RC_CHKTEX_COMMAND:
2114 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2123 case RC_CURSOR_FOLLOWS_SCROLLBAR:
2124 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.");
2127 case RC_CUSTOM_EXPORT_COMMAND:
2130 case RC_CUSTOM_EXPORT_FORMAT:
2133 case RC_CYGWIN_PATH_FIX:
2136 case RC_DATE_INSERT_FORMAT:
2137 //xgettext:no-c-format
2138 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2141 case RC_DEFAULT_LANGUAGE:
2142 str = _("New documents will be assigned this language.");
2145 case RC_DEFAULT_PAPERSIZE:
2146 str = _("Specify the default paper size.");
2149 case RC_DIALOGS_ICONIFY_WITH_MAIN:
2150 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2153 case RC_DISPLAY_GRAPHICS:
2154 str = _("Select how LyX will display any graphics.");
2157 case RC_DOCUMENTPATH:
2158 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2162 case RC_USE_ESC_CHARS:
2163 str = _("Specify additional chars that can be part of a word.");
2166 case RC_FONT_ENCODING:
2167 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2173 case RC_INDEX_COMMAND:
2174 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\".");
2181 case RC_KBMAP_PRIMARY:
2182 case RC_KBMAP_SECONDARY:
2183 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.");
2186 case RC_LABEL_INIT_LENGTH:
2187 str = _("Maximum number of words in the initialization string for a new label");
2190 case RC_LANGUAGE_AUTO_BEGIN:
2191 str = _("Select if a language switching command is needed at the beginning of the document.");
2194 case RC_LANGUAGE_AUTO_END:
2195 str = _("Select if a language switching command is needed at the end of the document.");
2198 case RC_LANGUAGE_COMMAND_BEGIN:
2199 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.");
2202 case RC_LANGUAGE_COMMAND_END:
2203 str = _("The LaTeX command for changing back to the language of the document.");
2206 case RC_LANGUAGE_COMMAND_LOCAL:
2207 str = _("The LaTeX command for local changing of the language.");
2210 case RC_LANGUAGE_GLOBAL_OPTIONS:
2211 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2214 case RC_LANGUAGE_PACKAGE:
2215 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2218 case RC_LANGUAGE_USE_BABEL:
2219 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2223 str = _("The file where the last-files information should be stored.");
2226 case RC_MAKE_BACKUP:
2227 str = _("De-select if you don't want LyX to create backup files.");
2230 case RC_MARK_FOREIGN_LANGUAGE:
2231 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2234 case RC_NUMLASTFILES:
2235 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."), maxlastfiles);
2238 case RC_PATH_PREFIX:
2239 str = _("Specify those directories which should be "
2240 "prepended to the PATH environment variable. "
2241 "Use the OS native format.");
2245 case RC_USE_PERS_DICT:
2246 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2249 case RC_POPUP_BOLD_FONT:
2250 str = _("The bold font in the dialogs.");
2253 case RC_POPUP_FONT_ENCODING:
2254 str = _("The encoding for the menu/popups fonts.");
2257 case RC_POPUP_NORMAL_FONT:
2258 str = _("The normal font in the dialogs.");
2262 str = _("Shows a typeset preview of things such as math");
2265 case RC_PREVIEW_HASHED_LABELS:
2266 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2269 case RC_PREVIEW_SCALE_FACTOR:
2270 str = _("Scale the preview size to suit.");
2273 case RC_PRINTCOLLCOPIESFLAG:
2274 str = _("The option for specifying whether the copies should be collated.");
2277 case RC_PRINTCOPIESFLAG:
2278 str = _("The option for specifying the number of copies to print.");
2282 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2285 case RC_PRINTEVENPAGEFLAG:
2286 str = _("The option to print only even pages.");
2289 case RC_PRINTEXSTRAOPTIONS:
2290 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2293 case RC_PRINTFILEEXTENSION:
2294 str = _("Extension of printer program output file. Usually \".ps\".");
2297 case RC_PRINTLANDSCAPEFLAG:
2298 str = _("The option to print out in landscape.");
2301 case RC_PRINTODDPAGEFLAG:
2302 str = _("The option to print only odd pages.");
2305 case RC_PRINTPAGERANGEFLAG:
2306 str = _("The option for specifying a comma-separated list of pages to print.");
2309 case RC_PRINTPAPERDIMENSIONFLAG:
2310 str = _("Option to specify the dimensions of the print paper.");
2313 case RC_PRINTPAPERFLAG:
2314 str = _("The option to specify paper type.");
2317 case RC_PRINTREVERSEFLAG:
2318 str = _("The option to reverse the order of the pages printed.");
2321 case RC_PRINTSPOOL_COMMAND:
2322 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.");
2325 case RC_PRINTSPOOL_PRINTERPREFIX:
2326 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.");
2329 case RC_PRINTTOFILE:
2330 str = _("Option to pass to the print program to print to a file.");
2333 case RC_PRINTTOPRINTER:
2334 str = _("Option to pass to the print program to print on a specific printer.");
2337 case RC_PRINT_ADAPTOUTPUT:
2338 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2341 case RC_PRINT_COMMAND:
2342 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2345 case RC_RTL_SUPPORT:
2346 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2350 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2353 case RC_SCREEN_FONT_ENCODING:
2354 str = _("The encoding for the screen fonts.");
2357 case RC_SCREEN_FONT_ROMAN:
2358 case RC_SCREEN_FONT_SANS:
2359 case RC_SCREEN_FONT_TYPEWRITER:
2360 str = _("The screen fonts used to display the text while editing.");
2363 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
2364 case RC_SCREEN_FONT_SANS_FOUNDRY:
2365 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2368 case RC_SCREEN_FONT_SCALABLE:
2369 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.");
2372 case RC_SCREEN_FONT_SIZES:
2373 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2376 case RC_SCREEN_ZOOM:
2377 //xgettext:no-c-format
2378 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2382 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2388 case RC_SHOW_BANNER:
2389 str = _("De-select if you don't want the startup banner.");
2392 case RC_SPELL_COMMAND:
2393 str = _("What command runs the spell checker?");
2396 case RC_TEMPDIRPATH:
2397 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2400 case RC_TEMPLATEPATH:
2401 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2404 case RC_TEX_ALLOWS_SPACES:
2408 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2420 case RC_USE_INP_ENC:
2421 str = _("Specify whether to pass the -T input encoding option to ispell. Enable this if you can't spellcheck words with international letters in them. This may not work with all dictionaries.");
2424 case RC_USE_SPELL_LIB:
2427 case RC_VIEWDVI_PAPEROPTION:
2428 str = _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2435 str = _("The number of lines that are scrolled by mice with wheels or five button mice.");
2445 // The global instance
2448 // The global copy of the system lyxrc entries (everything except preferences)