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
if helpers.pending_win32(pending) then return end
describe('ui/mouse/input', function()
local screen
before_each(function()
clear()
meths.set_option('mouse', 'a')
meths.set_option('listchars', 'eol:$')
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},
})
feed('itesting<cr>mouse<cr>support and selection<esc>')
screen:expect([[
testing |
mouse |
support and selectio^n |
{0:~ }|
|
]])
end)
after_each(function()
screen:detach()
end)
it('single left click moves cursor', function()
feed('<LeftMouse><2,1>')
screen:expect([[
testing |
mo^use |
support and selection |
{0:~ }|
|
]])
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}{3: } |
mouse |
support and selection |
{0:~ }|
{2:-- VISUAL LINE --} |
]])
end)
it('quadruple left click enters visual block 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>')
feed('<LeftMouse><0,0>')
feed('<LeftRelease><0,0>')
screen:expect([[
^testing |
mouse |
support and selection |
{0:~ }|
{2:-- VISUAL BLOCK --} |
]])
end)
describe('tab drag', function()
before_each(function()
screen:set_default_attr_ids( {
[0] = {bold=true, foreground=Screen.colors.Blue},
tab = { background=Screen.colors.LightGrey, underline=true },
sel = { bold=true },
fill = { reverse=true }
})
end)
it('in tabline on filler space moves tab to the end', function()
feed_command('%delete')
insert('this is foo')
feed_command('silent file foo | tabnew | file bar')
insert('this is bar')
screen:expect([[
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
this is ba^r |
{0:~ }|
{0:~ }|
|
]])
feed('<LeftMouse><4,0>')
screen:expect([[
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
this is fo^o |
{0:~ }|
{0:~ }|
|
]])
feed('<LeftDrag><14,0>')
screen:expect([[
{tab: + bar }{sel: + foo }{fill: }{tab:X}|
this is fo^o |
{0:~ }|
{0:~ }|
|
]])
end)
it('in tabline to the left moves tab left', function()
if helpers.skip_fragile(pending,
os.getenv("TRAVIS") and (helpers.os_name() == "osx"
or os.getenv("CLANG_SANITIZER") == "ASAN_UBSAN")) -- #4874
then
return
end
feed_command('%delete')
insert('this is foo')
feed_command('silent file foo | tabnew | file bar')
insert('this is bar')
screen:expect([[
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
this is ba^r |
{0:~ }|
{0:~ }|
|
]])
feed('<LeftMouse><11,0>')
screen:expect([[
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
this is ba^r |
{0:~ }|
{0:~ }|
|
]])
feed('<LeftDrag><6,0>')
screen:expect([[
{sel: + bar }{tab: + foo }{fill: }{tab:X}|
this is ba^r |
{0:~ }|
{0:~ }|
|
]])
end)
it('in tabline to the right moves tab right', function()
feed_command('%delete')
insert('this is foo')
feed_command('silent file foo | tabnew | file bar')
insert('this is bar')
screen:expect([[
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
this is ba^r |
{0:~ }|
{0:~ }|
|
]])
feed('<LeftMouse><4,0>')
screen:expect([[
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
this is fo^o |
{0:~ }|
{0:~ }|
|
]])
feed('<LeftDrag><7,0>')
screen:expect([[
{tab: + bar }{sel: + foo }{fill: }{tab:X}|
this is fo^o |
{0:~ }|
{0:~ }|
|
]])
end)
it('out of tabline under filler space moves tab to the end', function()
feed_command('%delete')
insert('this is foo')
feed_command('silent file foo | tabnew | file bar')
insert('this is bar')
screen:expect([[
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
this is ba^r |
{0:~ }|
{0:~ }|
|
]])
feed('<LeftMouse><4,0>'<
|