aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/msgpack_rpc/remote_ui.c
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-12-13 12:58:06 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-01-12 09:47:34 -0300
commit213c3c3e53459a77c77166cda85ba619e7eb2eb1 (patch)
tree517bff1698d6a71b622ed4213a72b67570fcb032 /src/nvim/msgpack_rpc/remote_ui.c
parent9b30abcecbc2492910f0281f596679714d95a88c (diff)
downloadrneovim-213c3c3e53459a77c77166cda85ba619e7eb2eb1.tar.gz
rneovim-213c3c3e53459a77c77166cda85ba619e7eb2eb1.tar.bz2
rneovim-213c3c3e53459a77c77166cda85ba619e7eb2eb1.zip
ui: Fix ui resizing and change some method names
Diffstat (limited to 'src/nvim/msgpack_rpc/remote_ui.c')
-rw-r--r--src/nvim/msgpack_rpc/remote_ui.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c
index e27d4383c0..a0bc573698 100644
--- a/src/nvim/msgpack_rpc/remote_ui.c
+++ b/src/nvim/msgpack_rpc/remote_ui.c
@@ -27,12 +27,15 @@ void remote_ui_init(void)
{
connected_uis = pmap_new(uint64_t)();
// Add handler for "attach_ui"
- String method = cstr_as_string("attach_ui");
+ String method = cstr_as_string("ui_attach");
MsgpackRpcRequestHandler handler = {.fn = remote_ui_attach, .defer = false};
msgpack_rpc_add_method_handler(method, handler);
- method = cstr_as_string("detach_ui");
+ method = cstr_as_string("ui_detach");
handler.fn = remote_ui_detach;
msgpack_rpc_add_method_handler(method, handler);
+ method = cstr_as_string("ui_try_resize");
+ handler.fn = remote_ui_try_resize;
+ msgpack_rpc_add_method_handler(method, handler);
}
void remote_ui_disconnect(uint64_t channel_id)
@@ -95,7 +98,6 @@ static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id,
ui->suspend = remote_ui_suspend;
pmap_put(uint64_t)(connected_uis, channel_id, ui);
ui_attach(ui);
-
return NIL;
}
@@ -110,6 +112,30 @@ static Object remote_ui_detach(uint64_t channel_id, uint64_t request_id,
return NIL;
}
+static Object remote_ui_try_resize(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"));
+ }
+
+ if (args.size != 2 || args.items[0].type != kObjectTypeInteger
+ || args.items[1].type != kObjectTypeInteger
+ || args.items[0].data.integer <= 0 || args.items[1].data.integer <= 0) {
+ api_set_error(error, Validation,
+ _("Arguments must be a pair of positive integers "
+ "representing the remote screen width/height"));
+ return NIL;
+ }
+
+ UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
+ ui->width = (int)args.items[0].data.integer;
+ ui->height = (int)args.items[1].data.integer;
+ ui_refresh();
+ return NIL;
+}
+
+
static void push_call(UI *ui, char *name, Array args)
{
Array call = ARRAY_DICT_INIT;