From f2e0ac2cd78f00f306c30fdd289e05992d3ade0c Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Sat, 30 May 2009 21:07:36 +0000 Subject: [PATCH] * Instead of moving bounds-height during paging, we now determine the exact next position of the caret and only scroll the distance between the current and the next position. This fixes #3981 * When paging upwards, we need to compensate for the fact that the caret position is always considered at the top of the line, as otherwise a page-up would pass one more line than a page-down git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30933 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/TextView.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index 4cd7e98e38..ec819887c4 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -3507,11 +3507,13 @@ BTextView::_HandlePageKey(uint32 inPageKey) case B_PAGE_UP: { - BPoint currentPos = PointAt(fClickOffset); - - currentPos.y -= Bounds().Height(); - fClickOffset = OffsetAt(LineAt(currentPos)); - _ScrollBy(0, -1 * Bounds().Height()); + float lineHeight; + BPoint currentPos = PointAt(fClickOffset, &lineHeight); + BPoint nextPos(currentPos.x, + currentPos.y + lineHeight - Bounds().Height()); + fClickOffset = OffsetAt(nextPos); + nextPos = PointAt(fClickOffset); + _ScrollBy(0, nextPos.y - currentPos.y); if (!fEditable) break; @@ -3538,10 +3540,10 @@ BTextView::_HandlePageKey(uint32 inPageKey) case B_PAGE_DOWN: { BPoint currentPos = PointAt(fClickOffset); - - currentPos.y += Bounds().Height(); - fClickOffset = OffsetAt(LineAt(currentPos)); - _ScrollBy(0, Bounds().Height()); + BPoint nextPos(currentPos.x, currentPos.y + Bounds().Height()); + fClickOffset = OffsetAt(nextPos); + nextPos = PointAt(fClickOffset); + _ScrollBy(0, nextPos.y - currentPos.y); if (!fEditable) break;