]> git.lyx.org Git - lyx.git/blobdiff - src/rowpainter.cpp
use return value of regex_match to check whether a match was found
[lyx.git] / src / rowpainter.cpp
index fccb894c3f7870552b7934d152600c2665d214f5..47ab84d3a2b5e7130eb47cebc276b3ebc8dae163 100644 (file)
@@ -38,6 +38,8 @@
 
 #include "insets/InsetText.h"
 
+#include "mathed/InsetMath.h"
+
 #include "support/debug.h"
 #include "support/gettext.h"
 #include "support/textutils.h"
@@ -392,7 +394,7 @@ void RowPainter::paintFromPos(pos_type & vpos, bool changed)
                                                lang == "farsi";
 
        // spelling correct?
-       bool const misspelled_ =
+       bool const misspelled =
                lyxrc.spellcheck_continuously && par_.isMisspelled(pos);
 
        // draw as many chars as we can
@@ -408,8 +410,23 @@ void RowPainter::paintFromPos(pos_type & vpos, bool changed)
 
        paintForeignMark(orig_x, orig_font.language());
 
-       if (lyxrc.spellcheck_continuously && misspelled_) {
-               paintMisspelledMark(orig_x, changed);
+       if (lyxrc.spellcheck_continuously && misspelled) {
+               // check for cursor position
+               // don't draw misspelled marker for words at cursor position
+               // we don't want to disturb the process of text editing
+               BufferView const * bv = pi_.base.bv;
+               DocIterator const nw = bv->cursor().newWord();
+               bool new_word = false;
+               if (!nw.empty() && par_.id() == nw.paragraph().id()) {
+                       pos_type cpos = nw.pos();
+                       if (cpos > 0 && cpos == par_.size() && !par_.isWordSeparator(cpos-1))
+                               --cpos;
+                       else if (cpos > 0 && par_.isWordSeparator(cpos))
+                               --cpos;
+                       new_word = par_.isSameSpellRange(pos, cpos) ;
+               }
+               if (!new_word)
+                       paintMisspelledMark(orig_x, changed);
        }
 }
 
@@ -752,9 +769,11 @@ void RowPainter::paintOnlyInsets()
        for (pos_type pos = row_.pos(); pos != end; ++pos) {
                // If outer row has changed, nested insets are repaint completely.
                Inset const * inset = par_.getInset(pos);
-               bool const nested_inset = inset && (inset->inMathed() ||
-                                                   inset->asInsetText() ||
-                                                   inset->asInsetTabular());
+               bool const nested_inset = inset &&
+                               ((inset->asInsetMath() &&
+                                 !inset->asInsetMath()->asMacroTemplate())
+                                || inset->asInsetText()
+                                || inset->asInsetTabular());
                if (!nested_inset)
                        continue;
                if (x_ > pi_.base.bv->workWidth()