]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
* sk.po
[lyx.git] / src / Cursor.cpp
index f2a61c28cc1c90df04a71ed647af348e0cd115fe..266938a2d9b341fd86f552dab9b43d07a535a118 100644 (file)
@@ -402,7 +402,7 @@ void Cursor::dispatch(FuncRequest const & cmd0)
                bool badcursor = notifyCursorLeavesOrEnters(old, *this);
                if (badcursor) {
                        fixIfBroken();
-                       bv().fixInlineCompletionPos();
+                       bv().resetInlineCompletionPos();
                }
                old.endUndoGroup();
        }
@@ -503,6 +503,7 @@ Row const & Cursor::textRow() const
 void Cursor::resetAnchor()
 {
        anchor_ = *this;
+       checkNewWordPosition();
 }
 
 
@@ -519,6 +520,58 @@ void Cursor::setCursorToAnchor()
 }
 
 
+void Cursor::markEditPosition()
+{
+       if (inTexted() && new_word_.empty()) {
+               FontSpan ow = locateWord(WHOLE_WORD);
+               if (ow.size() == 1) {
+                       LYXERR(Debug::DEBUG, "start new word: "
+                               << " par: " << pit()
+                               << " pos: " << ow.first);
+                       new_word_ = *this;
+               }
+       }
+}
+
+
+void Cursor::clearNewWordPosition()
+{
+       if (!new_word_.empty()) {
+               LYXERR(Debug::DEBUG, "clear new word: "
+                       << " par: " << pit()
+                       << " pos: " << pos());
+               new_word_.resize(0);
+       }
+}
+
+
+void Cursor::checkNewWordPosition()
+{
+       if (new_word_.empty())
+               return ;
+       if (!inTexted())
+               clearNewWordPosition();
+       else {
+               if (pit() != new_word_.pit())
+                       clearNewWordPosition();
+               else {
+                       FontSpan nw = locateWord(WHOLE_WORD);
+                       if (nw.size()) {
+                               FontSpan ow = new_word_.locateWord(WHOLE_WORD);
+                               if (nw.intersect(ow).empty())
+                                       clearNewWordPosition();
+                               else
+                                       LYXERR(Debug::DEBUG, "new word: "
+                                                  << " par: " << pit()
+                                                  << " pos: " << nw.first << ".." << nw.last);
+                       } else {
+                               clearNewWordPosition();
+                       }
+               }
+       }
+}
+
+
 bool Cursor::posBackward()
 {
        if (pos() == 0)
@@ -1337,7 +1390,7 @@ void Cursor::insert(Inset * inset0)
 }
 
 
-void Cursor::niceInsert(docstring const & t, Parse::flags f, bool enter)
+int Cursor::niceInsert(docstring const & t, Parse::flags f, bool enter)
 {
        MathData ar(buffer());
        asArray(t, ar, f);
@@ -1345,6 +1398,7 @@ void Cursor::niceInsert(docstring const & t, Parse::flags f, bool enter)
                niceInsert(ar[0]);
        else
                insert(ar);
+       return ar.size();
 }
 
 
@@ -1624,7 +1678,7 @@ bool Cursor::inMacroMode() const
 {
        if (!inMathed())
                return false;
-       if (pos() == 0)
+       if (pos() == 0 || cell().empty())
                return false;
        InsetMathUnknown const * p = prevAtom()->asUnknownInset();
        return p && !p->final();