From 79c5e1f2d102ffa9d5121ee1f32aee8ca00c2a72 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 13 Jan 2010 15:02:09 +0000 Subject: =?UTF-8?q?=E2=80=A2=20further=20improvements=20for=20F5=20complet?= =?UTF-8?q?ion=20-=20first=20steps=20for=20context-sensitive=20completion:?= =?UTF-8?q?=20parse=20left=20side=20of=20current=20word=20to=20look=20for?= =?UTF-8?q?=20db.table.field=20constructions=20-=20eg=20type:=20mysql.user?= =?UTF-8?q?.=20=20and=20press=20F5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note: work in progress :) --- Source/SPNarrowDownCompletion.m | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'Source/SPNarrowDownCompletion.m') 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:)]; } -- cgit v1.2.3