mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 02:46:31 +00:00
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.
This commit is contained in:

committed by
Justin M. Keyes

parent
61e4a32065
commit
fa48fc667a
@@ -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,
|
||||
|
Reference in New Issue
Block a user