mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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. 25ceadab37
),
so this required some translation, but the logic is the same.
This commit is contained in:
parent
fa48fc667a
commit
f79025b9de
@ -218,6 +218,8 @@ static void remote_ui_mode_change(UI *ui, int mode)
|
||||
Array args = ARRAY_DICT_INIT;
|
||||
if (mode == INSERT) {
|
||||
ADD(args, STRING_OBJ(cstr_to_string("insert")));
|
||||
} else if (mode == REPLACE) {
|
||||
ADD(args, STRING_OBJ(cstr_to_string("replace")));
|
||||
} else {
|
||||
assert(mode == NORMAL);
|
||||
ADD(args, STRING_OBJ(cstr_to_string("normal")));
|
||||
|
@ -61,7 +61,7 @@ typedef struct {
|
||||
struct {
|
||||
int enable_mouse, disable_mouse;
|
||||
int enable_bracketed_paste, disable_bracketed_paste;
|
||||
int enter_insert_mode, exit_insert_mode;
|
||||
int enter_insert_mode, enter_replace_mode, exit_insert_mode;
|
||||
int set_rgb_foreground, set_rgb_background;
|
||||
} unibi_ext;
|
||||
} TUIData;
|
||||
@ -105,6 +105,7 @@ UI *tui_start(void)
|
||||
data->unibi_ext.enable_bracketed_paste = -1;
|
||||
data->unibi_ext.disable_bracketed_paste = -1;
|
||||
data->unibi_ext.enter_insert_mode = -1;
|
||||
data->unibi_ext.enter_replace_mode = -1;
|
||||
data->unibi_ext.exit_insert_mode = -1;
|
||||
|
||||
// write output to stderr if stdout is not a tty
|
||||
@ -413,6 +414,10 @@ static void tui_mode_change(UI *ui, int mode)
|
||||
if (data->showing_mode != INSERT) {
|
||||
unibi_out(ui, data->unibi_ext.enter_insert_mode);
|
||||
}
|
||||
} else if (mode == REPLACE) {
|
||||
if (data->showing_mode != REPLACE) {
|
||||
unibi_out(ui, data->unibi_ext.enter_replace_mode);
|
||||
}
|
||||
} else {
|
||||
assert(mode == NORMAL);
|
||||
if (data->showing_mode != NORMAL) {
|
||||
@ -810,12 +815,16 @@ static void fix_terminfo(TUIData *data)
|
||||
// iterm
|
||||
data->unibi_ext.enter_insert_mode = (int)unibi_add_ext_str(ut, NULL,
|
||||
TMUX_WRAP("\x1b]50;CursorShape=1;BlinkingCursorEnabled=1\x07"));
|
||||
data->unibi_ext.enter_replace_mode = (int)unibi_add_ext_str(ut, NULL,
|
||||
TMUX_WRAP("\x1b]50;CursorShape=2;BlinkingCursorEnabled=1\x07"));
|
||||
data->unibi_ext.exit_insert_mode = (int)unibi_add_ext_str(ut, NULL,
|
||||
TMUX_WRAP("\x1b]50;CursorShape=0;BlinkingCursorEnabled=0\x07"));
|
||||
} else {
|
||||
// xterm-like sequences for blinking bar and solid block
|
||||
data->unibi_ext.enter_insert_mode = (int)unibi_add_ext_str(ut, NULL,
|
||||
TMUX_WRAP("\x1b[5 q"));
|
||||
data->unibi_ext.enter_replace_mode = (int)unibi_add_ext_str(ut, NULL,
|
||||
TMUX_WRAP("\x1b[3 q"));
|
||||
data->unibi_ext.exit_insert_mode = (int)unibi_add_ext_str(ut, NULL,
|
||||
TMUX_WRAP("\x1b[2 q"));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -341,7 +341,7 @@ function Screen:_handle_mouse_off()
|
||||
end
|
||||
|
||||
function Screen:_handle_mode_change(mode)
|
||||
assert(mode == 'insert' or mode == 'normal')
|
||||
assert(mode == 'insert' or mode == 'replace' or mode == 'normal')
|
||||
self._mode = mode
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user