TUI: can make the cursor transparent #11519
when setting 'guicursor' highlight blend=100.
This commit is contained in:
parent
486ddb6eb7
commit
65aca4d857
|
@ -149,6 +149,8 @@ Nvim will adjust the shape of the cursor from a block to a line when in insert
|
|||
mode (or as specified by the 'guicursor' option), on terminals that support
|
||||
it. It uses the same |terminfo| extensions that were pioneered by tmux for
|
||||
this: "Ss" and "Se".
|
||||
Similarly, if you set the cursor highlight group with blend=100, Nvim hides
|
||||
the cursor through the "cvvis" and "civis" extensions.
|
||||
|
||||
If your terminfo definition is missing them, then Nvim will decide whether to
|
||||
add them to your terminfo definition, by looking at $TERM and other
|
||||
|
|
|
@ -294,7 +294,8 @@ numerical highlight ids to the actual attributes.
|
|||
`underline`: underlined text. The line has `special` color.
|
||||
`undercurl`: undercurled text. The curl has `special` color.
|
||||
`blend`: Blend level (0-100). Could be used by UIs to support
|
||||
blending floating windows to the background.
|
||||
blending floating windows to the background or to
|
||||
signal a transparent cursor.
|
||||
|
||||
For absent color keys the default color should be used. Don't store
|
||||
the default value in the table, rather a sentinel value, so that
|
||||
|
|
|
@ -100,7 +100,7 @@ typedef struct {
|
|||
bool immediate_wrap_after_last_column;
|
||||
bool bce;
|
||||
bool mouse_enabled;
|
||||
bool busy, is_invisible;
|
||||
bool busy, is_invisible, want_invisible;
|
||||
bool cork, overflow;
|
||||
bool cursor_color_changed;
|
||||
bool is_starting;
|
||||
|
@ -198,6 +198,7 @@ static void terminfo_start(UI *ui)
|
|||
data->default_attr = false;
|
||||
data->can_clear_attr = false;
|
||||
data->is_invisible = true;
|
||||
data->want_invisible = false;
|
||||
data->busy = false;
|
||||
data->cork = false;
|
||||
data->overflow = false;
|
||||
|
@ -1032,7 +1033,11 @@ static void tui_set_mode(UI *ui, ModeShape mode)
|
|||
|
||||
if (c.id != 0 && c.id < (int)kv_size(data->attrs) && ui->rgb) {
|
||||
HlAttrs aep = kv_A(data->attrs, c.id);
|
||||
if (aep.rgb_ae_attr & HL_INVERSE) {
|
||||
|
||||
data->want_invisible = aep.hl_blend == 100;
|
||||
if (data->want_invisible) {
|
||||
unibi_out(ui, unibi_cursor_invisible);
|
||||
} else if (aep.rgb_ae_attr & HL_INVERSE) {
|
||||
// We interpret "inverse" as "default" (no termcode for "inverse"...).
|
||||
// Hopefully the user's default cursor color is inverse.
|
||||
unibi_out_ext(ui, data->unibi_ext.reset_cursor_color);
|
||||
|
@ -1980,10 +1985,12 @@ static void flush_buf(UI *ui)
|
|||
assert(data->is_invisible);
|
||||
// not busy and the cursor is invisible. Write a "cursor normal" command
|
||||
// after writing the buffer.
|
||||
bufp->base = data->norm;
|
||||
bufp->len = UV_BUF_LEN(data->normlen);
|
||||
bufp++;
|
||||
data->is_invisible = data->busy;
|
||||
if (!data->want_invisible) {
|
||||
bufp->base = data->norm;
|
||||
bufp->len = UV_BUF_LEN(data->normlen);
|
||||
bufp++;
|
||||
}
|
||||
data->is_invisible = false;
|
||||
}
|
||||
|
||||
uv_write(&req, STRUCT_CAST(uv_stream_t, &data->output_handle),
|
||||
|
|
|
@ -245,6 +245,25 @@ describe('ui/cursor', function()
|
|||
eq('normal', screen.mode)
|
||||
end)
|
||||
|
||||
-- update the highlight again to hide cursor
|
||||
helpers.command('hi Cursor blend=100')
|
||||
|
||||
for _, m in ipairs(expected_mode_info) do
|
||||
if m.hl_id then
|
||||
m.attr = {background = Screen.colors.Red, blend = 100}
|
||||
end
|
||||
end
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
test |
|
||||
]], condition=function()
|
||||
eq(expected_mode_info, screen._mode_info)
|
||||
end
|
||||
}
|
||||
|
||||
-- Another cursor style.
|
||||
meths.set_option('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173'
|
||||
..',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42')
|
||||
|
|
Loading…
Reference in New Issue