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, feed_command = helpers.insert, helpers.feed_command
local eq, funcs = helpers.eq, helpers.funcs
local command = helpers.command
describe('ui/mouse/input', function()
local screen
before_each(function()
clear()
meths.set_option('mouse', 'a')
meths.set_option('list', true)
-- NB: this is weird, but mostly irrelevant to the test
-- So I didn't bother to change it
command('set listchars=eol:$')
command('setl listchars=nbsp:x')
screen = Screen.new(25, 5)
screen:attach()
screen:set_default_attr_ids({
[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {background = Screen.colors.LightGrey},
[2] = {bold = true},
[3] = {
foreground = Screen.colors.Blue,
background = Screen.colors.LightGrey,
bold = true,
},
[4] = {reverse = true},
[5] = {bold = true, reverse = true},
[6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
[7] = {bold = true, foreground = Screen.colors.SeaGreen4},
})
command("set display-=msgsep")
feed('itesting<cr>mouse<cr>support and selection<esc>')
screen:expect([[
testing |
mouse |
support and selectio^n |
{0:~ }|
|
]])
end)
it('single left click moves cursor', function()
feed('<LeftMouse><2,1>')
screen:expect{grid=[[
testing |
mo^use |
support and selection |
{0:~ }|
|
]], mouse_enabled=true}
feed('<LeftMouse><0,0>')
screen:expect([[
^testing |
mouse |
support and selection |
{0:~ }|
|
]])
end)
it("in external ui works with unset 'mouse'", function()
meths.set_option('mouse', '')
feed('<LeftMouse><2,1>')
screen:expect{grid=[[
testing |
mo^use |
support and selection |
{0:~ }|
|
]], mouse_enabled=false}
feed('<LeftMouse><0,0>')
screen:expect([[
^testing |
mouse |
support and selection |
{0:~ }|
|
]])
end)
it('double left click enters visual mode', function()
feed('<LeftMouse><0,0>')
feed('<LeftRelease><0,0>')
feed('<LeftMouse><0,0>')
feed('<LeftRelease><0,0>')
screen:expect([[
{1:testin}^g |
mouse |
support and selection |
{0:~ }|
{2:-- VISUAL --} |
]])
end)
it('triple left click enters visual line mode', function()
feed('<LeftMouse><0,0>')
feed('<LeftRelease><0,0>')
feed('<LeftMouse><0,0>')
feed('<LeftRelease><0,0>')
feed('<LeftMouse><0,0>')
feed('<LeftRelease><0,0>')
screen:expect([[
^t{1:esting} |
mouse |
|