X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyXRC.cpp;h=1d7b3c3d8e345a041b3ce615dbccaee477919155;hb=c57dc64116d8d1beb87a6b76a54cfcf82314259a;hp=1a94ca0d403537e5538cc722a92d550b8f6bc8cf;hpb=ad1dc2fd6bb744c2c610d93debe1352b155df305;p=lyx.git diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 1a94ca0d40..1d7b3c3d8e 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -113,6 +113,7 @@ LexerKeyword lyxrcTags[] = { { "\\group_layouts", LyXRC::RC_GROUP_LAYOUTS }, { "\\gui_language", LyXRC::RC_GUI_LANGUAGE }, { "\\hunspelldir_path", LyXRC::RC_HUNSPELLDIR_PATH }, + { "\\icon_set", LyXRC::RC_ICON_SET }, { "\\index_alternatives", LyXRC::RC_INDEX_ALTERNATIVES }, { "\\index_command", LyXRC::RC_INDEX_COMMAND }, { "\\input", LyXRC::RC_INPUT }, @@ -191,6 +192,7 @@ LexerKeyword lyxrcTags[] = { { "\\template_path", LyXRC::RC_TEMPLATEPATH }, { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES }, { "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS }, + { "\\texinputs_prefix", LyXRC::RC_TEXINPUTS_PREFIX }, { "\\thesaurusdir_path", LyXRC::RC_THESAURUSDIRPATH }, { "\\ui_file", LyXRC::RC_UIFILE }, { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE }, @@ -222,9 +224,12 @@ LyXRC::LyXRC() void LyXRC::setDefaults() { + icon_set = string(); bind_file = "cua"; def_file = "default"; ui_file = "default"; + // The current document directory + texinputs_prefix = "."; // Get printer from the environment. If fail, use default "", // assuming that everything is set up correctly. printer = getEnv("PRINTER"); @@ -497,6 +502,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) lexrc >> tex_allows_spaces; break; + case RC_TEXINPUTS_PREFIX: + lexrc >> texinputs_prefix; + break; + case RC_KBMAP: lexrc >> use_kbmap; break; @@ -532,7 +541,7 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) case RC_FORCE_PAINT_SINGLE_CHAR: lexrc >> force_paint_single_char; break; - + case RC_PRINTER: lexrc >> printer; break; @@ -829,6 +838,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) lexrc >> check_lastfiles; break; + case RC_ICON_SET: + lexrc >> icon_set; + break; + case RC_SCREEN_FONT_ROMAN: if (lexrc.next()) { roman_font_name = lexrc.getString(); @@ -1133,7 +1146,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) } case RC_EDITOR_ALTERNATIVES: { string format, command; - lexrc >> format >> command; + if (lexrc.next()) + format = lexrc.getString(); + if (lexrc.eatLine()) + command = lexrc.getString(); editor_alternatives[format].insert(command); break; } @@ -1141,7 +1157,7 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) case RC_DEFAULT_VIEW_FORMAT: lexrc >> default_view_format; break; - + case RC_DEFAULT_LANGUAGE: lexrc >> default_language; break; @@ -1232,11 +1248,11 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) run_mode = single_instance ? USE_REMOTE : NEW_INSTANCE; break; case RC_FORWARD_SEARCH_DVI: - if (lexrc.next(true)) + if (lexrc.next(true)) forward_search_dvi = lexrc.getString(); break; case RC_FORWARD_SEARCH_PDF: - if (lexrc.next(true)) + if (lexrc.next(true)) forward_search_pdf = lexrc.getString(); break; case RC_EXPORT_OVERWRITE: @@ -1329,7 +1345,7 @@ namespace { // Escape \ and " so that LyXLex can read the string later string escapeCommand(string const & str) { - return subst(subst(str , "\\", "\\\\"), + return subst(subst(str , "\\", "\\\\"), "\"", "\\\""); } @@ -1339,7 +1355,7 @@ namespace { void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) const { LyXRCTags tag = RC_LAST; - + if (!name.empty()) { for (int i = 0; i != lyxrcCount; ++i) if ("\\" + name == lyxrcTags[i].tag) @@ -1596,8 +1612,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c if (tag != RC_LAST) break; case RC_TEX_EXPECTS_WINDOWS_PATHS: - if (ignore_system_lyxrc || - windows_style_tex_paths != system_lyxrc.windows_style_tex_paths) { + // Don't write this setting to the preferences file, + // but allow temporary changes (bug 7557). + if (ignore_system_lyxrc) { os << "\\tex_expects_windows_paths " << convert(windows_style_tex_paths) << '\n'; } @@ -1729,6 +1746,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c << "# SCREEN & FONTS SECTION ############################\n" << "#\n\n"; + case RC_ICON_SET: + if (ignore_system_lyxrc || + icon_set != system_lyxrc.icon_set) { + os << "\\icon_set \"" << icon_set + << "\"\n"; + } + if (tag != RC_LAST) + break; + case RC_SCREEN_DPI: if (ignore_system_lyxrc || dpi != system_lyxrc.dpi) { @@ -2195,6 +2221,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c << "# TEX SECTION #######################################\n" << "#\n\n"; + case RC_TEXINPUTS_PREFIX: + if (ignore_system_lyxrc || + texinputs_prefix != system_lyxrc.texinputs_prefix) { + os << "\\texinputs_prefix \"" << texinputs_prefix << "\"\n"; + } + if (tag != RC_LAST) + break; + case RC_FONT_ENCODING: if (ignore_system_lyxrc || fontenc != system_lyxrc.fontenc) { @@ -2546,7 +2580,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c language_package_selection != system_lyxrc.language_package_selection) { os << "\\language_package_selection "; switch (language_package_selection) { - case LP_AUTO: + case LP_AUTO: os << "0\n"; break; case LP_BABEL: @@ -2702,7 +2736,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c format->viewer() != cit->viewer() || format->editor() != cit->editor() || format->documentFormat() != cit->documentFormat() || - format->vectorFormat() != cit->vectorFormat()) { + format->vectorFormat() != cit->vectorFormat() || + format->inExportMenu() != cit->inExportMenu()) { os << "\\format \"" << cit->name() << "\" \"" << cit->extension() << "\" \"" << cit->prettyname() << "\" \"" @@ -2714,6 +2749,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c flags.push_back("document"); if (cit->vectorFormat()) flags.push_back("vector"); + if (cit->inExportMenu()) + flags.push_back("menu=export"); + os << getStringFromVector(flags); os << "\"\n"; } @@ -2730,19 +2768,19 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c case RC_VIEWER_ALTERNATIVES: { Alternatives::const_iterator it = viewer_alternatives.begin(); Alternatives::const_iterator const en = viewer_alternatives.end(); - Alternatives::const_iterator const sysend = + Alternatives::const_iterator const sysend = system_lyxrc.viewer_alternatives.end(); for (; it != en; ++it) { string const & fmt = it->first; CommandSet const & cmd = it->second; CommandSet::const_iterator sit = cmd.begin(); CommandSet::const_iterator const sen = cmd.end(); - Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? + Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? system_lyxrc.viewer_alternatives.begin() : // we won't use it in this case system_lyxrc.viewer_alternatives.find(fmt); for (; sit != sen; ++sit) { string const & cmd = *sit; - if (ignore_system_lyxrc + if (ignore_system_lyxrc || sysfmt == sysend // format not found || sysfmt->second.count(cmd) == 0 // this command not found ) @@ -2755,19 +2793,19 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c case RC_EDITOR_ALTERNATIVES: { Alternatives::const_iterator it = editor_alternatives.begin(); Alternatives::const_iterator const en = editor_alternatives.end(); - Alternatives::const_iterator const sysend = + Alternatives::const_iterator const sysend = system_lyxrc.editor_alternatives.end(); for (; it != en; ++it) { string const & fmt = it->first; CommandSet const & cmd = it->second; CommandSet::const_iterator sit = cmd.begin(); CommandSet::const_iterator const sen = cmd.end(); - Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? + Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? system_lyxrc.editor_alternatives.begin() : // we won't use it in this case system_lyxrc.editor_alternatives.find(fmt); for (; sit != sen; ++sit) { string const & cmd = *sit; - if (ignore_system_lyxrc + if (ignore_system_lyxrc || sysfmt == sysend // format not found || sysfmt->second.count(cmd) == 0 // this command not found ) @@ -2817,7 +2855,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c << "\" \"" << cit->to << "\" \"\" \"\"\n"; if (tag != RC_LAST) break; - + case RC_COPIER: if (tag == RC_LAST) os << "\n#\n" @@ -2863,6 +2901,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) // if we forget an element. LyXRC::LyXRCTags tag = LyXRC::RC_LAST; switch (tag) { + case LyXRC::RC_LAST: case LyXRC::RC_ACCEPT_COMPOUND: case LyXRC::RC_ALT_LANG: case LyXRC::RC_PLAINTEXT_LINELEN: @@ -2915,6 +2954,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_FILEFORMAT: case LyXRC::RC_GROUP_LAYOUTS: case LyXRC::RC_HUNSPELLDIR_PATH: + case LyXRC::RC_ICON_SET: case LyXRC::RC_INDEX_ALTERNATIVES: case LyXRC::RC_INDEX_COMMAND: case LyXRC::RC_JBIBTEX_COMMAND: @@ -2943,7 +2983,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_PARAGRAPH_MARKERS: case LyXRC::RC_PATH_PREFIX: if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) { - prependEnvPath("PATH", lyxrc.path_prefix); + prependEnvPath("PATH", lyxrc_new.path_prefix); } case LyXRC::RC_PREVIEW: case LyXRC::RC_PREVIEW_HASHED_LABELS: @@ -2994,6 +3034,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) { os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths); } + case LyXRC::RC_TEXINPUTS_PREFIX: case LyXRC::RC_THESAURUSDIRPATH: case LyXRC::RC_UIFILE: case LyXRC::RC_USER_EMAIL: @@ -3021,7 +3062,6 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_DEFAULT_DECIMAL_POINT: case LyXRC::RC_SCROLL_WHEEL_ZOOM: case LyXRC::RC_CURSOR_WIDTH: - case LyXRC::RC_LAST: break; } } @@ -3095,7 +3135,7 @@ string const LyXRC::getDescription(LyXRCTags tag) break; case RC_CURSOR_WIDTH: - str = _("Configure the width of the text cursor. Automatic zoom controled cursor width used when set to 0."); + str = _("Configure the width of the text cursor. Automatic zoom-controlled cursor width used when set to 0."); break; case RC_SCROLL_BELOW_DOCUMENT: @@ -3287,7 +3327,7 @@ string const LyXRC::getDescription(LyXRCTags tag) case RC_PATH_PREFIX: str = _("Specify those directories which should be " - "prepended to the PATH environment variable. " + "prepended to the PATH environment variable.\n" "Use the OS native format."); break; @@ -3444,6 +3484,13 @@ string const LyXRC::getDescription(LyXRCTags tag) case RC_TEX_EXPECTS_WINDOWS_PATHS: break; + case RC_TEXINPUTS_PREFIX: + str = _("Specify those directories which should be " + "prepended to the TEXINPUTS environment variable.\n" + "A '.' represents the current document directory. " + "Use the OS native format."); + break; + case RC_UIFILE: str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories."); break;