]> 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 3820ae29ff158c7d19042559eb47b6f551c5433f..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"
@@ -39,7 +40,8 @@
 #include "mathed/InsetMath.h"
 #include "mathed/InsetMathScript.h"
 #include "mathed/MathMacroTable.h"
-#include "mathed/MathParser.h"
+
+#include "frontends/Selection.h"
 
 #include "support/limited_stack.h"
 
@@ -375,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;
 }
 
@@ -404,6 +407,14 @@ void LCursor::getPos(int & x, int & y) const
 }
 
 
+Row const & LCursor::textRow() const
+{
+       ParagraphMetrics const & pm = bv().parMetrics(text(), pit());
+       BOOST_ASSERT(!pm.rows().empty());
+       return pm.getRow(pos(), boundary());
+}
+
+
 void LCursor::resetAnchor()
 {
        anchor_ = *this;
@@ -549,6 +560,7 @@ bool LCursor::selHandle(bool sel)
 
        resetAnchor();
        selection() = sel;
+       theSelection().haveSelection(sel);
        return true;
 }
 
@@ -756,7 +768,7 @@ bool LCursor::backspace()
        autocorrect() = false;
 
        if (selection()) {
-               cap::selDel(*this);
+               cap::eraseSelection(*this);
                return true;
        }
 
@@ -808,7 +820,7 @@ bool LCursor::erase()
                return true;
 
        if (selection()) {
-               cap::selDel(*this);
+               cap::eraseSelection(*this);
                return true;
        }
 
@@ -1190,18 +1202,18 @@ docstring LCursor::selectionAsString(bool label) const
 }
 
 
-string LCursor::currentState()
+docstring LCursor::currentState()
 {
        if (inMathed()) {
                odocstringstream os;
                info(os);
-               return to_utf8(os.str());
+               return os.str();
        }
 
        if (inTexted())
                return text()->currentState(*this);
 
-       return string();
+       return docstring();
 }