aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-08-04 07:08:49 +0000
committerBibiko <bibiko@eva.mpg.de>2009-08-04 07:08:49 +0000
commit4520742e325fd62423d0956450291cd10e407142 (patch)
tree6df8a8a5c48992e74218c5a79dcef1ab9ae77f64
parent9e8af4d33b11bdef14706955d9e71be6aaacf6a7 (diff)
downloadsequelpro-4520742e325fd62423d0956450291cd10e407142.tar.gz
sequelpro-4520742e325fd62423d0956450291cd10e407142.tar.bz2
sequelpro-4520742e325fd62423d0956450291cd10e407142.zip
• some corrections for Custom Query completion
- fixed issue if caret is inside `` for the narrow-down completion - fixed issue to add all 'Functions' for the "normal" completion - some minor code cleaning
-rw-r--r--Source/CMTextView.m38
1 files changed, 14 insertions, 24 deletions
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