]> git.lyx.org Git - lyx.git/commitdiff
fix cursor movements.
authorAbdelrazak Younes <younes@lyx.org>
Wed, 10 Jan 2007 10:59:18 +0000 (10:59 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 10 Jan 2007 10:59:18 +0000 (10:59 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16638 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/text.C
src/text2.C

index 7e084ad54836f7c737edac637fdb4838020ca745..31bb27145ce238f4f79380c002ba8f66c251fd5e 100644 (file)
@@ -1238,6 +1238,8 @@ void BufferView::setCursor(DocIterator const & dit)
                dit[i].inset().edit(cursor_, true);
 
        cursor_.setCursor(dit);
+       // remember new position.
+       cursor_.setTargetX();
        cursor_.selection() = false;
 }
 
@@ -1281,6 +1283,7 @@ bool BufferView::mouseSetCursor(LCursor & cur)
 
        cursor_ = cur;
        cursor_.clearSelection();
+       // remember new position.
        cursor_.setTargetX();
        finishUndo();
        return update;
index 7e841e122bae011b17754fa1cd0a296af101cba4..86110e88118276ce3d467fd89a3ff4c8715ad55b 100644 (file)
@@ -1724,6 +1724,8 @@ void LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y)
                << endl;
 
        setCursor(cur, pit, pos, true, bound);
+       // remember new position.
+       cur.setTargetX();
 }
 
 
index 6b13d5b5d82956fad0523b068baee809f4e4e6ea..ca16466462c7007b871458900a33606a82d7f8ae 100644 (file)
@@ -985,13 +985,16 @@ bool LyXText::cursorUp(LCursor & cur)
        ParagraphMetrics const & pm = tm.parMetrics(cur.pit());
 
        int row;
-       int const x = cur.targetX();
-
        if (cur.pos() && cur.boundary())
                row = pm.pos2row(cur.pos()-1);
        else
                row = pm.pos2row(cur.pos());
 
+       // remember current position only if we are not at the end of a row.
+       if (cur.pos() != pm.rows()[row].endpos())
+               cur.setTargetX();
+       int const x = cur.targetX();
+
        if (!cur.selection()) {
                int const y = bv_funcs::getPos(cur.bv(), cur, cur.boundary()).y_;
                LCursor old = cur;
@@ -1041,13 +1044,16 @@ bool LyXText::cursorDown(LCursor & cur)
        ParagraphMetrics const & pm = tm.parMetrics(cur.pit());
 
        int row;
-       int const x = cur.targetX();
-
        if (cur.pos() && cur.boundary())
                row = pm.pos2row(cur.pos()-1);
        else
                row = pm.pos2row(cur.pos());
 
+       // remember current position only if we are not at the end of a row.
+       if (cur.pos() != pm.rows()[row].endpos())
+               cur.setTargetX();
+       int const x = cur.targetX();
+
        if (!cur.selection()) {
                int const y = bv_funcs::getPos(cur.bv(), cur, cur.boundary()).y_;
                LCursor old = cur;