mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
parent
0df1b6655b
commit
d349f610ac
@ -2756,23 +2756,24 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
security reasons.
|
security reasons.
|
||||||
|
|
||||||
*'guicursor'* *'gcr'* *E545* *E546* *E548* *E549*
|
*'guicursor'* *'gcr'* *E545* *E546* *E548* *E549*
|
||||||
'guicursor' 'gcr' string (default "n-v-c:block-Cursor/lCursor,
|
'guicursor' 'gcr' string (default "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20")
|
||||||
ve:ver35-Cursor,
|
|
||||||
o:hor50-Cursor,
|
|
||||||
i-ci:ver25-Cursor/lCursor,
|
|
||||||
r-cr:hor20-Cursor/lCursor,
|
|
||||||
sm:block-Cursor
|
|
||||||
-blinkwait175-blinkoff150-blinkon175")
|
|
||||||
global
|
global
|
||||||
Configures the cursor style for each mode. Works in the GUI and some
|
Configures the cursor style for each mode. Works in the GUI and some
|
||||||
terminals. Unset to disable: >
|
terminals.
|
||||||
:set guicursor=
|
|
||||||
<
|
|
||||||
With tmux you might need this in ~/.tmux.conf (see terminal-overrides
|
With tmux you might need this in ~/.tmux.conf (see terminal-overrides
|
||||||
in the tmux(1) manual page): >
|
in the tmux(1) manual page): >
|
||||||
set -ga terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q'
|
set -ga terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q'
|
||||||
<
|
|
||||||
The option is a comma separated list of parts. Each part consists of a
|
< To disable cursor-styling, reset the option: >
|
||||||
|
:set guicursor=
|
||||||
|
|
||||||
|
< To enable mode shapes, "Cursor" highlight, and blinking: >
|
||||||
|
:set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50
|
||||||
|
\,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor
|
||||||
|
\,sm:block-blinkwait175-blinkoff150-blinkon175
|
||||||
|
|
||||||
|
< The option is a comma separated list of parts. Each part consists of a
|
||||||
mode-list and an argument-list:
|
mode-list and an argument-list:
|
||||||
mode-list:argument-list,mode-list:argument-list,..
|
mode-list:argument-list,mode-list:argument-list,..
|
||||||
The mode-list is a dash separated list of these modes:
|
The mode-list is a dash separated list of these modes:
|
||||||
@ -2800,14 +2801,9 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
the cursor starts blinking, blinkon is the time that
|
the cursor starts blinking, blinkon is the time that
|
||||||
the cursor is shown and blinkoff is the time that the
|
the cursor is shown and blinkoff is the time that the
|
||||||
cursor is not shown. The times are in msec. When one
|
cursor is not shown. The times are in msec. When one
|
||||||
of the numbers is zero, there is no blinking. The
|
of the numbers is zero, there is no blinking. E.g.: >
|
||||||
default is: "blinkwait700-blinkon400-blinkoff250".
|
:set guicursor=n:blinkon0
|
||||||
These numbers are used for a missing entry. This
|
< {group-name}
|
||||||
means that blinking is enabled by default. To switch
|
|
||||||
blinking off you can use "blinkon0". The cursor only
|
|
||||||
blinks when Vim is waiting for input, not while
|
|
||||||
executing a command.
|
|
||||||
{group-name}
|
|
||||||
a highlight group name, that sets the color and font
|
a highlight group name, that sets the color and font
|
||||||
for the cursor
|
for the cursor
|
||||||
{group-name}/{group-name}
|
{group-name}/{group-name}
|
||||||
|
@ -142,9 +142,9 @@ char_u *parse_shape_opt(int what)
|
|||||||
{
|
{
|
||||||
// Set the defaults, for the missing parts
|
// Set the defaults, for the missing parts
|
||||||
shape_table[idx].shape = SHAPE_BLOCK;
|
shape_table[idx].shape = SHAPE_BLOCK;
|
||||||
shape_table[idx].blinkwait = 700L;
|
shape_table[idx].blinkwait = 0L;
|
||||||
shape_table[idx].blinkon = 400L;
|
shape_table[idx].blinkon = 0L;
|
||||||
shape_table[idx].blinkoff = 250L;
|
shape_table[idx].blinkoff = 0L;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1000,7 +1000,7 @@ return {
|
|||||||
deny_duplicates=true,
|
deny_duplicates=true,
|
||||||
vi_def=true,
|
vi_def=true,
|
||||||
varname='p_guicursor',
|
varname='p_guicursor',
|
||||||
defaults={if_true={vi="n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175"}}
|
defaults={if_true={vi="n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20"}}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
full_name='guifont', abbreviation='gfn',
|
full_name='guifont', abbreviation='gfn',
|
||||||
|
@ -575,11 +575,11 @@ static void tui_set_mode(UI *ui, ModeShape mode)
|
|||||||
|
|
||||||
switch (shape) {
|
switch (shape) {
|
||||||
case SHAPE_BLOCK: shape = 1; break;
|
case SHAPE_BLOCK: shape = 1; break;
|
||||||
case SHAPE_VER: shape = 5; break;
|
|
||||||
case SHAPE_HOR: shape = 3; break;
|
case SHAPE_HOR: shape = 3; break;
|
||||||
|
case SHAPE_VER: shape = 5; break;
|
||||||
default: WLOG("Unknown shape value %d", shape); break;
|
default: WLOG("Unknown shape value %d", shape); break;
|
||||||
}
|
}
|
||||||
data->params[0].i = shape + (c.blinkon ==0);
|
data->params[0].i = shape + (int)(c.blinkon == 0);
|
||||||
unibi_format(vars, vars + 26, "\x1b[%p1%d q",
|
unibi_format(vars, vars + 26, "\x1b[%p1%d q",
|
||||||
data->params, out, ui, NULL, NULL);
|
data->params, out, ui, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
@ -20,102 +20,102 @@ describe('ui/cursor', function()
|
|||||||
it("'guicursor' is published as a UI event", function()
|
it("'guicursor' is published as a UI event", function()
|
||||||
local expected_mode_info = {
|
local expected_mode_info = {
|
||||||
[1] = {
|
[1] = {
|
||||||
blinkoff = 250,
|
blinkoff = 0,
|
||||||
blinkon = 400,
|
blinkon = 0,
|
||||||
blinkwait = 700,
|
blinkwait = 0,
|
||||||
cell_percentage = 0,
|
cell_percentage = 0,
|
||||||
cursor_shape = 'block',
|
cursor_shape = 'block',
|
||||||
name = 'normal',
|
name = 'normal',
|
||||||
hl_id = 46,
|
hl_id = 0,
|
||||||
id_lm = 47,
|
id_lm = 0,
|
||||||
mouse_shape = 0,
|
mouse_shape = 0,
|
||||||
short_name = 'n' },
|
short_name = 'n' },
|
||||||
[2] = {
|
[2] = {
|
||||||
blinkoff = 250,
|
blinkoff = 0,
|
||||||
blinkon = 400,
|
blinkon = 0,
|
||||||
blinkwait = 700,
|
blinkwait = 0,
|
||||||
cell_percentage = 0,
|
cell_percentage = 0,
|
||||||
cursor_shape = 'block',
|
cursor_shape = 'block',
|
||||||
name = 'visual',
|
name = 'visual',
|
||||||
hl_id = 46,
|
hl_id = 0,
|
||||||
id_lm = 47,
|
id_lm = 0,
|
||||||
mouse_shape = 0,
|
mouse_shape = 0,
|
||||||
short_name = 'v' },
|
short_name = 'v' },
|
||||||
[3] = {
|
[3] = {
|
||||||
blinkoff = 250,
|
blinkoff = 0,
|
||||||
blinkon = 400,
|
blinkon = 0,
|
||||||
blinkwait = 700,
|
blinkwait = 0,
|
||||||
cell_percentage = 25,
|
cell_percentage = 25,
|
||||||
cursor_shape = 'vertical',
|
cursor_shape = 'vertical',
|
||||||
name = 'insert',
|
name = 'insert',
|
||||||
hl_id = 46,
|
hl_id = 0,
|
||||||
id_lm = 47,
|
id_lm = 0,
|
||||||
mouse_shape = 0,
|
mouse_shape = 0,
|
||||||
short_name = 'i' },
|
short_name = 'i' },
|
||||||
[4] = {
|
[4] = {
|
||||||
blinkoff = 250,
|
blinkoff = 0,
|
||||||
blinkon = 400,
|
blinkon = 0,
|
||||||
blinkwait = 700,
|
blinkwait = 0,
|
||||||
cell_percentage = 20,
|
cell_percentage = 20,
|
||||||
cursor_shape = 'horizontal',
|
cursor_shape = 'horizontal',
|
||||||
name = 'replace',
|
name = 'replace',
|
||||||
hl_id = 46,
|
hl_id = 0,
|
||||||
id_lm = 47,
|
id_lm = 0,
|
||||||
mouse_shape = 0,
|
mouse_shape = 0,
|
||||||
short_name = 'r' },
|
short_name = 'r' },
|
||||||
[5] = {
|
[5] = {
|
||||||
blinkoff = 250,
|
blinkoff = 0,
|
||||||
blinkon = 400,
|
blinkon = 0,
|
||||||
blinkwait = 700,
|
blinkwait = 0,
|
||||||
cell_percentage = 0,
|
cell_percentage = 0,
|
||||||
cursor_shape = 'block',
|
cursor_shape = 'block',
|
||||||
name = 'cmdline_normal',
|
name = 'cmdline_normal',
|
||||||
hl_id = 46,
|
hl_id = 0,
|
||||||
id_lm = 47,
|
id_lm = 0,
|
||||||
mouse_shape = 0,
|
mouse_shape = 0,
|
||||||
short_name = 'c' },
|
short_name = 'c' },
|
||||||
[6] = {
|
[6] = {
|
||||||
blinkoff = 250,
|
blinkoff = 0,
|
||||||
blinkon = 400,
|
blinkon = 0,
|
||||||
blinkwait = 700,
|
blinkwait = 0,
|
||||||
cell_percentage = 25,
|
cell_percentage = 25,
|
||||||
cursor_shape = 'vertical',
|
cursor_shape = 'vertical',
|
||||||
name = 'cmdline_insert',
|
name = 'cmdline_insert',
|
||||||
hl_id = 46,
|
hl_id = 0,
|
||||||
id_lm = 47,
|
id_lm = 0,
|
||||||
mouse_shape = 0,
|
mouse_shape = 0,
|
||||||
short_name = 'ci' },
|
short_name = 'ci' },
|
||||||
[7] = {
|
[7] = {
|
||||||
blinkoff = 250,
|
blinkoff = 0,
|
||||||
blinkon = 400,
|
blinkon = 0,
|
||||||
blinkwait = 700,
|
blinkwait = 0,
|
||||||
cell_percentage = 20,
|
cell_percentage = 20,
|
||||||
cursor_shape = 'horizontal',
|
cursor_shape = 'horizontal',
|
||||||
name = 'cmdline_replace',
|
name = 'cmdline_replace',
|
||||||
hl_id = 46,
|
hl_id = 0,
|
||||||
id_lm = 47,
|
id_lm = 0,
|
||||||
mouse_shape = 0,
|
mouse_shape = 0,
|
||||||
short_name = 'cr' },
|
short_name = 'cr' },
|
||||||
[8] = {
|
[8] = {
|
||||||
blinkoff = 250,
|
blinkoff = 0,
|
||||||
blinkon = 400,
|
blinkon = 0,
|
||||||
blinkwait = 700,
|
blinkwait = 0,
|
||||||
cell_percentage = 50,
|
cell_percentage = 20,
|
||||||
cursor_shape = 'horizontal',
|
cursor_shape = 'horizontal',
|
||||||
name = 'operator',
|
name = 'operator',
|
||||||
hl_id = 46,
|
hl_id = 0,
|
||||||
id_lm = 46,
|
id_lm = 0,
|
||||||
mouse_shape = 0,
|
mouse_shape = 0,
|
||||||
short_name = 'o' },
|
short_name = 'o' },
|
||||||
[9] = {
|
[9] = {
|
||||||
blinkoff = 250,
|
blinkoff = 0,
|
||||||
blinkon = 400,
|
blinkon = 0,
|
||||||
blinkwait = 700,
|
blinkwait = 0,
|
||||||
cell_percentage = 35,
|
cell_percentage = 25,
|
||||||
cursor_shape = 'vertical',
|
cursor_shape = 'vertical',
|
||||||
name = 'visual_select',
|
name = 'visual_select',
|
||||||
hl_id = 46,
|
hl_id = 0,
|
||||||
id_lm = 46,
|
id_lm = 0,
|
||||||
mouse_shape = 0,
|
mouse_shape = 0,
|
||||||
short_name = 've' },
|
short_name = 've' },
|
||||||
[10] = {
|
[10] = {
|
||||||
@ -147,19 +147,19 @@ describe('ui/cursor', function()
|
|||||||
mouse_shape = 0,
|
mouse_shape = 0,
|
||||||
short_name = 'ml' },
|
short_name = 'ml' },
|
||||||
[17] = {
|
[17] = {
|
||||||
blinkoff = 150,
|
blinkoff = 0,
|
||||||
blinkon = 175,
|
blinkon = 0,
|
||||||
blinkwait = 175,
|
blinkwait = 0,
|
||||||
cell_percentage = 0,
|
cell_percentage = 0,
|
||||||
cursor_shape = 'block',
|
cursor_shape = 'block',
|
||||||
name = 'showmatch',
|
name = 'showmatch',
|
||||||
hl_id = 46,
|
hl_id = 0,
|
||||||
id_lm = 46,
|
id_lm = 0,
|
||||||
short_name = 'sm' },
|
short_name = 'sm' },
|
||||||
}
|
}
|
||||||
|
|
||||||
screen:expect(function()
|
screen:expect(function()
|
||||||
-- Default 'guicursor' published on startup.
|
-- Default 'guicursor', published on startup.
|
||||||
eq(expected_mode_info, screen._mode_info)
|
eq(expected_mode_info, screen._mode_info)
|
||||||
eq(true, screen._cursor_style_enabled)
|
eq(true, screen._cursor_style_enabled)
|
||||||
eq('normal', screen.mode)
|
eq('normal', screen.mode)
|
||||||
@ -179,20 +179,53 @@ describe('ui/cursor', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
-- Change the cursor style.
|
-- Change the 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')
|
helpers.command('set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr-o:hor20'
|
||||||
|
..',a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor'
|
||||||
|
..',sm:block-blinkwait175-blinkoff150-blinkon175')
|
||||||
|
|
||||||
|
-- Update the expected values.
|
||||||
|
for _, m in ipairs(expected_mode_info) do
|
||||||
|
if m.name == 'showmatch' then
|
||||||
|
if m.blinkon then m.blinkon = 175 end
|
||||||
|
if m.blinkoff then m.blinkoff = 150 end
|
||||||
|
if m.blinkwait then m.blinkwait = 175 end
|
||||||
|
else
|
||||||
|
if m.blinkon then m.blinkon = 250 end
|
||||||
|
if m.blinkoff then m.blinkoff = 400 end
|
||||||
|
if m.blinkwait then m.blinkwait = 700 end
|
||||||
|
end
|
||||||
|
if m.hl_id then m.hl_id = 46 end
|
||||||
|
if m.id_lm then m.id_lm = 47 end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Assert the new expectation.
|
||||||
|
screen:expect(function()
|
||||||
|
eq(expected_mode_info, screen._mode_info)
|
||||||
|
eq(true, screen._cursor_style_enabled)
|
||||||
|
eq('normal', screen.mode)
|
||||||
|
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')
|
||||||
screen:expect(function()
|
screen:expect(function()
|
||||||
local named = {}
|
local named = {}
|
||||||
for _, m in ipairs(screen._mode_info) do
|
for _, m in ipairs(screen._mode_info) do
|
||||||
named[m.name] = m
|
named[m.name] = m
|
||||||
end
|
end
|
||||||
eq('vertical', named.normal.cursor_shape)
|
eq('vertical', named.normal.cursor_shape)
|
||||||
|
eq(35, named.normal.cell_percentage)
|
||||||
eq('horizontal', named.visual_select.cursor_shape)
|
eq('horizontal', named.visual_select.cursor_shape)
|
||||||
|
eq(35, named.visual_select.cell_percentage)
|
||||||
eq('vertical', named.operator.cursor_shape)
|
eq('vertical', named.operator.cursor_shape)
|
||||||
|
eq(50, named.operator.cell_percentage)
|
||||||
eq('block', named.insert.cursor_shape)
|
eq('block', named.insert.cursor_shape)
|
||||||
eq('vertical', named.showmatch.cursor_shape)
|
eq('vertical', named.showmatch.cursor_shape)
|
||||||
|
eq(90, named.cmdline_replace.cell_percentage)
|
||||||
eq(171, named.normal.blinkwait)
|
eq(171, named.normal.blinkwait)
|
||||||
eq(172, named.normal.blinkoff)
|
eq(172, named.normal.blinkoff)
|
||||||
eq(173, named.normal.blinkon)
|
eq(173, named.normal.blinkon)
|
||||||
|
eq(42, named.showmatch.cell_percentage)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user