msgpack-rpc: Add remote_ui module

The remote_ui module is an implementation of the UI layer, and it attaches UI
instances that redirect redraw notifications to connected clients.
This commit is contained in:
Thiago de Arruda
2014-12-08 22:31:35 -03:00
parent 86542c6fd0
commit f8c3a14dc3
3 changed files with 305 additions and 0 deletions

View File

@@ -10,6 +10,7 @@
#include "nvim/api/private/helpers.h"
#include "nvim/api/vim.h"
#include "nvim/msgpack_rpc/channel.h"
#include "nvim/msgpack_rpc/remote_ui.h"
#include "nvim/os/event.h"
#include "nvim/os/rstream.h"
#include "nvim/os/rstream_defs.h"
@@ -100,6 +101,17 @@ void channel_init(void)
if (embedded_mode) {
channel_from_stdio();
}
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);
}
}
/// Teardown the module
@@ -645,6 +657,10 @@ static void on_stdio_close(Event e)
static void free_channel(Channel *channel)
{
if (abstract_ui) {
remote_ui_disconnect(channel->id);
}
pmap_del(uint64_t)(channels, channel->id);
msgpack_unpacker_free(channel->unpacker);