From 5b74654f969a6878dc0f85cab52eeee68053fb62 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 6 Nov 2010 23:16:00 +0000 Subject: 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 --- Source/SPNarrowDownCompletion.m | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Source/SPNarrowDownCompletion.m') 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]; } } -- cgit v1.2.3