Gently guessing prev. line caret pos on UP_ARROW

Fixes #3656
This commit is contained in:
Siarzhuk Zharski 2012-12-16 20:07:44 +01:00
parent 0d3bd614c7
commit 74f911be74
1 changed files with 11 additions and 2 deletions

View File

@ -3505,8 +3505,17 @@ BTextView::_HandleArrowKey(uint32 inArrowKey, bool commandKeyDown)
else { else {
float height; float height;
BPoint point = PointAt(fCaretOffset, &height); BPoint point = PointAt(fCaretOffset, &height);
point.y -= height; // find the caret position on the previous
fCaretOffset = OffsetAt(point); // 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 (shiftDown && fCaretOffset != lastClickOffset) {
if (fCaretOffset < fSelStart) { if (fCaretOffset < fSelStart) {
// extend selection to the top // extend selection to the top