Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added bracket insertion for Objective-J

  • Loading branch information...
commit eb284155adc45cc23b9aecc16e52f1473e00d743 1 parent 68c5207
@dbloete dbloete authored committed
Showing with 6 additions and 3 deletions.
  1. +1 −1  README.mdown
  2. +5 −2 src/BracketMatcher.mm
View
2  README.mdown
@@ -11,7 +11,7 @@ Watch [the screencast](http://ciaranwal.sh/files/xcode-bracket-matcher.mov) to s
# Usage
-When editing an Objective-C(++) file, you can type a `]` to add a message to the current line. The plug-in will automatically look backwards to insert the opening bracket at the appropriate location.
+When editing an Objective-C(++) or Objective-J file, you can type a `]` to add a message to the current line. The plug-in will automatically look backwards to insert the opening bracket at the appropriate location.
# Credit
View
7 src/BracketMatcher.mm
@@ -23,15 +23,16 @@ - (id)codeAssistant;
- (void)liveInlineRemoveCompletion;
@end
+static NSArray* BracketedLanguages;
+
@implementation NSTextView (BracketMatching)
- (void)BracketMatching_keyDown:(NSEvent*)event
{
BOOL didInsert = NO;
-
if([[event characters] isEqualToString:@"]"])
{
NSString* language = [[self textStorage] language];
- if([language isEqualToString:@"xcode.lang.objcpp"] || [language isEqualToString:@"xcode.lang.objc"])
+ if([BracketedLanguages containsObject:language])
didInsert = [[BracketMatcher sharedInstance] insertBracketForTextView:self];
}
@@ -48,6 +49,8 @@ + (void)load
if([NSClassFromString(@"XCSourceCodeTextView") jr_swizzleMethod:@selector(keyDown:) withMethod:@selector(BracketMatching_keyDown:) error:NULL])
NSLog(@"BracketMatcher loaded");
+
+ BracketedLanguages = [[NSArray alloc] initWithObjects:@"xcode.lang.objcpp", @"xcode.lang.objc", @"xcode.lang.objj", nil];
}
+ (BracketMatcher*)sharedInstance
Please sign in to comment.
Something went wrong with that request. Please try again.