2014-12-09 10:12:12 -07:00
|
|
|
local helpers = require('test.functional.helpers')
|
|
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
local clear, feed, nvim = helpers.clear, helpers.feed, helpers.nvim
|
2015-01-15 05:01:25 -07:00
|
|
|
local insert, execute = helpers.insert, helpers.execute
|
2014-12-09 10:12:12 -07:00
|
|
|
|
|
|
|
describe('Mouse input', function()
|
2015-01-26 11:32:20 -07:00
|
|
|
local screen
|
2014-12-09 10:12:12 -07:00
|
|
|
|
2015-01-26 11:32:20 -07:00
|
|
|
local hlgroup_colors = {
|
|
|
|
NonText = Screen.colors.Blue,
|
|
|
|
Visual = Screen.colors.LightGrey
|
|
|
|
}
|
2014-12-09 10:12:12 -07:00
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
nvim('set_option', 'mouse', 'a')
|
2016-01-19 00:47:49 -07:00
|
|
|
nvim('set_option', 'listchars', 'eol:$')
|
2014-12-09 10:12:12 -07:00
|
|
|
-- set mouset to very high value to ensure that even in valgrind/travis,
|
|
|
|
-- nvim will still pick multiple clicks
|
|
|
|
nvim('set_option', 'mouset', 5000)
|
|
|
|
screen = Screen.new(25, 5)
|
|
|
|
screen:attach()
|
|
|
|
screen:set_default_attr_ids({
|
2015-01-23 15:53:21 -07:00
|
|
|
[1] = {background = hlgroup_colors.Visual},
|
|
|
|
[2] = {bold = true}
|
2014-12-09 10:12:12 -07:00
|
|
|
})
|
2015-01-23 15:53:21 -07:00
|
|
|
screen:set_default_attr_ignore( {{bold=true, foreground=hlgroup_colors.NonText}} )
|
2014-12-09 10:12:12 -07:00
|
|
|
feed('itesting<cr>mouse<cr>support and selection<esc>')
|
|
|
|
screen:expect([[
|
|
|
|
testing |
|
|
|
|
mouse |
|
2015-03-05 02:07:55 -07:00
|
|
|
support and selectio^n |
|
2014-12-09 10:12:12 -07:00
|
|
|
~ |
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
after_each(function()
|
|
|
|
screen:detach()
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('left click moves cursor', function()
|
|
|
|
feed('<LeftMouse><2,1>')
|
|
|
|
screen:expect([[
|
|
|
|
testing |
|
2015-03-05 02:07:55 -07:00
|
|
|
mo^use |
|
2014-12-09 10:12:12 -07:00
|
|
|
support and selection |
|
|
|
|
~ |
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('<LeftMouse><0,0>')
|
|
|
|
screen:expect([[
|
2015-03-05 02:07:55 -07:00
|
|
|
^testing |
|
2014-12-09 10:12:12 -07:00
|
|
|
mouse |
|
|
|
|
support and selection |
|
|
|
|
~ |
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2015-04-12 17:06:31 -07:00
|
|
|
it('left click in tabline switches to tab', function()
|
|
|
|
local tab_attrs = {
|
|
|
|
tab = { background=Screen.colors.LightGrey, underline=true },
|
|
|
|
sel = { bold=true },
|
2015-04-12 18:24:50 -07:00
|
|
|
fill = { reverse=true }
|
2015-04-12 17:06:31 -07:00
|
|
|
}
|
|
|
|
execute('%delete')
|
|
|
|
insert('this is foo')
|
|
|
|
execute('silent file foo | tabnew | file bar')
|
|
|
|
insert('this is bar')
|
|
|
|
screen:expect([[
|
|
|
|
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
|
|
|
|
this is ba^r |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
|
|
|
|
|
]], tab_attrs)
|
|
|
|
feed('<LeftMouse><4,0>')
|
|
|
|
screen:expect([[
|
|
|
|
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
|
|
|
|
this is fo^o |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
|
|
|
|
|
]], tab_attrs)
|
|
|
|
end)
|
|
|
|
|
2014-12-09 10:12:12 -07:00
|
|
|
it('left drag changes visual selection', function()
|
|
|
|
-- drag events must be preceded by a click
|
|
|
|
feed('<LeftMouse><2,1>')
|
|
|
|
screen:expect([[
|
|
|
|
testing |
|
2015-03-05 02:07:55 -07:00
|
|
|
mo^use |
|
2014-12-09 10:12:12 -07:00
|
|
|
support and selection |
|
|
|
|
~ |
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('<LeftDrag><4,1>')
|
|
|
|
screen:expect([[
|
|
|
|
testing |
|
2015-03-05 02:07:55 -07:00
|
|
|
mo{1:us}^e |
|
2014-12-09 10:12:12 -07:00
|
|
|
support and selection |
|
|
|
|
~ |
|
2015-01-23 15:53:21 -07:00
|
|
|
{2:-- VISUAL --} |
|
2014-12-09 10:12:12 -07:00
|
|
|
]])
|
|
|
|
feed('<LeftDrag><2,2>')
|
|
|
|
screen:expect([[
|
|
|
|
testing |
|
|
|
|
mo{1:use } |
|
2015-03-05 02:07:55 -07:00
|
|
|
{1:su}^pport and selection |
|
2014-12-09 10:12:12 -07:00
|
|
|
~ |
|
2015-01-23 15:53:21 -07:00
|
|
|
{2:-- VISUAL --} |
|
2014-12-09 10:12:12 -07:00
|
|
|
]])
|
|
|
|
feed('<LeftDrag><0,0>')
|
|
|
|
screen:expect([[
|
2015-03-05 02:07:55 -07:00
|
|
|
^t{1:esting } |
|
2014-12-09 10:12:12 -07:00
|
|
|
{1:mou}se |
|
|
|
|
support and selection |
|
|
|
|
~ |
|
2015-01-23 15:53:21 -07:00
|
|
|
{2:-- VISUAL --} |
|
2014-12-09 10:12:12 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2015-04-12 18:24:50 -07:00
|
|
|
it('left drag changes visual selection after tab click', function()
|
|
|
|
local tab_attrs = {
|
|
|
|
tab = { background=Screen.colors.LightGrey, underline=true },
|
|
|
|
sel = { bold=true },
|
|
|
|
fill = { reverse=true },
|
|
|
|
vis = { background=Screen.colors.LightGrey }
|
|
|
|
}
|
|
|
|
execute('silent file foo | tabnew | file bar')
|
|
|
|
insert('this is bar')
|
|
|
|
execute('tabprevious') -- go to first tab
|
|
|
|
screen:expect([[
|
|
|
|
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
|
|
|
|
mouse |
|
|
|
|
support and selectio^n |
|
|
|
|
~ |
|
|
|
|
|
|
|
|
|
]], tab_attrs)
|
|
|
|
feed('<LeftMouse><10,0><LeftRelease>') -- go to second tab
|
|
|
|
helpers.wait()
|
|
|
|
feed('<LeftMouse><0,1>')
|
|
|
|
screen:expect([[
|
|
|
|
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
|
|
|
|
^this is bar |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
|
|
|
|
|
]], tab_attrs)
|
|
|
|
feed('<LeftDrag><4,1>')
|
|
|
|
screen:expect([[
|
|
|
|
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
|
|
|
|
{vis:this}^ is bar |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
{sel:-- VISUAL --} |
|
|
|
|
]], tab_attrs)
|
|
|
|
end)
|
|
|
|
|
2014-12-09 10:12:12 -07:00
|
|
|
it('two clicks will select the word and enter VISUAL', function()
|
|
|
|
feed('<LeftMouse><2,2><LeftMouse><2,2>')
|
|
|
|
screen:expect([[
|
|
|
|
testing |
|
|
|
|
mouse |
|
2015-03-05 02:07:55 -07:00
|
|
|
{1:suppor}^t and selection |
|
2014-12-09 10:12:12 -07:00
|
|
|
~ |
|
2015-01-23 15:53:21 -07:00
|
|
|
{2:-- VISUAL --} |
|
2014-12-09 10:12:12 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('three clicks will select the line and enter VISUAL LINE', function()
|
|
|
|
feed('<LeftMouse><2,2><LeftMouse><2,2><LeftMouse><2,2>')
|
|
|
|
screen:expect([[
|
|
|
|
testing |
|
|
|
|
mouse |
|
2015-03-05 02:07:55 -07:00
|
|
|
{1:su}^p{1:port and selection } |
|
2014-12-09 10:12:12 -07:00
|
|
|
~ |
|
2015-01-23 15:53:21 -07:00
|
|
|
{2:-- VISUAL LINE --} |
|
2014-12-09 10:12:12 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('four clicks will enter VISUAL BLOCK', function()
|
|
|
|
feed('<LeftMouse><2,2><LeftMouse><2,2><LeftMouse><2,2><LeftMouse><2,2>')
|
|
|
|
screen:expect([[
|
|
|
|
testing |
|
|
|
|
mouse |
|
2015-03-05 02:07:55 -07:00
|
|
|
su^pport and selection |
|
2014-12-09 10:12:12 -07:00
|
|
|
~ |
|
2015-01-23 15:53:21 -07:00
|
|
|
{2:-- VISUAL BLOCK --} |
|
2014-12-09 10:12:12 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('right click extends visual selection to the clicked location', function()
|
|
|
|
feed('<LeftMouse><0,0>')
|
|
|
|
screen:expect([[
|
2015-03-05 02:07:55 -07:00
|
|
|
^testing |
|
2014-12-09 10:12:12 -07:00
|
|
|
mouse |
|
|
|
|
support and selection |
|
|
|
|
~ |
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('<RightMouse><2,2>')
|
|
|
|
screen:expect([[
|
|
|
|
{1:testing } |
|
|
|
|
{1:mouse } |
|
2015-03-05 02:07:55 -07:00
|
|
|
{1:su}^pport and selection |
|
2014-12-09 10:12:12 -07:00
|
|
|
~ |
|
2015-01-23 15:53:21 -07:00
|
|
|
{2:-- VISUAL --} |
|
2014-12-09 10:12:12 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('ctrl + left click will search for a tag', function()
|
2015-01-28 15:48:36 -07:00
|
|
|
nvim('set_option', 'tags', './non-existent-tags-file')
|
2014-12-09 10:12:12 -07:00
|
|
|
feed('<C-LeftMouse><0,0>')
|
|
|
|
screen:expect([[
|
|
|
|
E433: No tags file |
|
|
|
|
E426: tag not found: test|
|
|
|
|
ing |
|
|
|
|
Press ENTER or type comma|
|
2015-03-05 02:07:55 -07:00
|
|
|
nd to continue^ |
|
2015-01-23 15:53:21 -07:00
|
|
|
]],nil,true)
|
2014-12-09 10:12:12 -07:00
|
|
|
feed('<cr>')
|
|
|
|
end)
|
2015-01-15 05:01:25 -07:00
|
|
|
|
|
|
|
it('mouse whell will target the hovered window', function()
|
|
|
|
feed('ggdG')
|
|
|
|
insert([[
|
|
|
|
Inserting
|
|
|
|
text
|
|
|
|
with
|
|
|
|
many
|
|
|
|
lines
|
|
|
|
to
|
|
|
|
test
|
|
|
|
mouse scrolling
|
|
|
|
]])
|
|
|
|
screen:try_resize(53, 14)
|
|
|
|
execute('sp', 'vsp')
|
2015-01-23 15:53:21 -07:00
|
|
|
screen:set_default_attr_ignore( {{bold=true, foreground=hlgroup_colors.NonText},
|
|
|
|
{reverse=true}, {bold=true, reverse=true}} )
|
2015-01-15 05:01:25 -07:00
|
|
|
screen:expect([[
|
|
|
|
lines |lines |
|
|
|
|
to |to |
|
|
|
|
test |test |
|
|
|
|
mouse scrolling |mouse scrolling |
|
2015-03-05 02:07:55 -07:00
|
|
|
^ | |
|
2015-01-15 05:01:25 -07:00
|
|
|
~ |~ |
|
|
|
|
[No Name] [+] [No Name] [+] |
|
|
|
|
to |
|
|
|
|
test |
|
|
|
|
mouse scrolling |
|
|
|
|
|
|
|
|
|
~ |
|
|
|
|
[No Name] [+] |
|
|
|
|
:vsp |
|
|
|
|
]])
|
|
|
|
feed('<MouseUp><0,0>')
|
|
|
|
screen:expect([[
|
|
|
|
mouse scrolling |lines |
|
2015-03-05 02:07:55 -07:00
|
|
|
^ |to |
|
2015-01-15 05:01:25 -07:00
|
|
|
~ |test |
|
|
|
|
~ |mouse scrolling |
|
|
|
|
~ | |
|
|
|
|
~ |~ |
|
|
|
|
[No Name] [+] [No Name] [+] |
|
|
|
|
to |
|
|
|
|
test |
|
|
|
|
mouse scrolling |
|
|
|
|
|
|
|
|
|
~ |
|
|
|
|
[No Name] [+] |
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('<MouseDown><27,0>')
|
|
|
|
screen:expect([[
|
|
|
|
mouse scrolling |text |
|
2015-03-05 02:07:55 -07:00
|
|
|
^ |with |
|
2015-01-15 05:01:25 -07:00
|
|
|
~ |many |
|
|
|
|
~ |lines |
|
|
|
|
~ |to |
|
|
|
|
~ |test |
|
|
|
|
[No Name] [+] [No Name] [+] |
|
|
|
|
to |
|
|
|
|
test |
|
|
|
|
mouse scrolling |
|
|
|
|
|
|
|
|
|
~ |
|
|
|
|
[No Name] [+] |
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('<MouseDown><27,7><MouseDown>')
|
|
|
|
screen:expect([[
|
|
|
|
mouse scrolling |text |
|
2015-03-05 02:07:55 -07:00
|
|
|
^ |with |
|
2015-01-15 05:01:25 -07:00
|
|
|
~ |many |
|
|
|
|
~ |lines |
|
|
|
|
~ |to |
|
|
|
|
~ |test |
|
|
|
|
[No Name] [+] [No Name] [+] |
|
|
|
|
Inserting |
|
|
|
|
text |
|
|
|
|
with |
|
|
|
|
many |
|
|
|
|
lines |
|
|
|
|
[No Name] [+] |
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
2014-12-09 10:12:12 -07:00
|
|
|
end)
|