]> git.lyx.org Git - lyx.git/blobdiff - src/cursor.C
* output_plaintext.C: cosmetics in comment: line length cannot be < 0
[lyx.git] / src / cursor.C
index 5bccc4d13b2a146428f7c7fc8a5b7504dd58045d..e9c4d753494781bc4ac1c11b5bdc5942eb3c74b9 100644 (file)
@@ -13,6 +13,7 @@
 #include <config.h>
 
 #include "BufferView.h"
+#include "bufferview_funcs.h"
 #include "buffer.h"
 #include "cursor.h"
 #include "coordcache.h"
@@ -40,6 +41,8 @@
 #include "mathed/InsetMathScript.h"
 #include "mathed/MathMacroTable.h"
 
+#include "frontends/Selection.h"
+
 #include "support/limited_stack.h"
 
 #include <boost/assert.hpp>
@@ -374,11 +377,12 @@ bool LCursor::popRight()
 {
        BOOST_ASSERT(!empty());
        //lyxerr << "Leaving inset to the right" << endl;
+       const pos_type lp = (depth() > 1) ? (*this)[depth() - 2].lastpos() : 0;
        inset().notifyCursorLeaves(*this);
        if (depth() == 1)
                return false;
        pop();
-       ++pos();
+       pos() += lastpos() - lp + 1;
        return true;
 }
 
@@ -403,17 +407,11 @@ void LCursor::getPos(int & x, int & y) const
 }
 
 
-Row & LCursor::textRow()
-{
-       BOOST_ASSERT(!paragraph().rows().empty());
-       return paragraph().getRow(pos(), boundary());
-}
-
-
 Row const & LCursor::textRow() const
 {
-       BOOST_ASSERT(!paragraph().rows().empty());
-       return paragraph().getRow(pos(), boundary());
+       ParagraphMetrics const & pm = bv().parMetrics(text(), pit());
+       BOOST_ASSERT(!pm.rows().empty());
+       return pm.getRow(pos(), boundary());
 }
 
 
@@ -562,6 +560,7 @@ bool LCursor::selHandle(bool sel)
 
        resetAnchor();
        selection() = sel;
+       theSelection().haveSelection(sel);
        return true;
 }
 
@@ -769,7 +768,7 @@ bool LCursor::backspace()
        autocorrect() = false;
 
        if (selection()) {
-               cap::selDel(*this);
+               cap::eraseSelection(*this);
                return true;
        }
 
@@ -821,7 +820,7 @@ bool LCursor::erase()
                return true;
 
        if (selection()) {
-               cap::selDel(*this);
+               cap::eraseSelection(*this);
                return true;
        }