X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyXRC.cpp;h=a07c8e6d805cd3c6f51aefe4585897b6d69b6f7a;hb=8ea66efe16ad109a5c107716185fb82bbebca8c8;hp=3aacf9638f061ce757c30fee2a498987f2d804c2;hpb=7f14df4af48bd887462b85f53b1395b1ec158316;p=lyx.git diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 3aacf9638f..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 = 6; // younes: add use_qimage option +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 }, @@ -302,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; @@ -815,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; @@ -1079,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; @@ -1118,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; } @@ -2301,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'; @@ -2696,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() << "\" \"" @@ -2714,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"; } } @@ -2723,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: { @@ -2887,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: