mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
plumb.app: accept plumb:foo as alias for foo
R=rsc CC=plan9port.codebot http://codereview.appspot.com/5495046
This commit is contained in:
parent
e4122a42b9
commit
e13727e3c4
1 changed files with 16 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue