mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-07 07:40:40 +03:00
Atom cli can be called multiple times. Successive calls will open the given path in the existing Atom process.
This commit is contained in:
parent
e2700395cf
commit
ff07710556
@ -9,6 +9,7 @@ class AtomCefClient;
|
||||
BOOL handlingSendEvent_;
|
||||
}
|
||||
|
||||
+ (AtomApplication *)sharedApplication;
|
||||
+ (id)applicationWithArguments:(char **)argv count:(int)argc;
|
||||
+ (CefSettings)createCefSettings;
|
||||
+ (NSDictionary *)parseArguments:(char **)argv count:(int)argc;
|
||||
|
@ -9,8 +9,12 @@
|
||||
|
||||
@synthesize arguments=_arguments;
|
||||
|
||||
+ (AtomApplication *)sharedApplication {
|
||||
return (AtomApplication *)[super sharedApplication];
|
||||
}
|
||||
|
||||
+ (id)applicationWithArguments:(char **)argv count:(int)argc {
|
||||
AtomApplication *application = (AtomApplication *)[super sharedApplication];
|
||||
AtomApplication *application = [self sharedApplication];
|
||||
CefInitialize(CefMainArgs(argc, argv), [self createCefSettings], new AtomCefApp);
|
||||
application.arguments = [self parseArguments:argv count:argc];
|
||||
|
||||
|
@ -67,18 +67,23 @@ void listenForPathToOpen(int fd, NSString *socketPath) {
|
||||
else {
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
dispatch_async(queue, ^{
|
||||
char buf[1000];
|
||||
char buf[MAXPATHLEN];
|
||||
struct sockaddr_un listen_addr;
|
||||
listen_addr.sun_family = AF_UNIX;
|
||||
strcpy(listen_addr.sun_path, [socketPath UTF8String]);
|
||||
socklen_t listen_addr_length;
|
||||
|
||||
while(true) {
|
||||
memset(buf, 0, MAXPATHLEN);
|
||||
if (recvfrom(fd, &buf, sizeof(buf), 0, (sockaddr *)&listen_addr, &listen_addr_length) < 0) {
|
||||
perror("ERROR: Receiving from socket");
|
||||
}
|
||||
else {
|
||||
NSLog(@"You should open the path %s", buf);
|
||||
NSString *path = [NSString stringWithUTF8String:buf];
|
||||
dispatch_queue_t mainQueue = dispatch_get_main_queue();
|
||||
dispatch_async(mainQueue, ^{
|
||||
[[AtomApplication sharedApplication] open:path];
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user