aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/QueryFavoriteManager.xib317
-rw-r--r--Source/CMTextView.h8
-rw-r--r--Source/CMTextView.m148
-rw-r--r--Source/CustomQuery.m24
-rw-r--r--Source/SPQueryController.m4
-rw-r--r--Source/SPQueryFavoriteManager.h1
-rw-r--r--Source/SPQueryFavoriteManager.m20
7 files changed, 469 insertions, 53 deletions
diff --git a/Interfaces/English.lproj/QueryFavoriteManager.xib b/Interfaces/English.lproj/QueryFavoriteManager.xib
index 27d90824..324c901c 100644
--- a/Interfaces/English.lproj/QueryFavoriteManager.xib
+++ b/Interfaces/English.lproj/QueryFavoriteManager.xib
@@ -3,7 +3,7 @@
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">10C540</string>
- <string key="IBDocument.InterfaceBuilderVersion">732</string>
+ <string key="IBDocument.InterfaceBuilderVersion">740</string>
<string key="IBDocument.AppKitVersion">1038.25</string>
<string key="IBDocument.HIToolboxVersion">458.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
@@ -15,18 +15,18 @@
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>732</string>
- <string>1.2.2</string>
+ <string>740</string>
+ <string>1.2.1</string>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="26"/>
+ <integer value="1"/>
</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 +56,7 @@
<string key="NSWindowTitle">Query Favorite Manager</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, 371}</string>
<object class="NSView" key="NSWindowView" id="1006">
<reference key="NSNextResponder"/>
@@ -334,14 +334,14 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableView" id="522643855">
<reference key="NSNextResponder" ref="106335880"/>
- <int key="NSvFlags">4352</int>
- <string key="NSFrameSize">{209, 322}</string>
+ <int key="NSvFlags">4370</int>
+ <string key="NSFrameSize">{210, 322}</string>
<reference key="NSSuperview" ref="106335880"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTableHeaderView" key="NSHeaderView" id="724842455">
<reference key="NSNextResponder" ref="642947098"/>
<int key="NSvFlags">4352</int>
- <string key="NSFrameSize">{209, 17}</string>
+ <string key="NSFrameSize">{210, 17}</string>
<reference key="NSSuperview" ref="642947098"/>
<reference key="NSTableView" ref="522643855"/>
</object>
@@ -355,7 +355,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableColumn" id="901293108">
<string key="NSIdentifier">name</string>
- <double key="NSWidth">206</double>
+ <double key="NSWidth">153</double>
<double key="NSMinWidth">40</double>
<double key="NSMaxWidth">1000</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
@@ -371,7 +371,7 @@
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
</object>
- <object class="NSColor" key="NSTextColor">
+ <object class="NSColor" key="NSTextColor" id="650810728">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">headerTextColor</string>
@@ -393,7 +393,7 @@
<string key="NSColorName">controlBackgroundColor</string>
<object class="NSColor" key="NSColor" id="276872502">
<int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
+ <bytes key="NSWhite">MC42NjY2NjY2ODY1AA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor" id="810868150">
@@ -408,6 +408,37 @@
<bool key="NSIsEditable">YES</bool>
<reference key="NSTableView" ref="522643855"/>
</object>
+ <object class="NSTableColumn" id="724452944">
+ <string key="NSIdentifier">tabtrigger</string>
+ <double key="NSWidth">51</double>
+ <double key="NSMinWidth">20</double>
+ <double key="NSMaxWidth">3.4028234663852886e+38</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">67110912</int>
+ <string key="NSContents"/>
+ <reference key="NSSupport" ref="26"/>
+ <object class="NSColor" key="NSBackgroundColor">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">headerColor</string>
+ <reference key="NSColor" ref="359131077"/>
+ </object>
+ <reference key="NSTextColor" ref="650810728"/>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="748556447">
+ <int key="NSCellFlags">337772096</int>
+ <int key="NSCellFlags2">133120</int>
+ <string key="NSContents">Text Cell</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="522643855"/>
+ <reference key="NSBackgroundColor" ref="392588142"/>
+ <reference key="NSTextColor" ref="810868150"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <reference key="NSTableView" ref="522643855"/>
+ </object>
</object>
<double key="NSIntercellSpacingWidth">3</double>
<double key="NSIntercellSpacingHeight">2</double>
@@ -430,11 +461,11 @@
</object>
</object>
<double key="NSRowHeight">16</double>
- <int key="NSTvFlags">1245708288</int>
+ <int key="NSTvFlags">1262485504</int>
<reference key="NSDelegate"/>
<reference key="NSDataSource"/>
<string key="NSAutosaveName">SPQueryFavoriteManagerTable</string>
- <int key="NSColumnAutoresizingStyle">4</int>
+ <int key="NSColumnAutoresizingStyle">5</int>
<int key="NSDraggingSourceMaskForLocal">15</int>
<int key="NSDraggingSourceMaskForNonLocal">0</int>
<bool key="NSAllowsTypeSelect">YES</bool>
@@ -442,7 +473,7 @@
<int key="NSTableViewDraggingDestinationStyle">1</int>
</object>
</object>
- <string key="NSFrame">{{0, 17}, {209, 322}}</string>
+ <string key="NSFrame">{{0, 17}, {210, 322}}</string>
<reference key="NSSuperview" ref="205303038"/>
<reference key="NSNextKeyView" ref="522643855"/>
<reference key="NSDocView" ref="522643855"/>
@@ -476,7 +507,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="724842455"/>
</object>
- <string key="NSFrameSize">{209, 17}</string>
+ <string key="NSFrameSize">{210, 17}</string>
<reference key="NSSuperview" ref="205303038"/>
<reference key="NSNextKeyView" ref="724842455"/>
<reference key="NSDocView" ref="724842455"/>
@@ -485,7 +516,7 @@
</object>
<reference ref="299150059"/>
</object>
- <string key="NSFrame">{{0, 22}, {209, 339}}</string>
+ <string key="NSFrame">{{-0.5, 22}, {210, 339}}</string>
<reference key="NSSuperview" ref="1030932325"/>
<reference key="NSNextKeyView" ref="106335880"/>
<int key="NSsFlags">528</int>
@@ -506,6 +537,49 @@
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSTextField" id="92903832">
+ <reference key="NSNextResponder" ref="954707656"/>
+ <int key="NSvFlags">290</int>
+ <string key="NSFrame">{{92, 54}, {178, 19}}</string>
+ <reference key="NSSuperview" ref="954707656"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="276546601">
+ <int key="NSCellFlags">-1804468671</int>
+ <int key="NSCellFlags2">272761856</int>
+ <string key="NSContents"/>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="92903832"/>
+ <bool key="NSDrawsBackground">YES</bool>
+ <reference key="NSBackgroundColor" ref="570692726"/>
+ <object class="NSColor" key="NSTextColor" id="726114975">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">textColor</string>
+ <reference key="NSColor" ref="646528321"/>
+ </object>
+ </object>
+ </object>
+ <object class="NSTextField" id="1033778944">
+ <reference key="NSNextResponder" ref="954707656"/>
+ <int key="NSvFlags">288</int>
+ <string key="NSFrame">{{17, 57}, {70, 14}}</string>
+ <reference key="NSSuperview" ref="954707656"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="497354008">
+ <int key="NSCellFlags">68288064</int>
+ <int key="NSCellFlags2">272761856</int>
+ <string key="NSContents">Tab Trigger:</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="1033778944"/>
+ <object class="NSColor" key="NSBackgroundColor" id="317688049">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlColor</string>
+ <reference key="NSColor" ref="276872502"/>
+ </object>
+ <reference key="NSTextColor" ref="810868150"/>
+ </object>
+ </object>
<object class="NSTextField" id="350107303">
<reference key="NSNextResponder" ref="954707656"/>
<int key="NSvFlags">268</int>
@@ -518,12 +592,7 @@
<string key="NSContents">Name:</string>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="350107303"/>
- <object class="NSColor" key="NSBackgroundColor">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">controlColor</string>
- <reference key="NSColor" ref="276872502"/>
- </object>
+ <reference key="NSBackgroundColor" ref="317688049"/>
<reference key="NSTextColor" ref="810868150"/>
</object>
</object>
@@ -542,12 +611,7 @@
<reference key="NSControlView" ref="247897226"/>
<bool key="NSDrawsBackground">YES</bool>
<reference key="NSBackgroundColor" ref="570692726"/>
- <object class="NSColor" key="NSTextColor">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">textColor</string>
- <reference key="NSColor" ref="646528321"/>
- </object>
+ <reference key="NSTextColor" ref="726114975"/>
</object>
</object>
<object class="NSScrollView" id="407061848">
@@ -660,7 +724,7 @@
<nil key="NSDelegate"/>
</object>
</object>
- <string key="NSFrame">{{1, 1}, {248, 264}}</string>
+ <string key="NSFrame">{{1, 1}, {248, 236}}</string>
<reference key="NSSuperview" ref="407061848"/>
<reference key="NSNextKeyView" ref="556251150"/>
<reference key="NSDocView" ref="556251150"/>
@@ -693,7 +757,7 @@
<double key="NSPercent">0.94565218687057495</double>
</object>
</object>
- <string key="NSFrame">{{20, 54}, {250, 266}}</string>
+ <string key="NSFrame">{{20, 82}, {250, 238}}</string>
<reference key="NSSuperview" ref="954707656"/>
<reference key="NSNextKeyView" ref="221447089"/>
<int key="NSsFlags">530</int>
@@ -761,7 +825,7 @@
<string key="NSAutosaveName">SPQueryFavoriteSplitView</string>
<object class="NSColor" key="BWSVColor">
<int key="NSColorSpace">1</int>
- <bytes key="NSRGB">MC42NjY2NjY2NjY3IDAuNjY2NjY2NjY2NyAwLjY2NjY2NjY2NjcAA</bytes>
+ <bytes key="NSRGB">MC42NjY2NjY2ODY1IDAuNjY2NjY2Njg2NSAwLjY2NjY2NjY4NjUAA</bytes>
</object>
<bool key="BWSVColorIsEnabled">YES</bool>
<object class="NSMutableDictionary" key="BWSVMinValues">
@@ -819,7 +883,7 @@
</object>
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
<string key="NSMinSize">{500, 393}</string>
- <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
+ <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
<string key="NSFrameAutosaveName">SPQueryFavoriteManagerWindow</string>
</object>
<object class="NSUserDefaultsController" id="592597522">
@@ -968,14 +1032,6 @@
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
- <string key="label">nextKeyView</string>
- <reference key="source" ref="407061848"/>
- <reference key="destination" ref="247897226"/>
- </object>
- <int key="connectionID">186</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1005"/>
<reference key="destination" ref="1001"/>
@@ -1202,6 +1258,46 @@
</object>
<int key="connectionID">301</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBBindingConnection" key="connection">
+ <string key="label">value: selection.tabtrigger</string>
+ <reference key="source" ref="92903832"/>
+ <reference key="destination" ref="863945469"/>
+ <object class="NSNibBindingConnector" key="connector">
+ <reference key="NSSource" ref="92903832"/>
+ <reference key="NSDestination" ref="863945469"/>
+ <string key="NSLabel">value: selection.tabtrigger</string>
+ <string key="NSBinding">value</string>
+ <string key="NSKeyPath">selection.tabtrigger</string>
+ <int key="NSNibBindingConnectorVersion">2</int>
+ </object>
+ </object>
+ <int key="connectionID">309</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">nextKeyView</string>
+ <reference key="source" ref="92903832"/>
+ <reference key="destination" ref="556514169"/>
+ </object>
+ <int key="connectionID">311</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">favoriteTabTriggerTextField</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="92903832"/>
+ </object>
+ <int key="connectionID">312</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="92903832"/>
+ <reference key="destination" ref="1001"/>
+ </object>
+ <int key="connectionID">313</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1313,6 +1409,8 @@
<reference ref="350107303"/>
<reference ref="556514169"/>
<reference ref="602197876"/>
+ <reference ref="1033778944"/>
+ <reference ref="92903832"/>
</object>
<reference key="parent" ref="588484039"/>
</object>
@@ -1479,6 +1577,7 @@
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="901293108"/>
+ <reference ref="724452944"/>
</object>
<reference key="parent" ref="205303038"/>
</object>
@@ -1589,6 +1688,48 @@
<reference key="object" ref="724842455"/>
<reference key="parent" ref="205303038"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">302</int>
+ <reference key="object" ref="724452944"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="748556447"/>
+ </object>
+ <reference key="parent" ref="522643855"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">303</int>
+ <reference key="object" ref="748556447"/>
+ <reference key="parent" ref="724452944"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">304</int>
+ <reference key="object" ref="92903832"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="276546601"/>
+ </object>
+ <reference key="parent" ref="954707656"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">305</int>
+ <reference key="object" ref="276546601"/>
+ <reference key="parent" ref="92903832"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">306</int>
+ <reference key="object" ref="1033778944"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="497354008"/>
+ </object>
+ <reference key="parent" ref="954707656"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">307</int>
+ <reference key="object" ref="497354008"/>
+ <reference key="parent" ref="1033778944"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1672,13 +1813,20 @@
<string>280.IBPluginDependency</string>
<string>281.IBPluginDependency</string>
<string>284.IBPluginDependency</string>
+ <string>302.IBPluginDependency</string>
+ <string>303.IBPluginDependency</string>
+ <string>304.IBPluginDependency</string>
+ <string>305.IBPluginDependency</string>
+ <string>306.IBAttributePlaceholdersKey</string>
+ <string>306.IBPluginDependency</string>
+ <string>307.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{289, 319}, {500, 371}}</string>
+ <string>{{113, 119}, {500, 371}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{289, 319}, {500, 371}}</string>
+ <string>{{113, 119}, {500, 371}}</string>
<boolean value="NO"/>
<string>{196, 240}</string>
<string>{{357, 418}, {480, 270}}</string>
@@ -1808,6 +1956,20 @@
<string>com.brandonwalkin.BWToolkit</string>
<string>com.brandonwalkin.BWToolkit</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <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="1033778944"/>
+ <string key="toolTip">Alphanumeric charater string which inserts the favorite query string after expansion by pressing the ⇥ key.</string>
+ </object>
+ </object>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -1826,7 +1988,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">301</int>
+ <int key="maxID">313</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -2028,6 +2190,73 @@
</object>
</object>
</object>
+ <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="203479207">
+ <string key="majorKey">IBDocumentRelativeSource</string>
+ <string key="minorKey">../../Source/SPQueryFavoriteManager.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">SPQueryFavoriteManager</string>
+ <string key="superclassName">NSWindowController</string>
+ <object class="NSMutableDictionary" key="actions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>addQueryFavorite:</string>
+ <string>closeQueryManagerSheet:</string>
+ <string>duplicateQueryFavorite:</string>
+ <string>exportFavorites:</string>
+ <string>importFavoritesByAdding:</string>
+ <string>importFavoritesByReplacing:</string>
+ <string>removeAllQueryFavorites:</string>
+ <string>removeQueryFavorite:</string>
+ <string>saveFavoriteToFile:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>encodingPopUp</string>
+ <string>favoriteNameTextField</string>
+ <string>favoriteQueryTextView</string>
+ <string>favoriteTabTriggerTextField</string>
+ <string>favoritesArrayController</string>
+ <string>favoritesTableView</string>
+ <string>removeButton</string>
+ <string>splitViewButtonBar</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>NSPopUpButton</string>
+ <string>NSTextField</string>
+ <string>NSTextView</string>
+ <string>NSTextField</string>
+ <string>NSArrayController</string>
+ <string>NSTableView</string>
+ <string>NSButton</string>
+ <string>BWAnchoredButtonBar</string>
+ </object>
+ </object>
+ <reference key="sourceIdentifier" ref="203479207"/>
+ </object>
+ </object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
diff --git a/Source/CMTextView.h b/Source/CMTextView.h
index 868e7093..137c5348 100644
--- a/Source/CMTextView.h
+++ b/Source/CMTextView.h
@@ -59,6 +59,11 @@ static inline void NSMutableAttributedStringAddAttributeValueRange (NSMutableAtt
MCPConnection *mySQLConnection;
NSInteger mySQLmajorVersion;
+ NSInteger snippetControlArray[20][2];
+ NSInteger snippetControlCounter;
+ NSInteger currentSnippetIndex;
+ BOOL snippetWasJustInserted;
+
}
- (IBAction)showMySQLHelpForCurrentWord:(id)sender;
@@ -91,6 +96,9 @@ static inline void NSMutableAttributedStringAddAttributeValueRange (NSMutableAtt
- (NSArray *)suggestionsForSQLCompletionWith:(NSString *)currentWord dictMode:(BOOL)isDictMode browseMode:(BOOL)dbBrowseMode withTableName:(NSString*)aTableName withDbName:(NSString*)aDbName;
- (void) selectCurrentQuery;
+- (BOOL)checkForCaretInsideSnippet;
+- (void)insertFavoriteAsSnippet:(NSString*)theSnippet atRange:(NSRange)targetRange;
+
- (NSUInteger)characterIndexOfPoint:(NSPoint)aPoint;
- (void)insertFileContentOfFile:(NSString *)aPath;
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 4b42d009..26c5790d 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -30,6 +30,7 @@
#import "SPTextViewAdditions.h"
#import "SPNarrowDownCompletion.h"
#import "SPConstants.h"
+#import "SPQueryController.h"
#pragma mark -
#pragma mark lex init
@@ -86,6 +87,7 @@ YY_BUFFER_STATE yy_scan_string (const char *);
autohelpEnabled = NO;
delBackwardsWasPressed = NO;
startListeningToBoundChanges = NO;
+ snippetControlCounter = -1;
lineNumberView = [[NoodleLineNumberView alloc] initWithScrollView:scrollView];
[scrollView setVerticalRulerView:lineNumberView];
@@ -796,6 +798,74 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
}
+- (void)selectCurrentSnippet
+{
+ if(snippetControlCounter > -1)
+ [self setSelectedRange:NSMakeRange(snippetControlArray[currentSnippetIndex][0], snippetControlArray[currentSnippetIndex][1])];
+}
+
+- (void)insertFavoriteAsSnippet:(NSString*)theSnippet atRange:(NSRange)targetRange
+{
+
+ if(theSnippet == nil || ![theSnippet length]) return;
+
+ NSMutableString *snip = [[NSMutableString string] autorelease];
+ // NSString *re = @"(?<!\\\\)\\$\\{([^\\{\\}]*)\\}";
+ [snip setString:theSnippet];
+
+ snippetControlCounter = -1;
+ // while([snip isMatchedByRegex:re]) {
+ // snippetControlCounter++;
+ // NSRange hintRange = [snip rangeOfRegex:re capture:1L];
+ // NSRange snipRange = [snip rangeOfRegex:re capture:0L];
+ // [snip replaceCharactersInRange:snipRange withString:[snip substringWithRange:hintRange]];
+ // snippetControlArray[snippetControlCounter][0] = snipRange.location + targetRange.location;
+ // snippetControlArray[snippetControlCounter][1] = snipRange.length-3;
+ // }
+ //
+ // if(snippetControlCounter > -1) {
+ // // Store the end for eventually tab out
+ // snippetControlCounter++;
+ // snippetControlArray[snippetControlCounter][0] = targetRange.location + [snip length];
+ // snippetControlArray[snippetControlCounter][1] = 0;
+ // }
+
+ [self breakUndoCoalescing];
+ [self setSelectedRange:targetRange];
+ snippetWasJustInserted = YES;
+ [self insertText:snip];
+
+ currentSnippetIndex = 0;
+ if(snippetControlCounter > -1)
+ [self selectCurrentSnippet];
+
+ snippetWasJustInserted = NO;
+}
+
+- (BOOL)checkForCaretInsideSnippet
+{
+
+ if(snippetControlCounter < 0 || currentSnippetIndex == snippetControlCounter) {
+ snippetControlCounter = -1;
+ return NO;
+ }
+
+ BOOL isCaretInsideASnippet = NO;
+ NSInteger caretPos = [self selectedRange].location;
+ NSInteger i;
+
+ for(i=0; i<snippetControlCounter; i++) {
+ if(caretPos >= snippetControlArray[i][0]
+ && caretPos <= snippetControlArray[i][0] + snippetControlArray[i][1]) {
+
+ isCaretInsideASnippet = YES;
+ break;
+ }
+ }
+ // if(!isCaretInsideASnippet)
+ // snippetControlCounter = -1;
+ return isCaretInsideASnippet;
+}
/*
* Handle some keyDown events in order to provide autopairing functionality (if enabled).
*/
@@ -839,6 +909,45 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
return;
}
+ // Check for {SHIFT}TAB to insert favorites via TAB-trigger if CMTextView belongs to CustomQuery
+ if ([theEvent keyCode] == 48 && [self isEditable] && [[self delegate] isKindOfClass:[CustomQuery class]]){
+ NSRange targetRange = [self getRangeForCurrentWord];
+ NSString *tabTrigger = [[self string] substringWithRange:targetRange];
+
+ // Is TAB trigger active change selection according to {SHIFT}TAB
+ if(snippetControlCounter > -1 && [self checkForCaretInsideSnippet]){
+ if(curFlags==(NSShiftKeyMask)) {
+ currentSnippetIndex--;
+ if(currentSnippetIndex < 0) {
+ snippetControlCounter = -1;
+ } else {
+ [self selectCurrentSnippet];
+ return;
+ }
+ } else {
+ currentSnippetIndex++;
+ if(currentSnippetIndex > snippetControlCounter) {
+ snippetControlCounter = -1;
+ } else if(currentSnippetIndex == snippetControlCounter) {
+ [self selectCurrentSnippet];
+ snippetControlCounter = -1;
+ return;
+ } else {
+ [self selectCurrentSnippet];
+ return;
+ }
+ }
+ }
+ // Check if tab-trigger is defined; if so insert it
+ if(snippetControlCounter < 0 && [[[self window] delegate] fileURL]) {
+ NSArray *snippets = [[SPQueryController sharedQueryController] queryFavoritesForFileURL:[[[self window] delegate] fileURL] andTabTrigger:tabTrigger includeGlobals:YES];
+ if([snippets count] > 0 && [(NSString*)[(NSDictionary*)[snippets objectAtIndex:0] objectForKey:@"query"] length]) {
+ [self insertFavoriteAsSnippet:[(NSDictionary*)[snippets objectAtIndex:0] objectForKey:@"query"] atRange:targetRange];
+ return;
+ }
+ }
+ }
+
// Note: switch(insertedCharacter) {} does not work instead use charactersIgnoringModifiers
if([charactersIgnMod isEqualToString:@"c"]) // ^C copy as RTF
if(curFlags==(NSControlKeyMask))
@@ -2719,9 +2828,12 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
//make sure that the notification is from the correct textStorage object
if (textStore!=[self textStorage]) return;
+ NSInteger editedMask = [textStore editedMask];
+
// Start autohelp only if the user really changed the text (not e.g. for setting a background color)
- if([prefs boolForKey:SPCustomQueryUpdateAutoHelp] && [textStore editedMask] != 1)
+ if([prefs boolForKey:SPCustomQueryUpdateAutoHelp] && editedMask != 1) {
[self performSelector:@selector(autoHelp) withObject:nil afterDelay:[[[prefs valueForKey:SPCustomQueryAutoHelpDelay] retain] doubleValue]];
+ }
if([[self string] length] > SP_TEXT_SIZE_TRIGGER_FOR_PARTLY_PARSING)
[NSObject cancelPreviousPerformRequestsWithTarget:self
@@ -2729,8 +2841,40 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
object:nil];
// Do syntax highlighting only if the user really changed the text
- if([textStore editedMask] != 1){
+ if(editedMask != 1) {
+
+ if(snippetControlCounter > -1 && !snippetWasJustInserted) {
+ NSInteger editStartPosition = [textStore editedRange].location;
+ NSInteger changeInLength = [textStore changeInLength];
+ NSInteger i;
+ BOOL isCaretInsideASnippet = NO;
+ for(i=0; i<=snippetControlCounter; i++) {
+ if(editStartPosition >= snippetControlArray[i][0]
+ && editStartPosition <= snippetControlArray[i][0] + snippetControlArray[i][1]) {
+
+ if(i!=snippetControlCounter)
+ isCaretInsideASnippet = YES;
+ snippetControlArray[i][1] += changeInLength;
+ if(snippetControlArray[i][1] < 0) {
+ snippetControlCounter = -1;
+ break;
+ }
+ // Adjust start position of snippets after caret position
+ } else if(editStartPosition < snippetControlArray[i][0]) {
+ snippetControlArray[i][0] += changeInLength;
+ if(snippetControlArray[i][1] < 0) {
+ snippetControlCounter = -1;
+ break;
+ }
+ }
+ }
+ if(!isCaretInsideASnippet)
+ snippetControlCounter = -1;
+
+ }
+
[self doSyntaxHighlighting];
+
}
startListeningToBoundChanges = YES;
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index b536491b..2e3b16c4 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -215,7 +215,7 @@
[textView setSelectedRange:NSMakeRange(0,[[textView string] length])];
// The actual query strings have been already stored as tooltip
- [textView insertText:[[queryFavoritesButton selectedItem] toolTip]];
+ [textView insertFavoriteAsSnippet:[[queryFavoritesButton selectedItem] toolTip] atRange:[textView selectedRange]];
}
}
@@ -2020,6 +2020,7 @@
// Ensure that the notification is from the custom query text view
if ( [aNotification object] != textView ) return;
+ [textView checkForCaretInsideSnippet];
// Remove all background color attributes used by highlighting the current query
if([prefs boolForKey:SPCustomQueryHighlightCurrentQuery]) {
// Remove only the background attribute for the current range if still valid
@@ -2701,8 +2702,17 @@
[menu addItem:headerMenuItem];
[headerMenuItem release];
for (NSDictionary *favorite in [[SPQueryController sharedQueryController] favoritesForFileURL:[tableDocumentInstance fileURL]]) {
- NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithString:[favorite objectForKey:@"name"]] action:NULL keyEquivalent:@""];
+ if (![favorite isKindOfClass:[NSDictionary class]] || ![favorite objectForKey:@"name"]) continue;
+ NSMutableParagraphStyle *paraStyle = [[[NSMutableParagraphStyle alloc] init] autorelease];
+ [paraStyle setTabStops:[NSArray array]];
+ [paraStyle addTabStop:[[[NSTextTab alloc] initWithType:NSRightTabStopType location:190.0] autorelease]];
+ NSDictionary *attributes = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:paraStyle, [NSFont systemFontOfSize:11], nil] forKeys:[NSArray arrayWithObjects:NSParagraphStyleAttributeName, NSFontAttributeName, nil]];
+ NSAttributedString *titleString = [[[NSAttributedString alloc]
+ initWithString:([favorite objectForKey:@"tabtrigger"] && [(NSString*)[favorite objectForKey:@"tabtrigger"] length]) ? [NSString stringWithFormat:@"%@\t%@⇥", [favorite objectForKey:@"name"], [favorite objectForKey:@"tabtrigger"]] : [favorite objectForKey:@"name"]
+ attributes:attributes] autorelease];
+ NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""];
[item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]];
+ [item setAttributedTitle:titleString];
[item setIndentationLevel:1];
[menu addItem:item];
[item release];
@@ -2717,8 +2727,16 @@
[headerMenuItem release];
for (NSDictionary *favorite in [prefs objectForKey:SPQueryFavorites]) {
if (![favorite isKindOfClass:[NSDictionary class]] || ![favorite objectForKey:@"name"]) continue;
- NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithString:[favorite objectForKey:@"name"]] action:NULL keyEquivalent:@""];
+ NSMutableParagraphStyle *paraStyle = [[[NSMutableParagraphStyle alloc] init] autorelease];
+ [paraStyle setTabStops:[NSArray array]];
+ [paraStyle addTabStop:[[[NSTextTab alloc] initWithType:NSRightTabStopType location:190.0] autorelease]];
+ NSDictionary *attributes = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:paraStyle, [NSFont systemFontOfSize:11], nil] forKeys:[NSArray arrayWithObjects:NSParagraphStyleAttributeName, NSFontAttributeName, nil]];
+ NSAttributedString *titleString = [[[NSAttributedString alloc]
+ initWithString:([favorite objectForKey:@"tabtrigger"] && [(NSString*)[favorite objectForKey:@"tabtrigger"] length]) ? [NSString stringWithFormat:@"%@\t%@⇥", [favorite objectForKey:@"name"], [favorite objectForKey:@"tabtrigger"]] : [favorite objectForKey:@"name"]
+ attributes:attributes] autorelease];
+ NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""];
[item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]];
+ [item setAttributedTitle:titleString];
[item setIndentationLevel:1];
[menu addItem:item];
[item release];
diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m
index 37b4aa97..9f28c226 100644
--- a/Source/SPQueryController.m
+++ b/Source/SPQueryController.m
@@ -664,8 +664,10 @@ static SPQueryController *sharedQueryController = nil;
if(includeGlobals && [prefs objectForKey:SPQueryFavorites]) {
for(id fav in [prefs objectForKey:SPQueryFavorites]) {
- if([fav objectForKey:@"tabtrigger"] && [[fav objectForKey:@"tabtrigger"] isEqualToString:tabTrigger])
+ if([fav objectForKey:@"tabtrigger"] && [[fav objectForKey:@"tabtrigger"] isEqualToString:tabTrigger]) {
[result addObject:fav];
+ break;
+ }
}
}
diff --git a/Source/SPQueryFavoriteManager.h b/Source/SPQueryFavoriteManager.h
index 9318ed22..2a9c3c56 100644
--- a/Source/SPQueryFavoriteManager.h
+++ b/Source/SPQueryFavoriteManager.h
@@ -41,6 +41,7 @@
IBOutlet NSPopUpButton *encodingPopUp;
IBOutlet NSTableView *favoritesTableView;
IBOutlet NSTextField *favoriteNameTextField;
+ IBOutlet NSTextField *favoriteTabTriggerTextField;
IBOutlet NSTextView *favoriteQueryTextView;
IBOutlet NSButton *removeButton;
IBOutlet BWAnchoredButtonBar *splitViewButtonBar;
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index 2745f83c..a6f8941b 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -29,6 +29,7 @@
#import "SPQueryController.h"
#import "SPConstants.h"
#import "SPConnectionController.h"
+#import "RegexKitLite.h"
#define SP_MULTIPLE_SELECTION_PLACEHOLDER_STRING NSLocalizedString(@"[multiple selection]", @"[multiple selection]")
#define SP_NO_SELECTION_PLACEHOLDER_STRING NSLocalizedString(@"[no selection]", @"[no selection]")
@@ -415,9 +416,15 @@
*/
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
- if(![[favorites objectAtIndex:rowIndex] objectForKey:[aTableColumn identifier]]) return @"";
- return [[favorites objectAtIndex:rowIndex] objectForKey:[aTableColumn identifier]];
+ if([[aTableColumn identifier] isEqualToString:@"name"]) {
+ if(![[favorites objectAtIndex:rowIndex] objectForKey:@"name"]) return @"";
+ return [[favorites objectAtIndex:rowIndex] objectForKey:@"name"];
+ } else if([[aTableColumn identifier] isEqualToString:@"tabtrigger"]) {
+ if(![[favorites objectAtIndex:rowIndex] objectForKey:@"tabtrigger"] || ![(NSString*)[[favorites objectAtIndex:rowIndex] objectForKey:@"tabtrigger"] length]) return @"";
+ return [NSString stringWithFormat:@"%@⇥", [[favorites objectAtIndex:rowIndex] objectForKey:@"tabtrigger"]];
+ }
+ return @"";
}
/*
@@ -511,7 +518,7 @@
}
/*
- * Changes in the name text field will be saved in data source directly
+ * Changes in the name/tabtrigger text field will be saved in data source directly
* to update the table view accordingly
*/
- (void)controlTextDidChange:(NSNotification *)notification
@@ -525,6 +532,13 @@
if(object == favoriteNameTextField) {
[[favorites objectAtIndex:[favoritesTableView selectedRow]] setObject:[favoriteNameTextField stringValue] forKey:@"name"];
[favoritesTableView reloadData];
+ }
+ else if(object == favoriteTabTriggerTextField){
+ //Validate trigger - it only may contain alphnumeric characters
+ NSString *tabTrigger = [NSString stringWithString:[[favoriteTabTriggerTextField stringValue] stringByReplacingOccurrencesOfRegex:@"[^\\w0-9]" withString:@""]];
+ [favoriteTabTriggerTextField setStringValue:tabTrigger];
+ [[favorites objectAtIndex:[favoritesTableView selectedRow]] setObject:tabTrigger forKey:@"tabtrigger"];
+ [favoritesTableView reloadData];
}
}