]> git.lyx.org Git - features.git/commitdiff
add comments and rtl support for cursor positioning problem
authorBernhard Roider <bernhard.roider@sonnenkinder.org>
Mon, 14 May 2007 20:03:40 +0000 (20:03 +0000)
committerBernhard Roider <bernhard.roider@sonnenkinder.org>
Mon, 14 May 2007 20:03:40 +0000 (20:03 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18323 a592a061-630c-0410-9148-cb99ea01b6c8

src/Text2.cpp

index 9992d257c218843275bebf0a66913532f0583ea6..527e32f1896f1ca5892ee61270b26ada205f0aed 100644 (file)
@@ -993,8 +993,16 @@ bool Text::cursorUp(Cursor & cur)
 
        int x = cur.targetX();
        cur.setTargetX();
-       if (cur.pos() != pm.rows()[row].endpos() || x < cur.targetX())
+       // We want to keep the x-target on subsequent up movements
+       // that cross beyond the end of short lines. Thus a special
+       // handling when the cursor is at the end of line: Use the new 
+       // x-target only if the old one was before the end of line.
+       if (cur.pos() != pm.rows()[row].endpos() 
+               || (!cur.isRTL() && x < cur.targetX())
+               || (cur.isRTL() && x > cur.targetX())) {
+
                x = cur.targetX();
+       }
 
        if (!cur.selection()) {
                int const y = bv_funcs::getPos(cur.bv(), cur, cur.boundary()).y_;
@@ -1052,8 +1060,16 @@ bool Text::cursorDown(Cursor & cur)
 
        int x = cur.targetX();
        cur.setTargetX();
-       if (cur.pos() != pm.rows()[row].endpos() || x < cur.targetX())
+       // We want to keep the x-target on subsequent down movements
+       // that cross beyond the end of short lines. Thus a special
+       // handling when the cursor is at the end of line: Use the new 
+       // x-target only if the old one was before the end of line.
+       if (cur.pos() != pm.rows()[row].endpos() 
+               || (!cur.isRTL() && x < cur.targetX())
+               || (cur.isRTL() && x > cur.targetX())) {
+
                x = cur.targetX();
+       }
 
        if (!cur.selection()) {
                int const y = bv_funcs::getPos(cur.bv(), cur, cur.boundary()).y_;