aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-01-09 22:48:42 +0000
committerBibiko <bibiko@eva.mpg.de>2010-01-09 22:48:42 +0000
commitcfd4efa37b38e213f71301355ac7b583d88d1b9e (patch)
tree420b132fe499274a687cbbb69fe76502d7fe1ce6
parentc2da83b99ca6db2e2d78b7cd79d4618e359c523a (diff)
downloadsequelpro-cfd4efa37b38e213f71301355ac7b583d88d1b9e.tar.gz
sequelpro-cfd4efa37b38e213f71301355ac7b583d88d1b9e.tar.bz2
sequelpro-cfd4efa37b38e213f71301355ac7b583d88d1b9e.zip
• reimplemented the F5 completion for quoted text i.e. completion based on NSSpellChecker only; language is selectable via right-click "Spelling and Grammar"
-rw-r--r--Source/CMTextView.m22
1 files changed, 15 insertions, 7 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 536f609f..befce811 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -128,11 +128,19 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
*/
- (NSArray *)suggestionsForSQLCompletionWith:(NSString *)currentWord dictMode:(BOOL)isDictMode
{
+
NSMutableArray *compl = [[NSMutableArray alloc] initWithCapacity:32];
- NSMutableArray *possibleCompletions = [[NSMutableArray alloc] initWithCapacity:32];
+ if(isDictMode) {
+ for (id w in [[NSSpellChecker sharedSpellChecker] completionsForPartialWordRange:NSMakeRange(0,[currentWord length]) inString:currentWord language:nil inSpellDocumentWithTag:0])
+ [compl addObject:[NSDictionary dictionaryWithObjectsAndKeys:w, @"display", @"dummy-small", @"image", nil]];
- if([mySQLConnection isConnected] && !isDictMode)
+ return [compl autorelease];
+ }
+
+ NSMutableArray *possibleCompletions = [[NSMutableArray alloc] initWithCapacity:32];
+
+ if([mySQLConnection isConnected])
{
// Add table names to completions list
for (id obj in [[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKey:@"allTableNames"])
@@ -214,16 +222,16 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
// No completion for a selection (yet?)
if ([self selectedRange].length > 0) return;
-
- // Refresh quote attributes
- [[self textStorage] removeAttribute:kQuote range:NSMakeRange(0,[[self string] length])];
- // [self insertText:@""];
-
+
// Check if the caret is inside quotes "" or ''; if so
// return the normal word suggestion due to the spelling's settings
// plus all unique words used in the textView
BOOL isDictMode = ([[[self textStorage] attribute:kQuote atIndex:[self getRangeForCurrentWord].location effectiveRange:nil] isEqualToString:kQuoteValue] );
+ // Refresh quote attributes
+ [[self textStorage] removeAttribute:kQuote range:NSMakeRange(0,[[self string] length])];
+ // [self insertText:@""];
+
NSString* filter = [[self string] substringWithRange:[self getRangeForCurrentWord]];
NSString* prefix = @"";
NSString* allow = @"_."; // additional chars which not close the popup