diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-01-01 12:46:47 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2019-01-20 10:32:05 +0100 |
commit | a2be9c7218d7fb431191cd6146fba61bcd1e193e (patch) | |
tree | 6a18ff845b028572d6aa1f35900b571821a2082d /test/functional/ui/mouse_spec.lua | |
parent | 8a5c68f6959f8d315adb126ff49fd1970e7e75be (diff) | |
download | rneovim-a2be9c7218d7fb431191cd6146fba61bcd1e193e.tar.gz rneovim-a2be9c7218d7fb431191cd6146fba61bcd1e193e.tar.bz2 rneovim-a2be9c7218d7fb431191cd6146fba61bcd1e193e.zip |
ui: multigrid mouse support
Diffstat (limited to 'test/functional/ui/mouse_spec.lua')
-rw-r--r-- | test/functional/ui/mouse_spec.lua | 92 |
1 files changed, 82 insertions, 10 deletions
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index 8d35df6f48..8ba03953b9 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -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 /\^/ |