aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-01-20 01:20:34 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-01-20 15:48:41 +0100
commitef753a76b95425e22638005f813cb2f22c6a0cfc (patch)
tree5e821b6e06848aa123931c191978833bd3a7e0d2 /src
parent8684fdda3b831c3ee75c65f70e6c088762b0b63e (diff)
downloadrneovim-ef753a76b95425e22638005f813cb2f22c6a0cfc.tar.gz
rneovim-ef753a76b95425e22638005f813cb2f22c6a0cfc.tar.bz2
rneovim-ef753a76b95425e22638005f813cb2f22c6a0cfc.zip
tui: Enable mode-sensitive cursor by default.
Also give NVIM_TUI_ENABLE_CURSOR_SHAPE more granularity: 0 = do not change cursor shape 1 = non-blinking ("steady") cursor with mode-sensitive shape 2 = blinking cursor with mode-sensitive shape Note: blink state is not changed for Konsole, instead user's terminal preference makes the decision. (Can't do that for xterm-likes, DECSCUSR forces us to choose blink-state.) This is a temporary step until the TUI respects 'guicursor' Ref: https://github.com/neovim/neovim/issues/2583#issuecomment-272988384
Diffstat (limited to 'src')
-rw-r--r--src/nvim/tui/tui.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index cb9f0a9635..342c68818d 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -877,9 +877,11 @@ static void fix_terminfo(TUIData *data)
unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB);
}
- if (os_getenv("NVIM_TUI_ENABLE_CURSOR_SHAPE") == NULL) {
+ const char * env_cusr_shape = os_getenv("NVIM_TUI_ENABLE_CURSOR_SHAPE");
+ if (env_cusr_shape && strncmp(env_cusr_shape, "0", 1) == 0) {
goto end;
}
+ bool cusr_blink = env_cusr_shape && strncmp(env_cusr_shape, "2", 1) == 0;
#define TMUX_WRAP(seq) (inside_tmux ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq)
// Support changing cursor shape on some popular terminals.
@@ -891,22 +893,22 @@ static void fix_terminfo(TUIData *data)
// Konsole uses a proprietary escape code to set the cursor shape
// and does not support DECSCUSR.
data->unibi_ext.set_cursor_shape_bar = (int)unibi_add_ext_str(ut, NULL,
- TMUX_WRAP("\x1b]50;CursorShape=1;BlinkingCursorEnabled=1\x07"));
+ TMUX_WRAP("\x1b]50;CursorShape=1\x07"));
data->unibi_ext.set_cursor_shape_ul = (int)unibi_add_ext_str(ut, NULL,
- TMUX_WRAP("\x1b]50;CursorShape=2;BlinkingCursorEnabled=1\x07"));
+ TMUX_WRAP("\x1b]50;CursorShape=2\x07"));
data->unibi_ext.set_cursor_shape_block = (int)unibi_add_ext_str(ut, NULL,
- TMUX_WRAP("\x1b]50;CursorShape=0;BlinkingCursorEnabled=0\x07"));
+ TMUX_WRAP("\x1b]50;CursorShape=0\x07"));
} else if (!vte_version || atoi(vte_version) >= 3900) {
// Assume that the terminal supports DECSCUSR unless it is an
// old VTE based terminal. This should not get wrapped for tmux,
// which will handle it via its Ss/Se terminfo extension - usually
// according to its terminal-overrides.
data->unibi_ext.set_cursor_shape_bar =
- (int)unibi_add_ext_str(ut, NULL, "\x1b[5 q");
+ (int)unibi_add_ext_str(ut, NULL, cusr_blink ? "\x1b[5 q" : "\x1b[6 q");
data->unibi_ext.set_cursor_shape_ul =
- (int)unibi_add_ext_str(ut, NULL, "\x1b[3 q");
+ (int)unibi_add_ext_str(ut, NULL, cusr_blink ? "\x1b[3 q" : "\x1b[4 q");
data->unibi_ext.set_cursor_shape_block =
- (int)unibi_add_ext_str(ut, NULL, "\x1b[2 q");
+ (int)unibi_add_ext_str(ut, NULL, cusr_blink ? "\x1b[1 q" : "\x1b[2 q");
}
end: