diff options
author | Rob Kroeger <robkroeger@gmail.com> | 2012-10-21 12:53:33 -0400 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2012-10-21 12:53:33 -0400 |
commit | e13727e3c4921bde411c275aef71999324cd3faf (patch) | |
tree | ad3c1d3e8157b7d92379a624acfb02818f3c64e4 | |
parent | e4122a42b922fd1047a4b5beee6fdc0ce623f873 (diff) | |
download | plan9port-e13727e3c4921bde411c275aef71999324cd3faf.tar.gz plan9port-e13727e3c4921bde411c275aef71999324cd3faf.tar.bz2 plan9port-e13727e3c4921bde411c275aef71999324cd3faf.zip |
plumb.app: accept plumb:foo as alias for foo
R=rsc
CC=plan9port.codebot
http://codereview.appspot.com/5495046
-rw-r--r-- | src/cmd/devdraw/macargv.m | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/cmd/devdraw/macargv.m b/src/cmd/devdraw/macargv.m index cf3e2282..ec5bf49f 100644 --- a/src/cmd/devdraw/macargv.m +++ b/src/cmd/devdraw/macargv.m @@ -1,8 +1,10 @@ #import <Cocoa/Cocoa.h> +#import <Foundation/Foundation.h> #include <u.h> #include <libc.h> +AUTOFRAMEWORK(Foundation) AUTOFRAMEWORK(Cocoa) @interface appdelegate : NSObject @end @@ -14,7 +16,13 @@ main(void) [NSAutoreleasePool new]; [NSApplication sharedApplication]; - [NSApp setDelegate:[appdelegate new]]; + NSObject *delegate = [appdelegate new]; + [NSApp setDelegate:delegate]; + + NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; /* Register a call-back for URL Events */ + [appleEventManager setEventHandler:delegate andSelector:@selector(handleGetURLEvent:withReplyEvent:) + forEventClass:kInternetEventClass andEventID:kAEGetURL]; + [NSApp run]; } @@ -31,4 +39,11 @@ main(void) } [NSApp terminate:self]; } + +- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent +{ + NSString* url = [[event descriptorForKeyword:keyDirectObject] stringValue]; + print("%s\n", [url UTF8String] + (sizeof("plumb:") - 1)); + [NSApp terminate:self]; +} @end |