diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMTextView.m | 6 | ||||
-rw-r--r-- | Source/SPNarrowDownCompletion.h | 3 | ||||
-rw-r--r-- | Source/SPNarrowDownCompletion.m | 28 |
3 files changed, 28 insertions, 9 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m index b21b65ee..2cdf2808 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -697,7 +697,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) withTableName:tableName selectedDb:currentDb caretMovedLeft:caretMovedLeft - autoComplete:autoCompleteMode]; + autoComplete:autoCompleteMode + oneColumn:isDictMode]; //Get the NSPoint of the first character of the current word NSRange glyphRange = [[self layoutManager] glyphRangeForCharacterRange:NSMakeRange(completionRange.location,1) actualCharacterRange:NULL]; @@ -1130,7 +1131,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) withTableName:@"" selectedDb:@"" caretMovedLeft:NO - autoComplete:NO]; + autoComplete:NO + oneColumn:YES]; //Get the NSPoint of the first character of the current word NSRange glyphRange = [[self layoutManager] glyphRangeForCharacterRange:NSMakeRange(r2.location,1) actualCharacterRange:NULL]; diff --git a/Source/SPNarrowDownCompletion.h b/Source/SPNarrowDownCompletion.h index 743f7cc5..0cc17c12 100644 --- a/Source/SPNarrowDownCompletion.h +++ b/Source/SPNarrowDownCompletion.h @@ -50,6 +50,7 @@ BOOL cursorMovedLeft; BOOL commaInsertionMode; BOOL autoCompletionMode; + BOOL oneColumnMode; NSInteger backtickMode; NSFont *tableFont; NSRange theCharRange; @@ -72,7 +73,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 autoComplete:(BOOL)autoComplete; + selectedDb:(NSString*)selectedDb caretMovedLeft:(BOOL)caretMovedLeft autoComplete:(BOOL)autoComplete oneColumn:(BOOL)oneColumn; - (void)setCaretPos:(NSPoint)aPos; - (void)insert_text:(NSString* )aString; - (void)insertCommonPrefix; diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index 9f539d67..ea6752f6 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -139,7 +139,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 autoComplete:(BOOL)autoComplete + selectedDb:(NSString*)selectedDb caretMovedLeft:(BOOL)caretMovedLeft autoComplete:(BOOL)autoComplete oneColumn:(BOOL)oneColumn { if(self = [self init]) { @@ -149,6 +149,7 @@ [mutablePrefix appendString:aUserString]; autoCompletionMode = autoComplete; + oneColumnMode = oneColumn; fuzzyMode = fuzzySearch; if(fuzzyMode) @@ -177,8 +178,25 @@ suggestions = [someSuggestions retain]; - [[theTableView tableColumnWithIdentifier:@"image"] setWidth:((dictMode) ? 0 : 20)]; - [[theTableView tableColumnWithIdentifier:@"name"] setWidth:((dictMode) ? 440 : 180)]; + if(dictMode || oneColumnMode) { + [[theTableView tableColumnWithIdentifier:@"image"] setWidth:0]; + if(!dictMode) { + NSUInteger maxLength = 0; + for(id w in someSuggestions) { + NSUInteger len = [[w objectForKey:@"display"] length]; + if(len>maxLength) maxLength = len; + } + NSMutableString *dummy = [NSMutableString string]; + for(NSUInteger i=0; i<maxLength; i++) + [dummy appendString:@" "]; + + CGFloat w = NSSizeToCGSize([dummy sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).width + 26.0f; + maxWindowWidth = (w>maxWindowWidth) ? maxWindowWidth : w; + } else { + maxWindowWidth = 220; + } + [[theTableView tableColumnWithIdentifier:@"name"] setWidth:maxWindowWidth]; + } currentDb = selectedDb; @@ -344,8 +362,6 @@ 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"] : @""; if([[filtered objectAtIndex:rowIndex] objectForKey:@"path"]) { NSPopUpButtonCell *b = [[NSPopUpButtonCell new] autorelease]; [b setPullsDown:NO]; @@ -542,7 +558,7 @@ else if(t == NSKeyDown) { NSUInteger flags = [event modifierFlags]; - unichar key = [[event characters] length] == 1 ? [[event characters] characterAtIndex:0] : 0; + unichar key = [[event characters] length] == 1 ? [[event characters] characterAtIndex:0] : 0; // Check if user pressed ⌥ to allow composing of accented characters. // e.g. for US keyboard "⌥u a" to insert ä |