diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-03-09 08:39:13 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-03-09 08:39:13 +0000 |
commit | aa0a178df3316777c001c59e03c534cfa537b365 (patch) | |
tree | 48fd04e1c7b26c543de4fcb3a002eb7afbf00462 | |
parent | c0aa273646ad4b6be2d1c47a6e9d4fa67a9c59b9 (diff) | |
download | sequelpro-aa0a178df3316777c001c59e03c534cfa537b365.tar.gz sequelpro-aa0a178df3316777c001c59e03c534cfa537b365.tar.bz2 sequelpro-aa0a178df3316777c001c59e03c534cfa537b365.zip |
• fixed some minor GUI issues for SPNarrowDownCompletion window
- added oneColumn mode for dict and list view to decrease the window's width
-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 ä |