From fa48fc667a1d27db6826075e23caff4f396f191a Mon Sep 17 00:00:00 2001 From: Omar Sandoval Date: Sun, 17 May 2015 01:22:46 -0700 Subject: api: Simplify UI API on mode change Currently, there are two functions in the UI API that are called when the mode changes: insert_mode() and normal_mode(). These can be folded into a single mode_change() entrypoint which can do whatever it wants based on the mode it is passed, limited to INSERT and NORMAL for now. --- src/nvim/msgpack_rpc/remote_ui.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/nvim/msgpack_rpc/remote_ui.c') diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c index 07d78dd9d7..35a76ac901 100644 --- a/src/nvim/msgpack_rpc/remote_ui.c +++ b/src/nvim/msgpack_rpc/remote_ui.c @@ -86,8 +86,7 @@ static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, ui->busy_stop = remote_ui_busy_stop; ui->mouse_on = remote_ui_mouse_on; ui->mouse_off = remote_ui_mouse_off; - ui->insert_mode = remote_ui_insert_mode; - ui->normal_mode = remote_ui_normal_mode; + ui->mode_change = remote_ui_mode_change; ui->set_scroll_region = remote_ui_set_scroll_region; ui->scroll = remote_ui_scroll; ui->highlight_set = remote_ui_highlight_set; @@ -214,16 +213,16 @@ static void remote_ui_mouse_off(UI *ui) push_call(ui, "mouse_off", args); } -static void remote_ui_insert_mode(UI *ui) +static void remote_ui_mode_change(UI *ui, int mode) { Array args = ARRAY_DICT_INIT; - push_call(ui, "insert_mode", args); -} - -static void remote_ui_normal_mode(UI *ui) -{ - Array args = ARRAY_DICT_INIT; - push_call(ui, "normal_mode", args); + if (mode == INSERT) { + ADD(args, STRING_OBJ(cstr_to_string("insert"))); + } else { + assert(mode == NORMAL); + ADD(args, STRING_OBJ(cstr_to_string("normal"))); + } + push_call(ui, "mode_change", args); } static void remote_ui_set_scroll_region(UI *ui, int top, int bot, int left, -- cgit