Permalink
Browse files

Removed custom implementation of getWordAtIndex since it's just calli…

…ng back into TEA, anyway
  • Loading branch information...
1 parent e4af63e commit dd6256a734f781ea5850496d3669b02ffc0fc2dc @onecrayon committed Dec 3, 2012
@@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
7A1BA5F714FEA1CA007860E6 /* OCShellHTMLOutputWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7A1BA5F614FEA1CA007860E6 /* OCShellHTMLOutputWindow.xib */; };
7A7FA5AD14F852B30079E541 /* NSMutableDictionary+OCSettingAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A7FA5AA14F852B30079E541 /* NSMutableDictionary+OCSettingAdditions.m */; };
- 7A7FA5AE14F852B30079E541 /* NSObject+OCTextActionContextAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A7FA5AC14F852B30079E541 /* NSObject+OCTextActionContextAdditions.m */; };
7A7FA5B114F853500079E541 /* OCShellAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A7FA5B014F853500079E541 /* OCShellAction.m */; };
7AB5CD70150149E6007B3F02 /* OCShellConsoleOutputWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7AB5CD6F150149E6007B3F02 /* OCShellConsoleOutputWindow.xib */; };
7AB5CD7315014B76007B3F02 /* OCShellConsoleOutputController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AB5CD7215014B76007B3F02 /* OCShellConsoleOutputController.m */; };
@@ -26,8 +25,6 @@
7A1BA5F614FEA1CA007860E6 /* OCShellHTMLOutputWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OCShellHTMLOutputWindow.xib; sourceTree = "<group>"; };
7A7FA5A914F852B30079E541 /* NSMutableDictionary+OCSettingAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSMutableDictionary+OCSettingAdditions.h"; path = "Classes/NSMutableDictionary+OCSettingAdditions.h"; sourceTree = "<group>"; };
7A7FA5AA14F852B30079E541 /* NSMutableDictionary+OCSettingAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSMutableDictionary+OCSettingAdditions.m"; path = "Classes/NSMutableDictionary+OCSettingAdditions.m"; sourceTree = "<group>"; };
- 7A7FA5AB14F852B30079E541 /* NSObject+OCTextActionContextAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSObject+OCTextActionContextAdditions.h"; path = "Classes/NSObject+OCTextActionContextAdditions.h"; sourceTree = "<group>"; };
- 7A7FA5AC14F852B30079E541 /* NSObject+OCTextActionContextAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSObject+OCTextActionContextAdditions.m"; path = "Classes/NSObject+OCTextActionContextAdditions.m"; sourceTree = "<group>"; };
7A7FA5AF14F853500079E541 /* OCShellAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OCShellAction.h; path = Classes/OCShellAction.h; sourceTree = "<group>"; };
7A7FA5B014F853500079E541 /* OCShellAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OCShellAction.m; path = Classes/OCShellAction.m; sourceTree = "<group>"; };
7AB5CD6F150149E6007B3F02 /* OCShellConsoleOutputWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OCShellConsoleOutputWindow.xib; sourceTree = "<group>"; };
@@ -68,8 +65,6 @@
children = (
7A7FA5A914F852B30079E541 /* NSMutableDictionary+OCSettingAdditions.h */,
7A7FA5AA14F852B30079E541 /* NSMutableDictionary+OCSettingAdditions.m */,
- 7A7FA5AB14F852B30079E541 /* NSObject+OCTextActionContextAdditions.h */,
- 7A7FA5AC14F852B30079E541 /* NSObject+OCTextActionContextAdditions.m */,
);
name = Categories;
sourceTree = "<group>";
@@ -238,7 +233,6 @@
buildActionMask = 2147483647;
files = (
7A7FA5AD14F852B30079E541 /* NSMutableDictionary+OCSettingAdditions.m in Sources */,
- 7A7FA5AE14F852B30079E541 /* NSObject+OCTextActionContextAdditions.m in Sources */,
7A7FA5B114F853500079E541 /* OCShellAction.m in Sources */,
7AC981BE14FEAB5100EB787A /* OCShellHTMLOutputController.m in Sources */,
7AB5CD7315014B76007B3F02 /* OCShellConsoleOutputController.m in Sources */,
@@ -1,17 +0,0 @@
-//
-// NSObject+OCTextActionContextAdditions.h
-// ShellActions.sugar
-//
-// Created by Ian Beck on 12/14/10.
-// Copyright 2010 Ian Beck. MIT license.
-//
-
-#import <Cocoa/Cocoa.h>
-
-
-@interface NSObject (OCTextActionContextAdditions)
-
-- (NSString *)getWordAtIndex:(NSUInteger)cursor range:(NSRange *)range;
-- (NSString *)getWordAtIndex:(NSUInteger)cursor allowExtraCharacters:(NSCharacterSet *)extraChars range:(NSRange *)range;
-
-@end
@@ -1,127 +0,0 @@
-//
-// NSObject+OCTextActionContextAdditions.m
-// ShellActions.sugar
-//
-// Created by Ian Beck on 12/14/10.
-// Copyright 2010 Ian Beck. MIT license.
-//
-
-#import "NSObject+OCTextActionContextAdditions.h"
-#import <EspressoTextActions.h>
-
-
-@implementation NSObject (OCTextActionContextAdditions)
-
-// Get the word in the current context around the given index; the range is returned by reference
-//
-// Defines a word as an alphanumeric character, or _
-//
-// Usage:
-// NSRange range;
-// [self getWordAtIndex:index range:&range];
-- (NSString *)getWordAtIndex:(NSUInteger)cursor range:(NSRange *)range {
- return [self getWordAtIndex:cursor allowExtraCharacters:[NSCharacterSet characterSetWithCharactersInString:@"_"] range:range];
-}
-
-// The extended version of getWordAtIndex:range:
-// Allows you to pass a specific characterset to choose which non-alphanumeric characters are legal
-
-- (NSString *)getWordAtIndex:(NSUInteger)cursor allowExtraCharacters:(NSCharacterSet *)extraChars range:(NSRange *)range {
- // Init memory-managed variables
- NSMutableString *word = [[NSMutableString alloc] initWithString:@""];
- NSMutableCharacterSet *legalChars = [[NSCharacterSet alphanumericCharacterSet] mutableCopy];
- if (extraChars != nil) {
- [legalChars formUnionWithCharacterSet:extraChars];
- }
- NSString *lineText;
-
- // Init non-pointer variables
- NSInteger maxindex = [[self string] length] - 1;
- unichar character;
- BOOL inword;
- NSInteger index = (NSInteger)cursor;
- NSUInteger firstindex, lastindex;
- // Vars for checking if the line ends with an HTML tag
- NSUInteger linestart;
- BOOL lineEndsWithTag;
-
- if (index < maxindex) {
- // Check if index is mid-word
- character = [[self string] characterAtIndex:(NSUInteger) (index+1)];
- if ([legalChars characterIsMember:character]) {
- inword = TRUE;
- // Parse forward until we hit the end of the word or document
- while (inword) {
- character = [[self string] characterAtIndex:(NSUInteger) index];
- // If word character, append and advance
- if ([legalChars characterIsMember:character]) {
- [word appendFormat:@"%C", character];
- } else {
- inword = NO;
- }
- index = index + 1;
- // End it if we're at the document end
- if (index == maxindex) {
- inword = NO;
- }
- }
- } else {
- // Although we haven't advanced any, lastindex logic assumes we've
- // been incrementing as we go, so bump it up one to compensate
- index = index + 1;
- }
- }
- // Set the last index of the word
- if (index <= maxindex) {
- lastindex = (NSUInteger) (index - 1);
- } else {
- lastindex = (NSUInteger) index;
- }
- // Ready to go backward, so reset index to one less than cursor location
- index = cursor - 1;
- // Only walk backwards if we aren't at the beginning of the document
- if (index >= 0) {
- inword = YES;
- while (inword) {
- character = [[self string] characterAtIndex:(NSUInteger) index];
-
- // Impossible for the line to the index to be an HTML tag if the character isn't a caret
- if (character != '>') {
- lineEndsWithTag = NO;
- } else {
- linestart = [[self lineStorage] lineStartIndexLessThanIndex:(NSUInteger) index];
- lineText = [[self string] substringWithRange:NSMakeRange(linestart, (NSUInteger) (index - linestart + 1))];
- // Not much point in loading up matches, so here's a regex approximation using NSPredicate
- // NSPredicate regex test courtesy of: http://www.stiefels.net/2007/01/24/regular-expressions-for-nsstring/
- // Using double backslashes to escape them
- NSString *regex = @".*(<\\/?[\\w:-]+[^>]*|\\s*(/|\\?|%|-{2,3}))>";
- NSPredicate *regextest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
- // Test it!
- lineEndsWithTag = [regextest evaluateWithObject:lineText];
- }
-
- if ([legalChars characterIsMember:character] && !lineEndsWithTag) {
- [word insertString:[NSString stringWithFormat:@"%C", character] atIndex:0];
- index = index - 1;
- } else {
- inword = NO;
- }
- if (index < 0) {
- inword = NO;
- }
- }
- }
- // Since index is left-aligned and we've overcompensated, need to increment +1
- firstindex = (NSUInteger) (index + 1);
- // Switch last index to length for use in range
- lastindex = lastindex - firstindex;
-
- // Cleanup
- [legalChars release];
-
- // Return our values!
- *range = NSMakeRange(firstindex, lastindex);
- return [word autorelease];
-}
-
-@end
@@ -7,7 +7,6 @@
//
#import "OCShellAction.h"
-#import "NSObject+OCTextActionContextAdditions.h"
#import "NSMutableDictionary+OCSettingAdditions.h"
#import "OCShellHTMLOutputController.h"
#import "OCShellConsoleOutputController.h"
@@ -29,6 +28,12 @@ @interface NSObject (OCShellActionPathInfo)
@property(readonly) id document;
@end
+// This is defined in TEA, but we need a category to prevent compiling errors
+@interface NSObject (OCTextActionContextAdditions)
+- (NSString *)getWordAtIndex:(NSUInteger)cursor range:(NSRange *)range;
+- (NSString *)getWordAtIndex:(NSUInteger)cursor allowExtraCharacters:(NSCharacterSet *)extraChars range:(NSRange *)range;
+@end
+
/*
This stuff is related to the thread-based STDIN handling necessary to pass arbitrary amounts of data through the pipe without breaking

0 comments on commit dd6256a

Please sign in to comment.