Implement a suggestion of Humdinger in the aftermath of #4785:

* make word-wise navigation via cursor keys match Pe, such that it is consistent
  throughout haiku (unless some applications brew their own)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33913 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe 2009-11-06 14:21:21 +00:00
parent be12bce74a
commit 5f917b22c8

View File

@ -3317,7 +3317,7 @@ BTextView::_HandleArrowKey(uint32 inArrowKey)
else { else {
fCaretOffset fCaretOffset
= ctrlDown = ctrlDown
? _NextWordStart(fCaretOffset) ? _NextWordEnd(fCaretOffset)
: _NextInitialByte(fCaretOffset); : _NextInitialByte(fCaretOffset);
if (shiftDown && fCaretOffset != lastClickOffset) { if (shiftDown && fCaretOffset != lastClickOffset) {
if (fCaretOffset > fSelEnd) { if (fCaretOffset > fSelEnd) {
@ -4070,18 +4070,18 @@ BTextView::_PreviousWordStart(int32 offset)
return 0; return 0;
--offset; // need to look at previous char --offset; // need to look at previous char
if (_CharClassification(offset) == CHAR_CLASS_WHITESPACE) { if (_CharClassification(offset) != CHAR_CLASS_DEFAULT) {
// skip whitespace // skip non-word characters
while (offset > 0) { while (offset > 0) {
offset = _PreviousInitialByte(offset); offset = _PreviousInitialByte(offset);
if (_CharClassification(offset) != CHAR_CLASS_WHITESPACE) if (_CharClassification(offset) == CHAR_CLASS_DEFAULT)
break; break;
} }
} }
while (offset > 0) { while (offset > 0) {
// find preceeding whitespace char. // skip to start of word
int32 previous = _PreviousInitialByte(offset); int32 previous = _PreviousInitialByte(offset);
if (_CharClassification(previous) == CHAR_CLASS_WHITESPACE) if (_CharClassification(previous) != CHAR_CLASS_DEFAULT)
break; break;
offset = previous; offset = previous;
} }
@ -4091,24 +4091,24 @@ BTextView::_PreviousWordStart(int32 offset)
int32 int32
BTextView::_NextWordStart(int32 offset) BTextView::_NextWordEnd(int32 offset)
{ {
int32 textLen = TextLength(); int32 textLen = TextLength();
if (offset >= textLen) if (offset >= textLen)
return textLen; return textLen;
if (_CharClassification(offset) != CHAR_CLASS_WHITESPACE) { if (_CharClassification(offset) != CHAR_CLASS_DEFAULT) {
// skip until the next whitespace // skip non-word characters
while (offset < textLen) { while (offset < textLen) {
offset = _NextInitialByte(offset); offset = _NextInitialByte(offset);
if (_CharClassification(offset) == CHAR_CLASS_WHITESPACE) if (_CharClassification(offset) == CHAR_CLASS_DEFAULT)
break; break;
} }
} }
while (offset < textLen) { while (offset < textLen) {
// find next non-white char // skip to end of word
offset = _NextInitialByte(offset); offset = _NextInitialByte(offset);
if (_CharClassification(offset) != CHAR_CLASS_WHITESPACE) if (_CharClassification(offset) != CHAR_CLASS_DEFAULT)
break; break;
} }