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/ui.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index dc2bc0898c..2e8fc7a6bb 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -121,7 +121,7 @@ void ui_update_encoding(void) // May update the shape of the cursor. void ui_cursor_shape(void) { - ui_change_mode(); + ui_mode_change(); } void ui_refresh(void) @@ -469,25 +469,18 @@ 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_change_mode(void) +static void ui_mode_change(void) { - static int showing_insert_mode = MAYBE; - + int mode; if (!full_screen) { return; } - - if (State & INSERT) { - if (showing_insert_mode != TRUE) { - UI_CALL(insert_mode); - } - showing_insert_mode = TRUE; - } else { - if (showing_insert_mode != FALSE) { - UI_CALL(normal_mode); - } - showing_insert_mode = FALSE; - } + /* Get a simple UI mode out of State. */ + if (State & INSERT) + mode = INSERT; + else + mode = NORMAL; + UI_CALL(mode_change, mode); conceal_check_cursur_line(); } -- cgit From f79025b9dea8e46afa0f10884a1759744ada5940 Mon Sep 17 00:00:00 2001 From: Omar Sandoval Date: Sun, 17 May 2015 01:39:22 -0700 Subject: tui: Use underline cursor in Replace mode This is a port of my original contribution to Vim, added in 7.4.687 (https://github.com/vim/vim/commit/v7-4-687). The TUI code has been heavily refactored (see esp. 25ceadab37edba13f5afa78d8b4723da03ef35f0), so this required some translation, but the logic is the same. --- src/nvim/ui.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 2e8fc7a6bb..7e155f9b4f 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -476,7 +476,9 @@ static void ui_mode_change(void) return; } /* Get a simple UI mode out of State. */ - if (State & INSERT) + if ((State & REPLACE) == REPLACE) + mode = REPLACE; + else if (State & INSERT) mode = INSERT; else mode = NORMAL; -- cgit