From 939b1a9c4c7c2fe05bc1b2e65e2e1dcc4549c33e Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Wed, 25 Aug 2004 07:50:35 +0000 Subject: [PATCH] PageDown and PageUp now behave a bit better. Still not completely ok, plus the code is a mess. Needs to cleanup git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8640 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/BTextView/TextView.cpp | 36 ++++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/BTextView/TextView.cpp b/src/kits/interface/BTextView/TextView.cpp index 7040a54940..620ba77f72 100644 --- a/src/kits/interface/BTextView/TextView.cpp +++ b/src/kits/interface/BTextView/TextView.cpp @@ -3048,19 +3048,47 @@ BTextView::HandlePageKey(uint32 inPageKey) } else Select(fClickOffset, fClickOffset); break; + + // TODO: Clean up this mess + case B_PAGE_UP: + { + int32 currentOffset = OffsetAt(fClickOffset); + float delta = Bounds().Height(); + + if (ScrollBar(B_VERTICAL) != NULL) + ScrollBar(B_VERTICAL)->SetValue(ScrollBar(B_VERTICAL)->Value() - delta); - case B_PAGE_UP: + int32 newOffset = OffsetAt(LineAt(PointAt(currentOffset - delta))); + + if (shiftDown) { + if (newOffset <= fSelStart) + Select(newOffset, fSelEnd); + else + Select(fSelStart, newOffset); + } else + Select(newOffset, newOffset); + + break; + } + case B_PAGE_DOWN: { int32 currentOffset = OffsetAt(fClickOffset); float delta = Bounds().Height(); - delta = (inPageKey == B_PAGE_UP) ? -delta : delta; if (ScrollBar(B_VERTICAL) != NULL) ScrollBar(B_VERTICAL)->SetValue(ScrollBar(B_VERTICAL)->Value() + delta); - // TODO: Selection - GoToLine(LineAt(PointAt(currentOffset + delta))); + int32 newOffset = OffsetAt(LineAt(PointAt(currentOffset + delta))); + + if (shiftDown) { + if (newOffset >= fSelEnd) + Select(fSelStart, newOffset); + else + Select(newOffset, fSelEnd); + } else + Select(newOffset, newOffset); + break; }