From c2826a7830ddba66261afdf45fcf4d0043506342 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 1 Apr 2017 13:08:42 +0200 Subject: 'guicursor': Empty means "block cursor in all modes". Also: update default 'guicursor' to match the documentation. --- test/functional/ui/cursor_spec.lua | 180 +++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 test/functional/ui/cursor_spec.lua (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua new file mode 100644 index 0000000000..6f5fd244d5 --- /dev/null +++ b/test/functional/ui/cursor_spec.lua @@ -0,0 +1,180 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths +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 + + before_each(function() + clear() + screen = Screen.new(25, 5) + screen:attach() + end) + + after_each(function() + screen:detach() + end) + + it("'guicursor' is published as a UI event", function() + command('redraw') + screen:expect('', nil, nil, nil, true) -- Tickle the event-loop. + local expected_cursor_style = { + cmd_insert = { + blinkoff = 250, + blinkon = 400, + blinkwait = 700, + cell_percentage = 25, + cursor_shape = 'vertical', + hl_id = 45, + id_lm = 46, + mouse_shape = 0, + short_name = 'ci' }, + cmd_line = { + mouse_shape = 0, + short_name = 'e' }, + cmd_normal = { + blinkoff = 250, + blinkon = 400, + blinkwait = 700, + cell_percentage = 0, + cursor_shape = 'block', + hl_id = 45, + id_lm = 46, + mouse_shape = 0, + short_name = 'c' }, + cmd_replace = { + blinkoff = 250, + blinkon = 400, + blinkwait = 700, + cell_percentage = 20, + cursor_shape = 'horizontal', + hl_id = 45, + id_lm = 46, + mouse_shape = 0, + short_name = 'cr' }, + drag_statusline = { + mouse_shape = 0, + short_name = 'sd' }, + insert = { + blinkoff = 250, + blinkon = 400, + blinkwait = 700, + cell_percentage = 25, + cursor_shape = 'vertical', + hl_id = 45, + 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' }, + more_lastline = { + mouse_shape = 0, + short_name = 'ml' }, + normal = { + blinkoff = 250, + blinkon = 400, + blinkwait = 700, + cell_percentage = 0, + cursor_shape = 'block', + hl_id = 45, + id_lm = 46, + mouse_shape = 0, + short_name = 'n' }, + pending = { + blinkoff = 250, + blinkon = 400, + blinkwait = 700, + cell_percentage = 50, + cursor_shape = 'horizontal', + hl_id = 45, + id_lm = 45, + mouse_shape = 0, + short_name = 'o' }, + replace = { + blinkoff = 250, + blinkon = 400, + blinkwait = 700, + cell_percentage = 20, + cursor_shape = 'horizontal', + hl_id = 45, + id_lm = 46, + mouse_shape = 0, + short_name = 'r' }, + statusline = { + mouse_shape = 0, + short_name = 's' }, + vdrag = { + mouse_shape = 0, + short_name = 'vd' }, + visual = { + blinkoff = 250, + blinkon = 400, + blinkwait = 700, + cell_percentage = 0, + cursor_shape = 'block', + hl_id = 45, + id_lm = 46, + mouse_shape = 0, + short_name = 'v' }, + visual_select = { + blinkoff = 250, + blinkon = 400, + blinkwait = 700, + cell_percentage = 35, + cursor_shape = 'vertical', + hl_id = 45, + id_lm = 45, + mouse_shape = 0, + short_name = 've' }, + vsep = { + mouse_shape = 0, + short_name = 'vs' } + } + -- Default 'guicursor' published on startup. + eq(expected_cursor_style, screen._cursor_style) + eq('normal', screen.mode) + + -- Event is published ONLY if the cursor style changed. + screen._cursor_style = nil + command('redraw') + screen:expect('', nil, nil, nil, true) -- Tickle the event-loop. + eq(nil, screen._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') + command('redraw') + 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('block', screen._cursor_style.insert.cursor_shape) + eq('vertical', screen._cursor_style.match_paren.cursor_shape) + 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', + 'visual_select', }) do + eq('block', screen._cursor_style[m].cursor_shape) + end + end) + +end) -- cgit From 3a69dbfca6642463ca8e19f814f71791f66332f3 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 1 Apr 2017 22:32:16 +0200 Subject: api/cursor_style_set: mode descriptions --- test/functional/ui/cursor_spec.lua | 62 ++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 30 deletions(-) (limited to 'test/functional/ui/cursor_spec.lua') 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) -- cgit From dc75766081e143401ae28bea66f970ab005402fc Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 3 Apr 2017 03:07:01 +0300 Subject: tests: Fix testlint errors --- test/functional/ui/cursor_spec.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 8b42c193ab..56f02e4e7f 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -1,8 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths -local insert, execute = helpers.insert, helpers.execute -local eq, funcs = helpers.eq, helpers.funcs +local clear, meths = helpers.clear, helpers.meths +local eq = helpers.eq local command = helpers.command describe('ui/cursor', function() -- cgit From bc6d868d00a739050b683f33994f7493cf81bd61 Mon Sep 17 00:00:00 2001 From: Yichao Zhou Date: Sun, 26 Mar 2017 03:15:52 -0700 Subject: 'listchars': `Whitespace` highlight group #6367 --- test/functional/ui/cursor_spec.lua | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 56f02e4e7f..1e3a9fcb60 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -30,8 +30,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 25, cursor_shape = 'vertical', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'ci' }, cmdline_normal = { @@ -40,8 +40,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 0, cursor_shape = 'block', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'c' }, cmdline_replace = { @@ -50,8 +50,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 20, cursor_shape = 'horizontal', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'cr' }, insert = { @@ -60,8 +60,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 25, cursor_shape = 'vertical', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'i' }, more = { @@ -76,8 +76,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 0, cursor_shape = 'block', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'n' }, operator = { @@ -86,8 +86,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 50, cursor_shape = 'horizontal', - hl_id = 45, - id_lm = 45, + hl_id = 46, + id_lm = 46, mouse_shape = 0, short_name = 'o' }, replace = { @@ -96,8 +96,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 20, cursor_shape = 'horizontal', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'r' }, showmatch = { @@ -106,8 +106,8 @@ describe('ui/cursor', function() blinkwait = 175, cell_percentage = 0, cursor_shape = 'block', - hl_id = 45, - id_lm = 45, + hl_id = 46, + id_lm = 46, short_name = 'sm' }, statusline_drag = { mouse_shape = 0, @@ -121,8 +121,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 0, cursor_shape = 'block', - hl_id = 45, - id_lm = 46, + hl_id = 46, + id_lm = 47, mouse_shape = 0, short_name = 'v' }, visual_select = { @@ -131,8 +131,8 @@ describe('ui/cursor', function() blinkwait = 700, cell_percentage = 35, cursor_shape = 'vertical', - hl_id = 45, - id_lm = 45, + hl_id = 46, + id_lm = 46, mouse_shape = 0, short_name = 've' }, vsep_drag = { -- cgit From 3ccd59ee8216f3da812c5cf81eb392e6a95b539a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 3 Apr 2017 16:16:21 +0200 Subject: 'guicursor': enabled=false if 'guicursor' is empty Closes #6429 Closes #6430 --- test/functional/ui/cursor_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 1e3a9fcb60..c022a5649e 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -144,6 +144,7 @@ describe('ui/cursor', function() } -- Default 'guicursor' published on startup. eq(expected_cursor_style, screen._cursor_style) + eq(true, screen._cursor_style_enabled) eq('normal', screen.mode) -- Event is published ONLY if the cursor style changed. -- cgit From e348e256f3ed93fe462971447ee79033307b2ddf Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 4 Apr 2017 02:37:43 +0200 Subject: 'guicursor': Disable by default for unknown terminals. User can still set guicursor explicitly in init.vim. Closes #5990 Closes #6403 --- test/functional/ui/cursor_spec.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index c022a5649e..3ec3ffd08c 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local clear, meths = helpers.clear, helpers.meths local eq = helpers.eq local command = helpers.command +local wait = helpers.wait describe('ui/cursor', function() local screen @@ -18,7 +19,7 @@ describe('ui/cursor', function() end) it("'guicursor' is published as a UI event", function() - command('redraw') + wait() screen:expect('', nil, nil, nil, true) -- Tickle the event-loop. local expected_cursor_style = { cmdline_hover = { @@ -149,13 +150,13 @@ describe('ui/cursor', function() -- Event is published ONLY if the cursor style changed. screen._cursor_style = nil - command('redraw') + wait() screen:expect('', nil, nil, nil, true) -- Tickle the event-loop. eq(nil, screen._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') - command('redraw') + wait() 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) @@ -171,6 +172,8 @@ describe('ui/cursor', function() meths.set_option('guicursor', '') command('redraw') screen:expect('', nil, nil, nil, true) -- Tickle the event-loop. + -- Empty 'guicursor' sets enabled=false. + eq(false, screen._cursor_style_enabled) for _, m in ipairs({ 'cmdline_insert', 'cmdline_normal', 'cmdline_replace', 'insert', 'showmatch', 'normal', 'replace', 'visual', 'visual_select', }) do -- cgit From 3b558e5d7b8c641896a57c5c4e09d9b8f8535fd5 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 4 Apr 2017 17:47:23 +0200 Subject: tests: short form `screen:except(func)` expects condition only. #6440 - Use this to properly test cursor shape events. - tests: update screen_basic_spec to use `screen:expect` short form. Clearer than using `screen:wait` directy. --- test/functional/ui/cursor_spec.lua | 69 +++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 31 deletions(-) (limited to 'test/functional/ui/cursor_spec.lua') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 3ec3ffd08c..02e9422781 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -3,7 +3,6 @@ local Screen = require('test.functional.ui.screen') local clear, meths = helpers.clear, helpers.meths local eq = helpers.eq local command = helpers.command -local wait = helpers.wait describe('ui/cursor', function() local screen @@ -19,8 +18,6 @@ describe('ui/cursor', function() end) it("'guicursor' is published as a UI event", function() - wait() - screen:expect('', nil, nil, nil, true) -- Tickle the event-loop. local expected_cursor_style = { cmdline_hover = { mouse_shape = 0, @@ -142,44 +139,54 @@ describe('ui/cursor', function() vsep_hover = { mouse_shape = 0, short_name = 'vs' } - } - -- Default 'guicursor' published on startup. - eq(expected_cursor_style, screen._cursor_style) - eq(true, screen._cursor_style_enabled) - eq('normal', screen.mode) + } + + screen:expect(function() + -- Default 'guicursor' published on startup. + eq(expected_cursor_style, screen._cursor_style) + eq(true, screen._cursor_style_enabled) + eq('normal', screen.mode) + end) -- Event is published ONLY if the cursor style changed. screen._cursor_style = nil - wait() - screen:expect('', nil, nil, nil, true) -- Tickle the event-loop. - eq(nil, screen._cursor_style) + command("echo 'test'") + screen:expect([[ + ^ | + ~ | + ~ | + ~ | + test | + ]], nil, nil, function() + eq(nil, screen._cursor_style) + 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') - wait() - 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.operator.cursor_shape) - eq('block', screen._cursor_style.insert.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) + screen:expect(function() + eq('vertical', screen._cursor_style.normal.cursor_shape) + eq('horizontal', screen._cursor_style.visual_select.cursor_shape) + eq('vertical', screen._cursor_style.operator.cursor_shape) + eq('block', screen._cursor_style.insert.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) 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. - -- Empty 'guicursor' sets enabled=false. - eq(false, screen._cursor_style_enabled) - 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 + screen:expect(function() + -- Empty 'guicursor' sets enabled=false. + eq(false, screen._cursor_style_enabled) + 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) end) end) -- cgit