From bed9ea8c6496a8d6fa7df641a036547670e6df1d Mon Sep 17 00:00:00 2001 From: Wolfgang Lux Date: Sat, 27 Mar 2010 21:51:33 +0000 Subject: [PATCH] Change move word forwoard to move to the next end of a word rather than the beginning of the next word so users can quickly navigate to either end of words. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30056 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 4 ++++ Source/NSAttributedString.m | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 383c75b79..e68e34429 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-03-27 Wolfgang Lux + * Source/NSAttributedString.m (-nextWordFromIndex:forward:): + Move to the next end of a word rather than the beginning of the + next word so users can quickly navigate to either end of words. + * Source/NSTextView.m (-setSelectedRange:affinity:stillSelecting:): * Source/NSTextView_actions.m (-deleteForward:, -deleteBackward:, -deleteToEndOfLine:): Usability improvements: When setting the diff --git a/Source/NSAttributedString.m b/Source/NSAttributedString.m index 3ce3be2f0..bbb9fb13f 100644 --- a/Source/NSAttributedString.m +++ b/Source/NSAttributedString.m @@ -577,18 +577,18 @@ create_error(int code, NSString* desc) if (isForward) { - /* What we want to do is: move forward to the next chunk of word - separator characters, skip them all, and return the location - just after them. */ + /* What we want to do is: move forward to the next chunk of + non-word separator characters, skip them all, and return the + location just after them. */ if (location == length) { return length; } - /* Move forward to the next word-separator. */ + /* Move forward to the next non-word separator. */ range = NSMakeRange (location, length - location); - range = [str rangeOfCharacterFromSet: wordBreakCSet + range = [str rangeOfCharacterFromSet: wordCSet options: NSLiteralSearch range: range]; if (range.location == NSNotFound) @@ -596,12 +596,12 @@ create_error(int code, NSString* desc) return length; } /* rangeOfCharacterFromSet: options: range: only returns the range - of the first word-separator character ... we want to skip + of the first non-word-separator character ... we want to skip them all! So we need to search again, this time for the - first non-word-separator character, and return the first such + first word-separator character, and return the first such character. */ range = NSMakeRange (range.location, length - range.location); - range = [str rangeOfCharacterFromSet: wordCSet + range = [str rangeOfCharacterFromSet: wordBreakCSet options: NSLiteralSearch range: range]; if (range.location == NSNotFound)