X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyXRC.cpp;h=a07c8e6d805cd3c6f51aefe4585897b6d69b6f7a;hb=8ea66efe16ad109a5c107716185fb82bbebca8c8;hp=6f5a19e6079d85db9f7039c92a370026606ae73e;hpb=5014b38cb7ca1967275050a90fcfe1aeade963e4;p=lyx.git diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 6f5a19e607..a07c8e6d80 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -55,7 +55,7 @@ namespace os = support::os; namespace { -static unsigned int const LYXRC_FILEFORMAT = 5; // vfr: add default length unit +static unsigned int const LYXRC_FILEFORMAT = 7; // gb: add mime types // when adding something to this array keep it sorted! LexerKeyword lyxrcTags[] = { @@ -78,6 +78,7 @@ LexerKeyword lyxrcTags[] = { { "\\completion_inline_dots", LyXRC::RC_COMPLETION_INLINE_DOTS }, { "\\completion_inline_math", LyXRC::RC_COMPLETION_INLINE_MATH }, { "\\completion_inline_text", LyXRC::RC_COMPLETION_INLINE_TEXT }, + { "\\completion_minlength", LyXRC::RC_COMPLETION_MINLENGTH }, { "\\completion_popup_after_complete", LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE }, { "\\completion_popup_delay", LyXRC::RC_COMPLETION_POPUP_DELAY }, { "\\completion_popup_math", LyXRC::RC_COMPLETION_POPUP_MATH }, @@ -199,6 +200,7 @@ LexerKeyword lyxrcTags[] = { { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE }, { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS }, { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE }, + { "\\use_qimage", LyXRC::RC_USE_QIMAGE }, // compatibility with versions older than 1.4.0 only { "\\use_system_colors", LyXRC::RC_USE_SYSTEM_COLORS }, { "\\use_tooltip", LyXRC::RC_USE_TOOLTIP }, @@ -301,6 +303,7 @@ void LyXRC::setDefaults() #endif spellchecker_accept_compound = false; spellcheck_continuously = false; + completion_minlength = 6; spellcheck_notes = true; use_kbmap = false; rtl_support = true; @@ -337,6 +340,7 @@ void LyXRC::setDefaults() use_system_colors = false; use_tooltip = true; use_pixmap_cache = false; + use_qimage = true; converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months user_name = to_utf8(support::user_name()); user_email = to_utf8(support::user_email()); @@ -813,6 +817,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) lexrc >> completion_popup_after_complete; break; + case RC_COMPLETION_MINLENGTH: + lexrc >> completion_minlength; + break; + case RC_NUMLASTFILES: lexrc >> num_lastfiles; break; @@ -951,6 +959,9 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) case RC_USE_PIXMAP_CACHE: lexrc >> use_pixmap_cache; break; + case RC_USE_QIMAGE: + lexrc >> use_qimage; + break; case RC_SPELLCHECKER: lexrc >> spellchecker; break; @@ -1074,28 +1085,29 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) break; } case RC_FILEFORMAT: { + bool ok = true; string format, extensions, prettyname, shortcut; - lexrc >> format >> extensions >> prettyname >> shortcut; + if (!(lexrc >> format >> extensions)) + ok = false; + if (ok && lexrc.next(true)) + prettyname = lexrc.getString(); + else + ok = false; + if (ok) + if(!(lexrc >> shortcut)) + ok = false; string viewer, editor; - if (lexrc.next(true)) + if (ok && lexrc.next(true)) viewer = lexrc.getString(); - if (lexrc.next(true)) + else + ok = false; + if (ok && lexrc.next(true)) editor = lexrc.getString(); - string flags; - // Hack to ensure compatibility with versions older - // than 1.5.0 - int le = lexrc.lex(); - if (le != Lexer::LEX_FEOF && le != Lexer::LEX_UNDEF) { - flags = lexrc.getString(); - if (le != Lexer::LEX_DATA) { - // We have got a known token. - // Therefore this is an old style - // format definition without - // flags. - lexrc.pushToken(flags); - flags.erase(); - } - } + else + ok = false; + string flags, mime; + if (!(lexrc >> flags >> mime)) + ok = false; int flgs = Format::none; while (!flags.empty()) { string flag; @@ -1113,14 +1125,16 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format) << flag << "' for format `" << format << "'."); } - if (prettyname.empty()) { + if (!ok) + LYXERR0("Syntax error in format " << format); + else if (prettyname.empty()) { if (theConverters().formatIsUsed(format)) LYXERR0("Can't delete format " << format); else formats.erase(format); } else { formats.add(format, extensions, prettyname, - shortcut, viewer, editor, flgs); + shortcut, viewer, editor, mime, flgs); } break; } @@ -2296,7 +2310,16 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; - case RC_NUMLASTFILES: + case RC_COMPLETION_MINLENGTH: + if (ignore_system_lyxrc || + completion_minlength != system_lyxrc.completion_minlength) { + os << "\\completion_minlength " << convert(completion_minlength) + << '\n'; + } + if (tag != RC_LAST) + break; + + case RC_NUMLASTFILES: if (ignore_system_lyxrc || num_lastfiles != system_lyxrc.num_lastfiles) { os << "\\num_lastfiles " << num_lastfiles << '\n'; @@ -2439,6 +2462,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; + case RC_USE_QIMAGE: + if (ignore_system_lyxrc || + use_qimage != system_lyxrc.use_qimage) { + os << "\\use_qimage " + << convert(use_qimage) + << '\n'; + } + if (tag != RC_LAST) + break; os << "\n#\n" << "# LANGUAGE SUPPORT SECTION ##########################\n" @@ -2682,7 +2714,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c format->editor() != cit->editor() || format->documentFormat() != cit->documentFormat() || format->vectorFormat() != cit->vectorFormat() || - format->inExportMenu() != cit->inExportMenu()) { + format->inExportMenu() != cit->inExportMenu() || + format->mime() != cit->mime()) { os << "\\format \"" << cit->name() << "\" \"" << cit->extensions() << "\" \"" << cit->prettyname() << "\" \"" @@ -2700,7 +2733,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c flags.push_back("menu=export"); os << getStringFromVector(flags); - os << "\"\n"; + os << "\" \"" << cit->mime() << "\"\n"; } } @@ -2709,7 +2742,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c cit != system_formats.end(); ++cit) if (!formats.getFormat(cit->name())) os << "\\format \"" << cit->name() - << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n"; + << "\" \"\" \"\" \"\" \"\" \"\" \"\" \"\"\n"; if (tag != RC_LAST) break; case RC_VIEWER_ALTERNATIVES: { @@ -2873,6 +2906,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_COMPLETION_POPUP_DELAY: case LyXRC::RC_COMPLETION_POPUP_MATH: case LyXRC::RC_COMPLETION_POPUP_TEXT: + case LyXRC::RC_COMPLETION_MINLENGTH: case LyXRC::RC_USELASTFILEPOS: case LyXRC::RC_LOADSESSION: case LyXRC::RC_CHKTEX_COMMAND: @@ -2993,6 +3027,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_USE_SYSTEM_COLORS: case LyXRC::RC_USE_TOOLTIP: case LyXRC::RC_USE_PIXMAP_CACHE: + case LyXRC::RC_USE_QIMAGE: case LyXRC::RC_VIEWDVI_PAPEROPTION: case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON: case LyXRC::RC_SINGLE_INSTANCE: