[haiku-commits] r33913 - haiku/trunk/src/kits/interface

  • From: zooey@xxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 6 Nov 2009 15:21:21 +0100 (CET)

Author: zooey
Date: 2009-11-06 15:21:21 +0100 (Fri, 06 Nov 2009)
New Revision: 33913
Changeset: http://dev.haiku-os.org/changeset/33913/haiku

Modified:
   haiku/trunk/src/kits/interface/TextView.cpp
Log:
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)


Modified: haiku/trunk/src/kits/interface/TextView.cpp
===================================================================
--- haiku/trunk/src/kits/interface/TextView.cpp 2009-11-06 08:46:42 UTC (rev 
33912)
+++ haiku/trunk/src/kits/interface/TextView.cpp 2009-11-06 14:21:21 UTC (rev 
33913)
@@ -3317,7 +3317,7 @@
                        else {
                                fCaretOffset
                                        = ctrlDown
-                                               ? _NextWordStart(fCaretOffset)
+                                               ? _NextWordEnd(fCaretOffset)
                                                : 
_NextInitialByte(fCaretOffset);
                                if (shiftDown && fCaretOffset != 
lastClickOffset) {
                                        if (fCaretOffset > fSelEnd) {
@@ -4070,18 +4070,18 @@
                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 @@
 
 
 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;
        }
 


Other related posts:

  • » [haiku-commits] r33913 - haiku/trunk/src/kits/interface - zooey