diff options
author | Bibiko <bibiko@eva.mpg.de> | 2011-01-21 13:05:55 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2011-01-21 13:05:55 +0000 |
commit | 28819b6ab639d29bf5e5897e7ac4c784771d3651 (patch) | |
tree | 6b370fe43d17aeb911ebb5dfb6b306fb799f9884 /Source/SPTextViewAdditions.m | |
parent | 218c2e17f054f3333d15af62a4f60f41b464c849 (diff) | |
download | sequelpro-28819b6ab639d29bf5e5897e7ac4c784771d3651.tar.gz sequelpro-28819b6ab639d29bf5e5897e7ac4c784771d3651.tar.bz2 sequelpro-28819b6ab639d29bf5e5897e7ac4c784771d3651.zip |
• sped up getRangeForCurrentWord
- fixes also the short interruption of the cursor blinking
- for completion the old method is used, since it's fine-tuned to use it - fix will come soon
- preparation for user-defined word symbols
• fixed issue for soft indent if user uses deleteForward: selector (⇧⌫)
Diffstat (limited to 'Source/SPTextViewAdditions.m')
-rw-r--r-- | Source/SPTextViewAdditions.m | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m index 750527f1..e5a15421 100644 --- a/Source/SPTextViewAdditions.m +++ b/Source/SPTextViewAdditions.m @@ -41,8 +41,69 @@ if (curRange.length) return curRange; + NSInteger curLocation = curRange.location; + NSInteger start = curLocation; + NSInteger end = curLocation; + NSUInteger strLen = [[self string] length]; + + NSMutableCharacterSet *wordCharSet = [NSMutableCharacterSet alphanumericCharacterSet]; + [wordCharSet addCharactersInString:@"_."]; + [wordCharSet removeCharactersInString:@"`"]; + + if(start) { + start--; + while([wordCharSet characterIsMember:[[self string] characterAtIndex:start]]) { + start--; + if(start < 0) break; + } + start++; + } + + while(end < strLen && [wordCharSet characterIsMember:[[self string] characterAtIndex:end]]) { + end++; + } + + return(NSMakeRange(start, end-start)); + +} +/* + * Returns the range of the current word. + * finds: [| := caret] |word wo|rd word| + * If | is in between whitespaces nothing will be selected. + */ +- (NSRange)getRangeForCurrentWordForCompletion +{ + NSRange curRange = [self selectedRange]; + + if (curRange.length) + return curRange; + NSUInteger curLocation = curRange.location; + NSMutableCharacterSet *wordCharSet = [NSMutableCharacterSet alphanumericCharacterSet]; + [wordCharSet addCharactersInString:@"_."]; + [wordCharSet removeCharactersInString:@"`"]; + + NSInteger start = curLocation; + NSInteger end = curLocation; + + if(start) { + start--; + while([wordCharSet characterIsMember:[[self string] characterAtIndex:start]]) { + start--; + if(start < 0) break; + } + start++; + } + + NSUInteger strLen = [[self string] length]; + if(end <= strLen-1) { + while(end < strLen && [wordCharSet characterIsMember:[[self string] characterAtIndex:end]]) { + end++; + } + } + return(NSMakeRange(start, end-start)); + [self moveWordLeft:self]; [self moveWordRightAndModifySelection:self]; |