From 4520742e325fd62423d0956450291cd10e407142 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 4 Aug 2009 07:08:49 +0000 Subject: =?UTF-8?q?=E2=80=A2=20some=20corrections=20for=20Custom=20Query?= =?UTF-8?q?=20completion=20-=20fixed=20issue=20if=20caret=20is=20inside=20?= =?UTF-8?q?``=20=20for=20the=20narrow-down=20completion=20-=20fixed=20issu?= =?UTF-8?q?e=20to=20add=20all=20'Functions'=20for=20the=20"normal"=20compl?= =?UTF-8?q?etion=20-=20some=20minor=20code=20cleaning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CMTextView.m | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'Source/CMTextView.m') diff --git a/Source/CMTextView.m b/Source/CMTextView.m index 2ce6022d..042a76fa 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -121,6 +121,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) * the set of unique words, SQL keywords, user-defined funcs/procs, tables etc. * NSDic key "display" := the displayed and to be inserted word * NSDic key "image" := an image to be shown left from "display" (optional) + * + * [NSDictionary dictionaryWithObjectsAndKeys:@"foo", @"display", @"`foo`", @"insert", @"func-small", @"image", nil] */ - (NSArray *)suggestionsForSQLCompletionWith:(NSString *)currentWord dictMode:(BOOL)isDictMode { @@ -181,27 +183,20 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:w, @"display", @"dummy-small", @"image", nil]]; } - } - // Add predefined keywords - if(!isDictMode) { - // [possibleCompletions addObjectsFromArray:[self keywords]]; - NSString *s; - enumerate([self keywords], s) - [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:s, @"display", @"dummy-small", @"image", nil]]; - } - + if(!isDictMode) { + // Add predefined keywords + for(id s in [self keywords]) + [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:s, @"display", @"dummy-small", @"image", nil]]; + + // Add predefined functions + for(id s in [self functions]) + [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:s, @"display", @"func-small", @"image", nil]]; + } - // Add predefined functions - if(!isDictMode) { - // [possibleCompletions addObjectsFromArray:[self functions]]; - NSString *s; - enumerate([self functions], s) - [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:s, @"display", @"func-small", @"image", nil]]; } - - // Build array of dictionaries as e.g.: - // [NSDictionary dictionaryWithObjectsAndKeys:@"foo", @"display", @"`foo`", @"insert", @"func-small", @"image", nil] + + // Make suggestions unique for(id suggestion in possibleCompletions) if(![compl containsObject:suggestion]) [compl addObject:suggestion]; @@ -912,12 +907,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) if(![[[self textStorage] attribute:kBTQuote atIndex:charRange.location effectiveRange:nil] isEqualToString:kBTQuoteValue] ) { // Only parse for words if text size is less than 6MB - // if([[self string] length]<6000000) - // { - // NSCharacterSet *separators = [NSCharacterSet characterSetWithCharactersInString:@" \t\r\n,()\"'`-!;=+|?:~@"]; - // NSArray *textViewWords = [[self string] componentsSeparatedByCharactersInSet:separators]; - // [possibleCompletions addObjectsFromArray:textViewWords]; - // } if([[self string] length]<6000000) { NSCharacterSet *separators = [NSCharacterSet characterSetWithCharactersInString:@" \t\r\n,()[]{}\"'`-!;=+|?:~@"]; @@ -927,6 +916,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } [possibleCompletions addObjectsFromArray:[self keywords]]; + [possibleCompletions addObjectsFromArray:[self functions]]; } // Check for possible completions -- cgit v1.2.3