aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/MainMenu.xib92
-rw-r--r--Source/SPTextViewAdditions.h1
-rw-r--r--Source/SPTextViewAdditions.m86
3 files changed, 170 insertions, 9 deletions
diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib
index 10bc76fc..0c2f5891 100644
--- a/Interfaces/English.lproj/MainMenu.xib
+++ b/Interfaces/English.lproj/MainMenu.xib
@@ -1,19 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">9J61</string>
- <string key="IBDocument.InterfaceBuilderVersion">672</string>
+ <string key="IBDocument.InterfaceBuilderVersion">677</string>
<string key="IBDocument.AppKitVersion">949.46</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="930"/>
+ <integer value="849"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="549353383">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="515727999">
@@ -624,6 +633,15 @@
<reference key="NSOnImage" ref="625762401"/>
<reference key="NSMixedImage" ref="315854375"/>
</object>
+ <object class="NSMenuItem" id="854155133">
+ <reference key="NSMenu" ref="1792"/>
+ <string key="NSTitle">Enclosing Brackets</string>
+ <string key="NSKeyEquiv">B</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="625762401"/>
+ <reference key="NSMixedImage" ref="315854375"/>
+ </object>
<object class="NSMenuItem" id="177107453">
<reference key="NSMenu" ref="1792"/>
<string key="NSTitle">All</string>
@@ -2398,6 +2416,14 @@
</object>
<int key="connectionID">931</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">selectEnclosingBrackets:</string>
+ <reference key="source" ref="63651044"/>
+ <reference key="destination" ref="854155133"/>
+ </object>
+ <int key="connectionID">933</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -3229,6 +3255,7 @@
<reference ref="177107453"/>
<reference ref="12564442"/>
<reference ref="57673608"/>
+ <reference ref="854155133"/>
</object>
<reference key="parent" ref="1946"/>
</object>
@@ -3579,6 +3606,11 @@
<reference key="object" ref="536279428"/>
<reference key="parent" ref="277457689"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">932</int>
+ <reference key="object" ref="854155133"/>
+ <reference key="parent" ref="1792"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -3914,6 +3946,7 @@
<string>926.ImportedFromIB2</string>
<string>928.IBPluginDependency</string>
<string>930.IBPluginDependency</string>
+ <string>932.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -3974,7 +4007,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
- <string>{{223, 594}, {268, 233}}</string>
+ <string>{{312, 486}, {268, 233}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{654, 613}, {157, 223}}</string>
@@ -4007,7 +4040,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{449, 1007}, {197, 53}}</string>
- <string>{{75, 827}, {511, 20}}</string>
+ <string>{{164, 719}, {511, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{506, 836}, {511, 20}}</string>
@@ -4017,7 +4050,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
- <string>{{390, 574}, {213, 133}}</string>
+ <string>{{390, 483}, {213, 133}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{399, 465}, {213, 93}}</string>
@@ -4184,7 +4217,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{181, 634}, {209, 193}}</string>
+ <string>{{181, 543}, {209, 193}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{180, 535}, {182, 253}}</string>
@@ -4218,7 +4251,7 @@
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{731, 582}, {115, 63}}</string>
+ <string>{{580, 506}, {221, 83}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
<string key="NS.key.0">ToolTip</string>
@@ -4289,6 +4322,7 @@ w6gg4oaSIGZhY2FkZV0</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -4311,7 +4345,7 @@ w6gg4oaSIGZhY2FkZV0</string>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">931</int>
+ <int key="maxID">933</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -4758,6 +4792,46 @@ w6gg4oaSIGZhY2FkZV0</string>
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">NSTextView</string>
+ <object class="NSMutableDictionary" key="actions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>doDecomposedStringWithCanonicalMapping:</string>
+ <string>doDecomposedStringWithCompatibilityMapping:</string>
+ <string>doPrecomposedStringWithCanonicalMapping:</string>
+ <string>doPrecomposedStringWithCompatibilityMapping:</string>
+ <string>doRemoveDiacritics:</string>
+ <string>doSelectionLowerCase:</string>
+ <string>doSelectionTitleCase:</string>
+ <string>doSelectionUpperCase:</string>
+ <string>doTranspose:</string>
+ <string>selectCurrentLine:</string>
+ <string>selectCurrentWord:</string>
+ <string>selectEnclosingBrackets:</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>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBDocumentRelativeSource</string>
+ <string key="minorKey">../../Source/SPTextViewAdditions.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">SUUpdater</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="actions">
diff --git a/Source/SPTextViewAdditions.h b/Source/SPTextViewAdditions.h
index 2e0753cc..d1fa91d8 100644
--- a/Source/SPTextViewAdditions.h
+++ b/Source/SPTextViewAdditions.h
@@ -30,6 +30,7 @@
- (IBAction)selectCurrentWord:(id)sender;
- (IBAction)selectCurrentLine:(id)sender;
+- (IBAction)selectEnclosingBrackets:(id)sender;
- (IBAction)doSelectionUpperCase:(id)sender;
- (IBAction)doSelectionLowerCase:(id)sender;
- (IBAction)doSelectionTitleCase:(id)sender;
diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m
index 134b93ca..34cbbab8 100644
--- a/Source/SPTextViewAdditions.m
+++ b/Source/SPTextViewAdditions.m
@@ -95,6 +95,92 @@
}
/*
+ *
+ */
+- (IBAction)selectEnclosingBrackets:(id)sender
+{
+ long caretPosition = [self selectedRange].location;
+ long stringLength = [[self string] length];
+ unichar co, cc;
+
+ if(caretPosition == 0 || caretPosition >= stringLength) return;
+
+ long pcnt = 0;
+ long bcnt = 0;
+ long scnt = 0;
+
+ long i;
+
+ // look for the first non-balanced closing bracket
+ for(i=caretPosition; i<stringLength; i++) {
+ switch([[self string] characterAtIndex:i]) {
+ case ')':
+ if(!pcnt) {
+ co='(';cc=')';
+ i=stringLength;
+ }
+ pcnt++; break;
+ case '(': pcnt--; break;
+ case ']':
+ if(!bcnt) {
+ co='[';cc=']';
+ i=stringLength;
+ }
+ bcnt++; break;
+ case '[': bcnt--; break;
+ case '}':
+ if(!scnt) {
+ co='{';cc='}';
+ i=stringLength;
+ }
+ scnt++; break;
+ case '{': scnt--; break;
+ }
+ }
+
+ long start = -1;
+ long end = -1;
+ long bracketCounter = 0;
+
+ if([[self string] characterAtIndex:caretPosition] == cc)
+ bracketCounter--;
+ if([[self string] characterAtIndex:caretPosition] == co)
+ bracketCounter++;
+
+ for(i=caretPosition; i>=0; i--) {
+ if([[self string] characterAtIndex:i] == co) {
+ if(!bracketCounter) {
+ start = i;
+ break;
+ }
+ bracketCounter--;
+ }
+ if([[self string] characterAtIndex:i] == cc) {
+ bracketCounter++;
+ }
+ }
+ if(start < 0 ) return;
+
+ bracketCounter = 0;
+ for(i=caretPosition; i<stringLength; i++) {
+ if([[self string] characterAtIndex:i] == co) {
+ bracketCounter++;
+ }
+ if([[self string] characterAtIndex:i] == cc) {
+ if(!bracketCounter) {
+ end = i+1;
+ break;
+ }
+ bracketCounter--;
+ }
+ }
+ if(end < 0 || bracketCounter || end-start < 1) return;
+
+ [self setSelectedRange:NSMakeRange(start, end-start)];
+
+}
+
+/*
* Change selection or current word to upper case and preserves the selection.
*/
- (IBAction)doSelectionUpperCase:(id)sender