diff --git a/AckMate.xcodeproj/project.pbxproj b/AckMate.xcodeproj/project.pbxproj index cb80328..0e5f138 100644 --- a/AckMate.xcodeproj/project.pbxproj +++ b/AckMate.xcodeproj/project.pbxproj @@ -332,7 +332,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "mkdir -p \"$HOME/Library/Application Support/TextMate/PlugIns\"\ncp -pR \"${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\" \"$HOME/Library/Application Support/TextMate/PlugIns\""; + shellScript = "mkdir -p \"$HOME/Library/Application Support/TextMate/PlugIns\"\n# adapted from: http://developer.apple.com/mac/library/qa/qa2006/qa1500.html\n# Depending on the build configuration, either copy or link to the most recent product\nrm -rf \"$HOME/Library/Application Support/TextMate/PlugIns/${FULL_PRODUCT_NAME}\"\nif [ \"${CONFIGURATION}\" == \"Debug\" ]; then\n # if we're debugging, add a symbolic link to the plug-in\n ln -sf \"${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\" \\\n \"$HOME/Library/Application Support/TextMate/PlugIns/${FULL_PRODUCT_NAME}\"\nelif [ \"${CONFIGURATION}\" == \"Release\" ]; then\n # if we're compiling for release, just copy the plugin to the Internet Plug-ins folder\n cp -pR \"${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\" \"$HOME/Library/Application Support/TextMate/PlugIns\"\nfi"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/source/controllers/JPAckWindowController.h b/source/controllers/JPAckWindowController.h index ba9e345..e290c27 100644 --- a/source/controllers/JPAckWindowController.h +++ b/source/controllers/JPAckWindowController.h @@ -36,6 +36,7 @@ extern NSString * const kJPAckWindowPosition; NSString* selectedSearchFolder; BOOL selectionSearch; NSString* fileName; + NSTask* mateTask; NSMutableDictionary* preferences; NSArray* history; diff --git a/source/controllers/JPAckWindowController.m b/source/controllers/JPAckWindowController.m index ddd1f20..1020233 100644 --- a/source/controllers/JPAckWindowController.m +++ b/source/controllers/JPAckWindowController.m @@ -20,6 +20,7 @@ - (void)updateSearchSelectionForEvent:(NSEvent*)event; @property(nonatomic, retain) NSArray* ackTypes; @property(nonatomic, readwrite, copy) NSArray* history; @property(nonatomic, copy) NSString* selectedSearchFolder; +@property(retain) NSTask* mateTask; @end @implementation JPAckWindowController @@ -50,6 +51,7 @@ @implementation JPAckWindowController @synthesize folders; @synthesize currentProcess; @synthesize currentTypesProcess; +@synthesize mateTask; + (NSSet*)keyPathsForValuesAffectingRunning { @@ -88,6 +90,8 @@ - (id)initWithProjectDirectory:(NSString*)directory controller:(id)controller pr preferences = prefs; pasteboardChangeCount = NSNotFound; + mateTask = nil; + NSString* projectfile = [projectController filename] ? [projectController filename] : directory; fileName = [[[projectfile lastPathComponent] stringByDeletingPathExtension] copy]; projectDirectory = [directory copy]; @@ -327,27 +331,17 @@ - (void)loadAckTypes - (void)openProjectFile:(NSString*)file atLine:(NSString*)line selectionRange:(NSRange)selectionRange { NSString* absolute = [projectDirectory stringByAppendingPathComponent:file]; - [[[NSApplication sharedApplication] delegate] openFiles:[NSArray arrayWithObject:absolute]]; - - for (NSWindow *w in [[NSApplication sharedApplication] orderedWindows]) - { - id wc = [w windowController]; - NSString* openFileName = nil; - if ([[wc className] isEqualToString:@"OakProjectController"] || [[wc className] isEqualToString:@"OakDocumentController"]) - openFileName = [[[wc textView] document] filename]; + self.mateTask = [[[NSTask alloc] init] autorelease]; + [self.mateTask setCurrentDirectoryPath:projectDirectory]; + [self.mateTask setLaunchPath:@"/usr/bin/env"]; - if ([openFileName isEqualToString:absolute]) - { - [[wc textView] goToLineNumber:line]; - [[wc textView] goToColumnNumber:[NSNumber numberWithInt:selectionRange.location + 1]]; + NSMutableArray* args = [NSMutableArray arrayWithObjects:@"mate", absolute, nil]; + [args addObject:@"-l"]; + [args addObject:line]; - if (selectionRange.length > 0) - [[wc textView] selectToLine:line andColumn:[NSNumber numberWithInt:selectionRange.location + selectionRange.length + 1]]; - - break; - } - } + [self.mateTask setArguments:args]; + [self.mateTask launch]; } - (IBAction)cancel:(id)sender