diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-07-15 09:13:08 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-07-15 09:13:08 +0000 |
commit | a1f15a4aff3e32817faa5b237f4d1febd3bc4410 (patch) | |
tree | 4d6fa4a661c174ac26435656ed74ba407448acb8 /Source/CMTextView.m | |
parent | 0b9c1d19c50dd993991dda997a48699b04894090 (diff) | |
download | sequelpro-a1f15a4aff3e32817faa5b237f4d1febd3bc4410.tar.gz sequelpro-a1f15a4aff3e32817faa5b237f4d1febd3bc4410.tar.bz2 sequelpro-a1f15a4aff3e32817faa5b237f4d1febd3bc4410.zip |
• narrow-down completion (F5)
- added view icon for Views
- improved some tiny code snippets
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r-- | Source/CMTextView.m | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m index c8f62e56..dbd33342 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -133,12 +133,12 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) if([mySQLConnection isConnected] && !isDictMode) { // Add table names to completions list - for (id obj in [[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKey:@"allTableAndViewNames"]) + for (id obj in [[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKey:@"allTableNames"]) [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:obj, @"display", @"table-small-square", @"image", nil]]; // Add view names to completions list - // for (id obj in [[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKey:@"allViewNames"]) - // [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:obj, @"display", @"table-view-small", @"image", nil]]; + for (id obj in [[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKey:@"allViewNames"]) + [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:obj, @"display", @"table-view-small-square", @"image", nil]]; // Add field names to completions list for currently selected table if ([[[self window] delegate] table] != nil) @@ -170,26 +170,18 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) if([[self string] length]<6000000) { NSCharacterSet *separators = [NSCharacterSet characterSetWithCharactersInString:@" \t\r\n,()[]{}\"'`-!;=+|?:~@"]; - NSArray *textViewWords = [[self string] componentsSeparatedByCharactersInSet:separators]; + NSMutableArray *uniqueArray = [NSMutableArray array]; - NSString *s; - enumerate(textViewWords, s) - if(![uniqueArray containsObject:s]) - [uniqueArray addObject:s]; + [uniqueArray addObjectsFromArray:[[NSSet setWithArray:[[self string] componentsSeparatedByCharactersInSet:separators]] allObjects]]; // Remove current word from list [uniqueArray removeObject:currentWord]; int reverseSort = NO; NSArray *sortedArray = [[[uniqueArray mutableCopy] autorelease] sortedArrayUsingFunction:alphabeticSort context:&reverseSort]; - // [possibleCompletions addObjectsFromArray:sortedArray]; - NSString *w; - enumerate(sortedArray, w) + for(id w in sortedArray) [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:w, @"display", @"dummy-small", @"image", nil]]; - - // Remove the current word - // [possibleCompletions removeObject:currentWord]; } } @@ -212,14 +204,12 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) // Build array of dictionaries as e.g.: // [NSDictionary dictionaryWithObjectsAndKeys:@"foo", @"display", @"`foo`", @"insert", @"func-small", @"image", nil] - NSString* candidate; - enumerate(possibleCompletions, candidate) - { - if(![compl containsObject:candidate]) - [compl addObject:candidate]; - } + for(id suggestion in possibleCompletions) + if(![compl containsObject:suggestion]) + [compl addObject:suggestion]; [possibleCompletions release]; + return [compl autorelease]; } |