diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-04-07 16:04:35 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-04-07 16:04:35 +0000 |
commit | c58984f7fb82a089bdc508f0bdf7dc6df89cb979 (patch) | |
tree | a38500ce609ad7f363202779ffec2d43d29b84e1 | |
parent | b5ade8a12cea34738d89508cb04d0cdfaf1174a9 (diff) | |
download | sequelpro-c58984f7fb82a089bdc508f0bdf7dc6df89cb979.tar.gz sequelpro-c58984f7fb82a089bdc508f0bdf7dc6df89cb979.tar.bz2 sequelpro-c58984f7fb82a089bdc508f0bdf7dc6df89cb979.zip |
Tried to fine-tune the auto-completion behaviour esp. for automatically inserted suggestions and increased the minimum auto-complete delay to 0.5s since below that a fight between computer speed and user typing speed could occur.
This addresses i625.
-rw-r--r-- | Interfaces/English.lproj/Preferences.xib | 27 | ||||
-rw-r--r-- | Source/CMTextView.m | 3 | ||||
-rw-r--r-- | Source/SPNarrowDownCompletion.h | 2 | ||||
-rw-r--r-- | Source/SPNarrowDownCompletion.m | 55 |
4 files changed, 69 insertions, 18 deletions
diff --git a/Interfaces/English.lproj/Preferences.xib b/Interfaces/English.lproj/Preferences.xib index 93d00394..9edaca7a 100644 --- a/Interfaces/English.lproj/Preferences.xib +++ b/Interfaces/English.lproj/Preferences.xib @@ -21,12 +21,13 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> + <integer value="1520"/> <integer value="60"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.brandonwalkin.BWToolkit</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> </object> <object class="NSMutableDictionary" key="IBDocument.Metadata"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -56,7 +57,7 @@ <string key="NSWindowTitle">Preferences</string> <string key="NSWindowClass">NSWindow</string> <nil key="NSViewClass"/> - <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> + <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{500, 0}</string> <object class="NSView" key="NSWindowView" id="1006"> <nil key="NSNextResponder"/> @@ -65,7 +66,7 @@ </object> <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string> <string key="NSMinSize">{500, 22}</string> - <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> + <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> </object> <object class="NSCustomView" id="594324362"> <nil key="NSNextResponder"/> @@ -454,7 +455,7 @@ <string key="NSColorName">controlColor</string> <object class="NSColor" key="NSColor" id="432854223"> <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes> + <bytes key="NSWhite">MC42NjY2NjY2ODY1AA</bytes> </object> </object> <object class="NSColor" key="NSTextColor" id="1035618107"> @@ -3221,7 +3222,7 @@ AQAAAAA</bytes> <string key="NSClassName">NSView</string> </object> <object class="NSCustomView" id="1033452264"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder"/> <int key="NSvFlags">268</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -3915,8 +3916,8 @@ AQAAAAA</bytes> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="409964321"> <int key="NSCellFlags">-1538130368</int> - <int key="NSCellFlags2">-2076048384</int> - <string key="NSContents">0.1</string> + <int key="NSCellFlags2">71435264</int> + <real value="0.5" key="NSContents"/> <reference key="NSSupport" ref="26"/> <object class="NSNumberFormatter" key="NSFormatter" id="706329937"> <object class="NSMutableDictionary" key="NS.attributes"> @@ -3945,7 +3946,7 @@ AQAAAAA</bytes> <reference ref="894463536"/> <real value="20"/> <integer value="1"/> - <real value="0.10000000000000001"/> + <real value="0.5"/> <integer value="1"/> <string>#.0</string> </object> @@ -3960,7 +3961,7 @@ AQAAAAA</bytes> <string key="NSString">NaN</string> <reference key="NSAttributes" ref="469277987"/> </object> - <real value="0.10000000000000001" key="NS.min"/> + <real value="0.5" key="NS.min"/> <real value="20" key="NS.max"/> <object class="NSDecimalNumberHandler" key="NS.rounding"> <int key="NS.roundingmode">3</int> @@ -4008,7 +4009,7 @@ AQAAAAA</bytes> <reference key="NSSupport" ref="26"/> <reference key="NSControlView" ref="107658761"/> <double key="NSValue">1</double> - <double key="NSMinValue">0.10000000000000001</double> + <double key="NSMinValue">0.5</double> <double key="NSMaxValue">5</double> <double key="NSIncrement">0.10000000000000001</double> <bool key="NSAutorepeat">YES</bool> @@ -4199,14 +4200,10 @@ AQAAAAA</bytes> </object> </object> <string key="NSFrameSize">{500, 395}</string> + <reference key="NSSuperview"/> <string key="NSClassName">NSView</string> </object> <object class="NSUserDefaultsController" id="151174232"> - <object class="NSMutableArray" key="NSDeclaredKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>SUSendProfileInfo</string> - <string>SUEnableAutomaticChecks</string> - </object> <bool key="NSSharedInstance">YES</bool> </object> <object class="NSArrayController" id="937123943"> diff --git a/Source/CMTextView.m b/Source/CMTextView.m index 0a753007..75839bc8 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -791,8 +791,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [completionPopUp setCaretPos:pos]; [completionPopUp orderFront:self]; - if(!autoCompleteMode) - [completionPopUp insertCommonPrefix]; + [completionPopUp insertCommonPrefix]; } diff --git a/Source/SPNarrowDownCompletion.h b/Source/SPNarrowDownCompletion.h index fc8bd942..032aef24 100644 --- a/Source/SPNarrowDownCompletion.h +++ b/Source/SPNarrowDownCompletion.h @@ -50,6 +50,8 @@ BOOL autoCompletionMode; BOOL oneColumnMode; BOOL isQueryingDatabaseStructure; + BOOL commonPrefixWasInsertedByAutoComplete; + NSMutableString *originalFilterString; NSInteger backtickMode; NSFont *tableFont; NSRange theCharRange; diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index 3de3067f..84568019 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -118,7 +118,10 @@ filtered = nil; spaceCounter = 0; currentSyncImage = 0; + commonPrefixWasInsertedByAutoComplete = NO; prefs = [NSUserDefaults standardUserDefaults]; + originalFilterString = [[NSMutableString alloc] init]; + [originalFilterString setString:@""]; tableFont = [NSUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] dataForKey:SPCustomQueryEditorFont]]; [self setupInterface]; @@ -146,7 +149,7 @@ [staticPrefix release]; [mutablePrefix release]; [textualInputCharacters release]; - + [originalFilterString release]; if(suggestions) [suggestions release]; if (filtered) [filtered release]; @@ -210,6 +213,10 @@ [mutablePrefix appendString:aUserString]; autoCompletionMode = autoComplete; + + if(autoCompletionMode) + [originalFilterString appendString:aUserString]; + oneColumnMode = oneColumn; isQueryingDatabaseStructure = isQueryingDBStructure; @@ -765,6 +772,16 @@ // e.g. for US keyboard "⌥u a" to insert ä if (([event modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask)) == NSAlternateKeyMask || [[event characters] length] == 0) { + if(autoCompletionMode) { + if(commonPrefixWasInsertedByAutoComplete) { + [theView setSelectedRange:theCharRange]; + [theView insertText:originalFilterString]; + [NSApp sendEvent:event]; + [theView setCompletionIsOpen:NO]; + [self close]; + break; + } + } [NSApp sendEvent: event]; if(commaInsertionMode) @@ -787,6 +804,15 @@ [theTableView setBackgroundColor:[NSColor colorWithCalibratedRed:0.9f green:0.9f blue:0.9f alpha:1.0f]]; [self filter]; } else { + if(autoCompletionMode) { + if(commonPrefixWasInsertedByAutoComplete) { + [theView setSelectedRange:theCharRange]; + [theView insertText:originalFilterString]; + } + [theView setCompletionIsOpen:NO]; + [self close]; + break; + } if(cursorMovedLeft) [theView performSelector:@selector(moveRight:)]; break; } @@ -797,6 +823,14 @@ } else if(key == NSBackspaceCharacter || key == NSDeleteCharacter) { + if(autoCompletionMode) { + if(commonPrefixWasInsertedByAutoComplete) { + [theView setSelectedRange:theCharRange]; + [theView insertText:originalFilterString]; + } + [NSApp sendEvent:event]; + break; + } [NSApp sendEvent:event]; if([mutablePrefix length] == 0 || commaInsertionMode) break; @@ -809,6 +843,18 @@ } else if([textualInputCharacters characterIsMember:key]) { + + if(autoCompletionMode) { + [theView setCompletionIsOpen:NO]; + [self close]; + if(commonPrefixWasInsertedByAutoComplete) { + [theView setSelectedRange:theCharRange]; + [theView insertText:originalFilterString]; + } + [NSApp sendEvent:event]; + return; + } + [NSApp sendEvent:event]; if(commaInsertionMode) @@ -837,6 +883,12 @@ } else { [NSApp sendEvent:event]; if(!NSPointInRect([NSEvent mouseLocation], [self frame])) { + if(autoCompletionMode) { + if(commonPrefixWasInsertedByAutoComplete) { + [theView setSelectedRange:theCharRange]; + [theView insertText:originalFilterString]; + } + } if(cursorMovedLeft) [theView performSelector:@selector(moveRight:)]; break; } @@ -887,6 +939,7 @@ theCharRange.length += [toInsert length]; theParseRange.length += [toInsert length]; [theView insertText:[toInsert lowercaseString]]; + commonPrefixWasInsertedByAutoComplete = YES; [self checkSpaceForAllowedCharacter]; } } |