diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-01-22 13:23:29 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-01-22 13:23:29 +0000 |
commit | 748b8d279907bd3ce5c1b0dbd33edaa296ea2bb5 (patch) | |
tree | 90f6630a287b4e7a0bc07eb9390ced2d72bf42a3 | |
parent | 2b706eeebd9f4a9eaa1ed970af6bb4050b29ab0f (diff) | |
download | sequelpro-748b8d279907bd3ce5c1b0dbd33edaa296ea2bb5.tar.gz sequelpro-748b8d279907bd3ce5c1b0dbd33edaa296ea2bb5.tar.bz2 sequelpro-748b8d279907bd3ce5c1b0dbd33edaa296ea2bb5.zip |
• bound Custom Query gear menu item "Completion List" (CTRL key is recognized)
• use regexp to get a list of current words and reduced that method to invoked if the text buffer is less than 60KB to speed up the completion (it's more likely that the user wants to complete a sql related term)
• some code cosmetics
-rw-r--r-- | Source/CMTextView.m | 24 | ||||
-rw-r--r-- | Source/CustomQuery.m | 5 |
2 files changed, 15 insertions, 14 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m index b64c07a0..4b42d009 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -169,13 +169,11 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) // If caret is not inside backticks add keywords and all words coming from the view. if(!dbBrowseMode) { - // Only parse for words if text size is less than 6MB - if([[self string] length] && [[self string] length]<6000000) + // Only parse for words if text size is less than 60kB + if([[self string] length] && [[self string] length]<60000) { - NSCharacterSet *separators = [NSCharacterSet characterSetWithCharactersInString:@" \t\r\n,()[]{}\"'`-!;=+|?:~@."]; - NSMutableArray *uniqueArray = [NSMutableArray array]; - [uniqueArray addObjectsFromArray:[[NSSet setWithArray:[[self string] componentsSeparatedByCharactersInSet:separators]] allObjects]]; + [uniqueArray addObjectsFromArray:[NSSet setWithArray:[[self string] componentsMatchedByRegex:@"\\w+"]]]; // Remove current word from list [uniqueArray removeObject:currentWord]; @@ -397,6 +395,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) // No completion for a selection (yet?) and if caret positiopn == 0 if([self selectedRange].length > 0 || ![self selectedRange].location) return; + [self breakUndoCoalescing]; + NSInteger caretPos = [self selectedRange].location; BOOL caretMovedLeft = NO; @@ -431,6 +431,11 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) NSInteger backtickMode = 0; // 0 none, 1 rigth only, 2 left only, 3 both BOOL caseInsensitive = YES; + // Remove that attribute to suppress auto-uppercasing of certain keyword combinations + if(![self selectedRange].length && [self selectedRange].location) + [[self textStorage] removeAttribute:kSQLkeyword range:completionRange]; + + if(!isDictMode) { // Parse for leading db.table.field infos @@ -822,22 +827,15 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) unichar insertedCharacter = [characters characterAtIndex:0]; long curFlags = ([theEvent modifierFlags] & allFlags); - if ([theEvent keyCode] == 53){ // ESC key for internal completion - [self breakUndoCoalescing]; + if ([theEvent keyCode] == 53 && [self isEditable]){ // ESC key for internal completion if(curFlags==(NSControlKeyMask)) [self doCompletionByUsingSpellChecker:NO fuzzyMode:YES]; else [self doCompletionByUsingSpellChecker:NO fuzzyMode:NO]; - // Remove that attribute to suppress auto-uppercasing of certain keyword combinations - if(![self selectedRange].length && [self selectedRange].location) - [[self textStorage] removeAttribute:kSQLkeyword range:[self getRangeForCurrentWord]]; return; } if (insertedCharacter == NSF5FunctionKey){ // F5 for completion based on spell checker [self doCompletionByUsingSpellChecker:YES fuzzyMode:NO]; - // Remove that attribute to suppress auto-uppercasing of certain keyword combinations - if(![self selectedRange].length && [self selectedRange].location) - [[self textStorage] removeAttribute:kSQLkeyword range:[self getRangeForCurrentWord]]; return; } diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 62deb15d..b536491b 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -283,7 +283,10 @@ // "Completion List" menu item - used to autocomplete. Uses a different shortcut to avoid the menu button flickering // on normal autocomplete usage. if (sender == completionListMenuItem) { - [textView complete:self]; + if([[NSApp currentEvent] modifierFlags] & (NSControlKeyMask)) + [textView doCompletionByUsingSpellChecker:NO fuzzyMode:YES]; + else + [textView doCompletionByUsingSpellChecker:NO fuzzyMode:NO]; } // "Editor font..." menu item to bring up the font panel |