3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Jean-Marc Lasgouttes
8 * \author Angus Leeming
10 * \author André Pönitz
14 * Full author contact details are available in file CREDITS.
25 #include "converter.h"
28 #include "lastfiles.h"
34 #include "graphics/GraphicsTypes.h"
36 #include "support/convert.h"
37 #include "support/environment.h"
38 #include "support/filetools.h"
39 #include "support/lstrings.h"
40 #include "support/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;
60 // when adding something to this array keep it sorted!
61 keyword_item lyxrcTags[] = {
62 { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
63 { "\\alternate_language", LyXRC::RC_ALT_LANG },
64 { "\\ascii_linelen", LyXRC::RC_ASCII_LINELEN },
65 { "\\ascii_roff_command", LyXRC::RC_ASCIIROFF_COMMAND },
66 { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
67 { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
68 { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
69 { "\\autosave", LyXRC::RC_AUTOSAVE },
70 { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
71 { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
72 { "\\bind_file", LyXRC::RC_BINDFILE },
73 { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
74 { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
75 { "\\converter", LyXRC::RC_CONVERTER },
76 { "\\copier", LyXRC::RC_COPIER },
77 { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
78 { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
79 { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
80 { "\\cygwin_path_fix_needed", LyXRC::RC_CYGWIN_PATH_FIX },
81 { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
82 { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
83 { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
84 { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
85 { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
86 { "\\document_path", LyXRC::RC_DOCUMENTPATH },
87 { "\\escape_chars", LyXRC::RC_ESC_CHARS },
88 { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
89 { "\\format", LyXRC::RC_FORMAT },
90 { "\\index_command", LyXRC::RC_INDEX_COMMAND },
91 { "\\input", LyXRC::RC_INPUT },
92 { "\\kbmap", LyXRC::RC_KBMAP },
93 { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
94 { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
95 { "\\label_init_length", LyXRC::RC_LABEL_INIT_LENGTH },
96 { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
97 { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
98 { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
99 { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
100 { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
101 { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
102 { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
103 { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
104 { "\\lastfiles", LyXRC::RC_LASTFILES },
105 { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
106 { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
107 { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
108 { "\\path_prefix", LyXRC::RC_PATH_PREFIX },
109 { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
110 { "\\popup_bold_font", LyXRC::RC_POPUP_BOLD_FONT },
111 { "\\popup_font_encoding", LyXRC::RC_POPUP_FONT_ENCODING },
112 { "\\popup_normal_font", LyXRC::RC_POPUP_NORMAL_FONT },
113 { "\\preview", LyXRC::RC_PREVIEW },
114 { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
115 { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
116 { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
117 { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
118 { "\\print_command", LyXRC::RC_PRINT_COMMAND },
119 { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
120 { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
121 { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
122 { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
123 { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
124 { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
125 { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
126 { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
127 { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
128 { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
129 { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
130 { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
131 { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
132 { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
133 { "\\printer", LyXRC::RC_PRINTER },
134 { "\\rtl", LyXRC::RC_RTL_SUPPORT },
135 { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
136 { "\\screen_font_encoding", LyXRC::RC_SCREEN_FONT_ENCODING },
137 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
138 { "\\screen_font_encoding_menu", LyXRC::RC_POPUP_FONT_ENCODING },
139 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
140 { "\\screen_font_menu", LyXRC::RC_POPUP_BOLD_FONT },
141 // compatibility with versions older than 1.2.0 only Angus 10 Jan 2002
142 { "\\screen_font_popup", LyXRC::RC_POPUP_NORMAL_FONT },
143 { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
144 { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
145 { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
146 { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
147 { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
148 { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
149 { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
150 { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
151 { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
152 { "\\serverpipe", LyXRC::RC_SERVERPIPE },
153 { "\\set_color", LyXRC::RC_SET_COLOR },
154 { "\\show_banner", LyXRC::RC_SHOW_BANNER },
155 { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
156 { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
157 { "\\template_path", LyXRC::RC_TEMPLATEPATH },
158 { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
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 tex_allows_spaces = false;
273 date_insert_format = "%A, %e %B %Y";
274 cursor_follows_scrollbar = false;
275 dialogs_iconify_with_main = false;
276 label_init_length = 3;
277 preview = PREVIEW_OFF;
278 preview_hashed_labels = false;
279 preview_scale_factor = "0.9";
281 user_name = lyx::support::user_name();
283 user_email = lyx::support::user_email();
289 void oldFontFormat(string & family, string & foundry)
291 if (family.empty() || family[0] != '-')
293 foundry = token(family, '-', 1);
294 family = token(family, '-', 2);
302 int LyXRC::read(string const & filename)
304 LyXLex lexrc(lyxrcTags, lyxrcCount);
305 if (lyxerr.debugging(Debug::PARSER))
306 lexrc.printTable(lyxerr);
308 lexrc.setFile(filename);
309 if (!lexrc.isOK()) return -2;
311 lyxerr[Debug::LYXRC] << "Reading '" << filename << "'..." << endl;
317 int LyXRC::read(std::istream & is)
319 LyXLex lexrc(lyxrcTags, lyxrcCount);
320 if (lyxerr.debugging(Debug::PARSER))
321 lexrc.printTable(lyxerr);
324 if (!lexrc.isOK()) return -2;
326 lyxerr[Debug::LYXRC] << "Reading istream..." << endl;
332 int LyXRC::read(LyXLex & lexrc)
334 if (!lexrc.isOK()) return -2;
336 while (lexrc.isOK()) {
337 // By using two switches we take advantage of the compiler
338 // telling us if we have missed a LyXRCTags element in
339 // the second switch.
340 // Note that this also shows a problem with LyXLex since it
341 // helps us avoid taking advantage of the strictness of the
344 int le = lexrc.lex();
346 case LyXLex::LEX_UNDEF:
347 lexrc.printError("Unknown tag `$$Token'");
349 case LyXLex::LEX_FEOF:
353 switch (static_cast<LyXRCTags>(le)) {
354 case RC_INPUT: // Include file
357 LibFileSearch(string(),
360 lexrc.printError("Error reading "
361 "included file: "+tmp);
365 case RC_BINDFILE: // RVDK_PATCH_5
367 bind_file = lexrc.getString();
373 ui_file = lexrc.getString();
377 case RC_AUTORESET_OPTIONS:
379 auto_reset_options = lexrc.getBool();
383 case RC_DISPLAY_GRAPHICS:
385 display_graphics = lyx::graphics::displayTranslator().find(lexrc.getString());
389 case RC_CYGWIN_PATH_FIX:
391 cygwin_path_fix = lexrc.getBool();
395 case RC_TEX_ALLOWS_SPACES:
397 tex_allows_spaces = lexrc.getBool();
403 use_kbmap = lexrc.getBool();
407 case RC_KBMAP_PRIMARY:
409 string const kmap(lexrc.getString());
412 } else if (!LibFileSearch("kbd", kmap,
414 primary_kbmap = kmap;
416 lexrc.printError("LyX: Keymap `$$Token' not found");
421 case RC_KBMAP_SECONDARY:
423 string const kmap(lexrc.getString());
426 } else if (!LibFileSearch("kbd", kmap,
428 secondary_kbmap = kmap;
430 lexrc.printError("LyX: Keymap `$$Token' not found");
435 case RC_FONT_ENCODING:
437 fontenc = lexrc.getString();
443 printer = lexrc.getString();
447 case RC_PRINT_COMMAND:
449 print_command = lexrc.getString();
453 case RC_PRINTEVENPAGEFLAG:
455 print_evenpage_flag = lexrc.getString();
459 case RC_PRINTODDPAGEFLAG:
461 print_oddpage_flag = lexrc.getString();
465 case RC_PRINTPAGERANGEFLAG:
467 print_pagerange_flag = lexrc.getString();
471 case RC_PRINTCOPIESFLAG:
473 print_copies_flag = lexrc.getString();
477 case RC_PRINTCOLLCOPIESFLAG:
479 print_collcopies_flag = lexrc.getString();
483 case RC_PRINTREVERSEFLAG:
485 print_reverse_flag = lexrc.getString();
489 case RC_PRINTLANDSCAPEFLAG:
491 print_landscape_flag = lexrc.getString();
495 case RC_PRINTTOPRINTER:
497 print_to_printer = lexrc.getString();
501 case RC_PRINT_ADAPTOUTPUT:
503 print_adapt_output = lexrc.getBool();
509 print_to_file = lexrc.getString();
513 case RC_PRINTFILEEXTENSION:
515 print_file_extension = lexrc.getString();
519 case RC_PRINTEXSTRAOPTIONS:
521 print_extra_options = lexrc.getString();
525 case RC_PRINTSPOOL_COMMAND:
527 print_spool_command = lexrc.getString();
531 case RC_PRINTSPOOL_PRINTERPREFIX:
533 print_spool_printerprefix = lexrc.getString();
537 case RC_PRINTPAPERDIMENSIONFLAG:
539 print_paper_dimension_flag = lexrc.getString();
543 case RC_PRINTPAPERFLAG:
545 print_paper_flag = lexrc.getString();
549 case RC_CUSTOM_EXPORT_COMMAND:
551 custom_export_command = lexrc.getString();
555 case RC_CUSTOM_EXPORT_FORMAT:
557 custom_export_format = lexrc.getString();
561 case RC_DEFAULT_PAPERSIZE:
564 ascii_lowercase(lexrc.getString());
565 if (size == "usletter")
568 else if (size == "legal")
571 else if (size == "executive")
573 PAPER_EXECUTIVEPAPER;
574 else if (size == "a3")
577 else if (size == "a4")
580 else if (size == "a5")
583 else if (size == "b5")
589 case RC_VIEWDVI_PAPEROPTION:
591 view_dvi_paper_option = lexrc.getString();
593 view_dvi_paper_option.erase();
597 case RC_CHKTEX_COMMAND:
599 chktex_command = lexrc.getString();
603 case RC_BIBTEX_COMMAND:
605 bibtex_command = lexrc.getString();
609 case RC_INDEX_COMMAND:
611 index_command = lexrc.getString();
617 dpi = lexrc.getInteger();
623 zoom = lexrc.getInteger();
629 wheel_jump = lexrc.getInteger();
633 case RC_SCREEN_FONT_SIZES:
635 font_sizes[LyXFont::SIZE_TINY] =
639 font_sizes[LyXFont::SIZE_SCRIPT] =
643 font_sizes[LyXFont::SIZE_FOOTNOTE] =
647 font_sizes[LyXFont::SIZE_SMALL] =
651 font_sizes[LyXFont::SIZE_NORMAL] =
655 font_sizes[LyXFont::SIZE_LARGE] =
659 font_sizes[LyXFont::SIZE_LARGER] =
663 font_sizes[LyXFont::SIZE_LARGEST] =
667 font_sizes[LyXFont::SIZE_HUGE] =
671 font_sizes[LyXFont::SIZE_HUGER] =
676 case RC_SCREEN_FONT_SCALABLE:
678 use_scalable_fonts = lexrc.getBool();
684 autosave = lexrc.getInteger();
688 case RC_DOCUMENTPATH:
690 document_path = ExpandPath(lexrc.getString());
694 case RC_TEMPLATEPATH:
696 template_path = ExpandPath(lexrc.getString());
702 tempdir_path = ExpandPath(lexrc.getString());
708 lyxerr << "Ignoring obsolete use_tempdir flag." << endl;
714 lastfiles = ExpandPath(lexrc.getString());
718 case RC_NUMLASTFILES:
720 num_lastfiles = lexrc.getInteger();
724 case RC_CHECKLASTFILES:
726 check_lastfiles = lexrc.getBool();
730 case RC_SCREEN_FONT_ROMAN:
732 roman_font_name = lexrc.getString();
733 oldFontFormat(roman_font_name,
738 case RC_SCREEN_FONT_SANS:
740 sans_font_name = lexrc.getString();
741 oldFontFormat(sans_font_name, sans_font_foundry);
745 case RC_SCREEN_FONT_TYPEWRITER:
747 typewriter_font_name = lexrc.getString();
748 oldFontFormat(typewriter_font_name,
749 typewriter_font_foundry);
753 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
755 roman_font_foundry = lexrc.getString();
759 case RC_SCREEN_FONT_SANS_FOUNDRY:
761 sans_font_foundry = lexrc.getString();
765 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
767 typewriter_font_foundry = lexrc.getString();
771 case RC_SCREEN_FONT_ENCODING:
773 font_norm = lexrc.getString();
774 set_font_norm_type();
778 case RC_POPUP_BOLD_FONT:
780 popup_bold_font = lexrc.getString();
784 case RC_POPUP_NORMAL_FONT:
786 popup_normal_font = lexrc.getString();
790 case RC_POPUP_FONT_ENCODING:
792 popup_font_encoding = lexrc.getString();
798 string lyx_name, x11_name;
801 lyx_name = lexrc.getString();
803 lexrc.printError("Missing color tag.");
808 x11_name = lexrc.getString();
810 lexrc.printError("Missing color name for color: `$$Token'");
814 LColor::color const col =
815 lcolor.getFromLyXName(lyx_name);
816 if (col == LColor::none ||
817 col == LColor::inherit ||
818 col == LColor::ignore)
821 if (!lcolor.setColor(col, x11_name)) {
822 lyxerr << "Bad lyxrc set_color for "
828 case RC_AUTOREGIONDELETE:
829 // Auto region delete defaults to true
831 auto_region_delete = lexrc.getBool();
837 lyxpipes = ExpandPath(lexrc.getString());
841 case RC_CURSOR_FOLLOWS_SCROLLBAR:
843 cursor_follows_scrollbar = lexrc.getBool();
847 case RC_DIALOGS_ICONIFY_WITH_MAIN:
849 dialogs_iconify_with_main = lexrc.getBool();
853 case RC_ASCIIROFF_COMMAND:
855 ascii_roff_command = lexrc.getString();
858 case RC_ASCII_LINELEN:
860 ascii_linelen = lexrc.getInteger();
863 // Spellchecker settings:
864 case RC_USE_SPELL_LIB:
866 use_spell_lib = lexrc.getBool();
869 case RC_SPELL_COMMAND:
871 isp_command = lexrc.getString();
874 case RC_ACCEPT_COMPOUND:
876 isp_accept_compound = lexrc.getBool();
881 isp_use_input_encoding = lexrc.getBool();
884 case RC_USE_ALT_LANG:
886 isp_use_alt_lang = lexrc.getBool();
889 case RC_USE_PERS_DICT:
891 isp_use_pers_dict = lexrc.getBool();
894 case RC_USE_ESC_CHARS:
896 isp_use_esc_chars = lexrc.getBool();
901 isp_alt_lang = lexrc.getString();
906 isp_pers_dict = lexrc.getString();
911 isp_esc_chars = lexrc.getString();
916 make_backup = lexrc.getBool();
919 case RC_BACKUPDIR_PATH:
921 backupdir_path = ExpandPath(lexrc.getString());
924 case RC_DATE_INSERT_FORMAT:
926 date_insert_format = lexrc.getString();
929 case RC_LANGUAGE_PACKAGE:
931 language_package = lexrc.getString();
934 case RC_LANGUAGE_AUTO_BEGIN:
936 language_auto_begin = lexrc.getBool();
939 case RC_LANGUAGE_AUTO_END:
941 language_auto_end = lexrc.getBool();
944 case RC_LANGUAGE_GLOBAL_OPTIONS:
946 language_global_options = lexrc.getBool();
949 case RC_LANGUAGE_USE_BABEL:
951 language_use_babel = lexrc.getBool();
954 case RC_LANGUAGE_COMMAND_BEGIN:
956 language_command_begin = lexrc.getString();
959 case RC_LANGUAGE_COMMAND_END:
961 language_command_end = lexrc.getString();
964 case RC_LANGUAGE_COMMAND_LOCAL:
966 language_command_local = lexrc.getString();
971 rtl_support = lexrc.getBool();
976 auto_number = lexrc.getBool();
979 case RC_MARK_FOREIGN_LANGUAGE:
981 mark_foreign_language = lexrc.getBool();
988 fmt = lexrc.getString();
991 command = lexrc.getString();
993 movers.set(fmt, command);
998 string from, to, command, flags;
1000 from = lexrc.getString();
1003 to = lexrc.getString();
1006 command = lexrc.getString();
1009 flags = lexrc.getString();
1012 || token(command, ' ', 0) == "none") {
1013 converters.erase(from, to);
1015 converters.add(from, to, command, flags);
1019 // compatibility with versions older than 1.4.0 only
1021 string format, command;
1023 format = lexrc.getString();
1026 command = lexrc.getString();
1027 if (token(command, ' ', 0) == "none")
1030 formats.setViewer(format, command);
1034 string format, extension, prettyname, shortcut;
1036 format = lexrc.getString();
1039 extension = lexrc.getString();
1042 prettyname = lexrc.getString();
1045 shortcut = lexrc.getString();
1047 string viewer, editor;
1048 // Hack to ensure compatibility with versions older
1050 int le = lexrc.lex();
1051 if (le != LyXLex::LEX_FEOF && le != LyXLex::LEX_UNDEF) {
1052 viewer = lexrc.getString();
1053 if (le == LyXLex::LEX_DATA) {
1054 if (token(viewer, ' ', 0) == "none")
1057 editor = lexrc.getString();
1058 if (token(editor, ' ', 0) == "none")
1062 // We have got a known token.
1063 // Therefore this is an old style
1064 // format definition without
1065 // viewer and editor.
1066 lexrc.pushToken(viewer);
1070 if (prettyname.empty()) {
1071 if (converters.formatIsUsed(format)) {
1072 lyxerr << "Can't delete format "
1075 formats.erase(format);
1078 formats.add(format, extension, prettyname,
1079 shortcut, viewer, editor);
1083 case RC_DEFAULT_LANGUAGE:
1085 default_language = lexrc.getString();
1089 case RC_LABEL_INIT_LENGTH:
1091 label_init_length = lexrc.getInteger();
1095 case RC_SHOW_BANNER:
1097 show_banner = lexrc.getBool();
1103 string const tmp = lexrc.getString();
1104 if (tmp == "true" || tmp == "on")
1105 preview = PREVIEW_ON;
1106 else if (tmp == "no_math")
1107 preview = PREVIEW_NO_MATH;
1109 preview = PREVIEW_OFF;
1110 if (tmp != "false" && tmp != "off")
1111 lyxerr << "Unrecognized "
1113 << tmp << '\n' << endl;
1118 case RC_PREVIEW_HASHED_LABELS:
1120 preview_hashed_labels = lexrc.getBool();
1124 case RC_PREVIEW_SCALE_FACTOR:
1126 preview_scale_factor = lexrc.getString();
1132 user_name = lexrc.getString();
1137 user_email = lexrc.getString();
1140 case RC_PATH_PREFIX:
1142 path_prefix = lexrc.getString();
1145 case RC_LAST: break; // this is just a dummy
1149 /// Update converters data-structures
1150 converters.update(formats);
1151 converters.buildGraph();
1157 void LyXRC::write(string const & filename, bool ignore_system_lyxrc) const
1159 ofstream ofs(filename.c_str());
1161 write(ofs, ignore_system_lyxrc);
1165 void LyXRC::print() const
1167 if (lyxerr.debugging())
1168 write(lyxerr, false);
1176 typedef std::pair<std::string, SpecialisedMover> Data;
1178 SameMover(Data const & comparison)
1179 : comparison_(comparison) {}
1181 bool operator()(Data const & data) const
1183 return data.first == comparison_.first &&
1184 data.second.command() == comparison_.second.command();
1192 void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
1194 os << "### This file is part of\n"
1195 << "### ========================================================\n"
1196 << "### LyX, The Document Processor\n"
1198 << "### Copyright 1995 Matthias Ettrich\n"
1199 << "### Copyright 1995-2001 The LyX Team.\n"
1201 << "### ========================================================\n"
1203 << "# This file is written by LyX, if you want to make your own\n"
1204 << "# modifications you should do them from inside LyX and save\n"
1207 // Why the switch you might ask. It is a trick to ensure that all
1208 // the elements in the LyXRCTags enum is handled. As you can see
1209 // there are no breaks at all. So it is just a huge fall-through.
1210 // The nice thing is that we will get a warning from the compiler
1211 // if we forget an element.
1212 LyXRCTags tag = RC_LAST;
1216 // input/include files are not done here
1218 if (ignore_system_lyxrc ||
1219 bind_file != system_lyxrc.bind_file) {
1220 os << "\\bind_file " << bind_file << "\n";
1226 << "# MISC SECTION ######################################\n"
1229 // bind files are not done here.
1231 case RC_PATH_PREFIX:
1232 if (ignore_system_lyxrc ||
1233 path_prefix != system_lyxrc.path_prefix) {
1234 os << "\\path_prefix \"" << path_prefix << "\"\n";
1238 if (ignore_system_lyxrc ||
1239 ui_file != system_lyxrc.ui_file) {
1240 os << "\\ui_file \"" << ui_file << "\"\n";
1242 case RC_AUTOREGIONDELETE:
1243 if (ignore_system_lyxrc ||
1244 auto_region_delete != system_lyxrc.auto_region_delete) {
1245 os << "# Set to false to inhibit automatic replacement of\n"
1246 << "# the current selection.\n"
1247 << "\\auto_region_delete " << convert<string>(auto_region_delete)
1250 case RC_AUTORESET_OPTIONS:
1251 if (ignore_system_lyxrc ||
1252 auto_reset_options != system_lyxrc.auto_reset_options) {
1253 os << "# Set to false to inhibit automatic reset of\n"
1254 << "# the class options to defaults on class change.\n"
1255 << "\\auto_reset_options "
1256 << convert<string>(auto_reset_options)
1260 if (ignore_system_lyxrc ||
1261 autosave != system_lyxrc.autosave) {
1262 os << "# The time interval between auto-saves in seconds.\n"
1263 << "\\autosave " << autosave << '\n';
1265 case RC_DISPLAY_GRAPHICS:
1266 if (ignore_system_lyxrc ||
1267 display_graphics != system_lyxrc.display_graphics) {
1268 os << "# Display graphics within LyX\n"
1269 << "# monochrome|grayscale|color|none\n"
1270 << "\\display_graphics "
1271 << lyx::graphics::displayTranslator().find(display_graphics)
1275 case RC_VIEWDVI_PAPEROPTION:
1276 if (ignore_system_lyxrc ||
1277 view_dvi_paper_option
1278 != system_lyxrc.view_dvi_paper_option) {
1279 os << "# Options used to specify paper size to the\n"
1280 << "# view_dvi_command (e.g. -paper)\n"
1281 << "\\view_dvi_paper_option \""
1282 << view_dvi_paper_option << "\"\n";
1284 case RC_DEFAULT_PAPERSIZE:
1285 if (ignore_system_lyxrc ||
1286 default_papersize != system_lyxrc.default_papersize) {
1287 os << "# The default papersize to use.\n"
1288 << "\\default_papersize \"";
1289 switch (default_papersize) {
1290 case PAPER_USLETTER:
1291 os << "usletter"; break;
1292 case PAPER_LEGALPAPER:
1293 os << "legal"; break;
1294 case PAPER_EXECUTIVEPAPER:
1295 os << "executive"; break;
1304 case PAPER_DEFAULT: break;
1308 case RC_CHKTEX_COMMAND:
1309 if (ignore_system_lyxrc ||
1310 chktex_command != system_lyxrc.chktex_command) {
1311 os << "\\chktex_command \"" << chktex_command << "\"\n";
1313 case RC_BIBTEX_COMMAND:
1314 if (ignore_system_lyxrc ||
1315 bibtex_command != system_lyxrc.bibtex_command) {
1316 os << "\\bibtex_command \"" << bibtex_command << "\"\n";
1318 case RC_INDEX_COMMAND:
1319 if (ignore_system_lyxrc ||
1320 index_command != system_lyxrc.index_command) {
1321 os << "\\index_command \"" << index_command << "\"\n";
1323 case RC_CYGWIN_PATH_FIX:
1324 if (ignore_system_lyxrc ||
1325 cygwin_path_fix != system_lyxrc.cygwin_path_fix) {
1326 os << "\\cygwin_path_fix_needed "
1327 << convert<string>(cygwin_path_fix) << '\n';
1329 case RC_TEX_ALLOWS_SPACES:
1330 if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
1331 os << "\\tex_allows_spaces "
1332 << convert<string>(tex_allows_spaces) << '\n';
1335 if (ignore_system_lyxrc ||
1336 use_kbmap != system_lyxrc.use_kbmap) {
1337 os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1339 case RC_KBMAP_PRIMARY:
1340 if (ignore_system_lyxrc ||
1341 primary_kbmap != system_lyxrc.primary_kbmap) {
1342 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1344 case RC_KBMAP_SECONDARY:
1345 if (ignore_system_lyxrc ||
1346 secondary_kbmap != system_lyxrc.secondary_kbmap) {
1347 os << "\\kbmap_secondary \"" << secondary_kbmap
1351 if (ignore_system_lyxrc ||
1352 lyxpipes != system_lyxrc.lyxpipes) {
1353 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1355 case RC_DATE_INSERT_FORMAT:
1356 if (ignore_system_lyxrc ||
1357 date_insert_format != system_lyxrc.date_insert_format) {
1358 os << "\\date_insert_format \"" << date_insert_format
1361 case RC_LABEL_INIT_LENGTH:
1362 if (ignore_system_lyxrc ||
1363 label_init_length != system_lyxrc.label_init_length) {
1364 os << "\\label_init_length " << label_init_length
1369 os << "\\user_name \"" << user_name << "\"\n";
1372 os << "\\user_email \"" << user_email << "\"\n";
1374 case RC_SHOW_BANNER:
1375 if (ignore_system_lyxrc ||
1376 show_banner != system_lyxrc.show_banner) {
1377 os << "\\show_banner " << convert<string>(show_banner) << '\n';
1381 if (ignore_system_lyxrc ||
1382 preview != system_lyxrc.preview) {
1388 case PREVIEW_NO_MATH:
1395 os << "\\preview " << status << '\n';
1398 case RC_PREVIEW_HASHED_LABELS:
1399 if (ignore_system_lyxrc ||
1400 preview_hashed_labels !=
1401 system_lyxrc.preview_hashed_labels) {
1402 os << "\\preview_hashed_labels "
1403 << convert<string>(preview_hashed_labels) << '\n';
1406 case RC_PREVIEW_SCALE_FACTOR:
1407 if (ignore_system_lyxrc ||
1408 preview_scale_factor != system_lyxrc.preview_scale_factor) {
1409 os << "\\preview_scale_factor "
1410 << preview_scale_factor << '\n';
1414 << "# SCREEN & FONTS SECTION ############################\n"
1417 case RC_POPUP_NORMAL_FONT:
1418 if (ignore_system_lyxrc ||
1419 popup_normal_font != system_lyxrc.popup_normal_font) {
1420 os << "\\popup_normal_font \"" << popup_normal_font
1423 case RC_POPUP_BOLD_FONT:
1424 if (ignore_system_lyxrc ||
1425 popup_bold_font != system_lyxrc.popup_bold_font) {
1426 os << "\\popup_bold_font \"" << popup_bold_font
1429 case RC_POPUP_FONT_ENCODING:
1430 if (ignore_system_lyxrc ||
1431 popup_font_encoding != system_lyxrc.popup_font_encoding) {
1432 os << "\\popup_font_encoding \"" << popup_font_encoding
1436 if (ignore_system_lyxrc ||
1437 dpi != system_lyxrc.dpi) {
1438 os << "\\screen_dpi " << dpi << '\n';
1440 case RC_SCREEN_ZOOM:
1441 if (ignore_system_lyxrc ||
1442 zoom != system_lyxrc.zoom) {
1443 os << "\\screen_zoom " << zoom << '\n';
1446 if (ignore_system_lyxrc ||
1447 wheel_jump != system_lyxrc.wheel_jump) {
1448 os << "\\wheel_jump " << wheel_jump << '\n';
1450 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1451 if (ignore_system_lyxrc ||
1452 cursor_follows_scrollbar
1453 != system_lyxrc.cursor_follows_scrollbar) {
1454 os << "\\cursor_follows_scrollbar "
1455 << convert<string>(cursor_follows_scrollbar) << '\n';
1457 case RC_DIALOGS_ICONIFY_WITH_MAIN:
1458 if (ignore_system_lyxrc ||
1459 dialogs_iconify_with_main
1460 != system_lyxrc.dialogs_iconify_with_main) {
1461 os << "\\dialogs_iconify_with_main "
1462 << convert<string>(dialogs_iconify_with_main) << '\n';
1464 case RC_SCREEN_FONT_ROMAN:
1465 if (ignore_system_lyxrc ||
1466 roman_font_name != system_lyxrc.roman_font_name) {
1467 os << "\\screen_font_roman \"" << roman_font_name
1470 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1471 if (ignore_system_lyxrc ||
1472 roman_font_foundry != system_lyxrc.roman_font_foundry) {
1473 os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1476 case RC_SCREEN_FONT_SANS:
1477 if (ignore_system_lyxrc ||
1478 sans_font_name != system_lyxrc.sans_font_name) {
1479 os << "\\screen_font_sans \"" << sans_font_name
1482 case RC_SCREEN_FONT_SANS_FOUNDRY:
1483 if (ignore_system_lyxrc ||
1484 sans_font_foundry != system_lyxrc.sans_font_foundry) {
1485 os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1488 case RC_SCREEN_FONT_TYPEWRITER:
1489 if (ignore_system_lyxrc ||
1490 typewriter_font_name != system_lyxrc.typewriter_font_name) {
1491 os << "\\screen_font_typewriter \""
1492 << typewriter_font_name << "\"\n";
1494 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1495 if (ignore_system_lyxrc ||
1496 typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1497 os << "\\screen_font_typewriter_foundry \""
1498 << typewriter_font_foundry << "\"\n";
1501 case RC_SCREEN_FONT_SCALABLE:
1502 if (ignore_system_lyxrc ||
1503 use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1504 os << "\\screen_font_scalable "
1505 << convert<string>(use_scalable_fonts)
1508 case RC_SCREEN_FONT_ENCODING:
1509 if (ignore_system_lyxrc ||
1510 font_norm != system_lyxrc.font_norm) {
1511 os << "\\screen_font_encoding \"" << font_norm
1514 case RC_SCREEN_FONT_SIZES:
1515 if (ignore_system_lyxrc ||
1516 font_sizes[LyXFont::SIZE_TINY]
1517 != system_lyxrc.font_sizes[LyXFont::SIZE_TINY] ||
1518 font_sizes[LyXFont::SIZE_SCRIPT]
1519 != system_lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] ||
1520 font_sizes[LyXFont::SIZE_FOOTNOTE]
1521 != system_lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] ||
1522 font_sizes[LyXFont::SIZE_SMALL]
1523 != system_lyxrc.font_sizes[LyXFont::SIZE_SMALL] ||
1524 font_sizes[LyXFont::SIZE_NORMAL]
1525 != system_lyxrc.font_sizes[LyXFont::SIZE_NORMAL] ||
1526 font_sizes[LyXFont::SIZE_LARGE]
1527 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGE] ||
1528 font_sizes[LyXFont::SIZE_LARGER]
1529 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGER] ||
1530 font_sizes[LyXFont::SIZE_LARGEST]
1531 != system_lyxrc.font_sizes[LyXFont::SIZE_LARGEST] ||
1532 font_sizes[LyXFont::SIZE_HUGE]
1533 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGE] ||
1534 font_sizes[LyXFont::SIZE_HUGER]
1535 != system_lyxrc.font_sizes[LyXFont::SIZE_HUGER]) {
1536 os.setf(ios::fixed);
1538 os << "\\screen_font_sizes"
1539 << ' ' << font_sizes[LyXFont::SIZE_TINY]
1540 << ' ' << font_sizes[LyXFont::SIZE_SCRIPT]
1541 << ' ' << font_sizes[LyXFont::SIZE_FOOTNOTE]
1542 << ' ' << font_sizes[LyXFont::SIZE_SMALL]
1543 << ' ' << font_sizes[LyXFont::SIZE_NORMAL]
1544 << ' ' << font_sizes[LyXFont::SIZE_LARGE]
1545 << ' ' << font_sizes[LyXFont::SIZE_LARGER]
1546 << ' ' << font_sizes[LyXFont::SIZE_LARGEST]
1547 << ' ' << font_sizes[LyXFont::SIZE_HUGE]
1548 << ' ' << font_sizes[LyXFont::SIZE_HUGER]
1553 << "# COLOR SECTION ###################################\n"
1557 for (int i = 0; i < LColor::ignore; ++i) {
1558 LColor::color lc = static_cast<LColor::color>(i);
1560 string const col(lcolor.getX11Name(lc));
1561 if (ignore_system_lyxrc ||
1562 col != system_lcolor.getX11Name(lc)) {
1563 os << "\\set_color \""
1564 << lcolor.getLyXName(lc) << "\" \""
1570 << "# PRINTER SECTION ###################################\n"
1574 if (ignore_system_lyxrc ||
1575 printer != system_lyxrc.printer) {
1576 os << "\\printer \"" << printer << "\"\n";
1578 case RC_PRINT_ADAPTOUTPUT:
1579 if (ignore_system_lyxrc ||
1580 print_adapt_output != system_lyxrc.print_adapt_output) {
1581 os << "\\print_adapt_output "
1582 << convert<string>(print_adapt_output)
1585 case RC_PRINT_COMMAND:
1586 if (ignore_system_lyxrc ||
1587 print_command != system_lyxrc.print_command) {
1588 os << "\\print_command \"" << print_command << "\"\n";
1590 case RC_PRINTEXSTRAOPTIONS:
1591 if (ignore_system_lyxrc ||
1592 print_extra_options != system_lyxrc.print_extra_options) {
1593 os << "\\print_extra_options \"" << print_extra_options
1596 case RC_PRINTSPOOL_COMMAND:
1597 if (ignore_system_lyxrc ||
1598 print_spool_command != system_lyxrc.print_spool_command) {
1599 os << "\\print_spool_command \"" << print_spool_command
1602 case RC_PRINTSPOOL_PRINTERPREFIX:
1603 if (ignore_system_lyxrc ||
1604 print_spool_printerprefix
1605 != system_lyxrc.print_spool_printerprefix) {
1606 os << "\\print_spool_printerprefix \""
1607 << print_spool_printerprefix << "\"\n";
1609 case RC_PRINTEVENPAGEFLAG:
1610 if (ignore_system_lyxrc ||
1611 print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1612 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1615 case RC_PRINTODDPAGEFLAG:
1616 if (ignore_system_lyxrc ||
1617 print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1618 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1621 case RC_PRINTREVERSEFLAG:
1622 if (ignore_system_lyxrc ||
1623 print_reverse_flag != system_lyxrc.print_reverse_flag) {
1624 os << "\\print_reverse_flag \"" << print_reverse_flag
1627 case RC_PRINTLANDSCAPEFLAG:
1628 if (ignore_system_lyxrc ||
1629 print_landscape_flag != system_lyxrc.print_landscape_flag) {
1630 os << "\\print_landscape_flag \"" << print_landscape_flag
1633 case RC_PRINTPAGERANGEFLAG:
1634 if (ignore_system_lyxrc ||
1635 print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1636 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1639 case RC_PRINTCOPIESFLAG:
1640 if (ignore_system_lyxrc ||
1641 print_copies_flag != system_lyxrc.print_copies_flag) {
1642 os << "\\print_copies_flag \"" << print_copies_flag
1645 case RC_PRINTCOLLCOPIESFLAG:
1646 if (ignore_system_lyxrc ||
1647 print_collcopies_flag
1648 != system_lyxrc.print_collcopies_flag) {
1649 os << "\\print_collcopies_flag \""
1650 << print_collcopies_flag
1653 case RC_PRINTPAPERFLAG:
1654 if (ignore_system_lyxrc ||
1655 print_paper_flag != system_lyxrc.print_paper_flag) {
1656 os << "\\print_paper_flag \"" << print_paper_flag
1659 case RC_PRINTPAPERDIMENSIONFLAG:
1660 if (ignore_system_lyxrc ||
1661 print_paper_dimension_flag
1662 != system_lyxrc.print_paper_dimension_flag) {
1663 os << "\\print_paper_dimension_flag \""
1664 << print_paper_dimension_flag << "\"\n";
1666 case RC_PRINTTOPRINTER:
1667 if (ignore_system_lyxrc ||
1668 print_to_printer != system_lyxrc.print_to_printer) {
1669 os << "\\print_to_printer \"" << print_to_printer
1672 case RC_PRINTTOFILE:
1673 if (ignore_system_lyxrc ||
1674 print_to_file != system_lyxrc.print_to_file) {
1675 os << "\\print_to_file \"" << print_to_file << "\"\n";
1677 case RC_PRINTFILEEXTENSION:
1678 if (ignore_system_lyxrc ||
1679 print_file_extension != system_lyxrc.print_file_extension) {
1680 os << "\\print_file_extension \""
1681 << print_file_extension
1686 << "# EXPORT SECTION ####################################\n"
1689 case RC_CUSTOM_EXPORT_COMMAND:
1690 if (ignore_system_lyxrc ||
1691 custom_export_command
1692 != system_lyxrc.custom_export_command) {
1693 os << "\\custom_export_command \""
1694 << custom_export_command
1697 case RC_CUSTOM_EXPORT_FORMAT:
1698 if (ignore_system_lyxrc ||
1699 custom_export_format
1700 != system_lyxrc.custom_export_format) {
1701 os << "\\custom_export_format \"" << custom_export_format
1706 << "# TEX SECTION #######################################\n"
1709 case RC_FONT_ENCODING:
1710 if (ignore_system_lyxrc ||
1711 fontenc != system_lyxrc.fontenc) {
1712 os << "\\font_encoding \"" << fontenc << "\"\n";
1716 << "# FILE SECTION ######################################\n"
1719 case RC_DOCUMENTPATH:
1720 if (ignore_system_lyxrc ||
1721 document_path != system_lyxrc.document_path) {
1722 os << "\\document_path \"" << document_path << "\"\n";
1725 if (ignore_system_lyxrc ||
1726 lastfiles != system_lyxrc.lastfiles) {
1727 os << "\\lastfiles \"" << lastfiles << "\"\n";
1729 case RC_NUMLASTFILES:
1730 if (ignore_system_lyxrc ||
1731 num_lastfiles != system_lyxrc.num_lastfiles) {
1732 os << "\\num_lastfiles " << num_lastfiles << '\n';
1734 case RC_CHECKLASTFILES:
1735 if (ignore_system_lyxrc ||
1736 check_lastfiles != system_lyxrc.check_lastfiles) {
1737 os << "\\check_lastfiles " << convert<string>(check_lastfiles)
1740 case RC_TEMPLATEPATH:
1741 if (ignore_system_lyxrc ||
1742 template_path != system_lyxrc.template_path) {
1743 os << "\\template_path \"" << template_path << "\"\n";
1745 case RC_TEMPDIRPATH:
1746 if (ignore_system_lyxrc ||
1747 tempdir_path != system_lyxrc.tempdir_path) {
1748 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1752 case RC_ASCII_LINELEN:
1753 if (ignore_system_lyxrc ||
1754 ascii_linelen != system_lyxrc.ascii_linelen) {
1755 os << "\\ascii_linelen " << ascii_linelen << '\n';
1757 case RC_MAKE_BACKUP:
1758 if (ignore_system_lyxrc ||
1759 make_backup != system_lyxrc.make_backup) {
1760 os << "\\make_backup " << convert<string>(make_backup) << '\n';
1762 case RC_BACKUPDIR_PATH:
1763 if (ignore_system_lyxrc ||
1764 backupdir_path != system_lyxrc.backupdir_path) {
1765 os << "\\backupdir_path \"" << backupdir_path << "\"\n";
1769 << "# ASCII EXPORT SECTION ##############################\n"
1772 case RC_ASCIIROFF_COMMAND:
1773 if (ignore_system_lyxrc ||
1774 ascii_roff_command != system_lyxrc.ascii_roff_command) {
1775 os << "\\ascii_roff_command \"" << ascii_roff_command
1780 << "# SPELLCHECKER SECTION ##############################\n"
1782 case RC_USE_SPELL_LIB:
1783 if (ignore_system_lyxrc ||
1784 use_spell_lib != system_lyxrc.use_spell_lib) {
1785 os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
1787 case RC_SPELL_COMMAND:
1788 if (ignore_system_lyxrc ||
1789 isp_command != system_lyxrc.isp_command) {
1790 os << "\\spell_command \"" << isp_command << "\"\n";
1792 case RC_ACCEPT_COMPOUND:
1793 if (ignore_system_lyxrc ||
1794 isp_accept_compound != system_lyxrc.isp_accept_compound) {
1795 os << "\\accept_compound " << convert<string>(isp_accept_compound)
1798 case RC_USE_ALT_LANG:
1799 if (ignore_system_lyxrc ||
1800 isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
1801 os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
1805 if (ignore_system_lyxrc ||
1806 isp_alt_lang != system_lyxrc.isp_alt_lang) {
1807 os << "\\alternate_language \"" << isp_alt_lang
1810 case RC_USE_ESC_CHARS:
1811 if (ignore_system_lyxrc ||
1812 isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
1813 os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
1817 if (ignore_system_lyxrc ||
1818 isp_esc_chars != system_lyxrc.isp_esc_chars) {
1819 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1821 case RC_USE_PERS_DICT:
1822 if (ignore_system_lyxrc ||
1823 isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
1824 os << "\\use_personal_dictionary "
1825 << convert<string>(isp_use_pers_dict)
1829 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
1830 os << "\\personal_dictionary \"" << isp_pers_dict
1833 case RC_USE_INP_ENC:
1834 if (ignore_system_lyxrc ||
1835 isp_use_input_encoding
1836 != system_lyxrc.isp_use_input_encoding) {
1837 os << "\\use_input_encoding "
1838 << convert<string>(isp_use_input_encoding)
1843 << "# LANGUAGE SUPPORT SECTION ##########################\n"
1846 case RC_RTL_SUPPORT:
1847 if (ignore_system_lyxrc ||
1848 rtl_support != system_lyxrc.rtl_support) {
1849 os << "\\rtl " << convert<string>(rtl_support) << '\n';
1851 case RC_LANGUAGE_PACKAGE:
1852 if (ignore_system_lyxrc ||
1853 language_package != system_lyxrc.language_package) {
1854 os << "\\language_package \"" << language_package
1857 case RC_LANGUAGE_GLOBAL_OPTIONS:
1858 if (ignore_system_lyxrc ||
1859 language_global_options
1860 != system_lyxrc.language_global_options) {
1861 os << "\\language_global_options \""
1862 << convert<string>(language_global_options)
1865 case RC_LANGUAGE_USE_BABEL:
1866 if (ignore_system_lyxrc ||
1867 language_use_babel != system_lyxrc.language_use_babel) {
1868 os << "\\language_use_babel \""
1869 << convert<string>(language_use_babel)
1872 case RC_LANGUAGE_COMMAND_BEGIN:
1873 if (ignore_system_lyxrc ||
1874 language_command_begin
1875 != system_lyxrc.language_command_begin) {
1876 os << "\\language_command_begin \""
1877 << language_command_begin
1880 case RC_LANGUAGE_COMMAND_END:
1881 if (ignore_system_lyxrc ||
1882 language_command_end
1883 != system_lyxrc.language_command_end) {
1884 os << "\\language_command_end \"" << language_command_end
1887 case RC_LANGUAGE_COMMAND_LOCAL:
1888 if (ignore_system_lyxrc ||
1889 language_command_local
1890 != system_lyxrc.language_command_local) {
1891 os << "\\language_command_local \""
1892 << language_command_local
1895 case RC_LANGUAGE_AUTO_BEGIN:
1896 if (ignore_system_lyxrc ||
1897 language_auto_begin != system_lyxrc.language_auto_begin) {
1898 os << "\\language_auto_begin "
1899 << convert<string>(language_auto_begin) << '\n';
1901 case RC_LANGUAGE_AUTO_END:
1902 if (ignore_system_lyxrc ||
1903 language_auto_end != system_lyxrc.language_auto_end) {
1904 os << "\\language_auto_end "
1905 << convert<string>(language_auto_end) << '\n';
1907 case RC_MARK_FOREIGN_LANGUAGE:
1908 if (ignore_system_lyxrc ||
1909 mark_foreign_language
1910 != system_lyxrc.mark_foreign_language) {
1911 os << "\\mark_foreign_language " <<
1912 convert<string>(mark_foreign_language) << '\n';
1916 << "# 2nd MISC SUPPORT SECTION ##########################\n"
1919 case RC_AUTO_NUMBER:
1920 if (ignore_system_lyxrc ||
1921 auto_number != system_lyxrc.auto_number) {
1922 os << "\\auto_number " << convert<string>(auto_number) << '\n';
1924 case RC_DEFAULT_LANGUAGE:
1925 if (ignore_system_lyxrc ||
1926 default_language != system_lyxrc.default_language) {
1927 os << "\\default_language " << default_language << '\n';
1931 << "# FORMATS SECTION ##########################\n"
1935 // New/modifed formats
1936 for (Formats::const_iterator cit = formats.begin();
1937 cit != formats.end(); ++cit) {
1938 Format const * format =
1939 system_formats.getFormat(cit->name());
1941 format->extension() != cit->extension() ||
1942 format->prettyname() != cit->prettyname() ||
1943 format->shortcut() != cit->shortcut() ||
1944 format->viewer() != cit->viewer() ||
1945 format->editor() != cit->editor())
1946 os << "\\format \"" << cit->name() << "\" \""
1947 << cit->extension() << "\" \""
1948 << cit->prettyname() << "\" \""
1949 << cit->shortcut() << "\" \""
1950 << cit->viewer() << "\" \""
1951 << cit->editor() << "\"\n";
1954 // Look for deleted formats
1955 for (Formats::const_iterator cit = system_formats.begin();
1956 cit != system_formats.end(); ++cit)
1957 if (!formats.getFormat(cit->name()))
1958 os << "\\format \"" << cit->name()
1959 << "\" \"\" \"\" \"\" \"\" \"\"\n";
1964 << "# CONVERTERS SECTION ##########################\n"
1968 // Look for new converters
1969 for (Converters::const_iterator cit = converters.begin();
1970 cit != converters.end(); ++cit) {
1971 Converter const * converter =
1972 system_converters.getConverter(cit->from,
1975 converter->command != cit->command ||
1976 converter->flags != cit->flags)
1977 os << "\\converter \"" << cit->from << "\" \""
1978 << cit->to << "\" \""
1979 << cit->command << "\" \""
1980 << cit->flags << "\"\n";
1983 // New/modifed converters
1984 for (Converters::const_iterator cit = system_converters.begin();
1985 cit != system_converters.end(); ++cit)
1986 if (!converters.getConverter(cit->from, cit->to))
1987 os << "\\converter \"" << cit->from
1988 << "\" \"" << cit->to << "\" \"\" \"\"\n";
1992 << "# COPIERS SECTION ##########################\n"
1995 // Look for new movers
1996 Movers::iterator const sysbegin = system_movers.begin();
1997 Movers::iterator const sysend = system_movers.end();
1999 for (Movers::iterator it = movers.begin(), end = movers.end();
2001 Movers::iterator const sysit =
2002 std::find_if(sysbegin, sysend, SameMover(*it));
2003 if (sysit == sysend) {
2004 std::string const & fmt = it->first;
2005 std::string const & command =
2006 it->second.command();
2008 os << "\\copier " << fmt
2009 << " \"" << command << "\"\n";
2013 // We don't actually delete SpecialisedMover(s) from the
2014 // map, just clear their 'command', so there's no need
2015 // to test for anything else.
2021 void LyXRC::set_font_norm_type()
2023 if (font_norm == "iso10646-1")
2024 font_norm_type = ISO_10646_1;
2025 else if (font_norm == "iso8859-1")
2026 font_norm_type = ISO_8859_1;
2027 else if (font_norm == "iso8859-3")
2028 font_norm_type = ISO_8859_3;
2029 else if (font_norm == "iso8859-4")
2030 font_norm_type = ISO_8859_4;
2031 else if (font_norm == "iso8859-6.8x")
2032 font_norm_type = ISO_8859_6_8;
2033 else if (font_norm == "iso8859-9")
2034 font_norm_type = ISO_8859_9;
2035 else if (font_norm == "iso8859-15")
2036 font_norm_type = ISO_8859_15;
2038 font_norm_type = OTHER_ENCODING;
2042 string const LyXRC::getDescription(LyXRCTags tag)
2047 case RC_ACCEPT_COMPOUND:
2048 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2052 case RC_USE_ALT_LANG:
2053 str = _("Specify an alternate language. The default is to use the language of the document.");
2056 case RC_ASCIIROFF_COMMAND:
2057 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.");
2060 case RC_ASCII_LINELEN:
2061 str = _("This is the maximum line length of an exported ASCII file (LaTeX, SGML or plain text).");
2064 case RC_AUTOREGIONDELETE:
2065 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2068 case RC_AUTORESET_OPTIONS:
2069 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2073 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2076 case RC_AUTO_NUMBER:
2079 case RC_BACKUPDIR_PATH:
2080 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.");
2083 case RC_BIBTEX_COMMAND:
2084 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2088 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2091 case RC_CHECKLASTFILES:
2092 str = _("Select to check whether the lastfiles still exist.");
2095 case RC_CHKTEX_COMMAND:
2096 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2105 case RC_CURSOR_FOLLOWS_SCROLLBAR:
2106 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.");
2109 case RC_CUSTOM_EXPORT_COMMAND:
2112 case RC_CUSTOM_EXPORT_FORMAT:
2115 case RC_CYGWIN_PATH_FIX:
2118 case RC_DATE_INSERT_FORMAT:
2119 //xgettext:no-c-format
2120 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2123 case RC_DEFAULT_LANGUAGE:
2124 str = _("New documents will be assigned this language.");
2127 case RC_DEFAULT_PAPERSIZE:
2128 str = _("Specify the default paper size.");
2131 case RC_DIALOGS_ICONIFY_WITH_MAIN:
2132 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2135 case RC_DISPLAY_GRAPHICS:
2136 str = _("Select how LyX will display any graphics.");
2139 case RC_DOCUMENTPATH:
2140 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2144 case RC_USE_ESC_CHARS:
2145 str = _("Specify additional chars that can be part of a word.");
2148 case RC_FONT_ENCODING:
2149 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2155 case RC_INDEX_COMMAND:
2156 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\".");
2163 case RC_KBMAP_PRIMARY:
2164 case RC_KBMAP_SECONDARY:
2165 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.");
2168 case RC_LABEL_INIT_LENGTH:
2169 str = _("Maximum number of words in the initialization string for a new label");
2172 case RC_LANGUAGE_AUTO_BEGIN:
2173 str = _("Select if a language switching command is needed at the beginning of the document.");
2176 case RC_LANGUAGE_AUTO_END:
2177 str = _("Select if a language switching command is needed at the end of the document.");
2180 case RC_LANGUAGE_COMMAND_BEGIN:
2181 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.");
2184 case RC_LANGUAGE_COMMAND_END:
2185 str = _("The LaTeX command for changing back to the language of the document.");
2188 case RC_LANGUAGE_COMMAND_LOCAL:
2189 str = _("The LaTeX command for local changing of the language.");
2192 case RC_LANGUAGE_GLOBAL_OPTIONS:
2193 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2196 case RC_LANGUAGE_PACKAGE:
2197 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2200 case RC_LANGUAGE_USE_BABEL:
2201 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2205 str = _("The file where the last-files information should be stored.");
2208 case RC_MAKE_BACKUP:
2209 str = _("De-select if you don't want LyX to create backup files.");
2212 case RC_MARK_FOREIGN_LANGUAGE:
2213 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2216 case RC_NUMLASTFILES:
2217 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."), maxlastfiles);
2220 case RC_PATH_PREFIX:
2221 str = _("Specify those directories which should be "
2222 "prepended to the PATH environment variable. "
2223 "Use the OS native format.");
2227 case RC_USE_PERS_DICT:
2228 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2231 case RC_POPUP_BOLD_FONT:
2232 str = _("The bold font in the dialogs.");
2235 case RC_POPUP_FONT_ENCODING:
2236 str = _("The encoding for the menu/popups fonts.");
2239 case RC_POPUP_NORMAL_FONT:
2240 str = _("The normal font in the dialogs.");
2244 str = _("Shows a typeset preview of things such as math");
2247 case RC_PREVIEW_HASHED_LABELS:
2248 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2251 case RC_PREVIEW_SCALE_FACTOR:
2252 str = _("Scale the preview size to suit.");
2255 case RC_PRINTCOLLCOPIESFLAG:
2256 str = _("The option for specifying whether the copies should be collated.");
2259 case RC_PRINTCOPIESFLAG:
2260 str = _("The option for specifying the number of copies to print.");
2264 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2267 case RC_PRINTEVENPAGEFLAG:
2268 str = _("The option to print only even pages.");
2271 case RC_PRINTEXSTRAOPTIONS:
2272 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2275 case RC_PRINTFILEEXTENSION:
2276 str = _("Extension of printer program output file. Usually \".ps\".");
2279 case RC_PRINTLANDSCAPEFLAG:
2280 str = _("The option to print out in landscape.");
2283 case RC_PRINTODDPAGEFLAG:
2284 str = _("The option to print only odd pages.");
2287 case RC_PRINTPAGERANGEFLAG:
2288 str = _("The option for specifying a comma-separated list of pages to print.");
2291 case RC_PRINTPAPERDIMENSIONFLAG:
2292 str = _("Option to specify the dimensions of the print paper.");
2295 case RC_PRINTPAPERFLAG:
2296 str = _("The option to specify paper type.");
2299 case RC_PRINTREVERSEFLAG:
2300 str = _("The option to reverse the order of the pages printed.");
2303 case RC_PRINTSPOOL_COMMAND:
2304 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.");
2307 case RC_PRINTSPOOL_PRINTERPREFIX:
2308 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.");
2311 case RC_PRINTTOFILE:
2312 str = _("Option to pass to the print program to print to a file.");
2315 case RC_PRINTTOPRINTER:
2316 str = _("Option to pass to the print program to print on a specific printer.");
2319 case RC_PRINT_ADAPTOUTPUT:
2320 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2323 case RC_PRINT_COMMAND:
2324 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2327 case RC_RTL_SUPPORT:
2328 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2332 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2335 case RC_SCREEN_FONT_ENCODING:
2336 str = _("The encoding for the screen fonts.");
2339 case RC_SCREEN_FONT_ROMAN:
2340 case RC_SCREEN_FONT_SANS:
2341 case RC_SCREEN_FONT_TYPEWRITER:
2342 str = _("The screen fonts used to display the text while editing.");
2345 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
2346 case RC_SCREEN_FONT_SANS_FOUNDRY:
2347 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2350 case RC_SCREEN_FONT_SCALABLE:
2351 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.");
2354 case RC_SCREEN_FONT_SIZES:
2355 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2358 case RC_SCREEN_ZOOM:
2359 //xgettext:no-c-format
2360 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2364 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2370 case RC_SHOW_BANNER:
2371 str = _("De-select if you don't want the startup banner.");
2374 case RC_SPELL_COMMAND:
2375 str = _("What command runs the spell checker?");
2378 case RC_TEMPDIRPATH:
2379 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2382 case RC_TEMPLATEPATH:
2383 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2386 case RC_TEX_ALLOWS_SPACES:
2390 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2402 case RC_USE_INP_ENC:
2403 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.");
2406 case RC_USE_SPELL_LIB:
2409 case RC_VIEWDVI_PAPEROPTION:
2410 str = _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2417 str = _("The number of lines that are scrolled by mice with wheels or five button mice.");
2427 // The global instance
2430 // The global copy of the system lyxrc entries (everything except preferences)