[haiku-commits] haiku: hrev45019 - src/kits/interface

  • From: zharik@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 16 Dec 2012 20:31:55 +0100 (CET)

hrev45019 adds 1 changeset to branch 'master'
old head: 0d3bd614c779194cb1394de2c84156538328273b
new head: 74f911be7405f34a43bcc173e00d7981e2bd269a
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=74f911b+%5E0d3bd61

----------------------------------------------------------------------------

74f911b: Gently guessing prev. line caret pos on UP_ARROW
  
  Fixes #3656

                                        [ Siarzhuk Zharski <zharik@xxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev45019
Commit:      74f911be7405f34a43bcc173e00d7981e2bd269a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=74f911b
Author:      Siarzhuk Zharski <zharik@xxxxxx>
Date:        Sun Dec 16 19:07:44 2012 UTC

Ticket:      https://dev.haiku-os.org/ticket/3656

----------------------------------------------------------------------------

1 file changed, 11 insertions(+), 2 deletions(-)
src/kits/interface/TextView.cpp | 13 +++++++++++--

----------------------------------------------------------------------------

diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp
index aa2300f..3d97a63 100644
--- a/src/kits/interface/TextView.cpp
+++ b/src/kits/interface/TextView.cpp
@@ -3505,8 +3505,17 @@ BTextView::_HandleArrowKey(uint32 inArrowKey, bool 
commandKeyDown)
                        else {
                                float height;
                                BPoint point = PointAt(fCaretOffset, &height);
-                               point.y -= height;
-                               fCaretOffset = OffsetAt(point);
+                               // find the caret position on the previous
+                               // line by gently stepping onto this line
+                               for (int i = 1; i <= height; i++) {
+                                       point.y--;
+                                       int32 offset = OffsetAt(point);
+                                       if (offset < fCaretOffset || i == 
height) {
+                                               fCaretOffset = offset;
+                                               break;
+                                       }
+                               }
+
                                if (shiftDown && fCaretOffset != 
lastClickOffset) {
                                        if (fCaretOffset < fSelStart) {
                                                // extend selection to the top


Other related posts:

  • » [haiku-commits] haiku: hrev45019 - src/kits/interface - zharik