aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPNarrowDownCompletion.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-01-13 15:02:09 +0000
committerBibiko <bibiko@eva.mpg.de>2010-01-13 15:02:09 +0000
commit79c5e1f2d102ffa9d5121ee1f32aee8ca00c2a72 (patch)
tree0da14eed0641ebab73db6fbe638107d502850669 /Source/SPNarrowDownCompletion.m
parentbf772fc91f17883aa87778e3d5eab9e4171259c2 (diff)
downloadsequelpro-79c5e1f2d102ffa9d5121ee1f32aee8ca00c2a72.tar.gz
sequelpro-79c5e1f2d102ffa9d5121ee1f32aee8ca00c2a72.tar.bz2
sequelpro-79c5e1f2d102ffa9d5121ee1f32aee8ca00c2a72.zip
• further improvements for F5 completion
- first steps for context-sensitive completion: parse left side of current word to look for db.table.field constructions - eg type: mysql.user. and press F5 Note: work in progress :)
Diffstat (limited to 'Source/SPNarrowDownCompletion.m')
-rw-r--r--Source/SPNarrowDownCompletion.m35
1 files changed, 25 insertions, 10 deletions
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index f47baeab..a041315e 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -124,7 +124,11 @@
[super dealloc];
}
-- (id)initWithItems:(NSArray*)someSuggestions alreadyTyped:(NSString*)aUserString staticPrefix:(NSString*)aStaticPrefix additionalWordCharacters:(NSString*)someAdditionalWordCharacters caseSensitive:(BOOL)isCaseSensitive charRange:(NSRange)initRange inView:(id)aView dictMode:(BOOL)mode dbMode:(BOOL)dbMode
+- (id)initWithItems:(NSArray*)someSuggestions alreadyTyped:(NSString*)aUserString staticPrefix:(NSString*)aStaticPrefix
+ additionalWordCharacters:(NSString*)someAdditionalWordCharacters caseSensitive:(BOOL)isCaseSensitive
+ charRange:(NSRange)initRange inView:(id)aView
+ dictMode:(BOOL)mode dbMode:(BOOL)theDbMode
+ backtickMode:(BOOL)theBackTickMode withDbName:(NSString*)dbName withTableName:(NSString*)tableName
{
if(self = [self init])
{
@@ -135,7 +139,9 @@
if(aUserString && !filterStringIsBacktick)
[mutablePrefix appendString:aUserString];
- dbStructureMode = dbMode;
+ dbStructureMode = theDbMode;
+
+ backtickMode = theBackTickMode;
if(aStaticPrefix)
staticPrefix = [aStaticPrefix retain];
@@ -150,7 +156,7 @@
theView = aView;
dictMode = mode;
-
+
if(!dictMode) {
suggestions = [someSuggestions retain];
words = nil;
@@ -256,16 +262,24 @@
if(imageName)
image = [NSImage imageNamed:imageName];
[[aTableColumn dataCell] setImage:image];
- return @"";
}
+ return @"";
} else if([[aTableColumn identifier] isEqualToString:@"name"]) {
- return [[filtered objectAtIndex:rowIndex] objectForKey:@"display"];
+ return (dictMode) ? [filtered objectAtIndex:rowIndex] : [[filtered objectAtIndex:rowIndex] objectForKey:@"display"];
} else if([[aTableColumn identifier] isEqualToString:@"type"]) {
- [[aTableColumn dataCell] setTextColor:([aTableView selectedRow] == rowIndex)?[NSColor whiteColor]:[NSColor darkGrayColor]];
- return ([[filtered objectAtIndex:rowIndex] objectForKey:@"type"])?[[filtered objectAtIndex:rowIndex] objectForKey:@"type"]:@"";
+ if(dictMode) {
+ return @"";
+ } else {
+ [[aTableColumn dataCell] setTextColor:([aTableView selectedRow] == rowIndex)?[NSColor whiteColor]:[NSColor darkGrayColor]];
+ return ([[filtered objectAtIndex:rowIndex] objectForKey:@"type"]) ? [[filtered objectAtIndex:rowIndex] objectForKey:@"type"] : @"";
+ }
} else if ([[aTableColumn identifier] isEqualToString:@"path"]) {
- [[aTableColumn dataCell] setTextColor:([aTableView selectedRow] == rowIndex)?[NSColor whiteColor]:[NSColor darkGrayColor]];
- return ([[filtered objectAtIndex:rowIndex] objectForKey:@"path"])?[[filtered objectAtIndex:rowIndex] objectForKey:@"path"]:@"";
+ if(dictMode) {
+ return @"";
+ } else {
+ [[aTableColumn dataCell] setTextColor:([aTableView selectedRow] == rowIndex)?[NSColor whiteColor]:[NSColor darkGrayColor]];
+ return ([[filtered objectAtIndex:rowIndex] objectForKey:@"path"]) ? [[filtered objectAtIndex:rowIndex] objectForKey:@"path"] : @"";
+ }
}
return [filtered objectAtIndex:rowIndex];
}
@@ -534,7 +548,8 @@
{
[theView setSelectedRange:theCharRange];
[theView insertText:aString];
- if(dbStructureMode)
+ // If completion was invoked inside backticks move caret out of the backticks
+ if(backtickMode)
[theView performSelector:@selector(moveRight:)];
}