From: Abdelrazak Younes Date: Mon, 10 Aug 2009 20:54:22 +0000 (+0000) Subject: Move the inline spellchecking code from collectWords() to the row drawing routine... X-Git-Tag: 2.0.0~5777 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=0cc197d3c1978214676532f872bff2f72931e45f;p=lyx.git Move the inline spellchecking code from collectWords() to the row drawing routine. The text row is spell checked only if changed! Now inline SpellChecker is faster than ever. Now, I honestly think that we blow out all the competitors (thunderbird, OO, MSWord, etc) :-) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30970 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 6dce930e9a..61ed9bb022 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3015,8 +3015,6 @@ void Paragraph::locateWord(pos_type & from, pos_type & to, void Paragraph::collectWords() { pos_type n = size(); - WordLangTuple wl; - docstring_list suggestions; for (pos_type pos = 0; pos < n; ++pos) { if (isWordSeparator(pos)) continue; @@ -3026,11 +3024,6 @@ void Paragraph::collectWords() docstring word = asString(from, pos, AS_STR_NONE); d->words_.insert(word); } - if (lyxrc.spellcheck_continuously - && spellCheck(from, pos, wl, suggestions)) { - for (size_t i = 0; i != suggestions.size(); ++i) - d->words_.insert(suggestions[i]); - } } } diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 47745c4a7c..178d0c97c4 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -40,6 +40,7 @@ #include "Text.h" #include "TextClass.h" #include "VSpace.h" +#include "WordLangTuple.h" #include "insets/InsetText.h" @@ -50,9 +51,11 @@ #include "frontends/Painter.h" #include "support/debug.h" -#include +#include "support/docstring_list.h" #include "support/lassert.h" +#include + using namespace std; @@ -2093,6 +2096,16 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type pit, int x, int y) co row.setCrc(pm.computeRowSignature(row, bparams)); bool row_has_changed = row.changed(); + // Take this opportunity to spellcheck the row contents. + if (row_has_changed && lyxrc.spellcheck_continuously) { + WordLangTuple wl; + // dummy variable, not used. + static docstring_list suggestions; + pos_type from = row.pos(); + pos_type to = row.endpos(); + text_->getPar(pit).spellCheck(from, to, wl, suggestions, false); + } + // Don't paint the row if a full repaint has not been requested // and if it has not changed. if (!pi.full_repaint && !row_has_changed) {