diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-03-07 22:07:58 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-03-07 22:07:58 +0000 |
commit | ee8c83d433d0351dffda4ce273e3d1278154f769 (patch) | |
tree | 04839edbaf31f4cf9c598dce58e24d65448f6472 /Source/SPNarrowDownCompletion.m | |
parent | fb4e3024ae282b557eef755b974c3e081dac0f3e (diff) | |
download | sequelpro-ee8c83d433d0351dffda4ce273e3d1278154f769.tar.gz sequelpro-ee8c83d433d0351dffda4ce273e3d1278154f769.tar.bz2 sequelpro-ee8c83d433d0351dffda4ce273e3d1278154f769.zip |
• added to CustomQuery's CMTextView the option to set auto-completion on/off, settable in Prefs and gear menu
- if inserted completion is marked as function it inserts snippet (${}1:) so far; function parameters as snippets follows soon
Diffstat (limited to 'Source/SPNarrowDownCompletion.m')
-rw-r--r-- | Source/SPNarrowDownCompletion.m | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index 032e80b3..8e5bebec 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -136,7 +136,7 @@ charRange:(NSRange)initRange parseRange:(NSRange)parseRange inView:(id)aView dictMode:(BOOL)mode dbMode:(BOOL)theDbMode tabTriggerMode:(BOOL)tabTriggerMode fuzzySearch:(BOOL)fuzzySearch backtickMode:(NSInteger)theBackTickMode withDbName:(NSString*)dbName withTableName:(NSString*)tableName - selectedDb:(NSString*)selectedDb caretMovedLeft:(BOOL)caretMovedLeft + selectedDb:(NSString*)selectedDb caretMovedLeft:(BOOL)caretMovedLeft autoComplete:(BOOL)autoComplete { if(self = [self init]) { @@ -145,6 +145,8 @@ if(aUserString) [mutablePrefix appendString:aUserString]; + autoCompletionMode = autoComplete; + fuzzyMode = fuzzySearch; if(fuzzyMode) [theTableView setBackgroundColor:[NSColor colorWithCalibratedRed:0.9f green:0.9f blue:0.9f alpha:1.0f]]; @@ -371,6 +373,7 @@ - (void)checkSpaceForAllowedCharacter { [textualInputCharacters removeCharactersInString:@" "]; + if(autoCompletionMode) return; if(spaceCounter < 1) for(id w in filtered){ if([[w objectForKey:@"match"] ?: [w objectForKey:@"display"] rangeOfString:@" "].length) { @@ -444,11 +447,16 @@ } if(![newFiltered count]) { - if([[self filterString] hasSuffix:@"."]) { - [theView doCompletionByUsingSpellChecker:dictMode fuzzyMode:fuzzyMode]; + if(autoCompletionMode) { closeMe = YES; + return; + } else { + if([[self filterString] hasSuffix:@"."]) { + [theView doCompletionByUsingSpellChecker:dictMode fuzzyMode:fuzzyMode autoCompleteMode:NO]; + closeMe = YES; + } + [newFiltered addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"No completions found", @"no completions found message"), @"display", @"", @"noCompletion", nil]]; } - [newFiltered addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"No completions found", @"no completions found message"), @"display", @"", @"noCompletion", nil]]; } NSPoint old = NSMakePoint([self frame].origin.x, [self frame].origin.y + [self frame].size.height); @@ -615,6 +623,7 @@ [NSApp sendEvent:event]; } } + [theView setCompletionIsOpen:NO]; [self close]; usleep(70); // tiny delay to suppress while continously pressing of ESC overlapping } @@ -665,6 +674,8 @@ // If completion string contains backticks move caret out of the backticks if(backtickMode && !triggerMode) [theView performSelector:@selector(moveRight:)]; + else if([[[filtered objectAtIndex:[theTableView selectedRow]] objectForKey:@"image"] hasPrefix:@"func"]) + [theView insertAsSnippet:@"(${1:})" atRange:[theView selectedRange]]; } - (void)completeAndInsertSnippet |