| Date: Sun, 21 Oct 2012 12:53:33 -0400
plumb.app: accept plumb:foo as alias for foo
R=rsc
CC=plan9port.codebot
http://codereview.appspot.com/5495046
Diffstat:
M src/cmd/devdraw/macargv.m | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
--- |
| t@@ -1,8 +1,10 @@
#import
+#import
#include
#include
+AUTOFRAMEWORK(Foundation)
AUTOFRAMEWORK(Cocoa)
@interface appdelegate : NSObject @end
t@@ -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];
}
t@@ -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 |