mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
ui: multigrid mouse support
This commit is contained in:
@@ -440,16 +440,34 @@ describe('ui/mouse/input', function()
|
||||
|
||||
local test_click = function(name, click_str, click_num, mouse_button,
|
||||
modifiers)
|
||||
it(name .. ' works', function()
|
||||
|
||||
local function doit(do_click)
|
||||
eq(1, funcs.has('tablineat'))
|
||||
feed(click_str .. '<3,0>')
|
||||
do_click(0,3)
|
||||
check_reply({0, click_num, mouse_button, modifiers})
|
||||
feed(click_str .. '<4,0>')
|
||||
do_click(0,4)
|
||||
check_reply({})
|
||||
feed(click_str .. '<6,0>')
|
||||
do_click(0,6)
|
||||
check_reply({5, click_num, mouse_button, modifiers, 2})
|
||||
feed(click_str .. '<13,0>')
|
||||
do_click(0,13)
|
||||
check_reply({5, click_num, mouse_button, modifiers, 2})
|
||||
end
|
||||
|
||||
it(name .. ' works (pseudokey)', function()
|
||||
doit(function (row,col)
|
||||
feed(click_str .. '<' .. col .. ',' .. row .. '>')
|
||||
end)
|
||||
end)
|
||||
|
||||
it(name .. ' works (nvim_input_mouse)', function()
|
||||
doit(function (row,col)
|
||||
local buttons = {l='left',m='middle',r='right'}
|
||||
local modstr = (click_num > 1) and tostring(click_num) or ''
|
||||
for char in string.gmatch(modifiers, '%w') do
|
||||
modstr = modstr .. char .. '-' -- - not needed but should be accepted
|
||||
end
|
||||
meths.input_mouse(buttons[mouse_button], 'press', modstr, 0, row, col)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -617,7 +635,7 @@ describe('ui/mouse/input', function()
|
||||
feed('<cr>')
|
||||
end)
|
||||
|
||||
it('mouse whell will target the hovered window', function()
|
||||
local function wheel(use_api)
|
||||
feed('ggdG')
|
||||
insert([[
|
||||
Inserting
|
||||
@@ -647,7 +665,11 @@ describe('ui/mouse/input', function()
|
||||
{4:[No Name] [+] }|
|
||||
:vsp |
|
||||
]])
|
||||
feed('<ScrollWheelDown><0,0>')
|
||||
if use_api then
|
||||
meths.input_mouse('wheel', 'down', '', 0, 0, 0)
|
||||
else
|
||||
feed('<ScrollWheelDown><0,0>')
|
||||
end
|
||||
screen:expect([[
|
||||
mouse scrolling {4:│}lines |
|
||||
^ {4:│}to |
|
||||
@@ -664,7 +686,11 @@ describe('ui/mouse/input', function()
|
||||
{4:[No Name] [+] }|
|
||||
:vsp |
|
||||
]])
|
||||
feed('<ScrollWheelUp><27,0>')
|
||||
if use_api then
|
||||
meths.input_mouse('wheel', 'up', '', 0, 0, 27)
|
||||
else
|
||||
feed('<ScrollWheelUp><27,0>')
|
||||
end
|
||||
screen:expect([[
|
||||
mouse scrolling {4:│}text |
|
||||
^ {4:│}with |
|
||||
@@ -681,7 +707,12 @@ describe('ui/mouse/input', function()
|
||||
{4:[No Name] [+] }|
|
||||
:vsp |
|
||||
]])
|
||||
feed('<ScrollWheelUp><27,7><ScrollWheelUp>')
|
||||
if use_api then
|
||||
meths.input_mouse('wheel', 'up', '', 0, 7, 27)
|
||||
meths.input_mouse('wheel', 'up', '', 0, 7, 27)
|
||||
else
|
||||
feed('<ScrollWheelUp><27,7><ScrollWheelUp>')
|
||||
end
|
||||
screen:expect([[
|
||||
mouse scrolling {4:│}text |
|
||||
^ {4:│}with |
|
||||
@@ -698,9 +729,17 @@ describe('ui/mouse/input', function()
|
||||
{4:[No Name] [+] }|
|
||||
:vsp |
|
||||
]])
|
||||
end
|
||||
|
||||
it('mouse wheel will target the hovered window (pseudokey)', function()
|
||||
wheel(false)
|
||||
end)
|
||||
|
||||
it('horizontal scrolling', function()
|
||||
it('mouse wheel will target the hovered window (nvim_input_mouse)', function()
|
||||
wheel(true)
|
||||
end)
|
||||
|
||||
it('horizontal scrolling (pseudokey)', function()
|
||||
command('set sidescroll=0')
|
||||
feed("<esc>:set nowrap<cr>")
|
||||
|
||||
@@ -732,6 +771,39 @@ describe('ui/mouse/input', function()
|
||||
]])
|
||||
end)
|
||||
|
||||
it('horizontal scrolling (nvim_input_mouse)', function()
|
||||
command('set sidescroll=0')
|
||||
feed("<esc>:set nowrap<cr>")
|
||||
|
||||
feed("a <esc>20Ab<esc>")
|
||||
screen:expect([[
|
||||
|
|
||||
|
|
||||
bbbbbbbbbbbbbbb^b |
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
|
||||
meths.input_mouse('wheel', 'left', '', 0, 0, 27)
|
||||
screen:expect([[
|
||||
|
|
||||
|
|
||||
n bbbbbbbbbbbbbbbbbbb^b |
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
|
||||
feed("^")
|
||||
meths.input_mouse('wheel', 'right', '', 0, 0, 0)
|
||||
screen:expect([[
|
||||
g |
|
||||
|
|
||||
^t and selection bbbbbbbbb|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
describe('on concealed text', function()
|
||||
-- Helpful for reading the test expectations:
|
||||
-- :match Error /\^/
|
||||
|
||||
Reference in New Issue
Block a user