diff options
| author | Omar Sandoval <osandov@osandov.com> | 2015-05-17 01:22:46 -0700 | 
|---|---|---|
| committer | Justin M. Keyes <justinkz@gmail.com> | 2015-07-26 23:38:35 -0400 | 
| commit | fa48fc667a1d27db6826075e23caff4f396f191a (patch) | |
| tree | 89048cb803717bbb43b653df2e3c23a164f1741f /src/nvim/msgpack_rpc/remote_ui.c | |
| parent | 61e4a320658ffd64103795cf9aeb9a53c1ac2032 (diff) | |
| download | rneovim-fa48fc667a1d27db6826075e23caff4f396f191a.tar.gz rneovim-fa48fc667a1d27db6826075e23caff4f396f191a.tar.bz2 rneovim-fa48fc667a1d27db6826075e23caff4f396f191a.zip  | |
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.
Diffstat (limited to 'src/nvim/msgpack_rpc/remote_ui.c')
| -rw-r--r-- | src/nvim/msgpack_rpc/remote_ui.c | 19 | 
1 files changed, 9 insertions, 10 deletions
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,  | 
