From 5f917b22c880e946571d67201f5da7ff417c0388 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Fri, 6 Nov 2009 14:21:21 +0000 Subject: [PATCH] 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 --- src/kits/interface/TextView.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index 99fc0ef923..3b0d9849c9 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -3317,7 +3317,7 @@ BTextView::_HandleArrowKey(uint32 inArrowKey) else { fCaretOffset = ctrlDown - ? _NextWordStart(fCaretOffset) + ? _NextWordEnd(fCaretOffset) : _NextInitialByte(fCaretOffset); if (shiftDown && fCaretOffset != lastClickOffset) { if (fCaretOffset > fSelEnd) { @@ -4070,18 +4070,18 @@ BTextView::_PreviousWordStart(int32 offset) return 0; --offset; // need to look at previous char - if (_CharClassification(offset) == CHAR_CLASS_WHITESPACE) { - // skip whitespace + if (_CharClassification(offset) != CHAR_CLASS_DEFAULT) { + // skip non-word characters while (offset > 0) { offset = _PreviousInitialByte(offset); - if (_CharClassification(offset) != CHAR_CLASS_WHITESPACE) + if (_CharClassification(offset) == CHAR_CLASS_DEFAULT) break; } } while (offset > 0) { - // find preceeding whitespace char. + // skip to start of word int32 previous = _PreviousInitialByte(offset); - if (_CharClassification(previous) == CHAR_CLASS_WHITESPACE) + if (_CharClassification(previous) != CHAR_CLASS_DEFAULT) break; offset = previous; } @@ -4091,24 +4091,24 @@ BTextView::_PreviousWordStart(int32 offset) int32 -BTextView::_NextWordStart(int32 offset) +BTextView::_NextWordEnd(int32 offset) { int32 textLen = TextLength(); if (offset >= textLen) return textLen; - if (_CharClassification(offset) != CHAR_CLASS_WHITESPACE) { - // skip until the next whitespace + if (_CharClassification(offset) != CHAR_CLASS_DEFAULT) { + // skip non-word characters while (offset < textLen) { offset = _NextInitialByte(offset); - if (_CharClassification(offset) == CHAR_CLASS_WHITESPACE) + if (_CharClassification(offset) == CHAR_CLASS_DEFAULT) break; } } while (offset < textLen) { - // find next non-white char + // skip to end of word offset = _NextInitialByte(offset); - if (_CharClassification(offset) != CHAR_CLASS_WHITESPACE) + if (_CharClassification(offset) != CHAR_CLASS_DEFAULT) break; }