diff --git a/NeoVimServer/NeoVimServer.h b/NeoVimServer/NeoVimServer.h new file mode 100644 index 00000000..f94b2346 --- /dev/null +++ b/NeoVimServer/NeoVimServer.h @@ -0,0 +1,22 @@ +/** + * Tae Won Ha - http://taewon.de - @hataewon + * See LICENSE + */ + +#import +#import "NeoVimUiBridgeProtocol.h" +#import "NeoVimServerMsgIds.h" + + +@interface NeoVimServer : NSObject + +- (instancetype)initWithUuid:(NSString *)uuid + localServerName:(NSString *)localServerName + remoteServerName:(NSString *)remoteServerName; + +- (NSData *)handleMessageWithId:(SInt32)msgid data:(NSData *)data; +- (void)sendMessageWithId:(NeoVimServerMsgId)msgid; +- (void)sendMessageWithId:(NeoVimServerMsgId)msgid data:(NSData *)data; +- (void)notifyReadiness; + +@end diff --git a/NeoVimServer/NeoVimServer.m b/NeoVimServer/NeoVimServer.m new file mode 100644 index 00000000..2d085dfc --- /dev/null +++ b/NeoVimServer/NeoVimServer.m @@ -0,0 +1,153 @@ +/** + * Tae Won Ha - http://taewon.de - @hataewon + * See LICENSE + */ + +#import "NeoVimServer.h" +#import "NeoVimServerMsgIds.h" +#import "server_globals.h" + + +static const double qTimeout = 10.0; + +static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info) { + @autoreleasepool { + NeoVimServer *neoVimServer = (NeoVimServer *) info; + NSData *responseData = [neoVimServer handleMessageWithId:msgid data:(NSData *) data]; + if (responseData == NULL) { + return NULL; + } + + return CFDataCreate(kCFAllocatorDefault, responseData.bytes, responseData.length); + } +} + + +@implementation NeoVimServer { + NSString *_uuid; + NSString *_localServerName; + NSString *_remoteServerName; + + NSThread *_localServerThread; + CFMessagePortRef _localServerPort; + + CFMessagePortRef _remoteServerPort; +} + +- (instancetype)initWithUuid:(NSString *)uuid + localServerName:(NSString *)localServerName + remoteServerName:(NSString *)remoteServerName +{ + self = [super init]; + if (self == nil) { + return nil; + } + + _uuid = [uuid retain]; + _localServerName = [localServerName retain]; + _remoteServerName = [remoteServerName retain]; + + _localServerThread = [[NSThread alloc] initWithTarget:self selector:@selector(runLocalServer) object:nil]; + [_localServerThread start]; + + _remoteServerPort = CFMessagePortCreateRemote(kCFAllocatorDefault, (CFStringRef) _remoteServerName); + + return self; +} + +- (void)dealloc { + [_uuid release]; + [_localServerName release]; + [_remoteServerName release]; + + CFMessagePortInvalidate(_localServerPort); + CFRelease(_localServerPort); + + [_localServerThread cancel]; + [_localServerThread release]; + + CFMessagePortInvalidate(_remoteServerPort); + CFRelease(_remoteServerPort); + + [super dealloc]; +} + +- (NSData *)handleMessageWithId:(SInt32)msgid data:(NSData *)data { + NSLog(@"msg received: %d -> %@", msgid, data); + + switch (msgid) { + + case NeoVimAgendMsgIdAgentReady: + start_neovim(); + return nil; + + case NeoVimAgentMsgIdInput: + return nil; + + case NeoVimAgentMsgIdInputMarked: + return nil; + + case NeoVimAgentMsgIdDelete: + return nil; + + case NeoVimAgentMsgIdResize: + return nil; + + case NeoVimAgentMsgIdRedraw: + return nil; + + default: + return nil; + } +} + +- (void)runLocalServer { + @autoreleasepool { + unsigned char shouldFree = false; + CFMessagePortContext localContext = { + .version = 0, + .info = (void *) self, + .retain = NULL, + .release = NULL, + .copyDescription = NULL + }; + + _localServerPort = CFMessagePortCreateLocal( + kCFAllocatorDefault, + (CFStringRef) _localServerName, + local_server_callback, + &localContext, + &shouldFree + ); + + // FIXME: handle shouldFree == true + + CFRunLoopRef runLoop = CFRunLoopGetCurrent(); + CFRunLoopSourceRef runLoopSrc = CFMessagePortCreateRunLoopSource(kCFAllocatorDefault, _localServerPort, 0); + CFRunLoopAddSource(runLoop, runLoopSrc, kCFRunLoopCommonModes); + CFRelease(runLoopSrc); + CFRunLoopRun(); + } +} + +- (void)sendMessageWithId:(NeoVimServerMsgId)msgid { + [self sendMessageWithId:msgid data:nil]; +} + +- (void)sendMessageWithId:(NeoVimServerMsgId)msgid data:(NSData *)data { + SInt32 responseCode = CFMessagePortSendRequest( + _remoteServerPort, msgid, (CFDataRef) data, qTimeout, qTimeout, NULL, NULL + ); + + if (responseCode == kCFMessagePortSuccess) { + return; + } + + NSLog(@"WARNING: (%d:%@) could not be sent!", (int) msgid, data); +} + +- (void)notifyReadiness { + [self sendMessageWithId:NeoVimServerMsgIdServerReady data:nil]; +} + +@end diff --git a/NeoVimServer/NeoVimServerMsgIds.h b/NeoVimServer/NeoVimServerMsgIds.h new file mode 100644 index 00000000..14e3f050 --- /dev/null +++ b/NeoVimServer/NeoVimServerMsgIds.h @@ -0,0 +1,55 @@ +/** + * Tae Won Ha - http://taewon.de - @hataewon + * See LICENSE + */ + +#import + + +typedef NS_ENUM(NSUInteger, NeoVimServerMsgId) { + NeoVimServerMsgIdServerReady = 0, + NeoVimServerMsgIdNeoVimReady, + NeoVimServerMsgIdResize, + NeoVimServerMsgIdClear, + NeoVimServerMsgIdEolClear, + NeoVimServerMsgIdSetPosition, + NeoVimServerMsgIdSetMenu, + NeoVimServerMsgIdBusyStart, + NeoVimServerMsgIdBusyStop, + NeoVimServerMsgIdMouseOn, + NeoVimServerMsgIdMouseOff, + NeoVimServerMsgIdModeChange, + NeoVimServerMsgIdSetScrollRegion, + NeoVimServerMsgIdScroll, + NeoVimServerMsgIdSetHighlightAttributes, + NeoVimServerMsgIdPut, + NeoVimServerMsgIdPutMarked, + NeoVimServerMsgIdUnmark, + NeoVimServerMsgIdBell, + NeoVimServerMsgIdVisualBell, + NeoVimServerMsgIdFlush, + NeoVimServerMsgIdSetForeground, + NeoVimServerMsgIdSetBackground, + NeoVimServerMsgIdSetSpecial, + NeoVimServerMsgIdSuspend, + NeoVimServerMsgIdSetTitle, + NeoVimServerMsgIdSetIcon, + NeoVimServerMsgIdStop, + +#ifdef DEBUG + NeoVimServerDebug1, +#endif +}; + +typedef NS_ENUM(NSUInteger, NeoVimAgentMsgId) { + NeoVimAgendMsgIdAgentReady = 0, + NeoVimAgentMsgIdInput, + NeoVimAgentMsgIdInputMarked, + NeoVimAgentMsgIdDelete, + NeoVimAgentMsgIdResize, + NeoVimAgentMsgIdRedraw, + +#ifdef DEBUG + NeoVimAgentDebug1, +#endif +}; diff --git a/NeoVimServer/main.m b/NeoVimServer/main.m new file mode 100644 index 00000000..85bb0e6e --- /dev/null +++ b/NeoVimServer/main.m @@ -0,0 +1,33 @@ +/** + * Tae Won Ha - http://taewon.de - @hataewon + * See LICENSE + */ + +#import +#import "NeoVimServer.h" +#import "server_globals.h" + + +NeoVimServer *_neovim_server; + + +int main(int argc, const char *argv[]) { + @autoreleasepool { + NSArray *arguments = [NSProcessInfo processInfo].arguments; + NSString *uuid = arguments[1]; + NSString *remoteServerName = arguments[2]; + NSString *localServerName = arguments[3]; + + _neovim_server = [[NeoVimServer alloc] initWithUuid:uuid + localServerName:localServerName + remoteServerName:remoteServerName]; + [_neovim_server notifyReadiness]; + + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + [runLoop addPort:[NSPort new] forMode:NSRunLoopCommonModes]; + [runLoop run]; + } + + return 0; +} + diff --git a/NeoVimServer/server_globals.h b/NeoVimServer/server_globals.h new file mode 100644 index 00000000..3bdbf32a --- /dev/null +++ b/NeoVimServer/server_globals.h @@ -0,0 +1,13 @@ +/** + * Tae Won Ha - http://taewon.de - @hataewon + * See LICENSE + */ + +#import + + +@class NeoVimServer; + +extern NeoVimServer *_neovim_server; + +extern void start_neovim(); diff --git a/NeoVimServer/server_ui.h b/NeoVimServer/server_ui.h new file mode 100644 index 00000000..2e100e57 --- /dev/null +++ b/NeoVimServer/server_ui.h @@ -0,0 +1,6 @@ +/** + * Tae Won Ha - http://taewon.de - @hataewon + * See LICENSE + */ + +#import diff --git a/NeoVimServer/server_ui.m b/NeoVimServer/server_ui.m new file mode 100644 index 00000000..4ed2754a --- /dev/null +++ b/NeoVimServer/server_ui.m @@ -0,0 +1,512 @@ +/** + * Tae Won Ha - http://taewon.de - @hataewon + * See LICENSE + */ + +#import "server_ui.h" +#import "NeoVimUiBridgeProtocol.h" +#import "Logging.h" +#import "server_globals.h" +#import "NeoVimServer.h" + +// FileInfo and Boolean are #defined by Carbon and NeoVim: Since we don't need the Carbon versions of them, we rename +// them. +#define FileInfo CarbonFileInfo +#define Boolean CarbonBoolean + +#import +#import +#import +#import +#import +#import +#import +#import + + +#define pun_type(t, x) (*((t *)(&x))) + +typedef struct { + UIBridgeData *bridge; + Loop *loop; + + bool stop; + + // FIXME: dunno whether we need this: copied from tui.c + bool cont_received; + SignalWatcher cont_handle; +} ServerUiData; + +// We declare nvim_main because it's not declared in any header files of neovim +extern int nvim_main(int argc, char **argv); + +static unsigned int _default_foreground = qDefaultForeground; +static unsigned int _default_background = qDefaultBackground; +static unsigned int _default_special = qDefaultSpecial; + +// The thread in which neovim's main runs +static uv_thread_t _nvim_thread; + +// Condition variable used by the XPC's init to wait till our custom UI initialization is finished inside neovim +static bool _is_ui_launched = false; +static uv_mutex_t _mutex; +static uv_cond_t _condition; + +static ServerUiData *_xpc_ui_data; + +static NSString *_marked_text = nil; + +static int _marked_row = 0; +static int _marked_column = 0; + +// for 하 -> hanja popup, Cocoa first inserts 하, then sets marked text, cf docs/notes-on-cocoa-text-input.md +static int _marked_delta = 0; + +static int _put_row = -1; +static int _put_column = -1; + +static NSString *_backspace = nil; + +static dispatch_queue_t _queue; + +static inline int screen_cursor_row() { + return curwin->w_winrow + curwin->w_wrow; +} + +static inline int screen_cursor_column() { + return curwin->w_wincol + curwin->w_wcol; +} + +static inline void queue(void (^block)()) { + dispatch_sync(_queue, ^{ + @autoreleasepool { + block(); + } + }); +} + +static void set_ui_size(UIBridgeData *bridge, int width, int height) { + bridge->ui->width = width; + bridge->ui->height = height; + bridge->bridge.width = width; + bridge->bridge.height = height; +} + +static void sigcont_cb(SignalWatcher *watcher __unused, int signum __unused, void *data) { + ((ServerUiData *) data)->cont_received = true; +} + +static void osx_xpc_ui_scheduler(Event event, void *d) { + UI *ui = d; + ServerUiData *data = ui->data; + loop_schedule(data->loop, event); +} + +static void osx_xpc_ui_main(UIBridgeData *bridge, UI *ui) { + Loop loop; + loop_init(&loop, NULL); + + _xpc_ui_data = xcalloc(1, sizeof(ServerUiData)); + ui->data = _xpc_ui_data; + _xpc_ui_data->bridge = bridge; + _xpc_ui_data->loop = &loop; + + // FIXME: dunno whether we need this: copied from tui.c + signal_watcher_init(_xpc_ui_data->loop, &_xpc_ui_data->cont_handle, _xpc_ui_data); + signal_watcher_start(&_xpc_ui_data->cont_handle, sigcont_cb, SIGCONT); + + set_ui_size(bridge, 30, 15); + + _xpc_ui_data->stop = false; + CONTINUE(bridge); + + uv_mutex_lock(&_mutex); + _is_ui_launched = true; + uv_cond_signal(&_condition); + uv_mutex_unlock(&_mutex); + + while (!_xpc_ui_data->stop) { + loop_poll_events(&loop, -1); + } + + ui_bridge_stopped(bridge); + loop_close(&loop); + + xfree(_xpc_ui_data); + xfree(ui); +} + +// FIXME: dunno whether we need this: copied from tui.c +static void suspend_event(void **argv) { + UI *ui = argv[0]; + ServerUiData *data = ui->data; + data->cont_received = false; + + kill(0, SIGTSTP); + + while (!data->cont_received) { + // poll the event loop until SIGCONT is received + loop_poll_events(data->loop, -1); + } + + CONTINUE(data->bridge); +} + +static void xpc_ui_resize(UI *ui __unused, int width, int height) { + queue(^{ + int values[] = { width, height }; + NSData *data = [[NSData alloc] initWithBytes:values length:(2 * sizeof(int))]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdResize data:data]; + [data release]; + NSLog(@"resized"); + }); +} + +static void xpc_ui_clear(UI *ui __unused) { + queue(^{ + [_neovim_server sendMessageWithId:NeoVimServerMsgIdClear]; + }); +} + +static void xpc_ui_eol_clear(UI *ui __unused) { + queue(^{ + [_neovim_server sendMessageWithId:NeoVimServerMsgIdEolClear]; + }); +} + +static void xpc_ui_cursor_goto(UI *ui __unused, int row, int col) { + queue(^{ + _put_row = row; + _put_column = col; + + int values[] = { row, col, screen_cursor_row(), screen_cursor_column() }; + NSData *data = [[NSData alloc] initWithBytes:values length:(4 * sizeof(int))]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdSetPosition data:data]; + [data release]; + }); +} + +static void xpc_ui_update_menu(UI *ui __unused) { + queue(^{ + [_neovim_server sendMessageWithId:NeoVimServerMsgIdSetMenu]; + }); +} + +static void xpc_ui_busy_start(UI *ui __unused) { + queue(^{ + [_neovim_server sendMessageWithId:NeoVimServerMsgIdBusyStart]; + }); +} + +static void xpc_ui_busy_stop(UI *ui __unused) { + queue(^{ + [_neovim_server sendMessageWithId:NeoVimServerMsgIdBusyStop]; + }); +} + +static void xpc_ui_mouse_on(UI *ui __unused) { + queue(^{ + [_neovim_server sendMessageWithId:NeoVimServerMsgIdMouseOn]; + }); +} + +static void xpc_ui_mouse_off(UI *ui __unused) { + queue(^{ + [_neovim_server sendMessageWithId:NeoVimServerMsgIdMouseOff]; + }); +} + +static void xpc_ui_mode_change(UI *ui __unused, int mode) { + queue(^{ + int value = mode; + NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(int))]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdModeChange data:data]; + [data release]; + }); +} + +static void xpc_ui_set_scroll_region(UI *ui __unused, int top, int bot, int left, int right) { + queue(^{ + int values[] = { top, bot, left, right }; + NSData *data = [[NSData alloc] initWithBytes:values length:(4 * sizeof(int))]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdSetScrollRegion data:data]; + [data release]; + }); +} + +static void xpc_ui_scroll(UI *ui __unused, int count) { + queue(^{ + int value = count; + NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(int))]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdScroll data:data]; + [data release]; + }); +} + +static void xpc_ui_highlight_set(UI *ui __unused, HlAttrs attrs) { + queue(^{ + FontTrait trait = FontTraitNone; + if (attrs.italic) { + trait |= FontTraitItalic; + } + if (attrs.bold) { + trait |= FontTraitBold; + } + if (attrs.underline) { + trait |= FontTraitUnderline; + } + if (attrs.undercurl) { + trait |= FontTraitUndercurl; + } + CellAttributes cellAttrs; + cellAttrs.fontTrait = trait; + + unsigned int fg = attrs.foreground == -1 ? _default_foreground : pun_type(unsigned int, attrs.foreground); + unsigned int bg = attrs.background == -1 ? _default_background : pun_type(unsigned int, attrs.background); + + cellAttrs.foreground = attrs.reverse ? bg : fg; + cellAttrs.background = attrs.reverse ? fg : bg; + cellAttrs.special = attrs.special == -1 ? _default_special : pun_type(unsigned int, attrs.special); + + NSData *data = [[NSData alloc] initWithBytes:&cellAttrs length:sizeof(CellAttributes)]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdSetHighlightAttributes data:data]; + [data release]; + }); +} + +static void xpc_ui_put(UI *ui __unused, uint8_t *str, size_t len) { + queue(^{ + NSString *string = [[NSString alloc] initWithBytes:str length:len encoding:NSUTF8StringEncoding]; +// printf("%s", [string cStringUsingEncoding:NSUTF8StringEncoding]); + + NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; + if (_marked_text != nil && _marked_row == _put_row && _marked_column == _put_column) { +// log4Debug("putting marked text: '%@'", string); + [_neovim_server sendMessageWithId:NeoVimServerMsgIdPutMarked data:data]; + } else if (_marked_text != nil && len == 0 && _marked_row == _put_row && _marked_column == _put_column - 1) { +// log4Debug("putting marked text cuz zero"); + [_neovim_server sendMessageWithId:NeoVimServerMsgIdPutMarked data:data]; + } else { +// log4Debug("putting non-marked text: '%@'", string); + [_neovim_server sendMessageWithId:NeoVimServerMsgIdPut data:data]; + } + + _put_column += 1; + [string release]; + }); +} + +static void xpc_ui_bell(UI *ui __unused) { + queue(^{ + [_neovim_server sendMessageWithId:NeoVimServerMsgIdBell]; + }); +} + +static void xpc_ui_visual_bell(UI *ui __unused) { + queue(^{ + [_neovim_server sendMessageWithId:NeoVimServerMsgIdVisualBell]; + }); +} + +static void xpc_ui_flush(UI *ui __unused) { + queue(^{ + [_neovim_server sendMessageWithId:NeoVimServerMsgIdFlush]; + }); +} + +static void xpc_ui_update_fg(UI *ui __unused, int fg) { + queue(^{ + int value; + + if (fg == -1) { + value = _default_foreground; + NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(int))]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdScroll data:data]; + [data release]; + + return; + } + + _default_foreground = pun_type(unsigned int, fg); + + value = fg; + NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(int))]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdScroll data:data]; + [data release]; + }); +} + +static void xpc_ui_update_bg(UI *ui __unused, int bg) { + queue(^{ + int value; + + if (bg == -1) { + value = _default_background; + NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(int))]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdScroll data:data]; + [data release]; + + return; + } + + _default_background = pun_type(unsigned int, bg); + value = bg; + NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(int))]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdScroll data:data]; + [data release]; + }); +} + +static void xpc_ui_update_sp(UI *ui __unused, int sp) { + queue(^{ + int value; + + if (sp == -1) { + value = _default_special; + NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(int))]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdScroll data:data]; + [data release]; + + return; + } + + _default_special = pun_type(unsigned int, sp); + value = sp; + NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(int))]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdScroll data:data]; + [data release]; + }); +} + +static void xpc_ui_suspend(UI *ui __unused) { + queue(^{ + [_neovim_server sendMessageWithId:NeoVimServerMsgIdSuspend]; + + ServerUiData *data = ui->data; + // FIXME: dunno whether we need this: copied from tui.c + // kill(0, SIGTSTP) won't stop the UI thread, so we must poll for SIGCONT + // before continuing. This is done in another callback to avoid + // loop_poll_events recursion + queue_put_event(data->loop->fast_events, event_create(1, suspend_event, 1, ui)); + }); +} + +static void xpc_ui_set_title(UI *ui __unused, char *title) { + queue(^{ + NSString *string = [[NSString alloc] initWithCString:title encoding:NSUTF8StringEncoding]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdSetTitle data:[string dataUsingEncoding:NSUTF8StringEncoding]]; + [string release]; + }); +} + +static void xpc_ui_set_icon(UI *ui __unused, char *icon) { + queue(^{ + NSString *string = [[NSString alloc] initWithCString:icon encoding:NSUTF8StringEncoding]; + [_neovim_server sendMessageWithId:NeoVimServerMsgIdSetIcon data:[string dataUsingEncoding:NSUTF8StringEncoding]]; + [string release]; + }); +} + +static void xpc_ui_stop(UI *ui __unused) { + queue(^{ + [_neovim_server sendMessageWithId:NeoVimServerMsgIdStop]; + + ServerUiData *data = (ServerUiData *) ui->data; + data->stop = true; + }); +} + +static void run_neovim(void *arg __unused) { + char *argv[1]; + argv[0] = "nvim"; + + int returnCode = nvim_main(1, argv); + + log4Debug("neovim's main returned with code: %d", returnCode); +} + +void custom_ui_start(void) { + UI *ui = xcalloc(1, sizeof(UI)); + + ui->rgb = true; + ui->stop = xpc_ui_stop; + ui->resize = xpc_ui_resize; + ui->clear = xpc_ui_clear; + ui->eol_clear = xpc_ui_eol_clear; + ui->cursor_goto = xpc_ui_cursor_goto; + ui->update_menu = xpc_ui_update_menu; + ui->busy_start = xpc_ui_busy_start; + ui->busy_stop = xpc_ui_busy_stop; + ui->mouse_on = xpc_ui_mouse_on; + ui->mouse_off = xpc_ui_mouse_off; + ui->mode_change = xpc_ui_mode_change; + ui->set_scroll_region = xpc_ui_set_scroll_region; + ui->scroll = xpc_ui_scroll; + ui->highlight_set = xpc_ui_highlight_set; + ui->put = xpc_ui_put; + ui->bell = xpc_ui_bell; + ui->visual_bell = xpc_ui_visual_bell; + ui->update_fg = xpc_ui_update_fg; + ui->update_bg = xpc_ui_update_bg; + ui->update_sp = xpc_ui_update_sp; + ui->flush = xpc_ui_flush; + ui->suspend = xpc_ui_suspend; + ui->set_title = xpc_ui_set_title; + ui->set_icon = xpc_ui_set_icon; + + ui_bridge_attach(ui, osx_xpc_ui_main, osx_xpc_ui_scheduler); +} + +static void force_redraw(void **argv __unused) { + must_redraw = CLEAR; + update_screen(0); +} + +static void refresh_ui(void **argv __unused) { + ui_refresh(); +} + +// TODO: optimize away @autoreleasepool? +static void neovim_input(void **argv) { + @autoreleasepool { + NSString *input = (NSString *) argv[0]; + + // FIXME: check the length of the consumed bytes by neovim and if not fully consumed, call vim_input again. + vim_input((String) { + .data = (char *) input.UTF8String, + .size = [input lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + }); + + [input release]; // retain in loop_schedule(&main_loop, ...) (in _queue) somewhere + } +} + +void start_neovim() { + _queue = dispatch_queue_create("com.qvacua.nvox.neovim-server.queue", DISPATCH_QUEUE_SERIAL); + + // set $VIMRUNTIME to ${RESOURCE_PATH_OF_XPC_BUNDLE}/runtime + NSString *bundlePath = [NSBundle bundleForClass:[NeoVimServer class]].bundlePath; + NSString *resourcesPath = [bundlePath.stringByDeletingLastPathComponent stringByAppendingPathComponent:@"Resources"]; + NSString *runtimePath = [resourcesPath stringByAppendingPathComponent:@"runtime"]; + setenv("VIMRUNTIME", runtimePath.fileSystemRepresentation, true); + + uv_mutex_init(&_mutex); + uv_cond_init(&_condition); + + uv_thread_create(&_nvim_thread, run_neovim, NULL); + + // continue only after our UI main code for neovim has been fully initialized + uv_mutex_lock(&_mutex); + while (!_is_ui_launched) { + uv_cond_wait(&_condition, &_mutex); + } + uv_mutex_unlock(&_mutex); + + uv_cond_destroy(&_condition); + uv_mutex_destroy(&_mutex); + + _backspace = [[NSString alloc] initWithString:@""]; + + [_neovim_server sendMessageWithId:NeoVimServerMsgIdNeoVimReady]; +} + diff --git a/SwiftNeoVim/NeoVim.swift b/SwiftNeoVim/NeoVim.swift index 0fccc129..1243abaa 100644 --- a/SwiftNeoVim/NeoVim.swift +++ b/SwiftNeoVim/NeoVim.swift @@ -6,34 +6,11 @@ import Foundation public class NeoVim { - - private static let qXpcName = "com.qvacua.nvox.xpc" - - private let xpcConnection: NSXPCConnection = NSXPCConnection(serviceName: NeoVim.qXpcName) - public let xpc: NeoVimXpc - public let view: NeoVimView + private let agent: NeoVimAgent public init() { - self.xpcConnection.remoteObjectInterface = NSXPCInterface(withProtocol: NeoVimXpc.self) - - self.xpc = self.xpcConnection.remoteObjectProxy as! NeoVimXpc - self.view = NeoVimView(xpc: self.xpc) - - self.xpcConnection.exportedInterface = NSXPCInterface(withProtocol: NeoVimUiBridgeProtocol.self) - self.xpcConnection.exportedObject = self.view - - self.xpcConnection.resume() - - // bring the XPC service to life - self.xpc.probe() let uuid = NSUUID().UUIDString - let wrapper = NeoVimUiWrapper(uuid: uuid, xpc: self.xpc) - wrapper.runLocalServer() - self.xpc.startServerWithUuid(uuid) - } - - deinit { - self.xpcConnection.invalidate() + self.agent = NeoVimAgent(uuid: uuid) } } diff --git a/SwiftNeoVim/NeoVimAgent.h b/SwiftNeoVim/NeoVimAgent.h new file mode 100644 index 00000000..e07f6ab6 --- /dev/null +++ b/SwiftNeoVim/NeoVimAgent.h @@ -0,0 +1,17 @@ +/** + * Tae Won Ha - http://taewon.de - @hataewon + * See LICENSE + */ + +#import + + +NS_ASSUME_NONNULL_BEGIN + +@interface NeoVimAgent : NSObject + +- (instancetype)initWithUuid:(NSString *)uuid; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SwiftNeoVim/NeoVimAgent.m b/SwiftNeoVim/NeoVimAgent.m new file mode 100644 index 00000000..3a6c45fc --- /dev/null +++ b/SwiftNeoVim/NeoVimAgent.m @@ -0,0 +1,218 @@ +/** + * Tae Won Ha - http://taewon.de - @hataewon + * See LICENSE + */ + +#import "NeoVimAgent.h" +#import "NeoVimServerMsgIds.h" + + +static const int qTimeout = 10; + +@interface NeoVimAgent () + +- (NSData *)handleMessageWithId:(SInt32)msgid data:(NSData *)data; + +@end + + +static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info) { + @autoreleasepool { + NeoVimAgent *agent = (__bridge NeoVimAgent *) info; + NSData *responseData = [agent handleMessageWithId:msgid data:(__bridge NSData *) (data)]; + if (responseData == NULL) { + return NULL; + } + + return CFDataCreate(kCFAllocatorDefault, responseData.bytes, responseData.length); + } +} + + +@implementation NeoVimAgent { + NSString *_uuid; + + CFMessagePortRef _localServerPort; + NSThread *_localServerThread; + + NSTask *_neoVimServerTask; + CFMessagePortRef _remoteServerPort; +} + +- (instancetype)initWithUuid:(NSString *)uuid { + self = [super init]; + if (self == nil) { + return nil; + } + + _uuid = uuid; + _localServerThread = [[NSThread alloc] initWithTarget:self selector:@selector(runLocalServer) object:nil]; + [_localServerThread start]; + + _neoVimServerTask = [[NSTask alloc] init]; + _neoVimServerTask.launchPath = [self neoVimServerExecutablePath]; + NSLog(@"%@", [self neoVimServerExecutablePath]); + + _neoVimServerTask.arguments = @[ _uuid, [self localServerName], [self remoteServerName] ]; + [_neoVimServerTask launch]; + + + return self; +} + +- (NSString *)neoVimServerExecutablePath { + return [[[NSBundle bundleForClass:[self class]] builtInPlugInsPath] stringByAppendingPathComponent:@"NeoVimServer"]; +} + +- (void)dealloc { + CFMessagePortInvalidate(_localServerPort); + CFRelease(_localServerPort); + + [_localServerThread cancel]; + + [_neoVimServerTask terminate]; + NSLog(@"terminated..."); +} + +- (void)runLocalServer { + @autoreleasepool { + CFMessagePortContext localContext = { + .version = 0, + .info = (__bridge void *) self, + .retain = NULL, + .release = NULL, + .copyDescription = NULL + }; + + unsigned char shouldFreeLocalServer = false; + _localServerPort = CFMessagePortCreateLocal( + kCFAllocatorDefault, + (__bridge CFStringRef) [self localServerName], + local_server_callback, + &localContext, + &shouldFreeLocalServer + ); + + // FIXME: handle shouldFreeLocalServer = true + + CFRunLoopRef runLoop = CFRunLoopGetCurrent(); + CFRunLoopSourceRef runLoopSrc = CFMessagePortCreateRunLoopSource(kCFAllocatorDefault, _localServerPort, 0); + CFRunLoopAddSource(runLoop, runLoopSrc, kCFRunLoopCommonModes); + CFRelease(runLoopSrc); + CFRunLoopRun(); + } +} + +- (NSData *)handleMessageWithId:(SInt32)msgid data:(NSData *)data { + NSLog(@"msg received: %d -> %@", msgid, data); + + switch (msgid) { + + case NeoVimServerMsgIdServerReady: + return [self setupNeoVimServer]; + + case NeoVimServerMsgIdNeoVimReady: + return nil; + + case NeoVimServerMsgIdResize: + return nil; + + case NeoVimServerMsgIdClear: + return nil; + + case NeoVimServerMsgIdEolClear: + return nil; + + case NeoVimServerMsgIdSetPosition: + return nil; + + case NeoVimServerMsgIdSetMenu: + return nil; + + case NeoVimServerMsgIdBusyStart: + return nil; + + case NeoVimServerMsgIdBusyStop: + return nil; + + case NeoVimServerMsgIdMouseOn: + return nil; + + case NeoVimServerMsgIdMouseOff: + return nil; + + case NeoVimServerMsgIdModeChange: + return nil; + + case NeoVimServerMsgIdSetScrollRegion: + return nil; + + case NeoVimServerMsgIdScroll: + return nil; + + case NeoVimServerMsgIdSetHighlightAttributes: + return nil; + + case NeoVimServerMsgIdPut: + return nil; + + case NeoVimServerMsgIdPutMarked: + return nil; + + case NeoVimServerMsgIdUnmark: + return nil; + + case NeoVimServerMsgIdBell: + return nil; + + case NeoVimServerMsgIdFlush: + return nil; + + case NeoVimServerMsgIdSetForeground: + return nil; + + case NeoVimServerMsgIdSetBackground: + return nil; + + case NeoVimServerMsgIdSetSpecial: + return nil; + + case NeoVimServerMsgIdSetTitle: + return nil; + + case NeoVimServerMsgIdSetIcon: + return nil; + + case NeoVimServerMsgIdStop: + return nil; + + default: + return nil; + } +} + +- (NSData *)setupNeoVimServer { + _remoteServerPort = CFMessagePortCreateRemote( + kCFAllocatorDefault, + (__bridge CFStringRef) [self remoteServerName] + ); + + SInt32 responseCode = CFMessagePortSendRequest( + _remoteServerPort, NeoVimAgendMsgIdAgentReady, nil, qTimeout, qTimeout, NULL, NULL + ); + if (responseCode == kCFMessagePortSuccess) { + NSLog(@"!!!!!!!! SUCCESS!!!!"); + } + + return nil; +} + +- (NSString *)localServerName { + return [NSString stringWithFormat:@"com.qvacua.nvox.%@", _uuid]; +} + +- (NSString *)remoteServerName { + return [NSString stringWithFormat:@"com.qvacua.nvox.neovim-server.%@", _uuid]; +} + +@end diff --git a/SwiftNeoVim/NeoVimUiWrapper.h b/SwiftNeoVim/NeoVimUiWrapper.h deleted file mode 100644 index 7cc26765..00000000 --- a/SwiftNeoVim/NeoVimUiWrapper.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// NeoVimUiClient.h -// nvox -// -// Created by Tae Won Ha on 08/07/16. -// Copyright © 2016 Tae Won Ha. All rights reserved. -// - -#import - -@protocol NeoVimXpc; - -NS_ASSUME_NONNULL_BEGIN - -@interface NeoVimUiWrapper : NSObject - -- (instancetype)initWithUuid:(NSString *)uuid xpc:(id)xpc; - -- (void)runLocalServer; - -- (NSData *)handleMessageWithId:(SInt32)msgid data:(NSData *)data; - -@end - -NS_ASSUME_NONNULL_END diff --git a/SwiftNeoVim/NeoVimUiWrapper.m b/SwiftNeoVim/NeoVimUiWrapper.m deleted file mode 100644 index c184c403..00000000 --- a/SwiftNeoVim/NeoVimUiWrapper.m +++ /dev/null @@ -1,115 +0,0 @@ -// -// NeoVimUiClient.m -// nvox -// -// Created by Tae Won Ha on 08/07/16. -// Copyright © 2016 Tae Won Ha. All rights reserved. -// - -#import "NeoVimUiWrapper.h" -#import "NeoVimXpc.h" - -typedef NS_ENUM(NSUInteger, MainAppMsgId) { - MainAppMsgIdRemoteNeoVimReady = 0 -}; - - -static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info) { - NeoVimUiWrapper *wrapper = (__bridge NeoVimUiWrapper *)info; - NSData *responseData = [wrapper handleMessageWithId:msgid data:(__bridge NSData *)(data)]; - if (responseData == NULL) { - return NULL; - } - - return CFDataCreate(kCFAllocatorDefault, responseData.bytes, responseData.length); -} - - -// let executablePath = NSBundle.mainBundle().bundlePath + "/Contents/XPCServices/DummyXpc.xpc/Contents/MacOS/DummyXpc" -@implementation NeoVimUiWrapper { - NSString *_uuid; - - id _xpc; - - CFMessagePortRef _remoteServerPort; - - CFMessagePortRef _localServerPort; - NSThread *_localServerThread; - CFRunLoopSourceRef _localServerRunLoopSrc; -} - -- (instancetype)initWithUuid:(NSString *)uuid xpc:(id )xpc { - self = [super init]; - if (self == nil) { - return nil; - } - - _xpc = xpc; - _uuid = uuid; - - - return self; -} - -- (void)dealloc { - CFMessagePortInvalidate(_localServerPort); - CFRelease(_localServerPort); - CFRelease(_localServerRunLoopSrc); - - [_localServerThread cancel]; -} - -- (void)runLocalServer { - _localServerThread = [[NSThread alloc] initWithTarget:self selector:@selector(doRunLocalServer) object:nil]; - [_localServerThread start]; -} - -- (void)doRunLocalServer { - NSString *localServerName = [NSString stringWithFormat:@"com.qvacua.nvox.%@", _uuid]; - NSLog(@"main app server name: %@", localServerName); - CFMessagePortContext localContext = { - .version = 0, - .info = (__bridge void *) self, - .retain = NULL, - .release = NULL, - .copyDescription = NULL - }; - - unsigned char shouldFreeLocalServer = false; - _localServerPort = CFMessagePortCreateLocal( - kCFAllocatorDefault, - (__bridge CFStringRef) localServerName, - local_server_callback, - &localContext, - &shouldFreeLocalServer - ); - // FIXME: handle shouldFreeLocalServer = true - - _localServerRunLoopSrc = CFMessagePortCreateRunLoopSource(kCFAllocatorDefault, _localServerPort, 0); - CFRunLoopRef cfRunLoop = [NSRunLoop currentRunLoop].getCFRunLoop; - CFRunLoopAddSource(cfRunLoop, _localServerRunLoopSrc, kCFRunLoopCommonModes); - [[NSRunLoop currentRunLoop] run]; -} - -- (NSData *)handleMessageWithId:(SInt32)msgid data:(NSData *)data { - switch (msgid) { - case MainAppMsgIdRemoteNeoVimReady: { - NSLog(@"!!!!!!!!!!!!!!!!!!!!!!!!! %d", msgid); - - _remoteServerPort = CFMessagePortCreateRemote(kCFAllocatorDefault, (__bridge CFStringRef) _uuid); - - NSData *somedata = [@"some data" dataUsingEncoding:NSUTF8StringEncoding]; - SInt32 reponseCode = CFMessagePortSendRequest( - _remoteServerPort, 13, (__bridge CFDataRef) somedata, 10, 10, NULL, NULL - ); - if (reponseCode == kCFMessagePortSuccess) { - NSLog(@"!!!!!!!! SUCCESS!!!!"); - } - return nil; - } - default: - return nil; - } -} - -@end diff --git a/SwiftNeoVim/NeoVimViewUiBridge.swift b/SwiftNeoVim/NeoVimViewUiBridge.swift index 8d3e0240..693b06ff 100644 --- a/SwiftNeoVim/NeoVimViewUiBridge.swift +++ b/SwiftNeoVim/NeoVimViewUiBridge.swift @@ -9,8 +9,8 @@ extension NeoVimView: NeoVimUiBridgeProtocol { public func neoVimUiIsReady() { DispatchUtils.gui { - NSLog("\(#function): \(self.frame)") - self.resizeNeoVimUiTo(size: self.frame.size) + NSLog("\(#function): \(self.frame)") + self.resizeNeoVimUiTo(size: self.frame.size) } } diff --git a/SwiftNeoVim/SwiftNeoVim.h b/SwiftNeoVim/SwiftNeoVim.h index 5ad728c7..9ca142fd 100644 --- a/SwiftNeoVim/SwiftNeoVim.h +++ b/SwiftNeoVim/SwiftNeoVim.h @@ -15,4 +15,4 @@ FOUNDATION_EXPORT const unsigned char SwiftNeoVimVersionString[]; // TODO: this header should not be public, but we cannot use a bridging header in a framework. #import #import -#import +#import diff --git a/nvox.xcodeproj/project.pbxproj b/nvox.xcodeproj/project.pbxproj index 570910da..2e7cebaa 100644 --- a/nvox.xcodeproj/project.pbxproj +++ b/nvox.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 1929B728262BAA14FC93F6AC /* NeoVimView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BF00B466B40629C2AABE /* NeoVimView.swift */; }; 1929BEB90DCDAF7A2B68C886 /* ColorUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BA6128BFDD54CA92F46E /* ColorUtils.swift */; }; + 1929BF81A40B4154D3EA33CE /* server_ui.m in Sources */ = {isa = PBXBuildFile; fileRef = 1929B93013228985F509C8F6 /* server_ui.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 4B1BB3531D16C5E500CA4FEF /* InputTestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1BB3521D16C5E500CA4FEF /* InputTestView.swift */; }; 4B2A2BEC1D02261F0074CE9A /* RxCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B2A2BE21D0225800074CE9A /* RxCocoa.framework */; }; 4B2A2BED1D02261F0074CE9A /* RxCocoa.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4B2A2BE21D0225800074CE9A /* RxCocoa.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -30,29 +31,43 @@ 4B56F2951D29903F00C1F92E /* SwiftNeoVim.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B2A2BF71D0351810074CE9A /* SwiftNeoVim.framework */; }; 4B56F29D1D29926600C1F92E /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B56F29B1D29926600C1F92E /* Nimble.framework */; }; 4B56F29E1D29926600C1F92E /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B56F29C1D29926600C1F92E /* Quick.framework */; }; - 4B570DC21D303CAF006EDC21 /* NeoVimUiWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B570DC01D303CAF006EDC21 /* NeoVimUiWrapper.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4B570DC31D303CAF006EDC21 /* NeoVimUiWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B570DC11D303CAF006EDC21 /* NeoVimUiWrapper.m */; }; + 4B570DC21D303CAF006EDC21 /* NeoVimAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B570DC01D303CAF006EDC21 /* NeoVimAgent.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4B570DC31D303CAF006EDC21 /* NeoVimAgent.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B570DC11D303CAF006EDC21 /* NeoVimAgent.m */; }; + 4B854A1D1D31447C00E08DE1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B854A1C1D31447C00E08DE1 /* main.m */; }; 4B9A15241D2993DA009F9F67 /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B56F29B1D29926600C1F92E /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4B9A15251D2993DA009F9F67 /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B56F29C1D29926600C1F92E /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4B9A15261D2993DF009F9F67 /* SwiftNeoVim.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B2A2BF71D0351810074CE9A /* SwiftNeoVim.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4BB202DC1D0359B0001D130D /* NeoVimXpc.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B2A2C211D0359650074CE9A /* NeoVimXpc.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BCADE081D11ED12004DAD0F /* CocoaExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BCADE071D11ED12004DAD0F /* CocoaExtensions.swift */; }; + 4BDCFACB1D31449700F62670 /* NeoVimServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BDCFACA1D31449700F62670 /* NeoVimServer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 4BDCFACD1D3145AC00F62670 /* libnvim.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFACC1D3145AC00F62670 /* libnvim.a */; }; + 4BDCFAD51D3145E500F62670 /* libjemalloc_pic.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFACE1D3145E500F62670 /* libjemalloc_pic.a */; }; + 4BDCFAD61D3145E500F62670 /* libjemalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFACF1D3145E500F62670 /* libjemalloc.a */; }; + 4BDCFAD71D3145E500F62670 /* libluajit-5.1.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFAD01D3145E500F62670 /* libluajit-5.1.a */; }; + 4BDCFAD81D3145E500F62670 /* libluv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFAD11D3145E500F62670 /* libluv.a */; }; + 4BDCFAD91D3145E500F62670 /* libmsgpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFAD21D3145E500F62670 /* libmsgpack.a */; }; + 4BDCFADA1D3145E500F62670 /* libuv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFAD31D3145E500F62670 /* libuv.a */; }; + 4BDCFADB1D3145E500F62670 /* libvterm.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFAD41D3145E500F62670 /* libvterm.a */; }; + 4BDCFAE11D31475000F62670 /* libjemalloc_pic.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFACE1D3145E500F62670 /* libjemalloc_pic.a */; }; + 4BDCFAE21D31475100F62670 /* libjemalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFACF1D3145E500F62670 /* libjemalloc.a */; }; + 4BDCFAE31D31475300F62670 /* libluajit-5.1.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFAD01D3145E500F62670 /* libluajit-5.1.a */; }; + 4BDCFAE41D31475500F62670 /* libluv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFAD11D3145E500F62670 /* libluv.a */; }; + 4BDCFAE51D31475700F62670 /* libmsgpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFAD21D3145E500F62670 /* libmsgpack.a */; }; + 4BDCFAE61D31475900F62670 /* libuv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFAD31D3145E500F62670 /* libuv.a */; }; + 4BDCFAE71D31475B00F62670 /* libvterm.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFAD41D3145E500F62670 /* libvterm.a */; }; + 4BDCFAE81D31475D00F62670 /* libnvim.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFACC1D3145AC00F62670 /* libnvim.a */; }; + 4BDCFAEA1D31486E00F62670 /* NeoVimServerMsgIds.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDCFAE91D3147A300F62670 /* NeoVimServerMsgIds.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 4BDCFAEB1D3148A100F62670 /* NeoVimServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDCFAC91D31449700F62670 /* NeoVimServer.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 4BDCFAED1D315CB800F62670 /* runtime in Resources */ = {isa = PBXBuildFile; fileRef = 4BEBA6621D00157A00673FDF /* runtime */; }; + 4BDCFAEF1D315CF200F62670 /* NeoVimServer in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B854A1A1D31447C00E08DE1 /* NeoVimServer */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 4BDF641C1D0887C100D47E1D /* TextDrawer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDF641A1D0887C100D47E1D /* TextDrawer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BDF641D1D0887C100D47E1D /* TextDrawer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BDF641B1D0887C100D47E1D /* TextDrawer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; - 4BDF64241D08CAB000D47E1D /* MMCoreTextView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDF64221D08CAB000D47E1D /* MMCoreTextView.h */; }; + 4BDF64241D08CAB000D47E1D /* MMCoreTextView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDF64221D08CAB000D47E1D /* MMCoreTextView.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4BDF64251D08CAB000D47E1D /* MMCoreTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BDF64231D08CAB000D47E1D /* MMCoreTextView.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 4BEBA5091CFF374B00673FDF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BEBA5081CFF374B00673FDF /* AppDelegate.swift */; }; 4BEBA50B1CFF374B00673FDF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4BEBA50A1CFF374B00673FDF /* Assets.xcassets */; }; 4BEBA50E1CFF374B00673FDF /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4BEBA50C1CFF374B00673FDF /* MainMenu.xib */; }; 4BEBA5191CFF374B00673FDF /* nvoxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BEBA5181CFF374B00673FDF /* nvoxTests.swift */; }; - 4BEBA5391CFF5E5D00673FDF /* libnvim.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BEBA5381CFF5E5D00673FDF /* libnvim.a */; }; - 4BEBA5431CFF5EA500673FDF /* libjemalloc_pic.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BEBA53A1CFF5EA500673FDF /* libjemalloc_pic.a */; }; - 4BEBA5441CFF5EA500673FDF /* libjemalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BEBA53B1CFF5EA500673FDF /* libjemalloc.a */; }; - 4BEBA5451CFF5EA500673FDF /* libluajit-5.1.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BEBA53C1CFF5EA500673FDF /* libluajit-5.1.a */; }; - 4BEBA5461CFF5EA500673FDF /* libluv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BEBA53D1CFF5EA500673FDF /* libluv.a */; }; - 4BEBA5471CFF5EA500673FDF /* libmsgpack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BEBA53E1CFF5EA500673FDF /* libmsgpack.a */; }; - 4BEBA54A1CFF5EA500673FDF /* libuv.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BEBA5411CFF5EA500673FDF /* libuv.a */; }; - 4BEBA54B1CFF5EA500673FDF /* libvterm.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BEBA5421CFF5EA500673FDF /* libvterm.a */; }; 4BEBA6631D00157A00673FDF /* runtime in Resources */ = {isa = PBXBuildFile; fileRef = 4BEBA6621D00157A00673FDF /* runtime */; }; 4BEE79121D16D0AC0012EDAA /* NeoVimViewUiBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BEE79111D16D0AC0012EDAA /* NeoVimViewUiBridge.swift */; }; 4BEE79151D16D2100012EDAA /* DispatchUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BEE79141D16D2100012EDAA /* DispatchUtils.swift */; }; @@ -69,13 +84,6 @@ remoteGlobalIDString = 4B2A2BF61D0351810074CE9A; remoteInfo = SwiftNeoVim; }; - 4B2A2C0B1D0353090074CE9A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4BEBA4FD1CFF374B00673FDF /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4BEBA5261CFF3DFF00673FDF; - remoteInfo = NeoVimXpc; - }; 4B56F2961D29903F00C1F92E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 4BEBA4FD1CFF374B00673FDF /* Project object */; @@ -83,6 +91,20 @@ remoteGlobalIDString = 4B2A2BF61D0351810074CE9A; remoteInfo = SwiftNeoVim; }; + 4B854A041D3137B000E08DE1 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4BEBA4FD1CFF374B00673FDF /* Project object */; + proxyType = 1; + remoteGlobalIDString = 4BEBA5261CFF3DFF00673FDF; + remoteInfo = NeoVimXpc; + }; + 4BDCFADD1D31465100F62670 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4BEBA4FD1CFF374B00673FDF /* Project object */; + proxyType = 1; + remoteGlobalIDString = 4B854A191D31447C00E08DE1; + remoteInfo = NeoVimServer; + }; 4BEBA5151CFF374B00673FDF /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 4BEBA4FD1CFF374B00673FDF /* Project object */; @@ -117,6 +139,25 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 4B854A061D3137B500E08DE1 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 4BDCFAEF1D315CF200F62670 /* NeoVimServer in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 4B854A181D31447C00E08DE1 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; 4B9A15231D2993D0009F9F67 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -132,7 +173,10 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 1929B1A51F076E088EF4CCA4 /* server_globals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = server_globals.h; sourceTree = ""; }; 1929B1C144A199B48B20EDE8 /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Logging.h; sourceTree = ""; }; + 1929B65CCAD78DAC01538B98 /* server_ui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = server_ui.h; sourceTree = ""; }; + 1929B93013228985F509C8F6 /* server_ui.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = server_ui.m; sourceTree = ""; }; 1929BA6128BFDD54CA92F46E /* ColorUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorUtils.swift; sourceTree = ""; }; 1929BF00B466B40629C2AABE /* NeoVimView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NeoVimView.swift; sourceTree = ""; }; 4B1BB3521D16C5E500CA4FEF /* InputTestView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InputTestView.swift; sourceTree = ""; }; @@ -157,9 +201,23 @@ 4B56F2941D29903F00C1F92E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4B56F29B1D29926600C1F92E /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/Mac/Nimble.framework; sourceTree = SOURCE_ROOT; }; 4B56F29C1D29926600C1F92E /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/Mac/Quick.framework; sourceTree = SOURCE_ROOT; }; - 4B570DC01D303CAF006EDC21 /* NeoVimUiWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NeoVimUiWrapper.h; sourceTree = ""; }; - 4B570DC11D303CAF006EDC21 /* NeoVimUiWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NeoVimUiWrapper.m; sourceTree = ""; }; + 4B570DC01D303CAF006EDC21 /* NeoVimAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NeoVimAgent.h; sourceTree = ""; }; + 4B570DC11D303CAF006EDC21 /* NeoVimAgent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NeoVimAgent.m; sourceTree = ""; }; + 4B854A1A1D31447C00E08DE1 /* NeoVimServer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = NeoVimServer; sourceTree = BUILT_PRODUCTS_DIR; }; + 4B854A1C1D31447C00E08DE1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 4BCADE071D11ED12004DAD0F /* CocoaExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CocoaExtensions.swift; sourceTree = ""; }; + 4BDCFAC91D31449700F62670 /* NeoVimServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NeoVimServer.h; sourceTree = ""; }; + 4BDCFACA1D31449700F62670 /* NeoVimServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NeoVimServer.m; sourceTree = ""; }; + 4BDCFACC1D3145AC00F62670 /* libnvim.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libnvim.a; path = neovim/build/lib/libnvim.a; sourceTree = SOURCE_ROOT; }; + 4BDCFACE1D3145E500F62670 /* libjemalloc_pic.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjemalloc_pic.a; path = neovim/.deps/usr/lib/libjemalloc_pic.a; sourceTree = SOURCE_ROOT; }; + 4BDCFACF1D3145E500F62670 /* libjemalloc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjemalloc.a; path = neovim/.deps/usr/lib/libjemalloc.a; sourceTree = SOURCE_ROOT; }; + 4BDCFAD01D3145E500F62670 /* libluajit-5.1.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libluajit-5.1.a"; path = "neovim/.deps/usr/lib/libluajit-5.1.a"; sourceTree = SOURCE_ROOT; }; + 4BDCFAD11D3145E500F62670 /* libluv.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libluv.a; path = neovim/.deps/usr/lib/libluv.a; sourceTree = SOURCE_ROOT; }; + 4BDCFAD21D3145E500F62670 /* libmsgpack.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmsgpack.a; path = neovim/.deps/usr/lib/libmsgpack.a; sourceTree = SOURCE_ROOT; }; + 4BDCFAD31D3145E500F62670 /* libuv.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libuv.a; path = neovim/.deps/usr/lib/libuv.a; sourceTree = SOURCE_ROOT; }; + 4BDCFAD41D3145E500F62670 /* libvterm.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libvterm.a; path = neovim/.deps/usr/lib/libvterm.a; sourceTree = SOURCE_ROOT; }; + 4BDCFAE01D31471500F62670 /* nvim */ = {isa = PBXFileReference; lastKnownFileType = folder; name = nvim; path = neovim/src/nvim; sourceTree = SOURCE_ROOT; }; + 4BDCFAE91D3147A300F62670 /* NeoVimServerMsgIds.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NeoVimServerMsgIds.h; sourceTree = ""; }; 4BDF641A1D0887C100D47E1D /* TextDrawer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextDrawer.h; sourceTree = ""; }; 4BDF641B1D0887C100D47E1D /* TextDrawer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextDrawer.m; sourceTree = ""; }; 4BDF64221D08CAB000D47E1D /* MMCoreTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMCoreTextView.h; sourceTree = ""; }; @@ -173,15 +231,6 @@ 4BEBA5181CFF374B00673FDF /* nvoxTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = nvoxTests.swift; sourceTree = ""; }; 4BEBA51A1CFF374B00673FDF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4BEBA5271CFF3DFF00673FDF /* NeoVimXpc.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = NeoVimXpc.xpc; sourceTree = BUILT_PRODUCTS_DIR; }; - 4BEBA5381CFF5E5D00673FDF /* libnvim.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libnvim.a; path = neovim/build/lib/libnvim.a; sourceTree = SOURCE_ROOT; }; - 4BEBA53A1CFF5EA500673FDF /* libjemalloc_pic.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjemalloc_pic.a; path = neovim/.deps/usr/lib/libjemalloc_pic.a; sourceTree = SOURCE_ROOT; }; - 4BEBA53B1CFF5EA500673FDF /* libjemalloc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjemalloc.a; path = neovim/.deps/usr/lib/libjemalloc.a; sourceTree = SOURCE_ROOT; }; - 4BEBA53C1CFF5EA500673FDF /* libluajit-5.1.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libluajit-5.1.a"; path = "neovim/.deps/usr/lib/libluajit-5.1.a"; sourceTree = SOURCE_ROOT; }; - 4BEBA53D1CFF5EA500673FDF /* libluv.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libluv.a; path = neovim/.deps/usr/lib/libluv.a; sourceTree = SOURCE_ROOT; }; - 4BEBA53E1CFF5EA500673FDF /* libmsgpack.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmsgpack.a; path = neovim/.deps/usr/lib/libmsgpack.a; sourceTree = SOURCE_ROOT; }; - 4BEBA5411CFF5EA500673FDF /* libuv.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libuv.a; path = neovim/.deps/usr/lib/libuv.a; sourceTree = SOURCE_ROOT; }; - 4BEBA5421CFF5EA500673FDF /* libvterm.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libvterm.a; path = neovim/.deps/usr/lib/libvterm.a; sourceTree = SOURCE_ROOT; }; - 4BEBA6611D0014A400673FDF /* nvim */ = {isa = PBXFileReference; lastKnownFileType = folder; name = nvim; path = neovim/src/nvim; sourceTree = SOURCE_ROOT; }; 4BEBA6621D00157A00673FDF /* runtime */ = {isa = PBXFileReference; lastKnownFileType = folder; name = runtime; path = neovim/runtime; sourceTree = SOURCE_ROOT; }; 4BEE79111D16D0AC0012EDAA /* NeoVimViewUiBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NeoVimViewUiBridge.swift; sourceTree = ""; }; 4BEE79141D16D2100012EDAA /* DispatchUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DispatchUtils.swift; sourceTree = ""; }; @@ -208,6 +257,21 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 4B854A171D31447C00E08DE1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4BDCFACD1D3145AC00F62670 /* libnvim.a in Frameworks */, + 4BDCFAD51D3145E500F62670 /* libjemalloc_pic.a in Frameworks */, + 4BDCFAD81D3145E500F62670 /* libluv.a in Frameworks */, + 4BDCFAD61D3145E500F62670 /* libjemalloc.a in Frameworks */, + 4BDCFADA1D3145E500F62670 /* libuv.a in Frameworks */, + 4BDCFAD91D3145E500F62670 /* libmsgpack.a in Frameworks */, + 4BDCFADB1D3145E500F62670 /* libvterm.a in Frameworks */, + 4BDCFAD71D3145E500F62670 /* libluajit-5.1.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 4BEBA5021CFF374B00673FDF /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -230,14 +294,14 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 4BEBA54A1CFF5EA500673FDF /* libuv.a in Frameworks */, - 4BEBA5391CFF5E5D00673FDF /* libnvim.a in Frameworks */, - 4BEBA5431CFF5EA500673FDF /* libjemalloc_pic.a in Frameworks */, - 4BEBA5461CFF5EA500673FDF /* libluv.a in Frameworks */, - 4BEBA54B1CFF5EA500673FDF /* libvterm.a in Frameworks */, - 4BEBA5441CFF5EA500673FDF /* libjemalloc.a in Frameworks */, - 4BEBA5471CFF5EA500673FDF /* libmsgpack.a in Frameworks */, - 4BEBA5451CFF5EA500673FDF /* libluajit-5.1.a in Frameworks */, + 4BDCFAE31D31475300F62670 /* libluajit-5.1.a in Frameworks */, + 4BDCFAE51D31475700F62670 /* libmsgpack.a in Frameworks */, + 4BDCFAE71D31475B00F62670 /* libvterm.a in Frameworks */, + 4BDCFAE61D31475900F62670 /* libuv.a in Frameworks */, + 4BDCFAE11D31475000F62670 /* libjemalloc_pic.a in Frameworks */, + 4BDCFAE81D31475D00F62670 /* libnvim.a in Frameworks */, + 4BDCFAE41D31475500F62670 /* libluv.a in Frameworks */, + 4BDCFAE21D31475100F62670 /* libjemalloc.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -260,13 +324,13 @@ 4B2A2BF81D0351810074CE9A /* SwiftNeoVim */ = { isa = PBXGroup; children = ( + 4B854A151D31444800E08DE1 /* resources */, + 4BEE79131D16D1C60012EDAA /* NeoVimView */, 4B2A2C0E1D0353E30074CE9A /* NeoVim.swift */, 4BEE79161D16D3800012EDAA /* CellAttributes.swift */, - 4BEE79131D16D1C60012EDAA /* NeoVimView */, 1929BA6128BFDD54CA92F46E /* ColorUtils.swift */, 4B2A2C061D0352CB0074CE9A /* NeoVimUiBridgeProtocol.h */, 4B2A2BF91D0351810074CE9A /* SwiftNeoVim.h */, - 4B2A2BFB1D0351810074CE9A /* Info.plist */, 4BDF641A1D0887C100D47E1D /* TextDrawer.h */, 4BDF641B1D0887C100D47E1D /* TextDrawer.m */, 4BDF64221D08CAB000D47E1D /* MMCoreTextView.h */, @@ -288,9 +352,50 @@ path = SwiftNeoVimTests; sourceTree = ""; }; + 4B854A151D31444800E08DE1 /* resources */ = { + isa = PBXGroup; + children = ( + 4B2A2BFB1D0351810074CE9A /* Info.plist */, + 4BEBA6621D00157A00673FDF /* runtime */, + ); + name = resources; + sourceTree = ""; + }; + 4B854A1B1D31447C00E08DE1 /* NeoVimServer */ = { + isa = PBXGroup; + children = ( + 4BDCFADC1D3145EA00F62670 /* lib */, + 4BDCFAE01D31471500F62670 /* nvim */, + 4BDCFAE91D3147A300F62670 /* NeoVimServerMsgIds.h */, + 4BDCFAC91D31449700F62670 /* NeoVimServer.h */, + 4BDCFACA1D31449700F62670 /* NeoVimServer.m */, + 4B854A1C1D31447C00E08DE1 /* main.m */, + 1929B93013228985F509C8F6 /* server_ui.m */, + 1929B65CCAD78DAC01538B98 /* server_ui.h */, + 1929B1A51F076E088EF4CCA4 /* server_globals.h */, + ); + path = NeoVimServer; + sourceTree = ""; + }; + 4BDCFADC1D3145EA00F62670 /* lib */ = { + isa = PBXGroup; + children = ( + 4BDCFACE1D3145E500F62670 /* libjemalloc_pic.a */, + 4BDCFACF1D3145E500F62670 /* libjemalloc.a */, + 4BDCFAD01D3145E500F62670 /* libluajit-5.1.a */, + 4BDCFAD11D3145E500F62670 /* libluv.a */, + 4BDCFAD21D3145E500F62670 /* libmsgpack.a */, + 4BDCFAD31D3145E500F62670 /* libuv.a */, + 4BDCFAD41D3145E500F62670 /* libvterm.a */, + 4BDCFACC1D3145AC00F62670 /* libnvim.a */, + ); + name = lib; + sourceTree = ""; + }; 4BEBA4FC1CFF374B00673FDF = { isa = PBXGroup; children = ( + 4B854A1B1D31447C00E08DE1 /* NeoVimServer */, 4B2A2BE61D0225840074CE9A /* Frameworks */, 4BEBA5071CFF374B00673FDF /* nvox */, 4BEBA5171CFF374B00673FDF /* nvoxTests */, @@ -309,6 +414,7 @@ 4BEBA5271CFF3DFF00673FDF /* NeoVimXpc.xpc */, 4B2A2BF71D0351810074CE9A /* SwiftNeoVim.framework */, 4B56F2901D29903F00C1F92E /* SwiftNeoVimTests.xctest */, + 4B854A1A1D31447C00E08DE1 /* NeoVimServer */, ); name = Products; sourceTree = ""; @@ -342,29 +448,11 @@ 4B2A2C231D0359650074CE9A /* NeoVimXpcImpl.m */, 4B2A2C201D0359650074CE9A /* main.m */, 4B2A2C1F1D0359650074CE9A /* Info.plist */, - 4BEBA5371CFF5E4100673FDF /* libs */, - 4BEBA6611D0014A400673FDF /* nvim */, - 4BEBA6621D00157A00673FDF /* runtime */, 1929B1C144A199B48B20EDE8 /* Logging.h */, ); path = NeoVimXpc; sourceTree = ""; }; - 4BEBA5371CFF5E4100673FDF /* libs */ = { - isa = PBXGroup; - children = ( - 4BEBA53A1CFF5EA500673FDF /* libjemalloc_pic.a */, - 4BEBA53B1CFF5EA500673FDF /* libjemalloc.a */, - 4BEBA53C1CFF5EA500673FDF /* libluajit-5.1.a */, - 4BEBA53D1CFF5EA500673FDF /* libluv.a */, - 4BEBA53E1CFF5EA500673FDF /* libmsgpack.a */, - 4BEBA5411CFF5EA500673FDF /* libuv.a */, - 4BEBA5421CFF5EA500673FDF /* libvterm.a */, - 4BEBA5381CFF5E5D00673FDF /* libnvim.a */, - ); - name = libs; - sourceTree = ""; - }; 4BEE79131D16D1C60012EDAA /* NeoVimView */ = { isa = PBXGroup; children = ( @@ -373,8 +461,8 @@ 4BEE79111D16D0AC0012EDAA /* NeoVimViewUiBridge.swift */, 4B401B191D046E0600D99EDC /* NeoVimViewDelegate.swift */, 4BFF04831D21984100063EF3 /* NeoVimViewResponder.swift */, - 4B570DC01D303CAF006EDC21 /* NeoVimUiWrapper.h */, - 4B570DC11D303CAF006EDC21 /* NeoVimUiWrapper.m */, + 4B570DC01D303CAF006EDC21 /* NeoVimAgent.h */, + 4B570DC11D303CAF006EDC21 /* NeoVimAgent.m */, ); name = NeoVimView; sourceTree = ""; @@ -387,11 +475,13 @@ buildActionMask = 2147483647; files = ( 4B2A2C091D0352CB0074CE9A /* NeoVimUiBridgeProtocol.h in Headers */, - 4B570DC21D303CAF006EDC21 /* NeoVimUiWrapper.h in Headers */, + 4B570DC21D303CAF006EDC21 /* NeoVimAgent.h in Headers */, 4BDF641C1D0887C100D47E1D /* TextDrawer.h in Headers */, 4B2A2BFA1D0351810074CE9A /* SwiftNeoVim.h in Headers */, 4BB202DC1D0359B0001D130D /* NeoVimXpc.h in Headers */, + 4BDCFAEB1D3148A100F62670 /* NeoVimServer.h in Headers */, 4BDF64241D08CAB000D47E1D /* MMCoreTextView.h in Headers */, + 4BDCFAEA1D31486E00F62670 /* NeoVimServerMsgIds.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -407,11 +497,13 @@ 4B2A2BF41D0351810074CE9A /* Headers */, 4B2A2BF51D0351810074CE9A /* Resources */, 4B2A2C031D03527D0074CE9A /* CopyFiles */, + 4B854A061D3137B500E08DE1 /* CopyFiles */, ); buildRules = ( ); dependencies = ( - 4B2A2C0C1D0353090074CE9A /* PBXTargetDependency */, + 4BDCFADE1D31465100F62670 /* PBXTargetDependency */, + 4B854A051D3137B000E08DE1 /* PBXTargetDependency */, ); name = SwiftNeoVim; productName = SwiftNeoVim; @@ -437,6 +529,23 @@ productReference = 4B56F2901D29903F00C1F92E /* SwiftNeoVimTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + 4B854A191D31447C00E08DE1 /* NeoVimServer */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4B854A1E1D31447C00E08DE1 /* Build configuration list for PBXNativeTarget "NeoVimServer" */; + buildPhases = ( + 4B854A161D31447C00E08DE1 /* Sources */, + 4B854A171D31447C00E08DE1 /* Frameworks */, + 4B854A181D31447C00E08DE1 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = NeoVimServer; + productName = NeoVimServer; + productReference = 4B854A1A1D31447C00E08DE1 /* NeoVimServer */; + productType = "com.apple.product-type.tool"; + }; 4BEBA5041CFF374B00673FDF /* nvox */ = { isa = PBXNativeTarget; buildConfigurationList = 4BEBA51D1CFF374B00673FDF /* Build configuration list for PBXNativeTarget "nvox" */; @@ -508,6 +617,9 @@ 4B56F28F1D29903F00C1F92E = { CreatedOnToolsVersion = 7.3.1; }; + 4B854A191D31447C00E08DE1 = { + CreatedOnToolsVersion = 7.3.1; + }; 4BEBA5041CFF374B00673FDF = { CreatedOnToolsVersion = 7.3.1; }; @@ -538,6 +650,7 @@ 4BEBA5261CFF3DFF00673FDF /* NeoVimXpc */, 4B2A2BF61D0351810074CE9A /* SwiftNeoVim */, 4B56F28F1D29903F00C1F92E /* SwiftNeoVimTests */, + 4B854A191D31447C00E08DE1 /* NeoVimServer */, ); }; /* End PBXProject section */ @@ -547,6 +660,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4BDCFAED1D315CB800F62670 /* runtime in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -612,7 +726,7 @@ 4BFF04841D21984100063EF3 /* NeoVimViewResponder.swift in Sources */, 1929B728262BAA14FC93F6AC /* NeoVimView.swift in Sources */, 4BEF363D1D1EC045002A9898 /* NeoVimViewEvents.swift in Sources */, - 4B570DC31D303CAF006EDC21 /* NeoVimUiWrapper.m in Sources */, + 4B570DC31D303CAF006EDC21 /* NeoVimAgent.m in Sources */, 4BEE79121D16D0AC0012EDAA /* NeoVimViewUiBridge.swift in Sources */, 4BEE79151D16D2100012EDAA /* DispatchUtils.swift in Sources */, 4BDF641D1D0887C100D47E1D /* TextDrawer.m in Sources */, @@ -630,6 +744,16 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 4B854A161D31447C00E08DE1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4BDCFACB1D31449700F62670 /* NeoVimServer.m in Sources */, + 4B854A1D1D31447C00E08DE1 /* main.m in Sources */, + 1929BF81A40B4154D3EA33CE /* server_ui.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 4BEBA5011CFF374B00673FDF /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -663,16 +787,21 @@ target = 4B2A2BF61D0351810074CE9A /* SwiftNeoVim */; targetProxy = 4B2A2BFC1D0351810074CE9A /* PBXContainerItemProxy */; }; - 4B2A2C0C1D0353090074CE9A /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4BEBA5261CFF3DFF00673FDF /* NeoVimXpc */; - targetProxy = 4B2A2C0B1D0353090074CE9A /* PBXContainerItemProxy */; - }; 4B56F2971D29903F00C1F92E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 4B2A2BF61D0351810074CE9A /* SwiftNeoVim */; targetProxy = 4B56F2961D29903F00C1F92E /* PBXContainerItemProxy */; }; + 4B854A051D3137B000E08DE1 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 4BEBA5261CFF3DFF00673FDF /* NeoVimXpc */; + targetProxy = 4B854A041D3137B000E08DE1 /* PBXContainerItemProxy */; + }; + 4BDCFADE1D31465100F62670 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 4B854A191D31447C00E08DE1 /* NeoVimServer */; + targetProxy = 4BDCFADD1D31465100F62670 /* PBXContainerItemProxy */; + }; 4BEBA5161CFF374B00673FDF /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 4BEBA5041CFF374B00673FDF /* nvox */; @@ -769,6 +898,52 @@ }; name = Release; }; + 4B854A1F1D31447C00E08DE1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + "CUSTOM_UI=1", + "INCLUDE_GENERATED_DECLARATIONS=1", + ); + HEADER_SEARCH_PATHS = ( + "$(PROJECT_DIR)/neovim/build/include", + "$(PROJECT_DIR)/neovim/src", + "$(PROJECT_DIR)/neovim/.deps/usr/include", + ); + LIBRARY_SEARCH_PATHS = ( + "$(PROJECT_DIR)/neovim/build/lib", + "$(PROJECT_DIR)/neovim/.deps/usr/lib", + ); + OTHER_LDFLAGS = ( + /usr/local/opt/gettext/lib/libintl.a, + "-liconv", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 4B854A201D31447C00E08DE1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(PROJECT_DIR)/neovim/build/include", + "$(PROJECT_DIR)/neovim/src", + "$(PROJECT_DIR)/neovim/.deps/usr/include", + ); + LIBRARY_SEARCH_PATHS = ( + "$(PROJECT_DIR)/neovim/build/lib", + "$(PROJECT_DIR)/neovim/.deps/usr/lib", + ); + OTHER_LDFLAGS = ( + /usr/local/opt/gettext/lib/libintl.a, + "-liconv", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; 4BEBA51B1CFF374B00673FDF /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -994,6 +1169,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 4B854A1E1D31447C00E08DE1 /* Build configuration list for PBXNativeTarget "NeoVimServer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4B854A1F1D31447C00E08DE1 /* Debug */, + 4B854A201D31447C00E08DE1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 4BEBA5001CFF374B00673FDF /* Build configuration list for PBXProject "nvox" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/nvox/AppDelegate.swift b/nvox/AppDelegate.swift index e0374a5d..5b3c1fbc 100644 --- a/nvox/AppDelegate.swift +++ b/nvox/AppDelegate.swift @@ -24,14 +24,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NeoVimViewDelegate { // self.window.makeFirstResponder(testView) self.neoVim = NeoVim() - self.neoVim.view.delegate = self - - let view = self.neoVim.view - view.translatesAutoresizingMaskIntoConstraints = false - self.window.contentView?.addSubview(self.neoVim.view) - view.autoPinEdgesToSuperviewEdges() - - self.window.makeFirstResponder(self.neoVim.view) } func setTitle(title: String) {