]> git.lyx.org Git - lyx.git/commitdiff
Move the inline spellchecking code from collectWords() to the row drawing routine...
authorAbdelrazak Younes <younes@lyx.org>
Mon, 10 Aug 2009 20:54:22 +0000 (20:54 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Mon, 10 Aug 2009 20:54:22 +0000 (20:54 +0000)
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

src/Paragraph.cpp
src/TextMetrics.cpp

index 6dce930e9a47e2bc0d036e2bbba67a8bece1c86a..61ed9bb0223718dabe152ed22d49bdffeec55973 100644 (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]);
-               }
        }
 }
 
index 47745c4a7c9f3cff8df9885ecf15d470cbc1ce44..178d0c97c44df8fbab2b44674daefe00d771879a 100644 (file)
@@ -40,6 +40,7 @@
 #include "Text.h"
 #include "TextClass.h"
 #include "VSpace.h"
+#include "WordLangTuple.h"
 
 #include "insets/InsetText.h"
 
 #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) {