aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTextViewAdditions.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-04-30 12:47:01 +0000
committerBibiko <bibiko@eva.mpg.de>2009-04-30 12:47:01 +0000
commit373af7d28f55328a0d004ddd106ccbaafdd782d4 (patch)
treeb3aba55c6bfd4ac45a56ec0bfb7dca5c167653fa /Source/SPTextViewAdditions.m
parent40dc576b30ec1da22ae58c1daaae86a6d1020b2c (diff)
downloadsequelpro-373af7d28f55328a0d004ddd106ccbaafdd782d4.tar.gz
sequelpro-373af7d28f55328a0d004ddd106ccbaafdd782d4.tar.bz2
sequelpro-373af7d28f55328a0d004ddd106ccbaafdd782d4.zip
• changed context menu item in CQ's textview to support "MySQL Help"
• prepared code to work with autoHelp • improved getRangeForCurrentWord (fix for " |a")
Diffstat (limited to 'Source/SPTextViewAdditions.m')
-rw-r--r--Source/SPTextViewAdditions.m15
1 files changed, 13 insertions, 2 deletions
diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m
index 38560b31..dc3d4c16 100644
--- a/Source/SPTextViewAdditions.m
+++ b/Source/SPTextViewAdditions.m
@@ -49,10 +49,21 @@
if(curLocation < newStartRange || curLocation > newEndRange)
{
[self setSelectedRange:curRange];
- [self moveWordRightAndModifySelection:self];
+ [self moveWordRight:self];
+ [self moveWordLeftAndModifySelection:self];
+ newStartRange = [self selectedRange].location;
+ newEndRange = newStartRange + [self selectedRange].length;
}
- if([[[self string] substringWithRange:[self selectedRange]] rangeOfCharacterFromSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].location != NSNotFound)
+ // how many space in front of the selection
+ int bias = [self selectedRange].length - [[[[self string] substringWithRange:[self selectedRange]] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length];
+ [self setSelectedRange:NSMakeRange([self selectedRange].location+bias, [self selectedRange].length-bias)];
+ newStartRange += bias;
+ newEndRange -= bias;
+
+ // is caret inside the selection still?
+ if(curLocation < newStartRange || curLocation > newEndRange
+ || [[[self string] substringWithRange:[self selectedRange]] rangeOfCharacterFromSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].location != NSNotFound)
[self setSelectedRange:curRange];
NSRange wordRange = [self selectedRange];