aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-04-26 01:43:03 +0200
committerJustin M. Keyes <justinkz@gmail.com>2017-04-30 13:44:31 +0200
commitd349f610ac9010cecb550c33fbab632b4e7946ca (patch)
tree2181dcc1fff40871fc40e7c9f3307ea1323e8d60
parent0df1b6655be5385c9cbb70dca1c042c6447ec50b (diff)
downloadrneovim-d349f610ac9010cecb550c33fbab632b4e7946ca.tar.gz
rneovim-d349f610ac9010cecb550c33fbab632b4e7946ca.tar.bz2
rneovim-d349f610ac9010cecb550c33fbab632b4e7946ca.zip
'guicursor': No color/blink by default
Closes #6577
-rw-r--r--runtime/doc/options.txt36
-rw-r--r--src/nvim/cursor_shape.c6
-rw-r--r--src/nvim/options.lua2
-rw-r--r--src/nvim/tui/tui.c4
-rw-r--r--test/functional/ui/cursor_spec.lua141
5 files changed, 109 insertions, 80 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 93ab956471..d3683f5135 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -2756,23 +2756,24 @@ A jump table for the options with a short description can be found at |Q_op|.
security reasons.
*'guicursor'* *'gcr'* *E545* *E546* *E548* *E549*
-'guicursor' 'gcr' string (default "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")
+'guicursor' 'gcr' string (default "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20")
global
Configures the cursor style for each mode. Works in the GUI and some
- terminals. Unset to disable: >
- :set guicursor=
-<
+ terminals.
+
With tmux you might need this in ~/.tmux.conf (see terminal-overrides
in the tmux(1) manual page): >
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:argument-list,mode-list:argument-list,..
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 is shown and blinkoff is the time that the
cursor is not shown. The times are in msec. When one
- of the numbers is zero, there is no blinking. The
- default is: "blinkwait700-blinkon400-blinkoff250".
- These numbers are used for a missing entry. This
- 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}
+ of the numbers is zero, there is no blinking. E.g.: >
+ :set guicursor=n:blinkon0
+< {group-name}
a highlight group name, that sets the color and font
for the cursor
{group-name}/{group-name}
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c
index dcc680f806..e302d5aa4c 100644
--- a/src/nvim/cursor_shape.c
+++ b/src/nvim/cursor_shape.c
@@ -142,9 +142,9 @@ char_u *parse_shape_opt(int what)
{
// Set the defaults, for the missing parts
shape_table[idx].shape = SHAPE_BLOCK;
- shape_table[idx].blinkwait = 700L;
- shape_table[idx].blinkon = 400L;
- shape_table[idx].blinkoff = 250L;
+ shape_table[idx].blinkwait = 0L;
+ shape_table[idx].blinkon = 0L;
+ shape_table[idx].blinkoff = 0L;
}
}
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index 4e7be63b63..ba7bf5bafb 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -1000,7 +1000,7 @@ return {
deny_duplicates=true,
vi_def=true,
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',
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 5653924154..d07f43f597 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -575,11 +575,11 @@ static void tui_set_mode(UI *ui, ModeShape mode)
switch (shape) {
case SHAPE_BLOCK: shape = 1; break;
- case SHAPE_VER: shape = 5; break;
case SHAPE_HOR: shape = 3; break;
+ case SHAPE_VER: shape = 5; 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",
data->params, out, ui, NULL, NULL);
}
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index abe0e0b1fd..e6036a6b79 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -20,102 +20,102 @@ describe('ui/cursor', function()
it("'guicursor' is published as a UI event", function()
local expected_mode_info = {
[1] = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 0,
cursor_shape = 'block',
name = 'normal',
- hl_id = 46,
- id_lm = 47,
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
short_name = 'n' },
[2] = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 0,
cursor_shape = 'block',
name = 'visual',
- hl_id = 46,
- id_lm = 47,
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
short_name = 'v' },
[3] = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 25,
cursor_shape = 'vertical',
name = 'insert',
- hl_id = 46,
- id_lm = 47,
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
short_name = 'i' },
[4] = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 20,
cursor_shape = 'horizontal',
name = 'replace',
- hl_id = 46,
- id_lm = 47,
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
short_name = 'r' },
[5] = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 0,
cursor_shape = 'block',
name = 'cmdline_normal',
- hl_id = 46,
- id_lm = 47,
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
short_name = 'c' },
[6] = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 25,
cursor_shape = 'vertical',
name = 'cmdline_insert',
- hl_id = 46,
- id_lm = 47,
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
short_name = 'ci' },
[7] = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 20,
cursor_shape = 'horizontal',
name = 'cmdline_replace',
- hl_id = 46,
- id_lm = 47,
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
short_name = 'cr' },
[8] = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
- cell_percentage = 50,
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 20,
cursor_shape = 'horizontal',
name = 'operator',
- hl_id = 46,
- id_lm = 46,
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
short_name = 'o' },
[9] = {
- blinkoff = 250,
- blinkon = 400,
- blinkwait = 700,
- cell_percentage = 35,
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
+ cell_percentage = 25,
cursor_shape = 'vertical',
name = 'visual_select',
- hl_id = 46,
- id_lm = 46,
+ hl_id = 0,
+ id_lm = 0,
mouse_shape = 0,
short_name = 've' },
[10] = {
@@ -147,19 +147,19 @@ describe('ui/cursor', function()
mouse_shape = 0,
short_name = 'ml' },
[17] = {
- blinkoff = 150,
- blinkon = 175,
- blinkwait = 175,
+ blinkoff = 0,
+ blinkon = 0,
+ blinkwait = 0,
cell_percentage = 0,
cursor_shape = 'block',
name = 'showmatch',
- hl_id = 46,
- id_lm = 46,
+ hl_id = 0,
+ id_lm = 0,
short_name = 'sm' },
}
screen:expect(function()
- -- Default 'guicursor' published on startup.
+ -- Default 'guicursor', published on startup.
eq(expected_mode_info, screen._mode_info)
eq(true, screen._cursor_style_enabled)
eq('normal', screen.mode)
@@ -179,20 +179,53 @@ describe('ui/cursor', function()
end)
-- 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()
local named = {}
for _, m in ipairs(screen._mode_info) do
named[m.name] = m
end
eq('vertical', named.normal.cursor_shape)
+ eq(35, named.normal.cell_percentage)
eq('horizontal', named.visual_select.cursor_shape)
+ eq(35, named.visual_select.cell_percentage)
eq('vertical', named.operator.cursor_shape)
+ eq(50, named.operator.cell_percentage)
eq('block', named.insert.cursor_shape)
eq('vertical', named.showmatch.cursor_shape)
+ eq(90, named.cmdline_replace.cell_percentage)
eq(171, named.normal.blinkwait)
eq(172, named.normal.blinkoff)
eq(173, named.normal.blinkon)
+ eq(42, named.showmatch.cell_percentage)
end)
end)