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/filetools.h"
38 #include "support/lstrings.h"
39 #include "support/os.h"
40 #include "support/userinfo.h"
42 using lyx::support::ascii_lowercase;
43 using lyx::support::bformat;
44 using lyx::support::ExpandPath;
45 using lyx::support::GetEnv;
46 using lyx::support::LibFileSearch;
47 using lyx::support::token;
49 namespace os = lyx::support::os;
62 // when adding something to this array keep it sorted!
63 keyword_item lyxrcTags[] = {
64 { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
65 { "\\alternate_language", LyXRC::RC_ALT_LANG },
66 { "\\ascii_linelen", LyXRC::RC_ASCII_LINELEN },
67 { "\\ascii_roff_command", LyXRC::RC_ASCIIROFF_COMMAND },
68 { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
69 { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
70 { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
71 { "\\autosave", LyXRC::RC_AUTOSAVE },
72 { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
73 { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
74 { "\\bind_file", LyXRC::RC_BINDFILE },
75 { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
76 { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
77 { "\\converter", LyXRC::RC_CONVERTER },
78 { "\\copier", LyXRC::RC_COPIER },
79 { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
80 { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
81 { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
82 { "\\cygwin_path_fix_needed", LyXRC::RC_CYGWIN_PATH_FIX },
83 { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
84 { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
85 { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
86 { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
87 { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
88 { "\\document_path", LyXRC::RC_DOCUMENTPATH },
89 { "\\escape_chars", LyXRC::RC_ESC_CHARS },
90 { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
91 { "\\format", LyXRC::RC_FORMAT },
92 { "\\index_command", LyXRC::RC_INDEX_COMMAND },
93 { "\\input", LyXRC::RC_INPUT },
94 { "\\kbmap", LyXRC::RC_KBMAP },
95 { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
96 { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
97 { "\\label_init_length", LyXRC::RC_LABEL_INIT_LENGTH },
98 { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
99 { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
100 { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
101 { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
102 { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
103 { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
104 { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
105 { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
106 { "\\lastfiles", LyXRC::RC_LASTFILES },
107 { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
108 { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
109 { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
110 { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
111 { "\\popup_bold_font", LyXRC::RC_POPUP_BOLD_FONT },
112 { "\\popup_font_encoding", LyXRC::RC_POPUP_FONT_ENCODING },
113 { "\\popup_normal_font", LyXRC::RC_POPUP_NORMAL_FONT },
114 { "\\preview", LyXRC::RC_PREVIEW },
115 { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
116 { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
117 { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
118 { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
119 { "\\print_command", LyXRC::RC_PRINT_COMMAND },
120 { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
121 { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
122 { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
123 { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
124 { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
125 { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
126 { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
127 { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
128 { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
129 { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
130 { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
131 { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
132 { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
133 { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
134 { "\\printer", LyXRC::RC_PRINTER },
135 { "\\rtl", LyXRC::RC_RTL_SUPPORT },
136 { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
137 { "\\screen_font_encoding", LyXRC::RC_SCREEN_FONT_ENCODING },
138 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
139 { "\\screen_font_encoding_menu", LyXRC::RC_POPUP_FONT_ENCODING },
140 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
141 { "\\screen_font_menu", LyXRC::RC_POPUP_BOLD_FONT },
142 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
143 { "\\screen_font_popup", LyXRC::RC_POPUP_NORMAL_FONT },
144 { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
145 { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
146 { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
147 { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
148 { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
149 { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
150 { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
151 { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
152 { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
153 { "\\serverpipe", LyXRC::RC_SERVERPIPE },
154 { "\\set_color", LyXRC::RC_SET_COLOR },
155 { "\\show_banner", LyXRC::RC_SHOW_BANNER },
156 { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
157 { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
158 { "\\template_path", LyXRC::RC_TEMPLATEPATH },
159 { "\\ui_file", LyXRC::RC_UIFILE },
160 { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
161 { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
162 { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
163 { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
164 // compatibility with versions older than 1.4.0 only
165 { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
166 { "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB },
167 // compatibility with versions older than 1.4.0 only
168 { "\\use_tempdir", LyXRC::RC_USETEMPDIR },
169 { "\\user_email", LyXRC::RC_USER_EMAIL },
170 { "\\user_name", LyXRC::RC_USER_NAME },
171 { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
172 // compatibility with versions older than 1.4.0 only
173 { "\\viewer" ,LyXRC::RC_VIEWER},
174 { "\\wheel_jump", LyXRC::RC_WHEEL_JUMP }
177 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
188 void LyXRC::setDefaults() {
191 // Get printer from the environment. If fail, use default "",
192 // assuming that everything is set up correctly.
193 printer = GetEnv("PRINTER");
194 print_adapt_output = false;
195 print_command = "dvips";
196 print_evenpage_flag = "-B";
197 print_oddpage_flag = "-A";
198 print_pagerange_flag = "-pp";
199 print_copies_flag = "-c";
200 print_collcopies_flag = "-C";
201 print_reverse_flag = "-r";
202 print_landscape_flag = "-t landscape";
203 print_to_printer = "-P";
204 print_to_file = "-o ";
205 print_file_extension = ".ps";
206 print_paper_flag = "-t";
207 print_paper_dimension_flag = "-T";
208 document_path.erase();
209 tempdir_path = "/tmp";
210 view_dvi_paper_option.erase();
211 default_papersize = PAPER_USLETTER;
212 custom_export_format = "ps";
213 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
214 bibtex_command = "bibtex";
216 index_command = "makeindex -c -q";
218 // Because a screen typically is wider than a piece of paper:
221 // Default LaTeX font size:
222 font_sizes[LyXFont::SIZE_TINY] = "5.0";
223 font_sizes[LyXFont::SIZE_SCRIPT] = "7.0";
224 font_sizes[LyXFont::SIZE_FOOTNOTE] = "8.0";
225 font_sizes[LyXFont::SIZE_SMALL] = "9.0";
226 font_sizes[LyXFont::SIZE_NORMAL] = "10.0";
227 font_sizes[LyXFont::SIZE_LARGE] = "12.0";
228 font_sizes[LyXFont::SIZE_LARGER] = "14.4";
229 font_sizes[LyXFont::SIZE_LARGEST] = "17.26";
230 font_sizes[LyXFont::SIZE_HUGE] = "20.74";
231 font_sizes[LyXFont::SIZE_HUGER] = "24.88";
232 use_scalable_fonts = true;
233 roman_font_name = "";
235 typewriter_font_name = "";
236 popup_bold_font = "-*-helvetica-bold-r";
237 popup_normal_font = "-*-helvetica-medium-r";
238 font_norm = "iso8859-1";
239 font_norm_type = ISO_8859_1;
240 popup_font_encoding.erase();
242 auto_region_delete = true;
243 auto_reset_options = false;
245 num_lastfiles = maxlastfiles;
246 check_lastfiles = true;
248 backupdir_path.erase();
249 display_graphics = lyx::graphics::ColorDisplay;
250 // Spellchecker settings:
251 use_spell_lib = true;
252 isp_command = "ispell";
253 isp_accept_compound = false;
254 isp_use_input_encoding = false;
255 isp_use_alt_lang = false;
256 isp_use_pers_dict = false;
257 isp_use_esc_chars = false;
261 mark_foreign_language = true;
262 language_auto_begin = true;
263 language_auto_end = true;
264 language_global_options = true;
265 language_use_babel = true;
266 language_package = "\\usepackage{babel}";
267 language_command_begin = "\\selectlanguage{$$lang}";
268 language_command_local = "\\foreignlanguage{$$lang}{";
269 default_language = "english";
271 cygwin_path_fix = false;
272 date_insert_format = "%A, %e %B %Y";
273 cursor_follows_scrollbar = false;
274 dialogs_iconify_with_main = false;
275 label_init_length = 3;
276 preview = PREVIEW_OFF;
277 preview_hashed_labels = false;
278 preview_scale_factor = "0.9";
280 user_name = lyx::support::user_name();
282 user_email = lyx::support::user_email();
288 void oldFontFormat(string & family, string & foundry)
290 if (family.empty() || family[0] != '-')
292 foundry = token(family, '-', 1);
293 family = token(family, '-', 2);
301 int LyXRC::read(string const & filename)
303 LyXLex lexrc(lyxrcTags, lyxrcCount);
304 if (lyxerr.debugging(Debug::PARSER))
305 lexrc.printTable(lyxerr);
307 lexrc.setFile(filename);
308 if (!lexrc.isOK()) return -2;
310 lyxerr[Debug::LYXRC] << "Reading '" << filename << "'..." << endl;
316 int LyXRC::read(std::istream & is)
318 LyXLex lexrc(lyxrcTags, lyxrcCount);
319 if (lyxerr.debugging(Debug::PARSER))
320 lexrc.printTable(lyxerr);
323 if (!lexrc.isOK()) return -2;
325 lyxerr[Debug::LYXRC] << "Reading istream..." << endl;
331 int LyXRC::read(LyXLex & lexrc)
333 if (!lexrc.isOK()) return -2;
335 while (lexrc.isOK()) {
336 // By using two switches we take advantage of the compiler
337 // telling us if we have missed a LyXRCTags element in
338 // the second switch.
339 // Note that this also shows a problem with LyXLex since it
340 // helps us avoid taking advantage of the strictness of the
343 int le = lexrc.lex();
345 case LyXLex::LEX_UNDEF:
346 lexrc.printError("Unknown tag `$$Token'");
348 case LyXLex::LEX_FEOF:
352 switch (static_cast<LyXRCTags>(le)) {
353 case RC_INPUT: // Include file
356 LibFileSearch(string(),
359 lexrc.printError("Error reading "
360 "included file: "+tmp);
364 case RC_BINDFILE: // RVDK_PATCH_5
366 bind_file = lexrc.getString();
372 ui_file = lexrc.getString();
376 case RC_AUTORESET_OPTIONS:
378 auto_reset_options = lexrc.getBool();
382 case RC_DISPLAY_GRAPHICS:
384 display_graphics = lyx::graphics::displayTranslator().find(lexrc.getString());
390 use_kbmap = lexrc.getBool();
394 case RC_CYGWIN_PATH_FIX:
396 cygwin_path_fix = lexrc.getBool();
397 os::cygwin_path_fix(cygwin_path_fix);
401 case RC_KBMAP_PRIMARY:
403 string const kmap(lexrc.getString());
406 } else if (!LibFileSearch("kbd", kmap,
408 primary_kbmap = kmap;
410 lexrc.printError("LyX: Keymap `$$Token' not found");
415 case RC_KBMAP_SECONDARY:
417 string const kmap(lexrc.getString());
420 } else if (!LibFileSearch("kbd", kmap,
422 secondary_kbmap = kmap;
424 lexrc.printError("LyX: Keymap `$$Token' not found");
429 case RC_FONT_ENCODING:
431 fontenc = lexrc.getString();
437 printer = lexrc.getString();
441 case RC_PRINT_COMMAND:
443 print_command = lexrc.getString();
447 case RC_PRINTEVENPAGEFLAG:
449 print_evenpage_flag = lexrc.getString();
453 case RC_PRINTODDPAGEFLAG:
455 print_oddpage_flag = lexrc.getString();
459 case RC_PRINTPAGERANGEFLAG:
461 print_pagerange_flag = lexrc.getString();
465 case RC_PRINTCOPIESFLAG:
467 print_copies_flag = lexrc.getString();
471 case RC_PRINTCOLLCOPIESFLAG:
473 print_collcopies_flag = lexrc.getString();
477 case RC_PRINTREVERSEFLAG:
479 print_reverse_flag = lexrc.getString();
483 case RC_PRINTLANDSCAPEFLAG:
485 print_landscape_flag = lexrc.getString();
489 case RC_PRINTTOPRINTER:
491 print_to_printer = lexrc.getString();
495 case RC_PRINT_ADAPTOUTPUT:
497 print_adapt_output = lexrc.getBool();
503 print_to_file = lexrc.getString();
507 case RC_PRINTFILEEXTENSION:
509 print_file_extension = lexrc.getString();
513 case RC_PRINTEXSTRAOPTIONS:
515 print_extra_options = lexrc.getString();
519 case RC_PRINTSPOOL_COMMAND:
521 print_spool_command = lexrc.getString();
525 case RC_PRINTSPOOL_PRINTERPREFIX:
527 print_spool_printerprefix = lexrc.getString();
531 case RC_PRINTPAPERDIMENSIONFLAG:
533 print_paper_dimension_flag = lexrc.getString();
537 case RC_PRINTPAPERFLAG:
539 print_paper_flag = lexrc.getString();
543 case RC_CUSTOM_EXPORT_COMMAND:
545 custom_export_command = lexrc.getString();
549 case RC_CUSTOM_EXPORT_FORMAT:
551 custom_export_format = lexrc.getString();
555 case RC_DEFAULT_PAPERSIZE:
558 ascii_lowercase(lexrc.getString());
559 if (size == "usletter")
562 else if (size == "legal")
565 else if (size == "executive")
567 PAPER_EXECUTIVEPAPER;
568 else if (size == "a3")
571 else if (size == "a4")
574 else if (size == "a5")
577 else if (size == "b5")
583 case RC_VIEWDVI_PAPEROPTION:
585 view_dvi_paper_option = lexrc.getString();
587 view_dvi_paper_option.erase();
591 case RC_CHKTEX_COMMAND:
593 chktex_command = lexrc.getString();
597 case RC_BIBTEX_COMMAND:
599 bibtex_command = lexrc.getString();
603 case RC_INDEX_COMMAND:
605 index_command = lexrc.getString();
611 dpi = lexrc.getInteger();
617 zoom = lexrc.getInteger();
623 wheel_jump = lexrc.getInteger();
627 case RC_SCREEN_FONT_SIZES:
629 font_sizes[LyXFont::SIZE_TINY] =
633 font_sizes[LyXFont::SIZE_SCRIPT] =
637 font_sizes[LyXFont::SIZE_FOOTNOTE] =
641 font_sizes[LyXFont::SIZE_SMALL] =
645 font_sizes[LyXFont::SIZE_NORMAL] =
649 font_sizes[LyXFont::SIZE_LARGE] =
653 font_sizes[LyXFont::SIZE_LARGER] =
657 font_sizes[LyXFont::SIZE_LARGEST] =
661 font_sizes[LyXFont::SIZE_HUGE] =
665 font_sizes[LyXFont::SIZE_HUGER] =
670 case RC_SCREEN_FONT_SCALABLE:
672 use_scalable_fonts = lexrc.getBool();
678 autosave = lexrc.getInteger();
682 case RC_DOCUMENTPATH:
684 document_path = ExpandPath(lexrc.getString());
688 case RC_TEMPLATEPATH:
690 template_path = ExpandPath(lexrc.getString());
696 tempdir_path = ExpandPath(lexrc.getString());
702 lyxerr << "Ignoring obsolete use_tempdir flag." << endl;
708 lastfiles = ExpandPath(lexrc.getString());
712 case RC_NUMLASTFILES:
714 num_lastfiles = lexrc.getInteger();
718 case RC_CHECKLASTFILES:
720 check_lastfiles = lexrc.getBool();
724 case RC_SCREEN_FONT_ROMAN:
726 roman_font_name = lexrc.getString();
727 oldFontFormat(roman_font_name,
732 case RC_SCREEN_FONT_SANS:
734 sans_font_name = lexrc.getString();
735 oldFontFormat(sans_font_name, sans_font_foundry);
739 case RC_SCREEN_FONT_TYPEWRITER:
741 typewriter_font_name = lexrc.getString();
742 oldFontFormat(typewriter_font_name,
743 typewriter_font_foundry);
747 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
749 roman_font_foundry = lexrc.getString();
753 case RC_SCREEN_FONT_SANS_FOUNDRY:
755 sans_font_foundry = lexrc.getString();
759 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
761 typewriter_font_foundry = lexrc.getString();
765 case RC_SCREEN_FONT_ENCODING:
767 font_norm = lexrc.getString();
768 set_font_norm_type();
772 case RC_POPUP_BOLD_FONT:
774 popup_bold_font = lexrc.getString();
778 case RC_POPUP_NORMAL_FONT:
780 popup_normal_font = lexrc.getString();
784 case RC_POPUP_FONT_ENCODING:
786 popup_font_encoding = lexrc.getString();
792 string lyx_name, x11_name;
795 lyx_name = lexrc.getString();
797 lexrc.printError("Missing color tag.");
802 x11_name = lexrc.getString();
804 lexrc.printError("Missing color name for color: `$$Token'");
808 LColor::color const col =
809 lcolor.getFromLyXName(lyx_name);
810 if (col == LColor::none ||
811 col == LColor::inherit ||
812 col == LColor::ignore)
815 if (!lcolor.setColor(col, x11_name)) {
816 lyxerr << "Bad lyxrc set_color for "
822 case RC_AUTOREGIONDELETE:
823 // Auto region delete defaults to true
825 auto_region_delete = lexrc.getBool();
831 lyxpipes = ExpandPath(lexrc.getString());
835 case RC_CURSOR_FOLLOWS_SCROLLBAR:
837 cursor_follows_scrollbar = lexrc.getBool();
841 case RC_DIALOGS_ICONIFY_WITH_MAIN:
843 dialogs_iconify_with_main = lexrc.getBool();
847 case RC_ASCIIROFF_COMMAND:
849 ascii_roff_command = lexrc.getString();
852 case RC_ASCII_LINELEN:
854 ascii_linelen = lexrc.getInteger();
857 // Spellchecker settings:
858 case RC_USE_SPELL_LIB:
860 use_spell_lib = lexrc.getBool();
863 case RC_SPELL_COMMAND:
865 isp_command = lexrc.getString();
868 case RC_ACCEPT_COMPOUND:
870 isp_accept_compound = lexrc.getBool();
875 isp_use_input_encoding = lexrc.getBool();
878 case RC_USE_ALT_LANG:
880 isp_use_alt_lang = lexrc.getBool();
883 case RC_USE_PERS_DICT:
885 isp_use_pers_dict = lexrc.getBool();
888 case RC_USE_ESC_CHARS:
890 isp_use_esc_chars = lexrc.getBool();
895 isp_alt_lang = lexrc.getString();
900 isp_pers_dict = lexrc.getString();
905 isp_esc_chars = lexrc.getString();
910 make_backup = lexrc.getBool();
913 case RC_BACKUPDIR_PATH:
915 backupdir_path = ExpandPath(lexrc.getString());
918 case RC_DATE_INSERT_FORMAT:
920 date_insert_format = lexrc.getString();
923 case RC_LANGUAGE_PACKAGE:
925 language_package = lexrc.getString();
928 case RC_LANGUAGE_AUTO_BEGIN:
930 language_auto_begin = lexrc.getBool();
933 case RC_LANGUAGE_AUTO_END:
935 language_auto_end = lexrc.getBool();
938 case RC_LANGUAGE_GLOBAL_OPTIONS:
940 language_global_options = lexrc.getBool();
943 case RC_LANGUAGE_USE_BABEL:
945 language_use_babel = lexrc.getBool();
948 case RC_LANGUAGE_COMMAND_BEGIN:
950 language_command_begin = lexrc.getString();
953 case RC_LANGUAGE_COMMAND_END:
955 language_command_end = lexrc.getString();
958 case RC_LANGUAGE_COMMAND_LOCAL:
960 language_command_local = lexrc.getString();
965 rtl_support = lexrc.getBool();
970 auto_number = lexrc.getBool();
973 case RC_MARK_FOREIGN_LANGUAGE:
975 mark_foreign_language = lexrc.getBool();
982 fmt = lexrc.getString();
985 command = lexrc.getString();
987 movers.set(fmt, command);
992 string from, to, command, flags;
994 from = lexrc.getString();
997 to = lexrc.getString();
1000 command = lexrc.getString();
1003 flags = lexrc.getString();
1006 || token(command, ' ', 0) == "none") {
1007 converters.erase(from, to);
1009 converters.add(from, to, command, flags);
1013 // compatibility with versions older than 1.4.0 only
1015 string format, command;
1017 format = lexrc.getString();
1020 command = lexrc.getString();
1021 if (token(command, ' ', 0) == "none")
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;
1042 // Hack to ensure compatibility with versions older
1044 int le = lexrc.lex();
1045 if (le != LyXLex::LEX_FEOF && le != LyXLex::LEX_UNDEF) {
1046 viewer = lexrc.getString();
1047 if (le == LyXLex::LEX_DATA) {
1048 if (token(viewer, ' ', 0) == "none")
1051 editor = lexrc.getString();
1052 if (token(editor, ' ', 0) == "none")
1056 // We have got a known token.
1057 // Therefore this is an old style
1058 // format definition without
1059 // viewer and editor.
1060 lexrc.pushToken(viewer);
1064 if (prettyname.empty()) {
1065 if (converters.formatIsUsed(format)) {
1066 lyxerr << "Can't delete format "
1069 formats.erase(format);
1072 formats.add(format, extension, prettyname,
1073 shortcut, viewer, editor);
1077 case RC_DEFAULT_LANGUAGE:
1079 default_language = lexrc.getString();
1083 case RC_LABEL_INIT_LENGTH:
1085 label_init_length = lexrc.getInteger();
1089 case RC_SHOW_BANNER:
1091 show_banner = lexrc.getBool();
1097 string const tmp = lexrc.getString();
1098 if (tmp == "true" || tmp == "on")
1099 preview = PREVIEW_ON;
1100 else if (tmp == "no_math")
1101 preview = PREVIEW_NO_MATH;
1103 preview = PREVIEW_OFF;
1104 if (tmp != "false" && tmp != "off")
1105 lyxerr << "Unrecognized "
1107 << tmp << '\n' << endl;
1112 case RC_PREVIEW_HASHED_LABELS:
1114 preview_hashed_labels = lexrc.getBool();
1118 case RC_PREVIEW_SCALE_FACTOR:
1120 preview_scale_factor = lexrc.getString();
1126 user_name = lexrc.getString();
1131 user_email = lexrc.getString();
1134 case RC_LAST: break; // this is just a dummy
1138 /// Update converters data-structures
1139 converters.update(formats);
1140 converters.buildGraph();
1146 void LyXRC::write(string const & filename, bool ignore_system_lyxrc) const
1148 ofstream ofs(filename.c_str());
1150 write(ofs, ignore_system_lyxrc);
1154 void LyXRC::print() const
1156 if (lyxerr.debugging())
1157 write(lyxerr, false);
1164 typedef std::pair<std::string, SpecialisedMover> Data;
1166 SameMover(Data const & comparison)
1167 : comparison_(comparison) {}
1169 bool operator()(Data const & data) const
1171 return data.first == comparison_.first &&
1172 data.second.command() == comparison_.second.command();
1180 void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
1182 os << "### This file is part of\n"
1183 << "### ========================================================\n"
1184 << "### LyX, The Document Processor\n"
1186 << "### Copyright 1995 Matthias Ettrich\n"
1187 << "### Copyright 1995-2001 The LyX Team.\n"
1189 << "### ========================================================\n"
1191 << "# This file is written by LyX, if you want to make your own\n"
1192 << "# modifications you should do them from inside LyX and save\n"
1195 // Why the switch you might ask. It is a trick to ensure that all
1196 // the elements in the LyXRCTags enum is handled. As you can see
1197 // there are no breaks at all. So it is just a huge fall-through.
1198 // The nice thing is that we will get a warning from the compiler
1199 // if we forget an element.
1200 LyXRCTags tag = RC_LAST;
1204 // input/include files are not done here
1206 if (ignore_system_lyxrc ||
1207 bind_file != system_lyxrc.bind_file) {
1208 os << "\\bind_file " << bind_file << "\n";
1214 << "# MISC SECTION ######################################\n"
1217 // bind files are not done here.
1219 if (ignore_system_lyxrc ||
1220 ui_file != system_lyxrc.ui_file) {
1221 os << "\\ui_file \"" << ui_file << "\"\n";
1223 case RC_AUTOREGIONDELETE:
1224 if (ignore_system_lyxrc ||
1225 auto_region_delete != system_lyxrc.auto_region_delete) {
1226 os << "# Set to false to inhibit automatic replacement of\n"
1227 << "# the current selection.\n"
1228 << "\\auto_region_delete " << convert<string>(auto_region_delete)
1231 case RC_AUTORESET_OPTIONS:
1232 if (ignore_system_lyxrc ||
1233 auto_reset_options != system_lyxrc.auto_reset_options) {
1234 os << "# Set to false to inhibit automatic reset of\n"
1235 << "# the class options to defaults on class change.\n"
1236 << "\\auto_reset_options "
1237 << convert<string>(auto_reset_options)
1241 if (ignore_system_lyxrc ||
1242 autosave != system_lyxrc.autosave) {
1243 os << "# The time interval between auto-saves in seconds.\n"
1244 << "\\autosave " << autosave << '\n';
1246 case RC_DISPLAY_GRAPHICS:
1247 if (ignore_system_lyxrc ||
1248 display_graphics != system_lyxrc.display_graphics) {
1249 os << "# Display graphics within LyX\n"
1250 << "# monochrome|grayscale|color|none\n"
1251 << "\\display_graphics "
1252 << lyx::graphics::displayTranslator().find(display_graphics)
1256 case RC_VIEWDVI_PAPEROPTION:
1257 if (ignore_system_lyxrc ||
1258 view_dvi_paper_option
1259 != system_lyxrc.view_dvi_paper_option) {
1260 os << "# Options used to specify paper size to the\n"
1261 << "# view_dvi_command (e.g. -paper)\n"
1262 << "\\view_dvi_paper_option \""
1263 << view_dvi_paper_option << "\"\n";
1265 case RC_DEFAULT_PAPERSIZE:
1266 if (ignore_system_lyxrc ||
1267 default_papersize != system_lyxrc.default_papersize) {
1268 os << "# The default papersize to use.\n"
1269 << "\\default_papersize \"";
1270 switch (default_papersize) {
1271 case PAPER_USLETTER:
1272 os << "usletter"; break;
1273 case PAPER_LEGALPAPER:
1274 os << "legal"; break;
1275 case PAPER_EXECUTIVEPAPER:
1276 os << "executive"; break;
1285 case PAPER_DEFAULT: break;
1289 case RC_CHKTEX_COMMAND:
1290 if (ignore_system_lyxrc ||
1291 chktex_command != system_lyxrc.chktex_command) {
1292 os << "\\chktex_command \"" << chktex_command << "\"\n";
1294 case RC_BIBTEX_COMMAND:
1295 if (ignore_system_lyxrc ||
1296 bibtex_command != system_lyxrc.bibtex_command) {
1297 os << "\\bibtex_command \"" << bibtex_command << "\"\n";
1299 case RC_INDEX_COMMAND:
1300 if (ignore_system_lyxrc ||
1301 index_command != system_lyxrc.index_command) {
1302 os << "\\index_command \"" << index_command << "\"\n";
1305 if (ignore_system_lyxrc ||
1306 use_kbmap != system_lyxrc.use_kbmap) {
1307 os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1310 case RC_CYGWIN_PATH_FIX:
1311 if (ignore_system_lyxrc ||
1312 cygwin_path_fix != system_lyxrc.cygwin_path_fix) {
1313 os << "\\cygwin_path_fix_needed "
1314 << convert<string>(cygwin_path_fix) << '\n';
1316 case RC_KBMAP_PRIMARY:
1317 if (ignore_system_lyxrc ||
1318 primary_kbmap != system_lyxrc.primary_kbmap) {
1319 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1321 case RC_KBMAP_SECONDARY:
1322 if (ignore_system_lyxrc ||
1323 secondary_kbmap != system_lyxrc.secondary_kbmap) {
1324 os << "\\kbmap_secondary \"" << secondary_kbmap
1328 if (ignore_system_lyxrc ||
1329 lyxpipes != system_lyxrc.lyxpipes) {
1330 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1332 case RC_DATE_INSERT_FORMAT:
1333 if (ignore_system_lyxrc ||
1334 date_insert_format != system_lyxrc.date_insert_format) {
1335 os << "\\date_insert_format \"" << date_insert_format
1338 case RC_LABEL_INIT_LENGTH:
1339 if (ignore_system_lyxrc ||
1340 label_init_length != system_lyxrc.label_init_length) {
1341 os << "\\label_init_length " << label_init_length
1346 os << "\\user_name \"" << user_name << "\"\n";
1349 os << "\\user_email \"" << user_email << "\"\n";
1351 case RC_SHOW_BANNER:
1352 if (ignore_system_lyxrc ||
1353 show_banner != system_lyxrc.show_banner) {
1354 os << "\\show_banner " << convert<string>(show_banner) << '\n';
1358 if (ignore_system_lyxrc ||
1359 preview != system_lyxrc.preview) {
1365 case PREVIEW_NO_MATH:
1372 os << "\\preview " << status << '\n';
1375 case RC_PREVIEW_HASHED_LABELS:
1376 if (ignore_system_lyxrc ||
1377 preview_hashed_labels !=
1378 system_lyxrc.preview_hashed_labels) {
1379 os << "\\preview_hashed_labels "
1380 << convert<string>(preview_hashed_labels) << '\n';
1383 case RC_PREVIEW_SCALE_FACTOR:
1384 if (ignore_system_lyxrc ||
1385 preview_scale_factor != system_lyxrc.preview_scale_factor) {
1386 os << "\\preview_scale_factor "
1387 << preview_scale_factor << '\n';
1391 << "# SCREEN & FONTS SECTION ############################\n"
1394 case RC_POPUP_NORMAL_FONT:
1395 if (ignore_system_lyxrc ||
1396 popup_normal_font != system_lyxrc.popup_normal_font) {
1397 os << "\\popup_normal_font \"" << popup_normal_font
1400 case RC_POPUP_BOLD_FONT:
1401 if (ignore_system_lyxrc ||
1402 popup_bold_font != system_lyxrc.popup_bold_font) {
1403 os << "\\popup_bold_font \"" << popup_bold_font
1406 case RC_POPUP_FONT_ENCODING:
1407 if (ignore_system_lyxrc ||
1408 popup_font_encoding != system_lyxrc.popup_font_encoding) {
1409 os << "\\popup_font_encoding \"" << popup_font_encoding
1413 if (ignore_system_lyxrc ||
1414 dpi != system_lyxrc.dpi) {
1415 os << "\\screen_dpi " << dpi << '\n';
1417 case RC_SCREEN_ZOOM:
1418 if (ignore_system_lyxrc ||
1419 zoom != system_lyxrc.zoom) {
1420 os << "\\screen_zoom " << zoom << '\n';
1423 if (ignore_system_lyxrc ||
1424 wheel_jump != system_lyxrc.wheel_jump) {
1425 os << "\\wheel_jump " << wheel_jump << '\n';
1427 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1428 if (ignore_system_lyxrc ||
1429 cursor_follows_scrollbar
1430 != system_lyxrc.cursor_follows_scrollbar) {
1431 os << "\\cursor_follows_scrollbar "
1432 << convert<string>(cursor_follows_scrollbar) << '\n';
1434 case RC_DIALOGS_ICONIFY_WITH_MAIN:
1435 if (ignore_system_lyxrc ||
1436 dialogs_iconify_with_main
1437 != system_lyxrc.dialogs_iconify_with_main) {
1438 os << "\\dialogs_iconify_with_main "
1439 << convert<string>(dialogs_iconify_with_main) << '\n';
1441 case RC_SCREEN_FONT_ROMAN:
1442 if (ignore_system_lyxrc ||
1443 roman_font_name != system_lyxrc.roman_font_name) {
1444 os << "\\screen_font_roman \"" << roman_font_name
1447 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1448 if (ignore_system_lyxrc ||
1449 roman_font_foundry != system_lyxrc.roman_font_foundry) {
1450 os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1453 case RC_SCREEN_FONT_SANS:
1454 if (ignore_system_lyxrc ||
1455 sans_font_name != system_lyxrc.sans_font_name) {
1456 os << "\\screen_font_sans \"" << sans_font_name
1459 case RC_SCREEN_FONT_SANS_FOUNDRY:
1460 if (ignore_system_lyxrc ||
1461 sans_font_foundry != system_lyxrc.sans_font_foundry) {
1462 os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1465 case RC_SCREEN_FONT_TYPEWRITER:
1466 if (ignore_system_lyxrc ||
1467 typewriter_font_name != system_lyxrc.typewriter_font_name) {
1468 os << "\\screen_font_typewriter \""
1469 << typewriter_font_name << "\"\n";
1471 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1472 if (ignore_system_lyxrc ||
1473 typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1474 os << "\\screen_font_typewriter_foundry \""
1475 << typewriter_font_foundry << "\"\n";
1478 case RC_SCREEN_FONT_SCALABLE:
1479 if (ignore_system_lyxrc ||
1480 use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1481 os << "\\screen_font_scalable "
1482 << convert<string>(use_scalable_fonts)
1485 case RC_SCREEN_FONT_ENCODING:
1486 if (ignore_system_lyxrc ||
1487 font_norm != system_lyxrc.font_norm) {
1488 os << "\\screen_font_encoding \"" << font_norm
1491 case RC_SCREEN_FONT_SIZES:
1492 if (ignore_system_lyxrc ||
1493 font_sizes[LyXFont::SIZE_TINY]
1494 != system_lyxrc.font_sizes[LyXFont::SIZE_TINY] ||
1495 font_sizes[LyXFont::SIZE_SCRIPT]
1496 != system_lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] ||
1497 font_sizes[LyXFont::SIZE_FOOTNOTE]
1498 != system_lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] ||
1499 font_sizes[LyXFont::SIZE_SMALL]
1500 != system_lyxrc.font_sizes[LyXFont::SIZE_SMALL] ||
1501 font_sizes[LyXFont::SIZE_NORMAL]
1502 != system_lyxrc.font_sizes[LyXFont::SIZE_NORMAL] ||
1503 font_sizes[LyXFont::SIZE_LARGE]
1504 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGE] ||
1505 font_sizes[LyXFont::SIZE_LARGER]
1506 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGER] ||
1507 font_sizes[LyXFont::SIZE_LARGEST]
1508 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGEST] ||
1509 font_sizes[LyXFont::SIZE_HUGE]
1510 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGE] ||
1511 font_sizes[LyXFont::SIZE_HUGER]
1512 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGER]) {
1513 os.setf(ios::fixed);
1515 os << "\\screen_font_sizes"
1516 << ' ' << font_sizes[LyXFont::SIZE_TINY]
1517 << ' ' << font_sizes[LyXFont::SIZE_SCRIPT]
1518 << ' ' << font_sizes[LyXFont::SIZE_FOOTNOTE]
1519 << ' ' << font_sizes[LyXFont::SIZE_SMALL]
1520 << ' ' << font_sizes[LyXFont::SIZE_NORMAL]
1521 << ' ' << font_sizes[LyXFont::SIZE_LARGE]
1522 << ' ' << font_sizes[LyXFont::SIZE_LARGER]
1523 << ' ' << font_sizes[LyXFont::SIZE_LARGEST]
1524 << ' ' << font_sizes[LyXFont::SIZE_HUGE]
1525 << ' ' << font_sizes[LyXFont::SIZE_HUGER]
1530 << "# COLOR SECTION ###################################\n"
1534 for (int i = 0; i < LColor::ignore; ++i) {
1535 LColor::color lc = static_cast<LColor::color>(i);
1537 string const col(lcolor.getX11Name(lc));
1538 if (ignore_system_lyxrc ||
1539 col != system_lcolor.getX11Name(lc)) {
1540 os << "\\set_color \""
1541 << lcolor.getLyXName(lc) << "\" \""
1547 << "# PRINTER SECTION ###################################\n"
1551 if (ignore_system_lyxrc ||
1552 printer != system_lyxrc.printer) {
1553 os << "\\printer \"" << printer << "\"\n";
1555 case RC_PRINT_ADAPTOUTPUT:
1556 if (ignore_system_lyxrc ||
1557 print_adapt_output != system_lyxrc.print_adapt_output) {
1558 os << "\\print_adapt_output "
1559 << convert<string>(print_adapt_output)
1562 case RC_PRINT_COMMAND:
1563 if (ignore_system_lyxrc ||
1564 print_command != system_lyxrc.print_command) {
1565 os << "\\print_command \"" << print_command << "\"\n";
1567 case RC_PRINTEXSTRAOPTIONS:
1568 if (ignore_system_lyxrc ||
1569 print_extra_options != system_lyxrc.print_extra_options) {
1570 os << "\\print_extra_options \"" << print_extra_options
1573 case RC_PRINTSPOOL_COMMAND:
1574 if (ignore_system_lyxrc ||
1575 print_spool_command != system_lyxrc.print_spool_command) {
1576 os << "\\print_spool_command \"" << print_spool_command
1579 case RC_PRINTSPOOL_PRINTERPREFIX:
1580 if (ignore_system_lyxrc ||
1581 print_spool_printerprefix
1582 != system_lyxrc.print_spool_printerprefix) {
1583 os << "\\print_spool_printerprefix \""
1584 << print_spool_printerprefix << "\"\n";
1586 case RC_PRINTEVENPAGEFLAG:
1587 if (ignore_system_lyxrc ||
1588 print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1589 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1592 case RC_PRINTODDPAGEFLAG:
1593 if (ignore_system_lyxrc ||
1594 print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1595 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1598 case RC_PRINTREVERSEFLAG:
1599 if (ignore_system_lyxrc ||
1600 print_reverse_flag != system_lyxrc.print_reverse_flag) {
1601 os << "\\print_reverse_flag \"" << print_reverse_flag
1604 case RC_PRINTLANDSCAPEFLAG:
1605 if (ignore_system_lyxrc ||
1606 print_landscape_flag != system_lyxrc.print_landscape_flag) {
1607 os << "\\print_landscape_flag \"" << print_landscape_flag
1610 case RC_PRINTPAGERANGEFLAG:
1611 if (ignore_system_lyxrc ||
1612 print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1613 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1616 case RC_PRINTCOPIESFLAG:
1617 if (ignore_system_lyxrc ||
1618 print_copies_flag != system_lyxrc.print_copies_flag) {
1619 os << "\\print_copies_flag \"" << print_copies_flag
1622 case RC_PRINTCOLLCOPIESFLAG:
1623 if (ignore_system_lyxrc ||
1624 print_collcopies_flag
1625 != system_lyxrc.print_collcopies_flag) {
1626 os << "\\print_collcopies_flag \""
1627 << print_collcopies_flag
1630 case RC_PRINTPAPERFLAG:
1631 if (ignore_system_lyxrc ||
1632 print_paper_flag != system_lyxrc.print_paper_flag) {
1633 os << "\\print_paper_flag \"" << print_paper_flag
1636 case RC_PRINTPAPERDIMENSIONFLAG:
1637 if (ignore_system_lyxrc ||
1638 print_paper_dimension_flag
1639 != system_lyxrc.print_paper_dimension_flag) {
1640 os << "\\print_paper_dimension_flag \""
1641 << print_paper_dimension_flag << "\"\n";
1643 case RC_PRINTTOPRINTER:
1644 if (ignore_system_lyxrc ||
1645 print_to_printer != system_lyxrc.print_to_printer) {
1646 os << "\\print_to_printer \"" << print_to_printer
1649 case RC_PRINTTOFILE:
1650 if (ignore_system_lyxrc ||
1651 print_to_file != system_lyxrc.print_to_file) {
1652 os << "\\print_to_file \"" << print_to_file << "\"\n";
1654 case RC_PRINTFILEEXTENSION:
1655 if (ignore_system_lyxrc ||
1656 print_file_extension != system_lyxrc.print_file_extension) {
1657 os << "\\print_file_extension \""
1658 << print_file_extension
1663 << "# EXPORT SECTION ####################################\n"
1666 case RC_CUSTOM_EXPORT_COMMAND:
1667 if (ignore_system_lyxrc ||
1668 custom_export_command
1669 != system_lyxrc.custom_export_command) {
1670 os << "\\custom_export_command \""
1671 << custom_export_command
1674 case RC_CUSTOM_EXPORT_FORMAT:
1675 if (ignore_system_lyxrc ||
1676 custom_export_format
1677 != system_lyxrc.custom_export_format) {
1678 os << "\\custom_export_format \"" << custom_export_format
1683 << "# TEX SECTION #######################################\n"
1686 case RC_FONT_ENCODING:
1687 if (ignore_system_lyxrc ||
1688 fontenc != system_lyxrc.fontenc) {
1689 os << "\\font_encoding \"" << fontenc << "\"\n";
1693 << "# FILE SECTION ######################################\n"
1696 case RC_DOCUMENTPATH:
1697 if (ignore_system_lyxrc ||
1698 document_path != system_lyxrc.document_path) {
1699 os << "\\document_path \"" << document_path << "\"\n";
1702 if (ignore_system_lyxrc ||
1703 lastfiles != system_lyxrc.lastfiles) {
1704 os << "\\lastfiles \"" << lastfiles << "\"\n";
1706 case RC_NUMLASTFILES:
1707 if (ignore_system_lyxrc ||
1708 num_lastfiles != system_lyxrc.num_lastfiles) {
1709 os << "\\num_lastfiles " << num_lastfiles << '\n';
1711 case RC_CHECKLASTFILES:
1712 if (ignore_system_lyxrc ||
1713 check_lastfiles != system_lyxrc.check_lastfiles) {
1714 os << "\\check_lastfiles " << convert<string>(check_lastfiles)
1717 case RC_TEMPLATEPATH:
1718 if (ignore_system_lyxrc ||
1719 template_path != system_lyxrc.template_path) {
1720 os << "\\template_path \"" << template_path << "\"\n";
1722 case RC_TEMPDIRPATH:
1723 if (ignore_system_lyxrc ||
1724 tempdir_path != system_lyxrc.tempdir_path) {
1725 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1729 case RC_ASCII_LINELEN:
1730 if (ignore_system_lyxrc ||
1731 ascii_linelen != system_lyxrc.ascii_linelen) {
1732 os << "\\ascii_linelen " << ascii_linelen << '\n';
1734 case RC_MAKE_BACKUP:
1735 if (ignore_system_lyxrc ||
1736 make_backup != system_lyxrc.make_backup) {
1737 os << "\\make_backup " << convert<string>(make_backup) << '\n';
1739 case RC_BACKUPDIR_PATH:
1740 if (ignore_system_lyxrc ||
1741 backupdir_path != system_lyxrc.backupdir_path) {
1742 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1746 << "# ASCII EXPORT SECTION ##############################\n"
1749 case RC_ASCIIROFF_COMMAND:
1750 if (ignore_system_lyxrc ||
1751 ascii_roff_command != system_lyxrc.ascii_roff_command) {
1752 os << "\\ascii_roff_command \"" << ascii_roff_command
1757 << "# SPELLCHECKER SECTION ##############################\n"
1759 case RC_USE_SPELL_LIB:
1760 if (ignore_system_lyxrc ||
1761 use_spell_lib != system_lyxrc.use_spell_lib) {
1762 os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
1764 case RC_SPELL_COMMAND:
1765 if (ignore_system_lyxrc ||
1766 isp_command != system_lyxrc.isp_command) {
1767 os << "\\spell_command \"" << isp_command << "\"\n";
1769 case RC_ACCEPT_COMPOUND:
1770 if (ignore_system_lyxrc ||
1771 isp_accept_compound != system_lyxrc.isp_accept_compound) {
1772 os << "\\accept_compound " << convert<string>(isp_accept_compound)
1775 case RC_USE_ALT_LANG:
1776 if (ignore_system_lyxrc ||
1777 isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
1778 os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
1782 if (ignore_system_lyxrc ||
1783 isp_alt_lang != system_lyxrc.isp_alt_lang) {
1784 os << "\\alternate_language \"" << isp_alt_lang
1787 case RC_USE_ESC_CHARS:
1788 if (ignore_system_lyxrc ||
1789 isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
1790 os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
1794 if (ignore_system_lyxrc ||
1795 isp_esc_chars != system_lyxrc.isp_esc_chars) {
1796 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1798 case RC_USE_PERS_DICT:
1799 if (ignore_system_lyxrc ||
1800 isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
1801 os << "\\use_personal_dictionary "
1802 << convert<string>(isp_use_pers_dict)
1806 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
1807 os << "\\personal_dictionary \"" << isp_pers_dict
1810 case RC_USE_INP_ENC:
1811 if (ignore_system_lyxrc ||
1812 isp_use_input_encoding
1813 != system_lyxrc.isp_use_input_encoding) {
1814 os << "\\use_input_encoding "
1815 << convert<string>(isp_use_input_encoding)
1820 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1823 case RC_RTL_SUPPORT:
1824 if (ignore_system_lyxrc ||
1825 rtl_support != system_lyxrc.rtl_support) {
1826 os << "\\rtl " << convert<string>(rtl_support) << '\n';
1828 case RC_LANGUAGE_PACKAGE:
1829 if (ignore_system_lyxrc ||
1830 language_package != system_lyxrc.language_package) {
1831 os << "\\language_package \"" << language_package
1834 case RC_LANGUAGE_GLOBAL_OPTIONS:
1835 if (ignore_system_lyxrc ||
1836 language_global_options
1837 != system_lyxrc.language_global_options) {
1838 os << "\\language_global_options \""
1839 << convert<string>(language_global_options)
1842 case RC_LANGUAGE_USE_BABEL:
1843 if (ignore_system_lyxrc ||
1844 language_use_babel != system_lyxrc.language_use_babel) {
1845 os << "\\language_use_babel \""
1846 << convert<string>(language_use_babel)
1849 case RC_LANGUAGE_COMMAND_BEGIN:
1850 if (ignore_system_lyxrc ||
1851 language_command_begin
1852 != system_lyxrc.language_command_begin) {
1853 os << "\\language_command_begin \""
1854 << language_command_begin
1857 case RC_LANGUAGE_COMMAND_END:
1858 if (ignore_system_lyxrc ||
1859 language_command_end
1860 != system_lyxrc.language_command_end) {
1861 os << "\\language_command_end \"" << language_command_end
1864 case RC_LANGUAGE_COMMAND_LOCAL:
1865 if (ignore_system_lyxrc ||
1866 language_command_local
1867 != system_lyxrc.language_command_local) {
1868 os << "\\language_command_local \""
1869 << language_command_local
1872 case RC_LANGUAGE_AUTO_BEGIN:
1873 if (ignore_system_lyxrc ||
1874 language_auto_begin != system_lyxrc.language_auto_begin) {
1875 os << "\\language_auto_begin "
1876 << convert<string>(language_auto_begin) << '\n';
1878 case RC_LANGUAGE_AUTO_END:
1879 if (ignore_system_lyxrc ||
1880 language_auto_end != system_lyxrc.language_auto_end) {
1881 os << "\\language_auto_end "
1882 << convert<string>(language_auto_end) << '\n';
1884 case RC_MARK_FOREIGN_LANGUAGE:
1885 if (ignore_system_lyxrc ||
1886 mark_foreign_language
1887 != system_lyxrc.mark_foreign_language) {
1888 os << "\\mark_foreign_language " <<
1889 convert<string>(mark_foreign_language) << '\n';
1893 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1896 case RC_AUTO_NUMBER:
1897 if (ignore_system_lyxrc ||
1898 auto_number != system_lyxrc.auto_number) {
1899 os << "\\auto_number " << convert<string>(auto_number) << '\n';
1901 case RC_DEFAULT_LANGUAGE:
1902 if (ignore_system_lyxrc ||
1903 default_language != system_lyxrc.default_language) {
1904 os << "\\default_language " << default_language << '\n';
1908 << "# FORMATS SECTION ##########################\n"
1912 // New/modifed formats
1913 for (Formats::const_iterator cit = formats.begin();
1914 cit != formats.end(); ++cit) {
1915 Format const * format =
1916 system_formats.getFormat(cit->name());
1918 format->extension() != cit->extension() ||
1919 format->prettyname() != cit->prettyname() ||
1920 format->shortcut() != cit->shortcut() ||
1921 format->viewer() != cit->viewer() ||
1922 format->editor() != cit->editor())
1923 os << "\\format \"" << cit->name() << "\" \""
1924 << cit->extension() << "\" \""
1925 << cit->prettyname() << "\" \""
1926 << cit->shortcut() << "\" \""
1927 << cit->viewer() << "\" \""
1928 << cit->editor() << "\"\n";
1931 // Look for deleted formats
1932 for (Formats::const_iterator cit = system_formats.begin();
1933 cit != system_formats.end(); ++cit)
1934 if (!formats.getFormat(cit->name()))
1935 os << "\\format \"" << cit->name()
1936 << "\" \"\" \"\" \"\" \"\" \"\"\n";
1941 << "# CONVERTERS SECTION ##########################\n"
1945 // Look for new converters
1946 for (Converters::const_iterator cit = converters.begin();
1947 cit != converters.end(); ++cit) {
1948 Converter const * converter =
1949 system_converters.getConverter(cit->from,
1952 converter->command != cit->command ||
1953 converter->flags != cit->flags)
1954 os << "\\converter \"" << cit->from << "\" \""
1955 << cit->to << "\" \""
1956 << cit->command << "\" \""
1957 << cit->flags << "\"\n";
1960 // New/modifed converters
1961 for (Converters::const_iterator cit = system_converters.begin();
1962 cit != system_converters.end(); ++cit)
1963 if (!converters.getConverter(cit->from, cit->to))
1964 os << "\\converter \"" << cit->from
1965 << "\" \"" << cit->to << "\" \"\" \"\"\n";
1969 << "# COPIERS SECTION ##########################\n"
1972 // Look for new movers
1973 Movers::iterator const sysbegin = system_movers.begin();
1974 Movers::iterator const sysend = system_movers.end();
1976 for (Movers::iterator it = movers.begin(), end = movers.end();
1978 Movers::iterator const sysit =
1979 std::find_if(sysbegin, sysend, SameMover(*it));
1980 if (sysit == sysend) {
1981 std::string const & fmt = it->first;
1982 std::string const & command =
1983 it->second.command();
1985 os << "\\copier " << fmt
1986 << " \"" << command << "\"\n";
1990 // We don't actually delete SpecialisedMover(s) from the
1991 // map, just clear their 'command', so there's no need
1992 // to test for anything else.
1998 void LyXRC::set_font_norm_type()
2000 if (font_norm == "iso10646-1")
2001 font_norm_type = ISO_10646_1;
2002 else if (font_norm == "iso8859-1")
2003 font_norm_type = ISO_8859_1;
2004 else if (font_norm == "iso8859-3")
2005 font_norm_type = ISO_8859_3;
2006 else if (font_norm == "iso8859-4")
2007 font_norm_type = ISO_8859_4;
2008 else if (font_norm == "iso8859-6.8x")
2009 font_norm_type = ISO_8859_6_8;
2010 else if (font_norm == "iso8859-9")
2011 font_norm_type = ISO_8859_9;
2012 else if (font_norm == "iso8859-15")
2013 font_norm_type = ISO_8859_15;
2015 font_norm_type = OTHER_ENCODING;
2019 string const LyXRC::getDescription(LyXRCTags tag)
2024 case RC_FONT_ENCODING:
2025 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2029 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2032 case RC_PRINT_COMMAND:
2033 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2036 case RC_PRINTEVENPAGEFLAG:
2037 str = _("The option to print only even pages.");
2040 case RC_PRINTODDPAGEFLAG:
2041 str = _("The option to print only odd pages.");
2044 case RC_PRINTPAGERANGEFLAG:
2045 str = _("The option for specifying a comma-separated list of pages to print.");
2048 case RC_PRINTCOPIESFLAG:
2049 str = _("The option for specifying the number of copies to print.");
2052 case RC_PRINTCOLLCOPIESFLAG:
2053 str = _("The option for specifying whether the copies should be collated.");
2056 case RC_PRINTREVERSEFLAG:
2057 str = _("The option to reverse the order of the pages printed.");
2060 case RC_PRINTLANDSCAPEFLAG:
2061 str = _("The option to print out in landscape.");
2064 case RC_PRINTPAPERFLAG:
2065 str = _("The option to specify paper type.");
2068 case RC_PRINTPAPERDIMENSIONFLAG:
2069 str = _("Option to specify the dimensions of the print paper.");
2072 case RC_PRINTTOPRINTER:
2073 str = _("Option to pass to the print program to print on a specific printer.");
2076 case RC_PRINT_ADAPTOUTPUT:
2077 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2080 case RC_PRINTTOFILE:
2081 str = _("Option to pass to the print program to print to a file.");
2084 case RC_PRINTFILEEXTENSION:
2085 str = _("Extension of printer program output file. Usually \".ps\".");
2088 case RC_PRINTEXSTRAOPTIONS:
2089 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2092 case RC_PRINTSPOOL_COMMAND:
2093 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.");
2096 case RC_PRINTSPOOL_PRINTERPREFIX:
2097 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.");
2101 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2104 case RC_SCREEN_ZOOM:
2105 //xgettext:no-c-format
2106 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2109 case RC_SCREEN_FONT_SIZES:
2110 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2113 case RC_SCREEN_FONT_ROMAN:
2114 case RC_SCREEN_FONT_SANS:
2115 case RC_SCREEN_FONT_TYPEWRITER:
2116 str = _("The screen fonts used to display the text while editing.");
2119 case RC_POPUP_BOLD_FONT:
2120 str = _("The bold font in the dialogs.");
2123 case RC_POPUP_NORMAL_FONT:
2124 str = _("The normal font in the dialogs.");
2127 case RC_SCREEN_FONT_ENCODING:
2128 str = _("The encoding for the screen fonts.");
2131 case RC_POPUP_FONT_ENCODING:
2132 str = _("The encoding for the menu/popups fonts.");
2139 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2142 case RC_DOCUMENTPATH:
2143 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2146 case RC_TEMPLATEPATH:
2147 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2150 case RC_TEMPDIRPATH:
2151 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2155 str = _("The file where the last-files information should be stored.");
2158 case RC_AUTOREGIONDELETE:
2159 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2162 case RC_AUTORESET_OPTIONS:
2163 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2167 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2171 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2175 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2179 case RC_KBMAP_PRIMARY:
2180 case RC_KBMAP_SECONDARY:
2181 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.");
2184 case RC_ASCIIROFF_COMMAND:
2185 str = _("Use to define an external program to render tables in the ASCII output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"none\" is specified, an internal routine is used.");
2188 case RC_ASCII_LINELEN:
2189 str = _("This is the maximum line length of an exported ASCII file (LaTeX, SGML or plain text).");
2192 case RC_NUMLASTFILES:
2193 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."), maxlastfiles);
2196 case RC_CHECKLASTFILES:
2197 str = _("Select to check whether the lastfiles still exist.");
2200 case RC_VIEWDVI_PAPEROPTION:
2201 str = _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2204 case RC_DEFAULT_PAPERSIZE:
2205 str = _("Specify the default paper size.");
2208 case RC_ACCEPT_COMPOUND:
2209 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2212 case RC_SPELL_COMMAND:
2213 str = _("What command runs the spell checker?");
2216 case RC_USE_INP_ENC:
2217 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.");
2220 case RC_USE_ALT_LANG:
2222 str = _("Specify an alternate language. The default is to use the language of the document.");
2225 case RC_USE_PERS_DICT:
2227 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2230 case RC_USE_ESC_CHARS:
2232 str = _("Specify additional chars that can be part of a word.");
2235 case RC_SCREEN_FONT_SCALABLE:
2236 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.");
2239 case RC_CHKTEX_COMMAND:
2240 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2243 case RC_BIBTEX_COMMAND:
2244 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2247 case RC_INDEX_COMMAND:
2248 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\".");
2251 case RC_CURSOR_FOLLOWS_SCROLLBAR:
2252 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.");
2255 case RC_DIALOGS_ICONIFY_WITH_MAIN:
2256 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2259 case RC_DISPLAY_GRAPHICS:
2260 str = _("Select how LyX will display any graphics.");
2263 case RC_MAKE_BACKUP:
2264 str = _("De-select if you don't want LyX to create backup files.");
2267 case RC_BACKUPDIR_PATH:
2268 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.");
2271 case RC_RTL_SUPPORT:
2272 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2275 case RC_MARK_FOREIGN_LANGUAGE:
2276 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2279 case RC_LANGUAGE_PACKAGE:
2280 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2283 case RC_LANGUAGE_GLOBAL_OPTIONS:
2284 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2287 case RC_LANGUAGE_USE_BABEL:
2288 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2291 case RC_LANGUAGE_AUTO_BEGIN:
2292 str = _("Select if a language switching command is needed at the beginning of the document.");
2295 case RC_LANGUAGE_AUTO_END:
2296 str = _("Select if a language switching command is needed at the end of the document.");
2299 case RC_LANGUAGE_COMMAND_BEGIN:
2300 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.");
2303 case RC_LANGUAGE_COMMAND_END:
2304 str = _("The LaTeX command for changing back to the language of the document.");
2307 case RC_LANGUAGE_COMMAND_LOCAL:
2308 str = _("The LaTeX command for local changing of the language.");
2311 case RC_DATE_INSERT_FORMAT:
2312 //xgettext:no-c-format
2313 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2316 case RC_SHOW_BANNER:
2317 str = _("De-select if you don't want the startup banner.");
2321 str = _("The number of lines that are scrolled by mice with wheels or five button mice.");
2333 case RC_DEFAULT_LANGUAGE:
2334 str = _("New documents will be assigned this language.");
2337 case RC_LABEL_INIT_LENGTH:
2338 str = _("Maximum number of words in the initialization string for a new label");
2342 str = _("Shows a typeset preview of things such as math");
2345 case RC_PREVIEW_HASHED_LABELS:
2346 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2349 case RC_PREVIEW_SCALE_FACTOR:
2350 str = _("Scale the preview size to suit.");
2360 // The global instance
2363 // The global copy of the system lyxrc entries (everything except preferences)