aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-04-01 22:32:16 +0200
committerJustin M. Keyes <justinkz@gmail.com>2017-04-01 23:29:10 +0200
commit3a69dbfca6642463ca8e19f814f71791f66332f3 (patch)
treef78118b0537e3965859bd6449d306c0f3ab88277
parentc2826a7830ddba66261afdf45fcf4d0043506342 (diff)
downloadrneovim-3a69dbfca6642463ca8e19f814f71791f66332f3.tar.gz
rneovim-3a69dbfca6642463ca8e19f814f71791f66332f3.tar.bz2
rneovim-3a69dbfca6642463ca8e19f814f71791f66332f3.zip
api/cursor_style_set: mode descriptions
-rw-r--r--src/nvim/cursor_shape.c44
-rw-r--r--src/nvim/cursor_shape.h4
-rw-r--r--src/nvim/tui/tui.c4
-rw-r--r--test/functional/ui/cursor_spec.lua62
-rw-r--r--test/functional/ui/screen.lua4
5 files changed, 55 insertions, 63 deletions
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c
index c78bcbc29d..7ec70bb724 100644
--- a/src/nvim/cursor_shape.c
+++ b/src/nvim/cursor_shape.c
@@ -13,35 +13,25 @@
/// Handling of cursor and mouse pointer shapes in various modes.
static cursorentry_T shape_table[SHAPE_IDX_COUNT] =
{
- // The values will be filled in from the 'guicursor' and 'mouseshape'
- // defaults when Vim starts.
- // Adjust the SHAPE_IDX_ defines when making changes!
- { "normal",
- 0, 0, 0, 700L, 400L, 250L, 0, 0, "n", SHAPE_CURSOR+SHAPE_MOUSE },
- { "visual",
- 0, 0, 0, 700L, 400L, 250L, 0, 0, "v", SHAPE_CURSOR+SHAPE_MOUSE },
- { "insert",
- 0, 0, 0, 700L, 400L, 250L, 0, 0, "i", SHAPE_CURSOR+SHAPE_MOUSE },
- { "replace",
- 0, 0, 0, 700L, 400L, 250L, 0, 0, "r", SHAPE_CURSOR+SHAPE_MOUSE },
- { "cmd_normal",
- 0, 0, 0, 700L, 400L, 250L, 0, 0, "c", SHAPE_CURSOR+SHAPE_MOUSE },
- { "cmd_insert", 0,
- 0, 0, 700L, 400L, 250L, 0, 0, "ci", SHAPE_CURSOR+SHAPE_MOUSE },
- { "cmd_replace",
- 0, 0, 0, 700L, 400L, 250L, 0, 0, "cr", SHAPE_CURSOR+SHAPE_MOUSE },
- { "pending",
- 0, 0, 0, 700L, 400L, 250L, 0, 0, "o", SHAPE_CURSOR+SHAPE_MOUSE },
- { "visual_select",
- 0, 0, 0, 700L, 400L, 250L, 0, 0, "ve", SHAPE_CURSOR+SHAPE_MOUSE },
- { "cmd_line", 0, 0, 0, 0L, 0L, 0L, 0, 0, "e", SHAPE_MOUSE },
- { "statusline", 0, 0, 0, 0L, 0L, 0L, 0, 0, "s", SHAPE_MOUSE },
- { "drag_statusline", 0, 0, 0, 0L, 0L, 0L, 0, 0, "sd", SHAPE_MOUSE },
- { "vsep", 0, 0, 0, 0L, 0L, 0L, 0, 0, "vs", SHAPE_MOUSE },
- { "vdrag", 0, 0, 0, 0L, 0L, 0L, 0, 0, "vd", SHAPE_MOUSE },
+ // Values are set by 'guicursor' and 'mouseshape'.
+ // Adjust the SHAPE_IDX_ defines when changing this!
+ { "normal", 0, 0, 0, 700L, 400L, 250L, 0, 0, "n", SHAPE_CURSOR+SHAPE_MOUSE },
+ { "visual", 0, 0, 0, 700L, 400L, 250L, 0, 0, "v", SHAPE_CURSOR+SHAPE_MOUSE },
+ { "insert", 0, 0, 0, 700L, 400L, 250L, 0, 0, "i", SHAPE_CURSOR+SHAPE_MOUSE },
+ { "replace", 0, 0, 0, 700L, 400L, 250L, 0, 0, "r", SHAPE_CURSOR+SHAPE_MOUSE },
+ { "cmdline_normal", 0, 0, 0, 700L, 400L, 250L, 0, 0, "c", SHAPE_CURSOR+SHAPE_MOUSE },
+ { "cmdline_insert", 0, 0, 0, 700L, 400L, 250L, 0, 0, "ci", SHAPE_CURSOR+SHAPE_MOUSE },
+ { "cmdline_replace", 0, 0, 0, 700L, 400L, 250L, 0, 0, "cr", SHAPE_CURSOR+SHAPE_MOUSE },
+ { "operator", 0, 0, 0, 700L, 400L, 250L, 0, 0, "o", SHAPE_CURSOR+SHAPE_MOUSE },
+ { "visual_select", 0, 0, 0, 700L, 400L, 250L, 0, 0, "ve", SHAPE_CURSOR+SHAPE_MOUSE },
+ { "cmdline_hover", 0, 0, 0, 0L, 0L, 0L, 0, 0, "e", SHAPE_MOUSE },
+ { "statusline_hover", 0, 0, 0, 0L, 0L, 0L, 0, 0, "s", SHAPE_MOUSE },
+ { "statusline_drag", 0, 0, 0, 0L, 0L, 0L, 0, 0, "sd", SHAPE_MOUSE },
+ { "vsep_hover", 0, 0, 0, 0L, 0L, 0L, 0, 0, "vs", SHAPE_MOUSE },
+ { "vsep_drag", 0, 0, 0, 0L, 0L, 0L, 0, 0, "vd", SHAPE_MOUSE },
{ "more", 0, 0, 0, 0L, 0L, 0L, 0, 0, "m", SHAPE_MOUSE },
{ "more_lastline", 0, 0, 0, 0L, 0L, 0L, 0, 0, "ml", SHAPE_MOUSE },
- { "match_paren", 0, 0, 0, 100L, 100L, 100L, 0, 0, "sm", SHAPE_CURSOR },
+ { "showmatch", 0, 0, 0, 100L, 100L, 100L, 0, 0, "sm", SHAPE_CURSOR },
};
/// Converts cursor_shapes into a Dictionary of dictionaries
diff --git a/src/nvim/cursor_shape.h b/src/nvim/cursor_shape.h
index 14ace2a861..0006ede31d 100644
--- a/src/nvim/cursor_shape.h
+++ b/src/nvim/cursor_shape.h
@@ -14,9 +14,9 @@ SHAPE_IDX_CR = 6, ///< Command line Replace mode
SHAPE_IDX_O = 7, ///< Operator-pending mode
SHAPE_IDX_VE = 8, ///< Visual mode with 'selection' exclusive
SHAPE_IDX_CLINE = 9, ///< On command line
-SHAPE_IDX_STATUS = 10, ///< status line
+SHAPE_IDX_STATUS = 10, ///< On status line
SHAPE_IDX_SDRAG = 11, ///< dragging a status line
-SHAPE_IDX_VSEP = 12, ///< A vertical separator line
+SHAPE_IDX_VSEP = 12, ///< On vertical separator line
SHAPE_IDX_VDRAG = 13, ///< dragging a vertical separator line
SHAPE_IDX_MORE = 14, ///< Hit-return or More
SHAPE_IDX_MOREL = 15, ///< Hit-return or More in last line
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index e1fec0f678..badc0cd870 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -487,7 +487,7 @@ static void tui_cursor_style_set(UI *ui, Dictionary args)
data->cursor_shapes[mode_id] = r;
}
- // force redrawal
+ // force redraw
MouseMode cursor_mode = tui_mode2cursor(data->showing_mode);
tui_set_cursor(ui, cursor_mode);
}
@@ -550,7 +550,7 @@ static void tui_set_cursor(UI *ui, MouseMode mode)
default: WLOG("Unknown shape value %d", shape); break;
}
data->params[0].i = shape;
- data->params[1].i = (c.blinkon ==0);
+ data->params[1].i = (c.blinkon == 0);
unibi_format(vars, vars + 26,
TMUX_WRAP("\x1b]50;CursorShape=%p1%d;BlinkingCursorEnabled=%p2%d\x07"),
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index 6f5fd244d5..8b42c193ab 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -5,8 +5,6 @@ local insert, execute = helpers.insert, helpers.execute
local eq, funcs = helpers.eq, helpers.funcs
local command = helpers.command
-if helpers.pending_win32(pending) then return end
-
describe('ui/cursor', function()
local screen
@@ -24,7 +22,10 @@ describe('ui/cursor', function()
command('redraw')
screen:expect('', nil, nil, nil, true) -- Tickle the event-loop.
local expected_cursor_style = {
- cmd_insert = {
+ cmdline_hover = {
+ mouse_shape = 0,
+ short_name = 'e' },
+ cmdline_insert = {
blinkoff = 250,
blinkon = 400,
blinkwait = 700,
@@ -34,10 +35,7 @@ describe('ui/cursor', function()
id_lm = 46,
mouse_shape = 0,
short_name = 'ci' },
- cmd_line = {
- mouse_shape = 0,
- short_name = 'e' },
- cmd_normal = {
+ cmdline_normal = {
blinkoff = 250,
blinkon = 400,
blinkwait = 700,
@@ -47,7 +45,7 @@ describe('ui/cursor', function()
id_lm = 46,
mouse_shape = 0,
short_name = 'c' },
- cmd_replace = {
+ cmdline_replace = {
blinkoff = 250,
blinkon = 400,
blinkwait = 700,
@@ -57,9 +55,6 @@ describe('ui/cursor', function()
id_lm = 46,
mouse_shape = 0,
short_name = 'cr' },
- drag_statusline = {
- mouse_shape = 0,
- short_name = 'sd' },
insert = {
blinkoff = 250,
blinkon = 400,
@@ -70,15 +65,6 @@ describe('ui/cursor', function()
id_lm = 46,
mouse_shape = 0,
short_name = 'i' },
- match_paren = {
- blinkoff = 150,
- blinkon = 175,
- blinkwait = 175,
- cell_percentage = 0,
- cursor_shape = 'block',
- hl_id = 45,
- id_lm = 45,
- short_name = 'sm' },
more = {
mouse_shape = 0,
short_name = 'm' },
@@ -95,7 +81,7 @@ describe('ui/cursor', function()
id_lm = 46,
mouse_shape = 0,
short_name = 'n' },
- pending = {
+ operator = {
blinkoff = 250,
blinkon = 400,
blinkwait = 700,
@@ -115,12 +101,21 @@ describe('ui/cursor', function()
id_lm = 46,
mouse_shape = 0,
short_name = 'r' },
- statusline = {
+ showmatch = {
+ blinkoff = 150,
+ blinkon = 175,
+ blinkwait = 175,
+ cell_percentage = 0,
+ cursor_shape = 'block',
+ hl_id = 45,
+ id_lm = 45,
+ short_name = 'sm' },
+ statusline_drag = {
mouse_shape = 0,
- short_name = 's' },
- vdrag = {
+ short_name = 'sd' },
+ statusline_hover = {
mouse_shape = 0,
- short_name = 'vd' },
+ short_name = 's' },
visual = {
blinkoff = 250,
blinkon = 400,
@@ -141,7 +136,10 @@ describe('ui/cursor', function()
id_lm = 45,
mouse_shape = 0,
short_name = 've' },
- vsep = {
+ vsep_drag = {
+ mouse_shape = 0,
+ short_name = 'vd' },
+ vsep_hover = {
mouse_shape = 0,
short_name = 'vs' }
}
@@ -161,19 +159,23 @@ describe('ui/cursor', function()
screen:expect('', nil, nil, nil, true) -- Tickle the event-loop.
eq('vertical', screen._cursor_style.normal.cursor_shape)
eq('horizontal', screen._cursor_style.visual_select.cursor_shape)
- eq('vertical', screen._cursor_style.pending.cursor_shape)
+ eq('vertical', screen._cursor_style.operator.cursor_shape)
eq('block', screen._cursor_style.insert.cursor_shape)
- eq('vertical', screen._cursor_style.match_paren.cursor_shape)
+ eq('vertical', screen._cursor_style.showmatch.cursor_shape)
+ eq(171, screen._cursor_style.normal.blinkwait)
+ eq(172, screen._cursor_style.normal.blinkoff)
+ eq(173, screen._cursor_style.normal.blinkon)
end)
it("empty 'guicursor' sets cursor_shape=block in all modes", function()
meths.set_option('guicursor', '')
command('redraw')
screen:expect('', nil, nil, nil, true) -- Tickle the event-loop.
- for _, m in ipairs({ 'cmd_insert', 'cmd_normal', 'cmd_replace', 'insert',
- 'match_paren', 'normal', 'replace', 'visual',
+ for _, m in ipairs({ 'cmdline_insert', 'cmdline_normal', 'cmdline_replace', 'insert',
+ 'showmatch', 'normal', 'replace', 'visual',
'visual_select', }) do
eq('block', screen._cursor_style[m].cursor_shape)
+ eq(0, screen._cursor_style[m].blinkon)
end
end)
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index f67a4abd29..3f8173c8e2 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -313,8 +313,8 @@ function Screen:_redraw(updates)
if handler ~= nil then
handler(self, unpack(update[i]))
else
- assert(self._on_event, "Either add an Screen:_handle_XXX method "..
- " or call Screen:set_on_event_handler")
+ assert(self._on_event,
+ "Add Screen:_handle_XXX method or call Screen:set_on_event_handler")
self._on_event(method, update[i])
end
end