Home / End go to the start/end of the line, not to the start/end of the buffer.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8445 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2004-07-21 07:22:22 +00:00
parent a0c20849b5
commit 539a90858a
+17 -8
View File
@@ -2912,30 +2912,39 @@ BTextView::HandlePageKey(uint32 inPageKey)
int32 modifiers = 0; int32 modifiers = 0;
BMessage *currentMessage = Window()->CurrentMessage(); BMessage *currentMessage = Window()->CurrentMessage();
currentMessage->FindInt32("modifiers", &modifiers); if (currentMessage)
currentMessage->FindInt32("modifiers", &modifiers);
bool shiftDown = modifiers & B_SHIFT_KEY; bool shiftDown = modifiers & B_SHIFT_KEY;
int32 oldOffset;;
int32 newOffset; int32 newOffset;
STELinePtr line = NULL;
switch (inPageKey) { switch (inPageKey) {
case B_HOME: case B_HOME:
oldOffset = fSelStart; line = (*fLines)[CurrentLine()];
newOffset = 0; newOffset = line->offset;
ScrollToOffset(newOffset); ScrollToOffset(newOffset);
if (shiftDown) if (shiftDown)
Select(newOffset, oldOffset); Select(newOffset, fSelStart);
else else
Select(newOffset, newOffset); Select(newOffset, newOffset);
break; break;
case B_END: case B_END:
oldOffset = fSelEnd; // If we are on the last line, just go to the last
newOffset = fText->Length(); // charachter in the buffer, otherwise get the starting
// offset of the next line, and go to the previous charachter
if (CurrentLine() + 1 < fLines->NumLines()) {
line = (*fLines)[CurrentLine() + 1];
newOffset = PreviousInitialByte(line->offset);
} else
newOffset = fText->Length();
ScrollToOffset(newOffset); ScrollToOffset(newOffset);
if (shiftDown) if (shiftDown)
Select(oldOffset, newOffset); Select(fSelEnd, newOffset);
else else
Select(newOffset, newOffset); Select(newOffset, newOffset);
break; break;