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
This commit is contained in:
Abdelrazak Younes 2009-08-10 20:54:22 +00:00
parent b3d7fce1b2
commit 0cc197d3c1
2 changed files with 14 additions and 8 deletions

View File

@ -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]);
}
}
}

View File

@ -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 <cstdlib>
#include "support/docstring_list.h"
#include "support/lassert.h"
#include <cstdlib>
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) {