X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyXRC.cpp;h=e6244f2d2ba03189d2ea8f0b015eb1f7dbd7f3a3;hb=28be7d552f62cc02fa86d7f79201d089bfb2d7b5;hp=4fb1b027c0ecf9fbbba6cd01bef885bd1db62d11;hpb=699a6db9fa168f91458a17d4f30c124e52a38054;p=lyx.git diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 4fb1b027c0..e6244f2d2b 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -18,6 +18,7 @@ #include "LyXRC.h" +#include "BufferList.h" #include "ColorSet.h" #include "Converter.h" #include "FontEnums.h" @@ -58,7 +59,7 @@ namespace { // The format should also be updated in configure.py, and conversion code // should be added to prefs2prefs_prefs.py. -static unsigned int const LYXRC_FILEFORMAT = 19; // rgh: remove print support +static unsigned int const LYXRC_FILEFORMAT = 22; // ef: pygmentize_command // when adding something to this array keep it sorted! LexerKeyword lyxrcTags[] = { @@ -123,6 +124,7 @@ LexerKeyword lyxrcTags[] = { { "\\index_alternatives", LyXRC::RC_INDEX_ALTERNATIVES }, { "\\index_command", LyXRC::RC_INDEX_COMMAND }, { "\\input", LyXRC::RC_INPUT }, + { "\\jbibtex_alternatives", LyXRC::RC_JBIBTEX_ALTERNATIVES }, { "\\jbibtex_command", LyXRC::RC_JBIBTEX_COMMAND }, { "\\jindex_command", LyXRC::RC_JINDEX_COMMAND }, { "\\kbmap", LyXRC::RC_KBMAP }, @@ -156,6 +158,7 @@ LexerKeyword lyxrcTags[] = { { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG }, { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG }, { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG }, + { "\\pygmentize_command", LyXRC::RC_PYGMENTIZE_COMMAND }, { "\\save_compressed", LyXRC::RC_SAVE_COMPRESSED }, { "\\save_origin", LyXRC::RC_SAVE_ORIGIN }, { "\\screen_dpi", LyXRC::RC_SCREEN_DPI }, @@ -188,6 +191,8 @@ LexerKeyword lyxrcTags[] = { { "\\thesaurusdir_path", LyXRC::RC_THESAURUSDIRPATH }, { "\\ui_file", LyXRC::RC_UIFILE }, { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE }, + { "\\use_converter_needauth", LyXRC::RC_USE_CONVERTER_NEEDAUTH }, + { "\\use_converter_needauth_forbidden", LyXRC::RC_USE_CONVERTER_NEEDAUTH_FORBIDDEN }, { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS }, { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE }, { "\\use_qimage", LyXRC::RC_USE_QIMAGE }, @@ -233,13 +238,15 @@ void LyXRC::setDefaults() default_view_format = "pdf2"; default_otf_view_format = "pdf4"; chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"; - bibtex_command = "bibtex"; + bibtex_command = "automatic"; fontenc = "default"; index_command = "makeindex -c -q"; nomencl_command = "makeindex -s nomencl.ist"; + pygmentize_command = string(); dpi = 75; // Because a screen is typically wider than a piece of paper: zoom = 150; + currentZoom = zoom; allow_geometry_session = true; // Default LaTeX font size: font_sizes[FONT_SIZE_TINY] = "5.0"; @@ -261,7 +268,7 @@ void LyXRC::setDefaults() auto_reset_options = false; plaintext_linelen = 65; mouse_wheel_speed = 1.0; - num_lastfiles = maxlastfiles; + num_lastfiles = 20; check_lastfiles = true; use_lastfilepos = true; load_session = false; @@ -315,6 +322,8 @@ void LyXRC::setDefaults() preview_hashed_labels = false; preview_scale_factor = 1.0; use_converter_cache = true; + use_converter_needauth_forbidden = true; + use_converter_needauth = true; use_system_colors = false; use_tooltip = true; use_pixmap_cache = false; @@ -537,6 +546,12 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) lexrc >> print_paper_flag; break; + case RC_PYGMENTIZE_COMMAND: + if (lexrc.next(true)) { + pygmentize_command = lexrc.getString(); + } + break; + case RC_VIEWDVI_PAPEROPTION: if (lexrc.next()) view_dvi_paper_option = lexrc.getString(); @@ -568,6 +583,12 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) } break; + case RC_JBIBTEX_ALTERNATIVES: + if (lexrc.next(true)) { + jbibtex_alternatives.insert(lexrc.getString()); + } + break; + case RC_INDEX_ALTERNATIVES: if (lexrc.next(true)) { index_alternatives.insert(lexrc.getString()); @@ -604,6 +625,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) case RC_SCREEN_ZOOM: lexrc >> zoom; + if (zoom < 10) + zoom = 10; break; case RC_GEOMETRY_SESSION: @@ -632,45 +655,33 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) break; case RC_DOCUMENTPATH: - if (lexrc.next()) { + if (lexrc.next()) document_path = os::internal_path(lexrc.getString()); - document_path = expandPath(document_path); - } break; case RC_EXAMPLEPATH: - if (lexrc.next()) { + if (lexrc.next()) example_path = os::internal_path(lexrc.getString()); - example_path = expandPath(example_path); - } break; case RC_TEMPLATEPATH: - if (lexrc.next()) { + if (lexrc.next()) template_path = os::internal_path(lexrc.getString()); - template_path = expandPath(template_path); - } break; case RC_TEMPDIRPATH: - if (lexrc.next()) { + if (lexrc.next()) tempdir_path = os::internal_path(lexrc.getString()); - tempdir_path = expandPath(tempdir_path); - } break; case RC_THESAURUSDIRPATH: - if (lexrc.next()) { + if (lexrc.next()) thesaurusdir_path = os::internal_path(lexrc.getString()); - thesaurusdir_path = expandPath(thesaurusdir_path); - } break; case RC_HUNSPELLDIR_PATH: - if (lexrc.next()) { + if (lexrc.next()) hunspelldir_path = os::internal_path(lexrc.getString()); - hunspelldir_path = expandPath(hunspelldir_path); - } break; case RC_USELASTFILEPOS: @@ -811,10 +822,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) break; case RC_SERVERPIPE: - if (lexrc.next()) { + if (lexrc.next()) lyxpipes = os::internal_path(lexrc.getString()); - lyxpipes = expandPath(lyxpipes); - } break; case RC_CURSOR_FOLLOWS_SCROLLBAR: @@ -899,10 +908,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) lexrc >> save_origin; break; case RC_BACKUPDIR_PATH: - if (lexrc.next()) { + if (lexrc.next()) backupdir_path = os::internal_path(lexrc.getString()); - backupdir_path = expandPath(backupdir_path); - } break; case RC_DEFAULT_DECIMAL_POINT: lexrc >> default_decimal_point; @@ -996,16 +1003,17 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) case RC_VIEWER: { string format, command; lexrc >> format >> command; - formats.setViewer(format, command); + theFormats().setViewer(format, command); break; } case RC_FILEFORMAT: { bool ok = true; - string format, extensions, prettyname, shortcut; + string format, extensions, shortcut; + docstring prettyname; if (!(lexrc >> format >> extensions)) ok = false; if (ok && lexrc.next(true)) - prettyname = lexrc.getString(); + prettyname = lexrc.getDocString(); else ok = false; if (ok) @@ -1046,25 +1054,27 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) if (theConverters().formatIsUsed(format)) LYXERR0("Can't delete format " << format); else - formats.erase(format); + theFormats().erase(format); } else { - formats.add(format, extensions, prettyname, + theFormats().add(format, extensions, prettyname, shortcut, viewer, editor, mime, flgs); } break; } case RC_VIEWER_ALTERNATIVES: { string format, command; - lexrc >> format; - lexrc >> command; - viewer_alternatives[format].insert(command); + if ((lexrc >> format) && lexrc.next(true)) { + command = lexrc.getString(); + viewer_alternatives[format].insert(command); + } break; } case RC_EDITOR_ALTERNATIVES: { string format, command; - lexrc >> format; - lexrc >> command; - editor_alternatives[format].insert(command); + if ((lexrc >> format) && lexrc.next(true)) { + command = lexrc.getString(); + editor_alternatives[format].insert(command); + } break; } @@ -1122,6 +1132,12 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) case RC_USE_CONVERTER_CACHE: lexrc >> use_converter_cache; break; + case RC_USE_CONVERTER_NEEDAUTH_FORBIDDEN: + lexrc >> use_converter_needauth_forbidden; + break; + case RC_USE_CONVERTER_NEEDAUTH: + lexrc >> use_converter_needauth; + break; case RC_CONVERTER_CACHE_MAXAGE: lexrc >> converter_cache_maxage; break; @@ -1220,8 +1236,9 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) } /// Update converters data-structures - theConverters().update(formats); + theConverters().update(theFormats()); theConverters().buildGraph(); + theBufferList().invalidateConverterCache(); return ReadOK; } @@ -1440,6 +1457,18 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; + case RC_JBIBTEX_ALTERNATIVES: { + CommandSet::const_iterator it = jbibtex_alternatives.begin(); + CommandSet::const_iterator end = jbibtex_alternatives.end(); + for ( ; it != end; ++it) { + if (ignore_system_lyxrc + || !system_lyxrc.jbibtex_alternatives.count(*it)) + os << "\\jbibtex_alternatives \"" + << *it << "\"\n"; + } + if (tag != RC_LAST) + break; + } case RC_INDEX_ALTERNATIVES: { CommandSet::const_iterator it = index_alternatives.begin(); CommandSet::const_iterator end = index_alternatives.end(); @@ -1480,6 +1509,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; + case RC_PYGMENTIZE_COMMAND: + if (ignore_system_lyxrc || + pygmentize_command != system_lyxrc.pygmentize_command) { + os << "\\pygmentize_command \"" << escapeCommand(pygmentize_command) << "\"\n"; + } + if (tag != RC_LAST) + break; case RC_TEX_EXPECTS_WINDOWS_PATHS: // Don't write this setting to the preferences file, // but allow temporary changes (bug 7557). @@ -1602,6 +1638,24 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c if (tag != RC_LAST) break; + case RC_USE_CONVERTER_NEEDAUTH_FORBIDDEN: + if (ignore_system_lyxrc || + use_converter_needauth_forbidden != system_lyxrc.use_converter_needauth_forbidden) { + os << "\\use_converter_needauth_forbidden " + << convert(use_converter_needauth_forbidden) << '\n'; + } + if (tag != RC_LAST) + break; + + case RC_USE_CONVERTER_NEEDAUTH: + if (ignore_system_lyxrc || + use_converter_needauth != system_lyxrc.use_converter_needauth) { + os << "\\use_converter_needauth " + << convert(use_converter_needauth) << '\n'; + } + if (tag != RC_LAST) + break; + case RC_CONVERTER_CACHE_MAXAGE: if (ignore_system_lyxrc || converter_cache_maxage != system_lyxrc.converter_cache_maxage) { @@ -2520,10 +2574,10 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c case RC_FILEFORMAT: // New/modified formats - for (Formats::const_iterator cit = formats.begin(); - cit != formats.end(); ++cit) { + for (Formats::const_iterator cit = theFormats().begin(); + cit != theFormats().end(); ++cit) { Format const * format = - system_formats.getFormat(cit->name()); + theSystemFormats().getFormat(cit->name()); if (!format || format->extensions() != cit->extensions() || format->prettyname() != cit->prettyname() || @@ -2536,7 +2590,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c format->mime() != cit->mime()) { os << "\\format \"" << cit->name() << "\" \"" << cit->extensions() << "\" \"" - << cit->prettyname() << "\" \"" + << to_utf8(cit->prettyname()) << "\" \"" << cit->shortcut() << "\" \"" << escapeCommand(cit->viewer()) << "\" \"" << escapeCommand(cit->editor()) << "\" \""; @@ -2556,9 +2610,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } // Look for deleted formats - for (Formats::const_iterator cit = system_formats.begin(); - cit != system_formats.end(); ++cit) - if (!formats.getFormat(cit->name())) + for (Formats::const_iterator cit = theSystemFormats().begin(); + cit != theSystemFormats().end(); ++cit) + if (!theFormats().getFormat(cit->name())) os << "\\format \"" << cit->name() << "\" \"\" \"\" \"\" \"\" \"\" \"\" \"\"\n"; if (tag != RC_LAST) @@ -2767,8 +2821,10 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_INDEX_ALTERNATIVES: case LyXRC::RC_INDEX_COMMAND: case LyXRC::RC_JBIBTEX_COMMAND: + case LyXRC::RC_JBIBTEX_ALTERNATIVES: case LyXRC::RC_JINDEX_COMMAND: case LyXRC::RC_NOMENCL_COMMAND: + case LyXRC::RC_PYGMENTIZE_COMMAND: case LyXRC::RC_INPUT: case LyXRC::RC_KBMAP: case LyXRC::RC_KBMAP_PRIMARY: @@ -2842,6 +2898,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_USER_EMAIL: case LyXRC::RC_USER_NAME: case LyXRC::RC_USE_CONVERTER_CACHE: + case LyXRC::RC_USE_CONVERTER_NEEDAUTH_FORBIDDEN: + case LyXRC::RC_USE_CONVERTER_NEEDAUTH: case LyXRC::RC_USE_SYSTEM_COLORS: case LyXRC::RC_USE_TOOLTIP: case LyXRC::RC_USE_PIXMAP_CACHE: @@ -2934,6 +2992,14 @@ string const LyXRC::getDescription(LyXRCTags tag) case RC_CONVERTER: break; + case RC_CONVERTER_NEEDAUTH_FORBIDDEN: + str = _("Forbid use of external converters with 'needauth' option to prevent undesired effects."); + break; + + case RC_CONVERTER_NEEDAUTH: + str = _("Ask user before calling external converters with 'needauth' option to prevent undesired effects."); + break; + case RC_COPIER: break; @@ -3017,6 +3083,10 @@ string const LyXRC::getDescription(LyXRCTags tag) str = _("Define the options of makeindex (cf. man makeindex) to be used for nomenclatures. This might differ from the index processing options."); break; + case RC_PYGMENTIZE_COMMAND: + str = _("The command to run the python pygments syntax highlighter."); + break; + case RC_INPUT: break; @@ -3075,8 +3145,7 @@ string const LyXRC::getDescription(LyXRCTags tag) break; case RC_MOUSE_WHEEL_SPEED: - str = bformat(_("The scrolling speed of the mouse wheel."), - maxlastfiles); + str = _("The scrolling speed of the mouse wheel."); break; case RC_COMPLETION_POPUP_DELAY: