From 3cf01ebabf08ed5547f657869e4f453f6cb3f65a Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 25 May 2009 16:01:48 +0000 Subject: =?UTF-8?q?=E2=80=A2=20improved=20narrow-down=20completion=20-=20i?= =?UTF-8?q?f=20suggestion=20list=20contains=20a=20space=20add=20a=20space?= =?UTF-8?q?=20to=20the=20allowed=20textual=20input=20characters=20if=20not?= =?UTF-8?q?=20a=20space=20closes=20the=20pull-down=20list=20-=20some=20min?= =?UTF-8?q?or=20fine-tuning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CMTextView.m | 2 +- Source/SPNarrowDownCompletion.m | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'Source') diff --git a/Source/CMTextView.m b/Source/CMTextView.m index f2b80a16..c147678a 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -237,7 +237,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) NSString* filter = [[self string] substringWithRange:[self getRangeForCurrentWord]]; NSString* prefix = @""; - NSString* allow = @" _."; // additional chars which not close the popup + NSString* allow = @"_."; // additional chars which not close the popup BOOL caseInsensitive = YES; SPNarrowDownCompletion* completionPopUp = [[SPNarrowDownCompletion alloc] initWithItems:[self suggestionsForSQLCompletionWith:filter dictMode:isDictMode] diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index 4f54924e..cce6341a 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -126,9 +126,6 @@ if(aStaticPrefix) staticPrefix = [aStaticPrefix retain]; - if(someAdditionalWordCharacters) - [textualInputCharacters addCharactersInString:someAdditionalWordCharacters]; - caseSensitive = isCaseSensitive; theCharRange = initRange; theView = aView; @@ -140,6 +137,10 @@ suggestions = [someSuggestions retain]; words = nil; } + + if(someAdditionalWordCharacters) + [textualInputCharacters addCharactersInString:someAdditionalWordCharacters]; + } return self; } @@ -187,7 +188,7 @@ [theTableView setHeaderView:nil]; NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@"foo"] autorelease]; - //TODO maybe in the future add an image... + // [column setDataCell:[ImageAndTextCell new]]; [column setEditable:NO]; [theTableView addTableColumn:column]; @@ -259,6 +260,8 @@ float maxLen = 1; NSString* item; int i; + BOOL spaceInSuggestion = NO; + [textualInputCharacters removeCharactersInString:@" "]; float maxWidth = [self frame].size.width; if([newFiltered count]>0) { @@ -268,10 +271,16 @@ item = [newFiltered objectAtIndex:i]; else item = [[newFiltered objectAtIndex:i] objectForKey:@"display"]; + // If space in suggestion add space to allowed input chars + if(!spaceInSuggestion && [item rangeOfString:@" "].length) { + [textualInputCharacters addCharactersInString:@" "]; + spaceInSuggestion = YES; + } + if([item length]>maxLen) maxLen = [item length]; } - maxWidth = maxLen*18; + maxWidth = maxLen*16; maxWidth = (maxWidth>340) ? 340 : maxWidth; } if(caretPos.y>=0 && (isAbove || caretPos.y