aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-11-06 23:16:00 +0000
committerrowanbeentje <rowan@beent.je>2010-11-06 23:16:00 +0000
commit5b74654f969a6878dc0f85cab52eeee68053fb62 (patch)
treec76a55b93eccb3a0ff1e6d85048c108d85ec88d6 /Source
parenta9be9780875d249019bd0cdf55eba960fb6f44be (diff)
downloadsequelpro-5b74654f969a6878dc0f85cab52eeee68053fb62.tar.gz
sequelpro-5b74654f969a6878dc0f85cab52eeee68053fb62.tar.bz2
sequelpro-5b74654f969a6878dc0f85cab52eeee68053fb62.zip
Minor tweaks to autocompletion:
- Show the text cursor at the location future input will be inserted for clarity - Show autocompleted text faded to indicate it's temporary and may be replaced by other keypresses
Diffstat (limited to 'Source')
-rw-r--r--Source/SPNarrowDownCompletion.m6
-rw-r--r--Source/SPTextView.m31
2 files changed, 22 insertions, 15 deletions
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index fc2c8728..d83f78c5 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -956,12 +956,18 @@
// Insert common prefix automatically
if([[self filterString] length] < [commonPrefix length]) {
+ NSUInteger currentSelectionPosition = [theView selectedRange].location;
NSString* toInsert = [commonPrefix substringFromIndex:[[self filterString] length]];
[mutablePrefix appendString:toInsert];
theCharRange.length += [toInsert length];
theParseRange.length += [toInsert length];
[theView insertText:[toInsert lowercaseString]];
commonPrefixWasInsertedByAutoComplete = YES;
+
+ // Restore the text selection location, and clearly mark the autosuggested text
+ [theView setSelectedRange:NSMakeRange(currentSelectionPosition, 0)];
+ NSMutableAttributedStringAddAttributeValueRange([theView textStorage], NSForegroundColorAttributeName, [[theView otherTextColor] colorWithAlphaComponent:0.3], NSMakeRange(currentSelectionPosition, [toInsert length]));
+
[self checkSpaceForAllowedCharacter];
}
}
diff --git a/Source/SPTextView.m b/Source/SPTextView.m
index e60a28f7..08feffe4 100644
--- a/Source/SPTextView.m
+++ b/Source/SPTextView.m
@@ -2694,6 +2694,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
// If the current token is marked as SQL keyword, uppercase it if required.
tokenEnd = tokenRange.location+tokenRange.length-1;
+
// Check the end of the token
if (textBufferSizeIncreased
&& allowToCheckForUpperCase
@@ -2703,23 +2704,23 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
// check if next char is not a kSQLkeyword or current kSQLkeyword is at the end;
// if so then upper case keyword if not already done
// @try catch() for catching valid index esp. after deleteBackward:
+ {
+
+ NSString* curTokenString = [selfstr substringWithRange:tokenRange];
+ BOOL doIt = NO;
+ @try
{
-
- NSString* curTokenString = [selfstr substringWithRange:tokenRange];
- BOOL doIt = NO;
- @try
- {
- doIt = ![(NSString*)NSMutableAttributedStringAttributeAtIndex(textStore, kSQLkeyword,tokenEnd+1,nil) length];
- } @catch(id ae) { doIt = NO; }
-
- if(doIt)
- {
- // Register it for undo works only partly for now, at least the uppercased keyword will be selected
- [self shouldChangeTextInRange:tokenRange replacementString:curTokenString];
- [self replaceCharactersInRange:tokenRange withString:[curTokenString uppercaseString]];
- }
+ doIt = ![(NSString*)NSMutableAttributedStringAttributeAtIndex(textStore, kSQLkeyword,tokenEnd+1,nil) length];
+ } @catch(id ae) { doIt = NO; }
+
+ if(doIt)
+ {
+ // Register it for undo works only partly for now, at least the uppercased keyword will be selected
+ [self shouldChangeTextInRange:tokenRange replacementString:curTokenString];
+ [self replaceCharactersInRange:tokenRange withString:[curTokenString uppercaseString]];
}
-
+ }
+
NSMutableAttributedStringAddAttributeValueRange(textStore, NSForegroundColorAttributeName, tokenColor, tokenRange);
// if(!allowToCheckForUpperCase) continue;