diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-12-13 09:20:00 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-01-10 21:41:32 -0300 |
commit | 9b30abcecbc2492910f0281f596679714d95a88c (patch) | |
tree | 052e79fa603558ffeaf02cc0b996deff4bba8cb5 /src | |
parent | 748920d505e2997c79e08d87d09c564eaea23a2f (diff) | |
download | rneovim-9b30abcecbc2492910f0281f596679714d95a88c.tar.gz rneovim-9b30abcecbc2492910f0281f596679714d95a88c.tar.bz2 rneovim-9b30abcecbc2492910f0281f596679714d95a88c.zip |
remote_ui: Move handler registration to remote_ui.c
Also don't defer attach_ui handling
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 7 | ||||
-rw-r--r-- | src/nvim/msgpack_rpc/remote_ui.c | 45 |
2 files changed, 26 insertions, 26 deletions
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 4c35cce09a..f3c5a7a1e2 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -103,14 +103,7 @@ void channel_init(void) } if (abstract_ui) { - // Add handler for "attach_ui" remote_ui_init(); - String method = cstr_as_string("attach_ui"); - MsgpackRpcRequestHandler handler = {.fn = remote_ui_attach, .defer = true}; - msgpack_rpc_add_method_handler(method, handler); - method = cstr_as_string("detach_ui"); - handler.fn = remote_ui_detach; - msgpack_rpc_add_method_handler(method, handler); } } diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c index af7b82dfd4..e27d4383c0 100644 --- a/src/nvim/msgpack_rpc/remote_ui.c +++ b/src/nvim/msgpack_rpc/remote_ui.c @@ -26,10 +26,32 @@ static PMap(uint64_t) *connected_uis = NULL; void remote_ui_init(void) { connected_uis = pmap_new(uint64_t)(); + // Add handler for "attach_ui" + String method = cstr_as_string("attach_ui"); + MsgpackRpcRequestHandler handler = {.fn = remote_ui_attach, .defer = false}; + msgpack_rpc_add_method_handler(method, handler); + method = cstr_as_string("detach_ui"); + handler.fn = remote_ui_detach; + msgpack_rpc_add_method_handler(method, handler); } -Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, Array args, - Error *error) +void remote_ui_disconnect(uint64_t channel_id) +{ + UI *ui = pmap_get(uint64_t)(connected_uis, channel_id); + if (!ui) { + return; + } + UIData *data = ui->data; + // destroy pending screen updates + api_free_array(data->buffer); + pmap_del(uint64_t)(connected_uis, channel_id); + free(ui->data); + ui_detach(ui); + free(ui); +} + +static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, + Array args, Error *error) { if (pmap_has(uint64_t)(connected_uis, channel_id)) { api_set_error(error, Exception, _("UI already attached for channel")); @@ -77,8 +99,8 @@ Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, Array args, return NIL; } -Object remote_ui_detach(uint64_t channel_id, uint64_t request_id, Array args, - Error *error) +static Object remote_ui_detach(uint64_t channel_id, uint64_t request_id, + Array args, Error *error) { if (!pmap_has(uint64_t)(connected_uis, channel_id)) { api_set_error(error, Exception, _("UI is not attached for channel")); @@ -88,21 +110,6 @@ Object remote_ui_detach(uint64_t channel_id, uint64_t request_id, Array args, return NIL; } -void remote_ui_disconnect(uint64_t channel_id) -{ - UI *ui = pmap_get(uint64_t)(connected_uis, channel_id); - if (!ui) { - return; - } - UIData *data = ui->data; - // destroy pending screen updates - api_free_array(data->buffer); - pmap_del(uint64_t)(connected_uis, channel_id); - free(ui->data); - ui_detach(ui); - free(ui); -} - static void push_call(UI *ui, char *name, Array args) { Array call = ARRAY_DICT_INIT; |