]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
Always place the cursor before a separator inset when moving up or down.
[lyx.git] / src / Cursor.cpp
index fe90f98debbb12e1e0abdf05f68a71408c4d1aa7..bc1219733f99a71d851d34ef5c6736336ca749f0 100644 (file)
@@ -548,6 +548,16 @@ int Cursor::currentMode()
 }
 
 
+bool Cursor::inCoordCache() const
+{
+       CoordCache::Insets const & icache = bv_->coordCache().getInsets();
+       for (size_t i = 0 ; i < depth() ; ++i)
+               if (!icache.has(&(*this)[i].inset()))
+                       return false;
+       return true;
+}
+
+
 void Cursor::getPos(int & x, int & y) const
 {
        Point p = bv().getPos(*this);
@@ -734,10 +744,7 @@ bool Cursor::posVisRight(bool skip_inset)
 
        }
 
-       bool moved = (new_cur.pos() != pos()
-                                 || new_cur.pit() != pit()
-                                 || new_cur.boundary() != boundary()
-                                 || &new_cur.inset() != &inset());
+       bool const moved = new_cur != *this || new_cur.boundary() != boundary();
 
        if (moved) {
                LYXERR(Debug::RTL, "moving to: " << new_cur.pos()
@@ -833,9 +840,7 @@ bool Cursor::posVisLeft(bool skip_inset)
 
        }
 
-       bool moved = (new_cur.pos() != pos()
-                                 || new_cur.pit() != pit()
-                                 || new_cur.boundary() != boundary());
+       bool const moved = new_cur != *this || new_cur.boundary() != boundary();
 
        if (moved) {
                LYXERR(Debug::RTL, "moving to: " << new_cur.pos()
@@ -1179,8 +1184,6 @@ void Cursor::info(odocstream & os) const
                if (inset)
                        prevInset()->infoize2(os);
        }
-       // overwite old message
-       os << "                    ";
 }
 
 
@@ -1295,7 +1298,7 @@ void Cursor::plainInsert(MathAtom const & t)
        ++pos();
        inset().setBuffer(bv_->buffer());
        inset().initView();
-       forceBufferUpdate();
+       checkBufferStructure();
 }
 
 
@@ -1686,7 +1689,9 @@ void Cursor::normalize()
                        << pos() << ' ' << lastpos() <<  " in idx: " << idx()
                       << " in atom: '";
                odocstringstream os;
-               WriteStream wi(os, false, true, WriteStream::wsDefault);
+               TexRow texrow(false);
+               otexrowstream ots(os,texrow);
+               WriteStream wi(ots, false, true, WriteStream::wsDefault);
                inset().asInsetMath()->write(wi);
                lyxerr << to_utf8(os.str()) << endl;
                pos() = lastpos();
@@ -1942,6 +1947,8 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                        // Make sure that cur gets back whatever happened to dummy (Lgb)
                        operator=(dummy);
                }
+               if (pos() && paragraph().isEnvSeparator(pos() - 1))
+                       posBackward();
        } else {
                // if there is a selection, we stay out of any inset,
                // and just jump to the right position:
@@ -2106,6 +2113,13 @@ docstring Cursor::currentState() const
        if (inMathed()) {
                odocstringstream os;
                info(os);
+#ifdef DEVEL_VERSION
+               InsetMath * math = inset().asInsetMath();
+               if (math)
+                       os << _(", Inset: ") << math->id();
+               os << _(", Cell: ") << idx();
+               os << _(", Position: ") << pos();
+#endif
                return os.str();
        }