X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FText3.cpp;h=22253f27f4b9a184060f96023e41cd8323d0b7d4;hb=472953dbe14b9d0fad8f50e9ca80e114bf30b946;hp=5e9f6cff38b20571b40248fab1788bac76129458;hpb=5d269df60674df4b8f5f56cdf4e16c88f23df32b;p=lyx.git diff --git a/src/Text3.cpp b/src/Text3.cpp index 5e9f6cff38..22253f27f4 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -313,6 +313,14 @@ static bool doInsertInset(Cursor & cur, Text * text, } text->insertInset(cur, inset); + InsetText * inset_text = inset->asInsetText(); + if (inset_text) { + Font const & font = inset->inheritFont() + ? cur.bv().textMetrics(text).displayFont(cur.pit(), cur.pos()) + : buffer.params().getFont(); + inset_text->setOuterFont(cur.bv(), font.fontInfo()); + } + if (edit) inset->edit(cur, true); @@ -323,7 +331,6 @@ static bool doInsertInset(Cursor & cur, Text * text, cur.buffer()->errors("Paste"); cur.clearSelection(); // bug 393 cur.finishUndo(); - InsetText * inset_text = inset->asInsetText(); if (inset_text) { inset_text->fixParagraphsFont(); cur.pos() = 0; @@ -2083,12 +2090,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // inside it. doInsertInset(cur, this, cmd, true, true); cur.posForward(); - /* The font of the inset is computed in metrics(), and this is - * used to compute the height of the caret (because the font - * is stored in TextMetrics::font_). When we insert, we have - * to make sure that metrics are computed so that the caret - * height is correct. Arguably, this is hackish.*/ - bv->processUpdateFlags(Update::SinglePar); cur.setCurrentFont(); // Some insets are numbered, others are shown in the outline pane so // let's update the labels and the toc backend. @@ -2732,6 +2733,35 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_SPELLING_ADD_LOCAL: { + Language const * language = getLanguage(cur, cmd.getArg(1)); + docstring word = from_utf8(cmd.getArg(0)); + if (word.empty()) { + word = cur.selectionAsString(false); + if (word.size() > 100) + break; + if (word.empty()) { + // Get word or selection + selectWordWhenUnderCursor(cur, WHOLE_WORD); + word = cur.selectionAsString(false); + } + } + WordLangTuple wl(word, language); + if (!bv->buffer().params().spellignored(wl)) { + cur.recordUndoBufferParams(); + bv->buffer().params().spellignore().push_back(wl); + cur.recordUndo(); + // trigger re-check + WordLangTuple wl; + docstring_list suggestions; + Paragraph const & par = cur.paragraph(); + pos_type from = cur.pos(); + pos_type to = from; + par.spellCheck(from, to, wl, suggestions, true, true); + } + break; + } + + case LFUN_SPELLING_REMOVE_LOCAL: { Language const * language = getLanguage(cur, cmd.getArg(1)); docstring word = from_utf8(cmd.getArg(0)); if (word.empty()) { @@ -2746,9 +2776,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } WordLangTuple wl(word, language); bool has_item = false; - vector il = bv->buffer().params().spellignore(); - vector::const_iterator it = il.begin(); - for (; it != il.end(); ++it) { + vector::const_iterator it = bv->buffer().params().spellignore().begin(); + for (; it != bv->buffer().params().spellignore().end(); ++it) { if (it->lang()->code() != wl.lang()->code()) continue; if (it->word() == wl.word()) { @@ -2756,9 +2785,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) break; } } - if (!has_item) { + if (has_item) { cur.recordUndoBufferParams(); - bv->buffer().params().spellignore().push_back(wl); + bv->buffer().params().spellignore().erase(it); cur.recordUndo(); // trigger re-check WordLangTuple wl; @@ -2770,7 +2799,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } break; } - + case LFUN_SPELLING_IGNORE: { Language const * language = getLanguage(cur, cmd.getArg(1)); @@ -3502,6 +3531,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_SPELLING_ADD: case LFUN_SPELLING_ADD_LOCAL: + case LFUN_SPELLING_REMOVE_LOCAL: case LFUN_SPELLING_IGNORE: case LFUN_SPELLING_REMOVE: enable = theSpellChecker() != nullptr;