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/userinfo.h"
41 using lyx::support::ascii_lowercase;
42 using lyx::support::bformat;
43 using lyx::support::ExpandPath;
44 using lyx::support::GetEnv;
45 using lyx::support::LibFileSearch;
46 using lyx::support::token;
59 // when adding something to this array keep it sorted!
60 keyword_item lyxrcTags[] = {
61 { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
62 { "\\alternate_language", LyXRC::RC_ALT_LANG },
63 { "\\ascii_linelen", LyXRC::RC_ASCII_LINELEN },
64 { "\\ascii_roff_command", LyXRC::RC_ASCIIROFF_COMMAND },
65 { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
66 { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
67 { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
68 { "\\autosave", LyXRC::RC_AUTOSAVE },
69 { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
70 { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
71 { "\\bind_file", LyXRC::RC_BINDFILE },
72 { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
73 { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
74 { "\\converter", LyXRC::RC_CONVERTER },
75 { "\\copier", LyXRC::RC_COPIER },
76 { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
77 { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
78 { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
79 { "\\cygwin_path_fix_needed", LyXRC::RC_CYGWIN_PATH_FIX },
80 { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
81 { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
82 { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
83 { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
84 { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
85 { "\\document_path", LyXRC::RC_DOCUMENTPATH },
86 { "\\escape_chars", LyXRC::RC_ESC_CHARS },
87 { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
88 { "\\format", LyXRC::RC_FORMAT },
89 { "\\index_command", LyXRC::RC_INDEX_COMMAND },
90 { "\\input", LyXRC::RC_INPUT },
91 { "\\kbmap", LyXRC::RC_KBMAP },
92 { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
93 { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
94 { "\\label_init_length", LyXRC::RC_LABEL_INIT_LENGTH },
95 { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
96 { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
97 { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
98 { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
99 { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
100 { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
101 { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
102 { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
103 { "\\lastfiles", LyXRC::RC_LASTFILES },
104 { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
105 { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
106 { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
107 { "\\path_prefix", LyXRC::RC_PATH_PREFIX },
108 { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
109 { "\\popup_bold_font", LyXRC::RC_POPUP_BOLD_FONT },
110 { "\\popup_font_encoding", LyXRC::RC_POPUP_FONT_ENCODING },
111 { "\\popup_normal_font", LyXRC::RC_POPUP_NORMAL_FONT },
112 { "\\preview", LyXRC::RC_PREVIEW },
113 { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
114 { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
115 { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
116 { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
117 { "\\print_command", LyXRC::RC_PRINT_COMMAND },
118 { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
119 { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
120 { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
121 { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
122 { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
123 { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
124 { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
125 { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
126 { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
127 { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
128 { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
129 { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
130 { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
131 { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
132 { "\\printer", LyXRC::RC_PRINTER },
133 { "\\rtl", LyXRC::RC_RTL_SUPPORT },
134 { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
135 { "\\screen_font_encoding", LyXRC::RC_SCREEN_FONT_ENCODING },
136 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
137 { "\\screen_font_encoding_menu", LyXRC::RC_POPUP_FONT_ENCODING },
138 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
139 { "\\screen_font_menu", LyXRC::RC_POPUP_BOLD_FONT },
140 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
141 { "\\screen_font_popup", LyXRC::RC_POPUP_NORMAL_FONT },
142 { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
143 { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
144 { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
145 { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
146 { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
147 { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
148 { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
149 { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
150 { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
151 { "\\serverpipe", LyXRC::RC_SERVERPIPE },
152 { "\\set_color", LyXRC::RC_SET_COLOR },
153 { "\\show_banner", LyXRC::RC_SHOW_BANNER },
154 { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
155 { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
156 { "\\template_path", LyXRC::RC_TEMPLATEPATH },
157 { "\\ui_file", LyXRC::RC_UIFILE },
158 { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
159 { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
160 { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
161 { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
162 // compatibility with versions older than 1.4.0 only
163 { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
164 { "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB },
165 // compatibility with versions older than 1.4.0 only
166 { "\\use_tempdir", LyXRC::RC_USETEMPDIR },
167 { "\\user_email", LyXRC::RC_USER_EMAIL },
168 { "\\user_name", LyXRC::RC_USER_NAME },
169 { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
170 // compatibility with versions older than 1.4.0 only
171 { "\\viewer" ,LyXRC::RC_VIEWER},
172 { "\\wheel_jump", LyXRC::RC_WHEEL_JUMP }
175 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
186 void LyXRC::setDefaults() {
189 // Get printer from the environment. If fail, use default "",
190 // assuming that everything is set up correctly.
191 printer = GetEnv("PRINTER");
192 print_adapt_output = false;
193 print_command = "dvips";
194 print_evenpage_flag = "-B";
195 print_oddpage_flag = "-A";
196 print_pagerange_flag = "-pp";
197 print_copies_flag = "-c";
198 print_collcopies_flag = "-C";
199 print_reverse_flag = "-r";
200 print_landscape_flag = "-t landscape";
201 print_to_printer = "-P";
202 print_to_file = "-o ";
203 print_file_extension = ".ps";
204 print_paper_flag = "-t";
205 print_paper_dimension_flag = "-T";
206 document_path.erase();
207 tempdir_path = "/tmp";
208 view_dvi_paper_option.erase();
209 default_papersize = PAPER_USLETTER;
210 custom_export_format = "ps";
211 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
212 bibtex_command = "bibtex";
214 index_command = "makeindex -c -q";
216 // Because a screen typically is wider than a piece of paper:
219 // Default LaTeX font size:
220 font_sizes[LyXFont::SIZE_TINY] = "5.0";
221 font_sizes[LyXFont::SIZE_SCRIPT] = "7.0";
222 font_sizes[LyXFont::SIZE_FOOTNOTE] = "8.0";
223 font_sizes[LyXFont::SIZE_SMALL] = "9.0";
224 font_sizes[LyXFont::SIZE_NORMAL] = "10.0";
225 font_sizes[LyXFont::SIZE_LARGE] = "12.0";
226 font_sizes[LyXFont::SIZE_LARGER] = "14.4";
227 font_sizes[LyXFont::SIZE_LARGEST] = "17.26";
228 font_sizes[LyXFont::SIZE_HUGE] = "20.74";
229 font_sizes[LyXFont::SIZE_HUGER] = "24.88";
230 use_scalable_fonts = true;
231 roman_font_name = "";
233 typewriter_font_name = "";
234 popup_bold_font = "-*-helvetica-bold-r";
235 popup_normal_font = "-*-helvetica-medium-r";
236 font_norm = "iso8859-1";
237 font_norm_type = ISO_8859_1;
238 popup_font_encoding.erase();
240 auto_region_delete = true;
241 auto_reset_options = false;
243 num_lastfiles = maxlastfiles;
244 check_lastfiles = true;
246 backupdir_path.erase();
247 display_graphics = lyx::graphics::ColorDisplay;
248 // Spellchecker settings:
249 use_spell_lib = true;
250 isp_command = "ispell";
251 isp_accept_compound = false;
252 isp_use_input_encoding = false;
253 isp_use_alt_lang = false;
254 isp_use_pers_dict = false;
255 isp_use_esc_chars = false;
259 mark_foreign_language = true;
260 language_auto_begin = true;
261 language_auto_end = true;
262 language_global_options = true;
263 language_use_babel = true;
264 language_package = "\\usepackage{babel}";
265 language_command_begin = "\\selectlanguage{$$lang}";
266 language_command_local = "\\foreignlanguage{$$lang}{";
267 default_language = "english";
269 cygwin_path_fix = false;
270 date_insert_format = "%A, %e %B %Y";
271 cursor_follows_scrollbar = false;
272 dialogs_iconify_with_main = false;
273 label_init_length = 3;
274 preview = PREVIEW_OFF;
275 preview_hashed_labels = false;
276 preview_scale_factor = "0.9";
278 user_name = lyx::support::user_name();
280 user_email = lyx::support::user_email();
286 void oldFontFormat(string & family, string & foundry)
288 if (family.empty() || family[0] != '-')
290 foundry = token(family, '-', 1);
291 family = token(family, '-', 2);
299 int LyXRC::read(string const & filename)
301 LyXLex lexrc(lyxrcTags, lyxrcCount);
302 if (lyxerr.debugging(Debug::PARSER))
303 lexrc.printTable(lyxerr);
305 lexrc.setFile(filename);
306 if (!lexrc.isOK()) return -2;
308 lyxerr[Debug::LYXRC] << "Reading '" << filename << "'..." << endl;
314 int LyXRC::read(std::istream & is)
316 LyXLex lexrc(lyxrcTags, lyxrcCount);
317 if (lyxerr.debugging(Debug::PARSER))
318 lexrc.printTable(lyxerr);
321 if (!lexrc.isOK()) return -2;
323 lyxerr[Debug::LYXRC] << "Reading istream..." << endl;
329 int LyXRC::read(LyXLex & lexrc)
331 if (!lexrc.isOK()) return -2;
333 while (lexrc.isOK()) {
334 // By using two switches we take advantage of the compiler
335 // telling us if we have missed a LyXRCTags element in
336 // the second switch.
337 // Note that this also shows a problem with LyXLex since it
338 // helps us avoid taking advantage of the strictness of the
341 int le = lexrc.lex();
343 case LyXLex::LEX_UNDEF:
344 lexrc.printError("Unknown tag `$$Token'");
346 case LyXLex::LEX_FEOF:
350 switch (static_cast<LyXRCTags>(le)) {
351 case RC_INPUT: // Include file
354 LibFileSearch(string(),
357 lexrc.printError("Error reading "
358 "included file: "+tmp);
362 case RC_BINDFILE: // RVDK_PATCH_5
364 bind_file = lexrc.getString();
370 ui_file = lexrc.getString();
374 case RC_AUTORESET_OPTIONS:
376 auto_reset_options = lexrc.getBool();
380 case RC_DISPLAY_GRAPHICS:
382 display_graphics = lyx::graphics::displayTranslator().find(lexrc.getString());
388 use_kbmap = lexrc.getBool();
392 case RC_CYGWIN_PATH_FIX:
394 cygwin_path_fix = lexrc.getBool();
398 case RC_KBMAP_PRIMARY:
400 string const kmap(lexrc.getString());
403 } else if (!LibFileSearch("kbd", kmap,
405 primary_kbmap = kmap;
407 lexrc.printError("LyX: Keymap `$$Token' not found");
412 case RC_KBMAP_SECONDARY:
414 string const kmap(lexrc.getString());
417 } else if (!LibFileSearch("kbd", kmap,
419 secondary_kbmap = kmap;
421 lexrc.printError("LyX: Keymap `$$Token' not found");
426 case RC_FONT_ENCODING:
428 fontenc = lexrc.getString();
434 printer = lexrc.getString();
438 case RC_PRINT_COMMAND:
440 print_command = lexrc.getString();
444 case RC_PRINTEVENPAGEFLAG:
446 print_evenpage_flag = lexrc.getString();
450 case RC_PRINTODDPAGEFLAG:
452 print_oddpage_flag = lexrc.getString();
456 case RC_PRINTPAGERANGEFLAG:
458 print_pagerange_flag = lexrc.getString();
462 case RC_PRINTCOPIESFLAG:
464 print_copies_flag = lexrc.getString();
468 case RC_PRINTCOLLCOPIESFLAG:
470 print_collcopies_flag = lexrc.getString();
474 case RC_PRINTREVERSEFLAG:
476 print_reverse_flag = lexrc.getString();
480 case RC_PRINTLANDSCAPEFLAG:
482 print_landscape_flag = lexrc.getString();
486 case RC_PRINTTOPRINTER:
488 print_to_printer = lexrc.getString();
492 case RC_PRINT_ADAPTOUTPUT:
494 print_adapt_output = lexrc.getBool();
500 print_to_file = lexrc.getString();
504 case RC_PRINTFILEEXTENSION:
506 print_file_extension = lexrc.getString();
510 case RC_PRINTEXSTRAOPTIONS:
512 print_extra_options = lexrc.getString();
516 case RC_PRINTSPOOL_COMMAND:
518 print_spool_command = lexrc.getString();
522 case RC_PRINTSPOOL_PRINTERPREFIX:
524 print_spool_printerprefix = lexrc.getString();
528 case RC_PRINTPAPERDIMENSIONFLAG:
530 print_paper_dimension_flag = lexrc.getString();
534 case RC_PRINTPAPERFLAG:
536 print_paper_flag = lexrc.getString();
540 case RC_CUSTOM_EXPORT_COMMAND:
542 custom_export_command = lexrc.getString();
546 case RC_CUSTOM_EXPORT_FORMAT:
548 custom_export_format = lexrc.getString();
552 case RC_DEFAULT_PAPERSIZE:
555 ascii_lowercase(lexrc.getString());
556 if (size == "usletter")
559 else if (size == "legal")
562 else if (size == "executive")
564 PAPER_EXECUTIVEPAPER;
565 else if (size == "a3")
568 else if (size == "a4")
571 else if (size == "a5")
574 else if (size == "b5")
580 case RC_VIEWDVI_PAPEROPTION:
582 view_dvi_paper_option = lexrc.getString();
584 view_dvi_paper_option.erase();
588 case RC_CHKTEX_COMMAND:
590 chktex_command = lexrc.getString();
594 case RC_BIBTEX_COMMAND:
596 bibtex_command = lexrc.getString();
600 case RC_INDEX_COMMAND:
602 index_command = lexrc.getString();
608 dpi = lexrc.getInteger();
614 zoom = lexrc.getInteger();
620 wheel_jump = lexrc.getInteger();
624 case RC_SCREEN_FONT_SIZES:
626 font_sizes[LyXFont::SIZE_TINY] =
630 font_sizes[LyXFont::SIZE_SCRIPT] =
634 font_sizes[LyXFont::SIZE_FOOTNOTE] =
638 font_sizes[LyXFont::SIZE_SMALL] =
642 font_sizes[LyXFont::SIZE_NORMAL] =
646 font_sizes[LyXFont::SIZE_LARGE] =
650 font_sizes[LyXFont::SIZE_LARGER] =
654 font_sizes[LyXFont::SIZE_LARGEST] =
658 font_sizes[LyXFont::SIZE_HUGE] =
662 font_sizes[LyXFont::SIZE_HUGER] =
667 case RC_SCREEN_FONT_SCALABLE:
669 use_scalable_fonts = lexrc.getBool();
675 autosave = lexrc.getInteger();
679 case RC_DOCUMENTPATH:
681 document_path = ExpandPath(lexrc.getString());
685 case RC_TEMPLATEPATH:
687 template_path = ExpandPath(lexrc.getString());
693 tempdir_path = ExpandPath(lexrc.getString());
699 lyxerr << "Ignoring obsolete use_tempdir flag." << endl;
705 lastfiles = ExpandPath(lexrc.getString());
709 case RC_NUMLASTFILES:
711 num_lastfiles = lexrc.getInteger();
715 case RC_CHECKLASTFILES:
717 check_lastfiles = lexrc.getBool();
721 case RC_SCREEN_FONT_ROMAN:
723 roman_font_name = lexrc.getString();
724 oldFontFormat(roman_font_name,
729 case RC_SCREEN_FONT_SANS:
731 sans_font_name = lexrc.getString();
732 oldFontFormat(sans_font_name, sans_font_foundry);
736 case RC_SCREEN_FONT_TYPEWRITER:
738 typewriter_font_name = lexrc.getString();
739 oldFontFormat(typewriter_font_name,
740 typewriter_font_foundry);
744 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
746 roman_font_foundry = lexrc.getString();
750 case RC_SCREEN_FONT_SANS_FOUNDRY:
752 sans_font_foundry = lexrc.getString();
756 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
758 typewriter_font_foundry = lexrc.getString();
762 case RC_SCREEN_FONT_ENCODING:
764 font_norm = lexrc.getString();
765 set_font_norm_type();
769 case RC_POPUP_BOLD_FONT:
771 popup_bold_font = lexrc.getString();
775 case RC_POPUP_NORMAL_FONT:
777 popup_normal_font = lexrc.getString();
781 case RC_POPUP_FONT_ENCODING:
783 popup_font_encoding = lexrc.getString();
789 string lyx_name, x11_name;
792 lyx_name = lexrc.getString();
794 lexrc.printError("Missing color tag.");
799 x11_name = lexrc.getString();
801 lexrc.printError("Missing color name for color: `$$Token'");
805 LColor::color const col =
806 lcolor.getFromLyXName(lyx_name);
807 if (col == LColor::none ||
808 col == LColor::inherit ||
809 col == LColor::ignore)
812 if (!lcolor.setColor(col, x11_name)) {
813 lyxerr << "Bad lyxrc set_color for "
819 case RC_AUTOREGIONDELETE:
820 // Auto region delete defaults to true
822 auto_region_delete = lexrc.getBool();
828 lyxpipes = ExpandPath(lexrc.getString());
832 case RC_CURSOR_FOLLOWS_SCROLLBAR:
834 cursor_follows_scrollbar = lexrc.getBool();
838 case RC_DIALOGS_ICONIFY_WITH_MAIN:
840 dialogs_iconify_with_main = lexrc.getBool();
844 case RC_ASCIIROFF_COMMAND:
846 ascii_roff_command = lexrc.getString();
849 case RC_ASCII_LINELEN:
851 ascii_linelen = lexrc.getInteger();
854 // Spellchecker settings:
855 case RC_USE_SPELL_LIB:
857 use_spell_lib = lexrc.getBool();
860 case RC_SPELL_COMMAND:
862 isp_command = lexrc.getString();
865 case RC_ACCEPT_COMPOUND:
867 isp_accept_compound = lexrc.getBool();
872 isp_use_input_encoding = lexrc.getBool();
875 case RC_USE_ALT_LANG:
877 isp_use_alt_lang = lexrc.getBool();
880 case RC_USE_PERS_DICT:
882 isp_use_pers_dict = lexrc.getBool();
885 case RC_USE_ESC_CHARS:
887 isp_use_esc_chars = lexrc.getBool();
892 isp_alt_lang = lexrc.getString();
897 isp_pers_dict = lexrc.getString();
902 isp_esc_chars = lexrc.getString();
907 make_backup = lexrc.getBool();
910 case RC_BACKUPDIR_PATH:
912 backupdir_path = ExpandPath(lexrc.getString());
915 case RC_DATE_INSERT_FORMAT:
917 date_insert_format = lexrc.getString();
920 case RC_LANGUAGE_PACKAGE:
922 language_package = lexrc.getString();
925 case RC_LANGUAGE_AUTO_BEGIN:
927 language_auto_begin = lexrc.getBool();
930 case RC_LANGUAGE_AUTO_END:
932 language_auto_end = lexrc.getBool();
935 case RC_LANGUAGE_GLOBAL_OPTIONS:
937 language_global_options = lexrc.getBool();
940 case RC_LANGUAGE_USE_BABEL:
942 language_use_babel = lexrc.getBool();
945 case RC_LANGUAGE_COMMAND_BEGIN:
947 language_command_begin = lexrc.getString();
950 case RC_LANGUAGE_COMMAND_END:
952 language_command_end = lexrc.getString();
955 case RC_LANGUAGE_COMMAND_LOCAL:
957 language_command_local = lexrc.getString();
962 rtl_support = lexrc.getBool();
967 auto_number = lexrc.getBool();
970 case RC_MARK_FOREIGN_LANGUAGE:
972 mark_foreign_language = lexrc.getBool();
979 fmt = lexrc.getString();
982 command = lexrc.getString();
984 movers.set(fmt, command);
989 string from, to, command, flags;
991 from = lexrc.getString();
994 to = lexrc.getString();
997 command = lexrc.getString();
1000 flags = lexrc.getString();
1003 || token(command, ' ', 0) == "none") {
1004 converters.erase(from, to);
1006 converters.add(from, to, command, flags);
1010 // compatibility with versions older than 1.4.0 only
1012 string format, command;
1014 format = lexrc.getString();
1017 command = lexrc.getString();
1018 if (token(command, ' ', 0) == "none")
1021 formats.setViewer(format, command);
1025 string format, extension, prettyname, shortcut;
1027 format = lexrc.getString();
1030 extension = lexrc.getString();
1033 prettyname = lexrc.getString();
1036 shortcut = lexrc.getString();
1038 string viewer, editor;
1039 // Hack to ensure compatibility with versions older
1041 int le = lexrc.lex();
1042 if (le != LyXLex::LEX_FEOF && le != LyXLex::LEX_UNDEF) {
1043 viewer = lexrc.getString();
1044 if (le == LyXLex::LEX_DATA) {
1045 if (token(viewer, ' ', 0) == "none")
1048 editor = lexrc.getString();
1049 if (token(editor, ' ', 0) == "none")
1053 // We have got a known token.
1054 // Therefore this is an old style
1055 // format definition without
1056 // viewer and editor.
1057 lexrc.pushToken(viewer);
1061 if (prettyname.empty()) {
1062 if (converters.formatIsUsed(format)) {
1063 lyxerr << "Can't delete format "
1066 formats.erase(format);
1069 formats.add(format, extension, prettyname,
1070 shortcut, viewer, editor);
1074 case RC_DEFAULT_LANGUAGE:
1076 default_language = lexrc.getString();
1080 case RC_LABEL_INIT_LENGTH:
1082 label_init_length = lexrc.getInteger();
1086 case RC_SHOW_BANNER:
1088 show_banner = lexrc.getBool();
1094 string const tmp = lexrc.getString();
1095 if (tmp == "true" || tmp == "on")
1096 preview = PREVIEW_ON;
1097 else if (tmp == "no_math")
1098 preview = PREVIEW_NO_MATH;
1100 preview = PREVIEW_OFF;
1101 if (tmp != "false" && tmp != "off")
1102 lyxerr << "Unrecognized "
1104 << tmp << '\n' << endl;
1109 case RC_PREVIEW_HASHED_LABELS:
1111 preview_hashed_labels = lexrc.getBool();
1115 case RC_PREVIEW_SCALE_FACTOR:
1117 preview_scale_factor = lexrc.getString();
1123 user_name = lexrc.getString();
1128 user_email = lexrc.getString();
1131 case RC_PATH_PREFIX:
1133 path_prefix = lexrc.getString();
1136 case RC_LAST: break; // this is just a dummy
1140 /// Update converters data-structures
1141 converters.update(formats);
1142 converters.buildGraph();
1148 void LyXRC::write(string const & filename, bool ignore_system_lyxrc) const
1150 ofstream ofs(filename.c_str());
1152 write(ofs, ignore_system_lyxrc);
1156 void LyXRC::print() const
1158 if (lyxerr.debugging())
1159 write(lyxerr, false);
1167 typedef std::pair<std::string, SpecialisedMover> Data;
1169 SameMover(Data const & comparison)
1170 : comparison_(comparison) {}
1172 bool operator()(Data const & data) const
1174 return data.first == comparison_.first &&
1175 data.second.command() == comparison_.second.command();
1183 void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
1185 os << "### This file is part of\n"
1186 << "### ========================================================\n"
1187 << "### LyX, The Document Processor\n"
1189 << "### Copyright 1995 Matthias Ettrich\n"
1190 << "### Copyright 1995-2001 The LyX Team.\n"
1192 << "### ========================================================\n"
1194 << "# This file is written by LyX, if you want to make your own\n"
1195 << "# modifications you should do them from inside LyX and save\n"
1198 // Why the switch you might ask. It is a trick to ensure that all
1199 // the elements in the LyXRCTags enum is handled. As you can see
1200 // there are no breaks at all. So it is just a huge fall-through.
1201 // The nice thing is that we will get a warning from the compiler
1202 // if we forget an element.
1203 LyXRCTags tag = RC_LAST;
1207 // input/include files are not done here
1209 if (ignore_system_lyxrc ||
1210 bind_file != system_lyxrc.bind_file) {
1211 os << "\\bind_file " << bind_file << "\n";
1217 << "# MISC SECTION ######################################\n"
1220 // bind files are not done here.
1222 case RC_PATH_PREFIX:
1223 if (ignore_system_lyxrc ||
1224 path_prefix != system_lyxrc.path_prefix) {
1225 os << "\\path_prefix \"" << path_prefix << "\"\n";
1229 if (ignore_system_lyxrc ||
1230 ui_file != system_lyxrc.ui_file) {
1231 os << "\\ui_file \"" << ui_file << "\"\n";
1233 case RC_AUTOREGIONDELETE:
1234 if (ignore_system_lyxrc ||
1235 auto_region_delete != system_lyxrc.auto_region_delete) {
1236 os << "# Set to false to inhibit automatic replacement of\n"
1237 << "# the current selection.\n"
1238 << "\\auto_region_delete " << convert<string>(auto_region_delete)
1241 case RC_AUTORESET_OPTIONS:
1242 if (ignore_system_lyxrc ||
1243 auto_reset_options != system_lyxrc.auto_reset_options) {
1244 os << "# Set to false to inhibit automatic reset of\n"
1245 << "# the class options to defaults on class change.\n"
1246 << "\\auto_reset_options "
1247 << convert<string>(auto_reset_options)
1251 if (ignore_system_lyxrc ||
1252 autosave != system_lyxrc.autosave) {
1253 os << "# The time interval between auto-saves in seconds.\n"
1254 << "\\autosave " << autosave << '\n';
1256 case RC_DISPLAY_GRAPHICS:
1257 if (ignore_system_lyxrc ||
1258 display_graphics != system_lyxrc.display_graphics) {
1259 os << "# Display graphics within LyX\n"
1260 << "# monochrome|grayscale|color|none\n"
1261 << "\\display_graphics "
1262 << lyx::graphics::displayTranslator().find(display_graphics)
1266 case RC_VIEWDVI_PAPEROPTION:
1267 if (ignore_system_lyxrc ||
1268 view_dvi_paper_option
1269 != system_lyxrc.view_dvi_paper_option) {
1270 os << "# Options used to specify paper size to the\n"
1271 << "# view_dvi_command (e.g. -paper)\n"
1272 << "\\view_dvi_paper_option \""
1273 << view_dvi_paper_option << "\"\n";
1275 case RC_DEFAULT_PAPERSIZE:
1276 if (ignore_system_lyxrc ||
1277 default_papersize != system_lyxrc.default_papersize) {
1278 os << "# The default papersize to use.\n"
1279 << "\\default_papersize \"";
1280 switch (default_papersize) {
1281 case PAPER_USLETTER:
1282 os << "usletter"; break;
1283 case PAPER_LEGALPAPER:
1284 os << "legal"; break;
1285 case PAPER_EXECUTIVEPAPER:
1286 os << "executive"; break;
1295 case PAPER_DEFAULT: break;
1299 case RC_CHKTEX_COMMAND:
1300 if (ignore_system_lyxrc ||
1301 chktex_command != system_lyxrc.chktex_command) {
1302 os << "\\chktex_command \"" << chktex_command << "\"\n";
1304 case RC_BIBTEX_COMMAND:
1305 if (ignore_system_lyxrc ||
1306 bibtex_command != system_lyxrc.bibtex_command) {
1307 os << "\\bibtex_command \"" << bibtex_command << "\"\n";
1309 case RC_INDEX_COMMAND:
1310 if (ignore_system_lyxrc ||
1311 index_command != system_lyxrc.index_command) {
1312 os << "\\index_command \"" << index_command << "\"\n";
1315 if (ignore_system_lyxrc ||
1316 use_kbmap != system_lyxrc.use_kbmap) {
1317 os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1320 case RC_CYGWIN_PATH_FIX:
1321 if (ignore_system_lyxrc ||
1322 cygwin_path_fix != system_lyxrc.cygwin_path_fix) {
1323 os << "\\cygwin_path_fix_needed "
1324 << convert<string>(cygwin_path_fix) << '\n';
1326 case RC_KBMAP_PRIMARY:
1327 if (ignore_system_lyxrc ||
1328 primary_kbmap != system_lyxrc.primary_kbmap) {
1329 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1331 case RC_KBMAP_SECONDARY:
1332 if (ignore_system_lyxrc ||
1333 secondary_kbmap != system_lyxrc.secondary_kbmap) {
1334 os << "\\kbmap_secondary \"" << secondary_kbmap
1338 if (ignore_system_lyxrc ||
1339 lyxpipes != system_lyxrc.lyxpipes) {
1340 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1342 case RC_DATE_INSERT_FORMAT:
1343 if (ignore_system_lyxrc ||
1344 date_insert_format != system_lyxrc.date_insert_format) {
1345 os << "\\date_insert_format \"" << date_insert_format
1348 case RC_LABEL_INIT_LENGTH:
1349 if (ignore_system_lyxrc ||
1350 label_init_length != system_lyxrc.label_init_length) {
1351 os << "\\label_init_length " << label_init_length
1356 os << "\\user_name \"" << user_name << "\"\n";
1359 os << "\\user_email \"" << user_email << "\"\n";
1361 case RC_SHOW_BANNER:
1362 if (ignore_system_lyxrc ||
1363 show_banner != system_lyxrc.show_banner) {
1364 os << "\\show_banner " << convert<string>(show_banner) << '\n';
1368 if (ignore_system_lyxrc ||
1369 preview != system_lyxrc.preview) {
1375 case PREVIEW_NO_MATH:
1382 os << "\\preview " << status << '\n';
1385 case RC_PREVIEW_HASHED_LABELS:
1386 if (ignore_system_lyxrc ||
1387 preview_hashed_labels !=
1388 system_lyxrc.preview_hashed_labels) {
1389 os << "\\preview_hashed_labels "
1390 << convert<string>(preview_hashed_labels) << '\n';
1393 case RC_PREVIEW_SCALE_FACTOR:
1394 if (ignore_system_lyxrc ||
1395 preview_scale_factor != system_lyxrc.preview_scale_factor) {
1396 os << "\\preview_scale_factor "
1397 << preview_scale_factor << '\n';
1401 << "# SCREEN & FONTS SECTION ############################\n"
1404 case RC_POPUP_NORMAL_FONT:
1405 if (ignore_system_lyxrc ||
1406 popup_normal_font != system_lyxrc.popup_normal_font) {
1407 os << "\\popup_normal_font \"" << popup_normal_font
1410 case RC_POPUP_BOLD_FONT:
1411 if (ignore_system_lyxrc ||
1412 popup_bold_font != system_lyxrc.popup_bold_font) {
1413 os << "\\popup_bold_font \"" << popup_bold_font
1416 case RC_POPUP_FONT_ENCODING:
1417 if (ignore_system_lyxrc ||
1418 popup_font_encoding != system_lyxrc.popup_font_encoding) {
1419 os << "\\popup_font_encoding \"" << popup_font_encoding
1423 if (ignore_system_lyxrc ||
1424 dpi != system_lyxrc.dpi) {
1425 os << "\\screen_dpi " << dpi << '\n';
1427 case RC_SCREEN_ZOOM:
1428 if (ignore_system_lyxrc ||
1429 zoom != system_lyxrc.zoom) {
1430 os << "\\screen_zoom " << zoom << '\n';
1433 if (ignore_system_lyxrc ||
1434 wheel_jump != system_lyxrc.wheel_jump) {
1435 os << "\\wheel_jump " << wheel_jump << '\n';
1437 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1438 if (ignore_system_lyxrc ||
1439 cursor_follows_scrollbar
1440 != system_lyxrc.cursor_follows_scrollbar) {
1441 os << "\\cursor_follows_scrollbar "
1442 << convert<string>(cursor_follows_scrollbar) << '\n';
1444 case RC_DIALOGS_ICONIFY_WITH_MAIN:
1445 if (ignore_system_lyxrc ||
1446 dialogs_iconify_with_main
1447 != system_lyxrc.dialogs_iconify_with_main) {
1448 os << "\\dialogs_iconify_with_main "
1449 << convert<string>(dialogs_iconify_with_main) << '\n';
1451 case RC_SCREEN_FONT_ROMAN:
1452 if (ignore_system_lyxrc ||
1453 roman_font_name != system_lyxrc.roman_font_name) {
1454 os << "\\screen_font_roman \"" << roman_font_name
1457 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1458 if (ignore_system_lyxrc ||
1459 roman_font_foundry != system_lyxrc.roman_font_foundry) {
1460 os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1463 case RC_SCREEN_FONT_SANS:
1464 if (ignore_system_lyxrc ||
1465 sans_font_name != system_lyxrc.sans_font_name) {
1466 os << "\\screen_font_sans \"" << sans_font_name
1469 case RC_SCREEN_FONT_SANS_FOUNDRY:
1470 if (ignore_system_lyxrc ||
1471 sans_font_foundry != system_lyxrc.sans_font_foundry) {
1472 os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1475 case RC_SCREEN_FONT_TYPEWRITER:
1476 if (ignore_system_lyxrc ||
1477 typewriter_font_name != system_lyxrc.typewriter_font_name) {
1478 os << "\\screen_font_typewriter \""
1479 << typewriter_font_name << "\"\n";
1481 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1482 if (ignore_system_lyxrc ||
1483 typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1484 os << "\\screen_font_typewriter_foundry \""
1485 << typewriter_font_foundry << "\"\n";
1488 case RC_SCREEN_FONT_SCALABLE:
1489 if (ignore_system_lyxrc ||
1490 use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1491 os << "\\screen_font_scalable "
1492 << convert<string>(use_scalable_fonts)
1495 case RC_SCREEN_FONT_ENCODING:
1496 if (ignore_system_lyxrc ||
1497 font_norm != system_lyxrc.font_norm) {
1498 os << "\\screen_font_encoding \"" << font_norm
1501 case RC_SCREEN_FONT_SIZES:
1502 if (ignore_system_lyxrc ||
1503 font_sizes[LyXFont::SIZE_TINY]
1504 != system_lyxrc.font_sizes[LyXFont::SIZE_TINY] ||
1505 font_sizes[LyXFont::SIZE_SCRIPT]
1506 != system_lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] ||
1507 font_sizes[LyXFont::SIZE_FOOTNOTE]
1508 != system_lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] ||
1509 font_sizes[LyXFont::SIZE_SMALL]
1510 != system_lyxrc.font_sizes[LyXFont::SIZE_SMALL] ||
1511 font_sizes[LyXFont::SIZE_NORMAL]
1512 != system_lyxrc.font_sizes[LyXFont::SIZE_NORMAL] ||
1513 font_sizes[LyXFont::SIZE_LARGE]
1514 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGE] ||
1515 font_sizes[LyXFont::SIZE_LARGER]
1516 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGER] ||
1517 font_sizes[LyXFont::SIZE_LARGEST]
1518 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGEST] ||
1519 font_sizes[LyXFont::SIZE_HUGE]
1520 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGE] ||
1521 font_sizes[LyXFont::SIZE_HUGER]
1522 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGER]) {
1523 os.setf(ios::fixed);
1525 os << "\\screen_font_sizes"
1526 << ' ' << font_sizes[LyXFont::SIZE_TINY]
1527 << ' ' << font_sizes[LyXFont::SIZE_SCRIPT]
1528 << ' ' << font_sizes[LyXFont::SIZE_FOOTNOTE]
1529 << ' ' << font_sizes[LyXFont::SIZE_SMALL]
1530 << ' ' << font_sizes[LyXFont::SIZE_NORMAL]
1531 << ' ' << font_sizes[LyXFont::SIZE_LARGE]
1532 << ' ' << font_sizes[LyXFont::SIZE_LARGER]
1533 << ' ' << font_sizes[LyXFont::SIZE_LARGEST]
1534 << ' ' << font_sizes[LyXFont::SIZE_HUGE]
1535 << ' ' << font_sizes[LyXFont::SIZE_HUGER]
1540 << "# COLOR SECTION ###################################\n"
1544 for (int i = 0; i < LColor::ignore; ++i) {
1545 LColor::color lc = static_cast<LColor::color>(i);
1547 string const col(lcolor.getX11Name(lc));
1548 if (ignore_system_lyxrc ||
1549 col != system_lcolor.getX11Name(lc)) {
1550 os << "\\set_color \""
1551 << lcolor.getLyXName(lc) << "\" \""
1557 << "# PRINTER SECTION ###################################\n"
1561 if (ignore_system_lyxrc ||
1562 printer != system_lyxrc.printer) {
1563 os << "\\printer \"" << printer << "\"\n";
1565 case RC_PRINT_ADAPTOUTPUT:
1566 if (ignore_system_lyxrc ||
1567 print_adapt_output != system_lyxrc.print_adapt_output) {
1568 os << "\\print_adapt_output "
1569 << convert<string>(print_adapt_output)
1572 case RC_PRINT_COMMAND:
1573 if (ignore_system_lyxrc ||
1574 print_command != system_lyxrc.print_command) {
1575 os << "\\print_command \"" << print_command << "\"\n";
1577 case RC_PRINTEXSTRAOPTIONS:
1578 if (ignore_system_lyxrc ||
1579 print_extra_options != system_lyxrc.print_extra_options) {
1580 os << "\\print_extra_options \"" << print_extra_options
1583 case RC_PRINTSPOOL_COMMAND:
1584 if (ignore_system_lyxrc ||
1585 print_spool_command != system_lyxrc.print_spool_command) {
1586 os << "\\print_spool_command \"" << print_spool_command
1589 case RC_PRINTSPOOL_PRINTERPREFIX:
1590 if (ignore_system_lyxrc ||
1591 print_spool_printerprefix
1592 != system_lyxrc.print_spool_printerprefix) {
1593 os << "\\print_spool_printerprefix \""
1594 << print_spool_printerprefix << "\"\n";
1596 case RC_PRINTEVENPAGEFLAG:
1597 if (ignore_system_lyxrc ||
1598 print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1599 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1602 case RC_PRINTODDPAGEFLAG:
1603 if (ignore_system_lyxrc ||
1604 print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1605 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1608 case RC_PRINTREVERSEFLAG:
1609 if (ignore_system_lyxrc ||
1610 print_reverse_flag != system_lyxrc.print_reverse_flag) {
1611 os << "\\print_reverse_flag \"" << print_reverse_flag
1614 case RC_PRINTLANDSCAPEFLAG:
1615 if (ignore_system_lyxrc ||
1616 print_landscape_flag != system_lyxrc.print_landscape_flag) {
1617 os << "\\print_landscape_flag \"" << print_landscape_flag
1620 case RC_PRINTPAGERANGEFLAG:
1621 if (ignore_system_lyxrc ||
1622 print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1623 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1626 case RC_PRINTCOPIESFLAG:
1627 if (ignore_system_lyxrc ||
1628 print_copies_flag != system_lyxrc.print_copies_flag) {
1629 os << "\\print_copies_flag \"" << print_copies_flag
1632 case RC_PRINTCOLLCOPIESFLAG:
1633 if (ignore_system_lyxrc ||
1634 print_collcopies_flag
1635 != system_lyxrc.print_collcopies_flag) {
1636 os << "\\print_collcopies_flag \""
1637 << print_collcopies_flag
1640 case RC_PRINTPAPERFLAG:
1641 if (ignore_system_lyxrc ||
1642 print_paper_flag != system_lyxrc.print_paper_flag) {
1643 os << "\\print_paper_flag \"" << print_paper_flag
1646 case RC_PRINTPAPERDIMENSIONFLAG:
1647 if (ignore_system_lyxrc ||
1648 print_paper_dimension_flag
1649 != system_lyxrc.print_paper_dimension_flag) {
1650 os << "\\print_paper_dimension_flag \""
1651 << print_paper_dimension_flag << "\"\n";
1653 case RC_PRINTTOPRINTER:
1654 if (ignore_system_lyxrc ||
1655 print_to_printer != system_lyxrc.print_to_printer) {
1656 os << "\\print_to_printer \"" << print_to_printer
1659 case RC_PRINTTOFILE:
1660 if (ignore_system_lyxrc ||
1661 print_to_file != system_lyxrc.print_to_file) {
1662 os << "\\print_to_file \"" << print_to_file << "\"\n";
1664 case RC_PRINTFILEEXTENSION:
1665 if (ignore_system_lyxrc ||
1666 print_file_extension != system_lyxrc.print_file_extension) {
1667 os << "\\print_file_extension \""
1668 << print_file_extension
1673 << "# EXPORT SECTION ####################################\n"
1676 case RC_CUSTOM_EXPORT_COMMAND:
1677 if (ignore_system_lyxrc ||
1678 custom_export_command
1679 != system_lyxrc.custom_export_command) {
1680 os << "\\custom_export_command \""
1681 << custom_export_command
1684 case RC_CUSTOM_EXPORT_FORMAT:
1685 if (ignore_system_lyxrc ||
1686 custom_export_format
1687 != system_lyxrc.custom_export_format) {
1688 os << "\\custom_export_format \"" << custom_export_format
1693 << "# TEX SECTION #######################################\n"
1696 case RC_FONT_ENCODING:
1697 if (ignore_system_lyxrc ||
1698 fontenc != system_lyxrc.fontenc) {
1699 os << "\\font_encoding \"" << fontenc << "\"\n";
1703 << "# FILE SECTION ######################################\n"
1706 case RC_DOCUMENTPATH:
1707 if (ignore_system_lyxrc ||
1708 document_path != system_lyxrc.document_path) {
1709 os << "\\document_path \"" << document_path << "\"\n";
1712 if (ignore_system_lyxrc ||
1713 lastfiles != system_lyxrc.lastfiles) {
1714 os << "\\lastfiles \"" << lastfiles << "\"\n";
1716 case RC_NUMLASTFILES:
1717 if (ignore_system_lyxrc ||
1718 num_lastfiles != system_lyxrc.num_lastfiles) {
1719 os << "\\num_lastfiles " << num_lastfiles << '\n';
1721 case RC_CHECKLASTFILES:
1722 if (ignore_system_lyxrc ||
1723 check_lastfiles != system_lyxrc.check_lastfiles) {
1724 os << "\\check_lastfiles " << convert<string>(check_lastfiles)
1727 case RC_TEMPLATEPATH:
1728 if (ignore_system_lyxrc ||
1729 template_path != system_lyxrc.template_path) {
1730 os << "\\template_path \"" << template_path << "\"\n";
1732 case RC_TEMPDIRPATH:
1733 if (ignore_system_lyxrc ||
1734 tempdir_path != system_lyxrc.tempdir_path) {
1735 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1739 case RC_ASCII_LINELEN:
1740 if (ignore_system_lyxrc ||
1741 ascii_linelen != system_lyxrc.ascii_linelen) {
1742 os << "\\ascii_linelen " << ascii_linelen << '\n';
1744 case RC_MAKE_BACKUP:
1745 if (ignore_system_lyxrc ||
1746 make_backup != system_lyxrc.make_backup) {
1747 os << "\\make_backup " << convert<string>(make_backup) << '\n';
1749 case RC_BACKUPDIR_PATH:
1750 if (ignore_system_lyxrc ||
1751 backupdir_path != system_lyxrc.backupdir_path) {
1752 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1756 << "# ASCII EXPORT SECTION ##############################\n"
1759 case RC_ASCIIROFF_COMMAND:
1760 if (ignore_system_lyxrc ||
1761 ascii_roff_command != system_lyxrc.ascii_roff_command) {
1762 os << "\\ascii_roff_command \"" << ascii_roff_command
1767 << "# SPELLCHECKER SECTION ##############################\n"
1769 case RC_USE_SPELL_LIB:
1770 if (ignore_system_lyxrc ||
1771 use_spell_lib != system_lyxrc.use_spell_lib) {
1772 os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
1774 case RC_SPELL_COMMAND:
1775 if (ignore_system_lyxrc ||
1776 isp_command != system_lyxrc.isp_command) {
1777 os << "\\spell_command \"" << isp_command << "\"\n";
1779 case RC_ACCEPT_COMPOUND:
1780 if (ignore_system_lyxrc ||
1781 isp_accept_compound != system_lyxrc.isp_accept_compound) {
1782 os << "\\accept_compound " << convert<string>(isp_accept_compound)
1785 case RC_USE_ALT_LANG:
1786 if (ignore_system_lyxrc ||
1787 isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
1788 os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
1792 if (ignore_system_lyxrc ||
1793 isp_alt_lang != system_lyxrc.isp_alt_lang) {
1794 os << "\\alternate_language \"" << isp_alt_lang
1797 case RC_USE_ESC_CHARS:
1798 if (ignore_system_lyxrc ||
1799 isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
1800 os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
1804 if (ignore_system_lyxrc ||
1805 isp_esc_chars != system_lyxrc.isp_esc_chars) {
1806 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1808 case RC_USE_PERS_DICT:
1809 if (ignore_system_lyxrc ||
1810 isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
1811 os << "\\use_personal_dictionary "
1812 << convert<string>(isp_use_pers_dict)
1816 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
1817 os << "\\personal_dictionary \"" << isp_pers_dict
1820 case RC_USE_INP_ENC:
1821 if (ignore_system_lyxrc ||
1822 isp_use_input_encoding
1823 != system_lyxrc.isp_use_input_encoding) {
1824 os << "\\use_input_encoding "
1825 << convert<string>(isp_use_input_encoding)
1830 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1833 case RC_RTL_SUPPORT:
1834 if (ignore_system_lyxrc ||
1835 rtl_support != system_lyxrc.rtl_support) {
1836 os << "\\rtl " << convert<string>(rtl_support) << '\n';
1838 case RC_LANGUAGE_PACKAGE:
1839 if (ignore_system_lyxrc ||
1840 language_package != system_lyxrc.language_package) {
1841 os << "\\language_package \"" << language_package
1844 case RC_LANGUAGE_GLOBAL_OPTIONS:
1845 if (ignore_system_lyxrc ||
1846 language_global_options
1847 != system_lyxrc.language_global_options) {
1848 os << "\\language_global_options \""
1849 << convert<string>(language_global_options)
1852 case RC_LANGUAGE_USE_BABEL:
1853 if (ignore_system_lyxrc ||
1854 language_use_babel != system_lyxrc.language_use_babel) {
1855 os << "\\language_use_babel \""
1856 << convert<string>(language_use_babel)
1859 case RC_LANGUAGE_COMMAND_BEGIN:
1860 if (ignore_system_lyxrc ||
1861 language_command_begin
1862 != system_lyxrc.language_command_begin) {
1863 os << "\\language_command_begin \""
1864 << language_command_begin
1867 case RC_LANGUAGE_COMMAND_END:
1868 if (ignore_system_lyxrc ||
1869 language_command_end
1870 != system_lyxrc.language_command_end) {
1871 os << "\\language_command_end \"" << language_command_end
1874 case RC_LANGUAGE_COMMAND_LOCAL:
1875 if (ignore_system_lyxrc ||
1876 language_command_local
1877 != system_lyxrc.language_command_local) {
1878 os << "\\language_command_local \""
1879 << language_command_local
1882 case RC_LANGUAGE_AUTO_BEGIN:
1883 if (ignore_system_lyxrc ||
1884 language_auto_begin != system_lyxrc.language_auto_begin) {
1885 os << "\\language_auto_begin "
1886 << convert<string>(language_auto_begin) << '\n';
1888 case RC_LANGUAGE_AUTO_END:
1889 if (ignore_system_lyxrc ||
1890 language_auto_end != system_lyxrc.language_auto_end) {
1891 os << "\\language_auto_end "
1892 << convert<string>(language_auto_end) << '\n';
1894 case RC_MARK_FOREIGN_LANGUAGE:
1895 if (ignore_system_lyxrc ||
1896 mark_foreign_language
1897 != system_lyxrc.mark_foreign_language) {
1898 os << "\\mark_foreign_language " <<
1899 convert<string>(mark_foreign_language) << '\n';
1903 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1906 case RC_AUTO_NUMBER:
1907 if (ignore_system_lyxrc ||
1908 auto_number != system_lyxrc.auto_number) {
1909 os << "\\auto_number " << convert<string>(auto_number) << '\n';
1911 case RC_DEFAULT_LANGUAGE:
1912 if (ignore_system_lyxrc ||
1913 default_language != system_lyxrc.default_language) {
1914 os << "\\default_language " << default_language << '\n';
1918 << "# FORMATS SECTION ##########################\n"
1922 // New/modifed formats
1923 for (Formats::const_iterator cit = formats.begin();
1924 cit != formats.end(); ++cit) {
1925 Format const * format =
1926 system_formats.getFormat(cit->name());
1928 format->extension() != cit->extension() ||
1929 format->prettyname() != cit->prettyname() ||
1930 format->shortcut() != cit->shortcut() ||
1931 format->viewer() != cit->viewer() ||
1932 format->editor() != cit->editor())
1933 os << "\\format \"" << cit->name() << "\" \""
1934 << cit->extension() << "\" \""
1935 << cit->prettyname() << "\" \""
1936 << cit->shortcut() << "\" \""
1937 << cit->viewer() << "\" \""
1938 << cit->editor() << "\"\n";
1941 // Look for deleted formats
1942 for (Formats::const_iterator cit = system_formats.begin();
1943 cit != system_formats.end(); ++cit)
1944 if (!formats.getFormat(cit->name()))
1945 os << "\\format \"" << cit->name()
1946 << "\" \"\" \"\" \"\" \"\" \"\"\n";
1951 << "# CONVERTERS SECTION ##########################\n"
1955 // Look for new converters
1956 for (Converters::const_iterator cit = converters.begin();
1957 cit != converters.end(); ++cit) {
1958 Converter const * converter =
1959 system_converters.getConverter(cit->from,
1962 converter->command != cit->command ||
1963 converter->flags != cit->flags)
1964 os << "\\converter \"" << cit->from << "\" \""
1965 << cit->to << "\" \""
1966 << cit->command << "\" \""
1967 << cit->flags << "\"\n";
1970 // New/modifed converters
1971 for (Converters::const_iterator cit = system_converters.begin();
1972 cit != system_converters.end(); ++cit)
1973 if (!converters.getConverter(cit->from, cit->to))
1974 os << "\\converter \"" << cit->from
1975 << "\" \"" << cit->to << "\" \"\" \"\"\n";
1979 << "# COPIERS SECTION ##########################\n"
1982 // Look for new movers
1983 Movers::iterator const sysbegin = system_movers.begin();
1984 Movers::iterator const sysend = system_movers.end();
1986 for (Movers::iterator it = movers.begin(), end = movers.end();
1988 Movers::iterator const sysit =
1989 std::find_if(sysbegin, sysend, SameMover(*it));
1990 if (sysit == sysend) {
1991 std::string const & fmt = it->first;
1992 std::string const & command =
1993 it->second.command();
1995 os << "\\copier " << fmt
1996 << " \"" << command << "\"\n";
2000 // We don't actually delete SpecialisedMover(s) from the
2001 // map, just clear their 'command', so there's no need
2002 // to test for anything else.
2008 void LyXRC::set_font_norm_type()
2010 if (font_norm == "iso10646-1")
2011 font_norm_type = ISO_10646_1;
2012 else if (font_norm == "iso8859-1")
2013 font_norm_type = ISO_8859_1;
2014 else if (font_norm == "iso8859-3")
2015 font_norm_type = ISO_8859_3;
2016 else if (font_norm == "iso8859-4")
2017 font_norm_type = ISO_8859_4;
2018 else if (font_norm == "iso8859-6.8x")
2019 font_norm_type = ISO_8859_6_8;
2020 else if (font_norm == "iso8859-9")
2021 font_norm_type = ISO_8859_9;
2022 else if (font_norm == "iso8859-15")
2023 font_norm_type = ISO_8859_15;
2025 font_norm_type = OTHER_ENCODING;
2029 string const LyXRC::getDescription(LyXRCTags tag)
2034 case RC_ACCEPT_COMPOUND:
2035 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2039 case RC_USE_ALT_LANG:
2040 str = _("Specify an alternate language. The default is to use the language of the document.");
2043 case RC_ASCIIROFF_COMMAND:
2044 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.");
2047 case RC_ASCII_LINELEN:
2048 str = _("This is the maximum line length of an exported ASCII file (LaTeX, SGML or plain text).");
2051 case RC_AUTOREGIONDELETE:
2052 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2055 case RC_AUTORESET_OPTIONS:
2056 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2060 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2063 case RC_AUTO_NUMBER:
2066 case RC_BACKUPDIR_PATH:
2067 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.");
2070 case RC_BIBTEX_COMMAND:
2071 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2075 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2078 case RC_CHECKLASTFILES:
2079 str = _("Select to check whether the lastfiles still exist.");
2082 case RC_CHKTEX_COMMAND:
2083 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2092 case RC_CURSOR_FOLLOWS_SCROLLBAR:
2093 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.");
2096 case RC_CUSTOM_EXPORT_COMMAND:
2099 case RC_CUSTOM_EXPORT_FORMAT:
2102 case RC_CYGWIN_PATH_FIX:
2105 case RC_DATE_INSERT_FORMAT:
2106 //xgettext:no-c-format
2107 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2110 case RC_DEFAULT_LANGUAGE:
2111 str = _("New documents will be assigned this language.");
2114 case RC_DEFAULT_PAPERSIZE:
2115 str = _("Specify the default paper size.");
2118 case RC_DIALOGS_ICONIFY_WITH_MAIN:
2119 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2122 case RC_DISPLAY_GRAPHICS:
2123 str = _("Select how LyX will display any graphics.");
2126 case RC_DOCUMENTPATH:
2127 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2131 case RC_USE_ESC_CHARS:
2132 str = _("Specify additional chars that can be part of a word.");
2135 case RC_FONT_ENCODING:
2136 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2142 case RC_INDEX_COMMAND:
2143 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\".");
2150 case RC_KBMAP_PRIMARY:
2151 case RC_KBMAP_SECONDARY:
2152 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.");
2155 case RC_LABEL_INIT_LENGTH:
2156 str = _("Maximum number of words in the initialization string for a new label");
2159 case RC_LANGUAGE_AUTO_BEGIN:
2160 str = _("Select if a language switching command is needed at the beginning of the document.");
2163 case RC_LANGUAGE_AUTO_END:
2164 str = _("Select if a language switching command is needed at the end of the document.");
2167 case RC_LANGUAGE_COMMAND_BEGIN:
2168 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.");
2171 case RC_LANGUAGE_COMMAND_END:
2172 str = _("The LaTeX command for changing back to the language of the document.");
2175 case RC_LANGUAGE_COMMAND_LOCAL:
2176 str = _("The LaTeX command for local changing of the language.");
2179 case RC_LANGUAGE_GLOBAL_OPTIONS:
2180 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2183 case RC_LANGUAGE_PACKAGE:
2184 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2187 case RC_LANGUAGE_USE_BABEL:
2188 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2192 str = _("The file where the last-files information should be stored.");
2195 case RC_MAKE_BACKUP:
2196 str = _("De-select if you don't want LyX to create backup files.");
2199 case RC_MARK_FOREIGN_LANGUAGE:
2200 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2203 case RC_NUMLASTFILES:
2204 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."), maxlastfiles);
2207 case RC_PATH_PREFIX:
2208 str = _("Specify those directories which should be "
2209 "prepended to the PATH environment variable. "
2210 "Use the OS native format.");
2214 case RC_USE_PERS_DICT:
2215 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2218 case RC_POPUP_BOLD_FONT:
2219 str = _("The bold font in the dialogs.");
2222 case RC_POPUP_FONT_ENCODING:
2223 str = _("The encoding for the menu/popups fonts.");
2226 case RC_POPUP_NORMAL_FONT:
2227 str = _("The normal font in the dialogs.");
2231 str = _("Shows a typeset preview of things such as math");
2234 case RC_PREVIEW_HASHED_LABELS:
2235 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2238 case RC_PREVIEW_SCALE_FACTOR:
2239 str = _("Scale the preview size to suit.");
2242 case RC_PRINTCOLLCOPIESFLAG:
2243 str = _("The option for specifying whether the copies should be collated.");
2246 case RC_PRINTCOPIESFLAG:
2247 str = _("The option for specifying the number of copies to print.");
2251 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2254 case RC_PRINTEVENPAGEFLAG:
2255 str = _("The option to print only even pages.");
2258 case RC_PRINTEXSTRAOPTIONS:
2259 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2262 case RC_PRINTFILEEXTENSION:
2263 str = _("Extension of printer program output file. Usually \".ps\".");
2266 case RC_PRINTLANDSCAPEFLAG:
2267 str = _("The option to print out in landscape.");
2270 case RC_PRINTODDPAGEFLAG:
2271 str = _("The option to print only odd pages.");
2274 case RC_PRINTPAGERANGEFLAG:
2275 str = _("The option for specifying a comma-separated list of pages to print.");
2278 case RC_PRINTPAPERDIMENSIONFLAG:
2279 str = _("Option to specify the dimensions of the print paper.");
2282 case RC_PRINTPAPERFLAG:
2283 str = _("The option to specify paper type.");
2286 case RC_PRINTREVERSEFLAG:
2287 str = _("The option to reverse the order of the pages printed.");
2290 case RC_PRINTSPOOL_COMMAND:
2291 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.");
2294 case RC_PRINTSPOOL_PRINTERPREFIX:
2295 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.");
2298 case RC_PRINTTOFILE:
2299 str = _("Option to pass to the print program to print to a file.");
2302 case RC_PRINTTOPRINTER:
2303 str = _("Option to pass to the print program to print on a specific printer.");
2306 case RC_PRINT_ADAPTOUTPUT:
2307 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2310 case RC_PRINT_COMMAND:
2311 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2314 case RC_RTL_SUPPORT:
2315 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2319 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2322 case RC_SCREEN_FONT_ENCODING:
2323 str = _("The encoding for the screen fonts.");
2326 case RC_SCREEN_FONT_ROMAN:
2327 case RC_SCREEN_FONT_SANS:
2328 case RC_SCREEN_FONT_TYPEWRITER:
2329 str = _("The screen fonts used to display the text while editing.");
2332 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
2333 case RC_SCREEN_FONT_SANS_FOUNDRY:
2334 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2337 case RC_SCREEN_FONT_SCALABLE:
2338 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.");
2341 case RC_SCREEN_FONT_SIZES:
2342 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2345 case RC_SCREEN_ZOOM:
2346 //xgettext:no-c-format
2347 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2351 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2357 case RC_SHOW_BANNER:
2358 str = _("De-select if you don't want the startup banner.");
2361 case RC_SPELL_COMMAND:
2362 str = _("What command runs the spell checker?");
2365 case RC_TEMPDIRPATH:
2366 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2369 case RC_TEMPLATEPATH:
2370 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2374 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2386 case RC_USE_INP_ENC:
2387 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.");
2390 case RC_USE_SPELL_LIB:
2393 case RC_VIEWDVI_PAPEROPTION:
2394 str = _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2401 str = _("The number of lines that are scrolled by mice with wheels or five button mice.");
2411 // The global instance
2414 // The global copy of the system lyxrc entries (everything except preferences)