diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-04-21 19:09:50 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-04-21 19:09:50 +0200 |
commit | 10f119ab87442a9798bdd2d375b167fca5a0c62d (patch) | |
tree | 9db1c7094b4b998fa4090169d3d59b46ad24629a /src/nvim/ui.c | |
parent | f50e03f2e35cf4bee8cedb2c95bf9619f3b57bc2 (diff) | |
parent | 48f0542ad6f923443ab4bba858aae2d9558f8d76 (diff) | |
download | rneovim-10f119ab87442a9798bdd2d375b167fca5a0c62d.tar.gz rneovim-10f119ab87442a9798bdd2d375b167fca5a0c62d.tar.bz2 rneovim-10f119ab87442a9798bdd2d375b167fca5a0c62d.zip |
Merge #6539 'More cursor shape modes'
Diffstat (limited to 'src/nvim/ui.c')
-rw-r--r-- | src/nvim/ui.c | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/src/nvim/ui.c b/src/nvim/ui.c index cfa186987c..69916fa4cd 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -56,6 +56,7 @@ static int current_attr_code = 0; static bool pending_cursor_update = false; static int busy = 0; static int height, width; +static int old_mode_idx = -1; // UI_CALL invokes a function on all registered UI instances. The functions can // have 0-5 arguments (configurable by SELECT_NTH). @@ -153,12 +154,6 @@ void ui_event(char *name, Array args) } } -// May update the shape of the cursor. -void ui_cursor_shape(void) -{ - ui_mode_change(); -} - void ui_refresh(void) { if (!ui_active()) { @@ -183,7 +178,9 @@ void ui_refresh(void) row = col = 0; screen_resize(width, height); pum_set_external(pum_external); - ui_cursor_style_set(); + ui_mode_info_set(); + old_mode_idx = -1; + ui_cursor_shape(); } static void ui_refresh_event(void **argv) @@ -381,12 +378,12 @@ void ui_cursor_goto(int new_row, int new_col) pending_cursor_update = true; } -void ui_cursor_style_set(void) +void ui_mode_info_set(void) { - Dictionary style = cursor_shape_dict(); + Array style = mode_style_array(); bool enabled = (*p_guicursor != NUL); - UI_CALL(cursor_style_set, enabled, style); - api_free_dictionary(style); + UI_CALL(mode_info_set, enabled, style); + api_free_array(style); } void ui_update_menu(void) @@ -544,25 +541,19 @@ static void flush_cursor_update(void) } } -// Notify that the current mode has changed. Can be used to change cursor -// shape, for example. -static void ui_mode_change(void) +/// Check if current mode has changed. +/// May update the shape of the cursor. +void ui_cursor_shape(void) { - int mode; if (!full_screen) { return; } - // Get a simple UI mode out of State. - if ((State & REPLACE) == REPLACE) { - mode = REPLACE; - } else if (State & INSERT) { - mode = INSERT; - } else if (State & CMDLINE) { - mode = CMDLINE; - } else { - mode = NORMAL; + int mode_idx = cursor_get_mode_idx(); + + if (old_mode_idx != mode_idx) { + old_mode_idx = mode_idx; + UI_CALL(mode_change, mode_idx); } - UI_CALL(mode_change, mode); conceal_check_cursur_line(); } |