aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-03-09 12:18:45 +0000
committerBibiko <bibiko@eva.mpg.de>2010-03-09 12:18:45 +0000
commit2006cf37271812027cdf5659308eec6ff095ed09 (patch)
tree59b6302eadd05216b9977953b0ebb76ff34a39be
parenta896123760846a4e38c5061f335056ca8658d013 (diff)
downloadsequelpro-2006cf37271812027cdf5659308eec6ff095ed09.tar.gz
sequelpro-2006cf37271812027cdf5659308eec6ff095ed09.tar.bz2
sequelpro-2006cf37271812027cdf5659308eec6ff095ed09.zip
• fixed bug in snippet list - now it inserts the chosen item correctly after narrow-down the list
• added chance to invoke the snippet list in fuzzy search mode by the template ¦¦a¦b¦¦ • added new snippet placeholders: ¦$SP_ASLIST_ALL_TABLES¦ displays a list of all tables incl. views from the current db ¦$SP_ASLIST_ALL_DATABASES¦ displays a list of all dbs from the current connection This makes it possible to write eg a query fav: USE ¦¦$SP_ASLIST_ALL_DATABASES¦¦; to search via fuzzy mode for a db and to use it
-rw-r--r--Interfaces/English.lproj/QueryFavoriteManager.xib202
-rw-r--r--Source/CMTextView.m102
-rw-r--r--Source/SPNarrowDownCompletion.m1
3 files changed, 277 insertions, 28 deletions
diff --git a/Interfaces/English.lproj/QueryFavoriteManager.xib b/Interfaces/English.lproj/QueryFavoriteManager.xib
index 1a3cf4d3..bc83f0d5 100644
--- a/Interfaces/English.lproj/QueryFavoriteManager.xib
+++ b/Interfaces/English.lproj/QueryFavoriteManager.xib
@@ -618,6 +618,26 @@
<string key="NSAction">_popUpItemAction:</string>
<reference key="NSTarget" ref="1063983207"/>
</object>
+ <object class="NSMenuItem" id="190127525">
+ <reference key="NSMenu" ref="217968621"/>
+ <string key="NSTitle">list template (fuzzy search)</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="451328194"/>
+ <reference key="NSMixedImage" ref="770393621"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="1063983207"/>
+ </object>
+ <object class="NSMenuItem" id="915013440">
+ <reference key="NSMenu" ref="217968621"/>
+ <string key="NSTitle">list separator</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="451328194"/>
+ <reference key="NSMixedImage" ref="770393621"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="1063983207"/>
+ </object>
<object class="NSMenuItem" id="465218922">
<reference key="NSMenu" ref="217968621"/>
<bool key="NSIsDisabled">YES</bool>
@@ -660,10 +680,62 @@
<string key="NSAction">_popUpItemAction:</string>
<reference key="NSTarget" ref="1063983207"/>
</object>
+ <object class="NSMenuItem" id="825914912">
+ <reference key="NSMenu" ref="217968621"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="451328194"/>
+ <reference key="NSMixedImage" ref="770393621"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="1063983207"/>
+ </object>
+ <object class="NSMenuItem" id="385598013">
+ <reference key="NSMenu" ref="217968621"/>
+ <string key="NSTitle">table name list</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="451328194"/>
+ <reference key="NSMixedImage" ref="770393621"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="1063983207"/>
+ </object>
+ <object class="NSMenuItem" id="844132671">
+ <reference key="NSMenu" ref="217968621"/>
+ <string key="NSTitle">table name list (fuzzy search)</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="451328194"/>
+ <reference key="NSMixedImage" ref="770393621"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="1063983207"/>
+ </object>
+ <object class="NSMenuItem" id="827337733">
+ <reference key="NSMenu" ref="217968621"/>
+ <string key="NSTitle">database names as list</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="451328194"/>
+ <reference key="NSMixedImage" ref="770393621"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="1063983207"/>
+ </object>
+ <object class="NSMenuItem" id="781935079">
+ <reference key="NSMenu" ref="217968621"/>
+ <string key="NSTitle">database names as list (fuzzy search)</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="451328194"/>
+ <reference key="NSMixedImage" ref="770393621"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="1063983207"/>
+ </object>
</object>
<reference key="NSMenuFont" ref="1071840538"/>
</object>
- <int key="NSSelectedIndex">4</int>
+ <int key="NSSelectedIndex">15</int>
<bool key="NSPullDown">YES</bool>
<int key="NSPreferredEdge">1</int>
<bool key="NSUsesItemFromMenu">YES</bool>
@@ -1911,6 +1983,13 @@
<reference ref="816443132"/>
<reference ref="613928550"/>
<reference ref="866231750"/>
+ <reference ref="190127525"/>
+ <reference ref="915013440"/>
+ <reference ref="827337733"/>
+ <reference ref="781935079"/>
+ <reference ref="825914912"/>
+ <reference ref="385598013"/>
+ <reference ref="844132671"/>
</object>
<reference key="parent" ref="1063983207"/>
</object>
@@ -1959,6 +2038,41 @@
<reference key="object" ref="866231750"/>
<reference key="parent" ref="217968621"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">327</int>
+ <reference key="object" ref="190127525"/>
+ <reference key="parent" ref="217968621"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">328</int>
+ <reference key="object" ref="915013440"/>
+ <reference key="parent" ref="217968621"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">329</int>
+ <reference key="object" ref="827337733"/>
+ <reference key="parent" ref="217968621"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">330</int>
+ <reference key="object" ref="781935079"/>
+ <reference key="parent" ref="217968621"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">331</int>
+ <reference key="object" ref="825914912"/>
+ <reference key="parent" ref="217968621"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">332</int>
+ <reference key="object" ref="385598013"/>
+ <reference key="parent" ref="217968621"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">333</int>
+ <reference key="object" ref="844132671"/>
+ <reference key="parent" ref="217968621"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -2068,6 +2182,19 @@
<string>325.IBPluginDependency</string>
<string>326.IBAttributePlaceholdersKey</string>
<string>326.IBPluginDependency</string>
+ <string>327.IBAttributePlaceholdersKey</string>
+ <string>327.IBPluginDependency</string>
+ <string>328.IBAttributePlaceholdersKey</string>
+ <string>328.IBPluginDependency</string>
+ <string>329.IBAttributePlaceholdersKey</string>
+ <string>329.IBPluginDependency</string>
+ <string>330.IBAttributePlaceholdersKey</string>
+ <string>330.IBPluginDependency</string>
+ <string>331.IBPluginDependency</string>
+ <string>332.IBAttributePlaceholdersKey</string>
+ <string>332.IBPluginDependency</string>
+ <string>333.IBAttributePlaceholdersKey</string>
+ <string>333.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -2220,7 +2347,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{371, 195}, {216, 142}}</string>
+ <string>{{371, 83}, {260, 254}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
@@ -2291,6 +2418,75 @@ b2YgdGFiIHNuaXBwZXRzXQ</string>
</object>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="190127525"/>
+ <string type="base64-UTF8" key="toolTip">wqbCpmHCpmLCpsKmIOKAkyBzdWNoIGEgc25pcHBldCB3aWxsIGJlIHNob3duIGFzIGNvbXBsZXRpb24g
+bGlzdCB3aXRoIHRoZSBpdGVtcyDigJxh4oCdIGFuZCDigJxi4oCdIGluIGZ1enp5IHNlYXJjaCBtb2Rl
+Cgpbb25seSBhdmFpbGFibGUgaW5zaWRlIG9mIHRhYiBzbmlwcGV0c10</string>
+ </object>
+ </object>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="915013440"/>
+ <string type="base64-UTF8" key="toolTip">wqYg4oCTIGxpc3Qgc2VwYXJhdG9yCgpbb25seSBhdmFpbGFibGUgaW5zaWRlIG9mIHRhYiBzbmlwcGV0
+c10</string>
+ </object>
+ </object>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="827337733"/>
+ <string type="base64-UTF8" key="toolTip">wqYkU1BfQVNMSVNUX0FMTF9EQVRBQkFTRVPCpiDigJMgc3VjaCBhIHNuaXBwZXQgd2lsbCBiZSBzaG93
+biBhcyBjb21wbGV0aW9uIGxpc3Qgd2l0aCBhbGwgZGF0YWJhc2UgbmFtZXMgZnJvbSB0aGUgY3VycmVu
+dCBjb25uZWN0aW9uCgpbb25seSBhdmFpbGFibGUgaW5zaWRlIG9mIHRhYiBzbmlwcGV0c10</string>
+ </object>
+ </object>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="781935079"/>
+ <string type="base64-UTF8" key="toolTip">wqbCpiRTUF9BU0xJU1RfQUxMX0RBVEFCQVNFU8KmwqYg4oCTIHN1Y2ggYSBzbmlwcGV0IHdpbGwgYmUg
+c2hvd24gYXMgY29tcGxldGlvbiBsaXN0IHdpdGggYWxsIGRhdGFiYXNlIG5hbWVzIGZyb20gdGhlIGN1
+cnJlbnQgY29ubmVjdGlvbiBpbiBmdXp6eSBzZWFyY2ggbW9kZQoKW29ubHkgYXZhaWxhYmxlIGluc2lk
+ZSBvZiB0YWIgc25pcHBldHNdA</string>
+ </object>
+ </object>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="385598013"/>
+ <string type="base64-UTF8" key="toolTip">wqYkU1BfQVNMSVNUX0FMTF9UQUJMRVPCpiDigJMgc3VjaCBhIHNuaXBwZXQgd2lsbCBiZSBzaG93biBh
+cyBjb21wbGV0aW9uIGxpc3Qgd2l0aCBhbGwgdGFibGUgbmFtZXMgKGluY2wuIHZpZXdzKSBmcm9tIHRo
+ZSBjdXJyZW50IHNlbGVjdGVkIGRhdGFiYXNlCgpbb25seSBhdmFpbGFibGUgaW5zaWRlIG9mIHRhYiBz
+bmlwcGV0c10</string>
+ </object>
+ </object>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="844132671"/>
+ <string type="base64-UTF8" key="toolTip">wqbCpiRTUF9BU0xJU1RfQUxMX1RBQkxFU8KmwqYg4oCTIHN1Y2ggYSBzbmlwcGV0IHdpbGwgYmUgc2hv
+d24gYXMgY29tcGxldGlvbiBsaXN0IHdpdGggYWxsIHRhYmxlIG5hbWVzIChpbmNsLiB2aWV3cykgZnJv
+bSB0aGUgY3VycmVudCBzZWxlY3RlZCBkYXRhYmFzZSBpbiBmdXp6eSBzZWFyY2ggbW9kZQoKW29ubHkg
+YXZhaWxhYmxlIGluc2lkZSBvZiB0YWIgc25pcHBldHNdA</string>
+ </object>
+ </object>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -2309,7 +2505,7 @@ b2YgdGFiIHNuaXBwZXRzXQ</string>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">326</int>
+ <int key="maxID">333</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 2cdf2808..7a0cfae4 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -1108,32 +1108,84 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
if(r1.location == r2.location && r1.length == r2.length) {
[self setSelectedRange:r2];
NSString *snip = [[self string] substringWithRange:r2];
- if([snip length] > 2 && [snip hasPrefix:@"¦"] && [snip hasSuffix:@"¦"]) {
- NSArray *list = [[snip substringWithRange:NSMakeRange(1,[snip length]-2)] componentsSeparatedByString:@"¦"];
- NSMutableArray *possibleCompletions = [[[NSMutableArray alloc] initWithCapacity:[list count]] autorelease];
- for(id w in list)
- [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:w, @"display", @"dummy-small", @"image", nil]];
-
- SPNarrowDownCompletion* completionPopUp = [[SPNarrowDownCompletion alloc] initWithItems:possibleCompletions
- alreadyTyped:@""
- staticPrefix:@""
- additionalWordCharacters:@"_."
- caseSensitive:NO
- charRange:r2
- parseRange:r2
- inView:self
- dictMode:NO
- dbMode:NO
- tabTriggerMode:[self isSnippetMode]
- fuzzySearch:NO
- backtickMode:NO
- withDbName:@""
- withTableName:@""
- selectedDb:@""
- caretMovedLeft:NO
- autoComplete:NO
- oneColumn:YES];
+
+ if([snip length] > 2 && [snip hasPrefix:@"¦"] && [snip hasSuffix:@"¦"]) {
+ BOOL fuzzySearchMode = ([snip hasPrefix:@"¦¦"] && [snip hasSuffix:@"¦¦"]) ? YES : NO;
+ NSInteger offset = (fuzzySearchMode) ? 2 : 1;
+ NSRange insertRange = NSMakeRange(r2.location,0);
+ SPNarrowDownCompletion* completionPopUp;
+ NSString *newSnip = [snip substringWithRange:NSMakeRange(1*offset,[snip length]-(2*offset))];
+ if([newSnip hasPrefix:@"$SP_ASLIST_"]) {
+ NSMutableArray *possibleCompletions = [[[NSMutableArray alloc] initWithCapacity:5] autorelease];
+ NSArray *arr = nil;
+ if([newSnip isEqualToString:@"$SP_ASLIST_ALL_TABLES"]) {
+ arr = [NSArray arrayWithArray:[[[self delegate] valueForKeyPath:@"tablesListInstance"] allTableAndViewNames]];
+ if(arr == nil) {
+ arr = [NSArray array];
+ }
+ for(id w in arr)
+ [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:w, @"display", @"table-small-square", @"image", @"", @"isRef", nil]];
+ }
+ else if([newSnip isEqualToString:@"$SP_ASLIST_ALL_DATABASES"]) {
+ arr = [NSArray arrayWithArray:[[[self delegate] valueForKeyPath:@"tablesListInstance"] allDatabaseNames]];
+ if(arr == nil) {
+ arr = [NSArray array];
+ }
+ for(id w in arr)
+ [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:w, @"display", @"database-small", @"image", @"", @"isRef", nil]];
+ arr = [NSArray arrayWithArray:[[[self delegate] valueForKeyPath:@"tablesListInstance"] allSystemDatabaseNames]];
+ if(arr == nil) {
+ arr = [NSArray array];
+ }
+ for(id w in arr)
+ [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:w, @"display", @"database-small", @"image", @"", @"isRef", nil]];
+ }
+ completionPopUp = [[SPNarrowDownCompletion alloc] initWithItems:possibleCompletions
+ alreadyTyped:@""
+ staticPrefix:@""
+ additionalWordCharacters:@"_."
+ caseSensitive:NO
+ charRange:insertRange
+ parseRange:insertRange
+ inView:self
+ dictMode:NO
+ dbMode:YES
+ tabTriggerMode:[self isSnippetMode]
+ fuzzySearch:fuzzySearchMode
+ backtickMode:NO
+ withDbName:@""
+ withTableName:@""
+ selectedDb:@""
+ caretMovedLeft:NO
+ autoComplete:NO
+ oneColumn:NO];
+ } else {
+ NSArray *list = [[snip substringWithRange:NSMakeRange(1*offset,[snip length]-(2*offset))] componentsSeparatedByString:@"¦"];
+ NSMutableArray *possibleCompletions = [[[NSMutableArray alloc] initWithCapacity:[list count]] autorelease];
+ for(id w in list)
+ [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:w, @"display", @"dummy-small", @"image", nil]];
+
+ completionPopUp = [[SPNarrowDownCompletion alloc] initWithItems:possibleCompletions
+ alreadyTyped:@""
+ staticPrefix:@""
+ additionalWordCharacters:@"_."
+ caseSensitive:NO
+ charRange:insertRange
+ parseRange:insertRange
+ inView:self
+ dictMode:NO
+ dbMode:NO
+ tabTriggerMode:[self isSnippetMode]
+ fuzzySearch:fuzzySearchMode
+ backtickMode:NO
+ withDbName:@""
+ withTableName:@""
+ selectedDb:@""
+ caretMovedLeft: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];
NSRect boundingRect = [[self layoutManager] boundingRectForGlyphRange:glyphRange inTextContainer:[self textContainer]];
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index 2651024a..d7ac8048 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -750,6 +750,7 @@
- (void)insert_text:(NSString* )aString
{
+
[theView setSelectedRange:theCharRange];
[theView insertText:aString];