Merge pull request #24554 from zeertzjq/backport

Backport libvterm bump to release-0.9
This commit is contained in:
zeertzjq
2023-08-04 10:57:24 +08:00
committed by GitHub
4 changed files with 220 additions and 67 deletions

View File

@@ -154,8 +154,8 @@ set(UNIBILIUM_SHA256 9c4747c862ab5e3076dcf8fa8f0ea7a6b50f20ec5905618b95366555967
set(LIBTERMKEY_URL https://github.com/neovim/deps/raw/aa004f1b2b6470a92363cba8e1cc1874141dacc4/opt/libtermkey-0.22.tar.gz)
set(LIBTERMKEY_SHA256 6945bd3c4aaa83da83d80a045c5563da4edd7d0374c62c0d35aec09eb3014600)
set(LIBVTERM_URL https://github.com/neovim/deps/raw/aa004f1b2b6470a92363cba8e1cc1874141dacc4/opt/libvterm-0.3.1.tar.gz)
set(LIBVTERM_SHA256 25a8ad9c15485368dfd0a8a9dca1aec8fea5c27da3fa74ec518d5d3787f0c397)
set(LIBVTERM_URL https://github.com/neovim/deps/raw/12c9dcf1d823ac4acbccf494c93c4774a87db11d/opt/libvterm-0.3.3.tar.gz)
set(LIBVTERM_SHA256 09156f43dd2128bd347cbeebe50d9a571d32c64e0cf18d211197946aff7226e0)
set(LUV_URL https://github.com/luvit/luv/archive/093a977b82077591baefe1e880d37dfa2730bd54.tar.gz)
set(LUV_SHA256 222b38b6425f0926218e14e7da81481fdde6f9660c1feac25a53e6fb52e886e6)

View File

@@ -576,6 +576,8 @@ static int terminal_execute(VimState *state, int key)
case K_RIGHTRELEASE:
case K_MOUSEDOWN:
case K_MOUSEUP:
case K_MOUSELEFT:
case K_MOUSERIGHT:
if (send_mouse_event(s->term, key)) {
return 0;
}
@@ -1439,6 +1441,10 @@ static bool send_mouse_event(Terminal *term, int c)
pressed = true; button = 4; break;
case K_MOUSEUP:
pressed = true; button = 5; break;
case K_MOUSELEFT:
pressed = true; button = 7; break;
case K_MOUSERIGHT:
pressed = true; button = 6; break;
default:
return false;
}

View File

@@ -467,6 +467,7 @@ describe('terminal input', function()
'<S-RightMouse>', '<S-RightRelease>', '<2-RightMouse>', '<2-RightRelease>',
'<M-MiddleMouse>', '<M-MiddleRelease>', '<2-MiddleMouse>', '<2-MiddleRelease>',
'<S-ScrollWheelUp>', '<S-ScrollWheelDown>', '<ScrollWheelUp>', '<ScrollWheelDown>',
'<S-ScrollWheelLeft>', '<S-ScrollWheelRight>', '<ScrollWheelLeft>', '<ScrollWheelRight>',
}) do
feed('<CR><C-V>' .. key)
retry(nil, nil, function() eq(key, meths.get_current_line()) end)

View File

@@ -330,7 +330,7 @@ describe('TUI', function()
]], attrs)
end)
it('accepts mouse wheel events #19992', function()
local function test_mouse_wheel(esc)
child_session:request('nvim_exec2', [[
set number nostartofline nowrap mousescroll=hor:1,ver:1
call setline(1, repeat([join(range(10), '----')], 10))
@@ -346,7 +346,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <ScrollWheelDown> in active window
feed_data('\027[<65;8;1M')
if esc then
feed_data('\027[<65;8;1M')
else
meths.input_mouse('wheel', 'down', '', 0, 0, 7)
end
screen:expect([[
{11: 2 }{1:0}----1----2----3----4│{11: 1 }0----1----2----3----|
{11: 3 }0----1----2----3----4│{11: 2 }0----1----2----3----|
@@ -357,7 +361,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <ScrollWheelDown> in inactive window
feed_data('\027[<65;48;1M')
if esc then
feed_data('\027[<65;48;1M')
else
meths.input_mouse('wheel', 'down', '', 0, 0, 47)
end
screen:expect([[
{11: 2 }{1:0}----1----2----3----4│{11: 2 }0----1----2----3----|
{11: 3 }0----1----2----3----4│{11: 3 }0----1----2----3----|
@@ -368,7 +376,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <ScrollWheelRight> in active window
feed_data('\027[<67;8;1M')
if esc then
feed_data('\027[<67;8;1M')
else
meths.input_mouse('wheel', 'right', '', 0, 0, 7)
end
screen:expect([[
{11: 2 }{1:-}---1----2----3----4-│{11: 2 }0----1----2----3----|
{11: 3 }----1----2----3----4-│{11: 3 }0----1----2----3----|
@@ -379,7 +391,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <ScrollWheelRight> in inactive window
feed_data('\027[<67;48;1M')
if esc then
feed_data('\027[<67;48;1M')
else
meths.input_mouse('wheel', 'right', '', 0, 0, 47)
end
screen:expect([[
{11: 2 }{1:-}---1----2----3----4-│{11: 2 }----1----2----3----4|
{11: 3 }----1----2----3----4-│{11: 3 }----1----2----3----4|
@@ -390,7 +406,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <S-ScrollWheelDown> in active window
feed_data('\027[<69;8;1M')
if esc then
feed_data('\027[<69;8;1M')
else
meths.input_mouse('wheel', 'down', 'S', 0, 0, 7)
end
screen:expect([[
{11: 5 }{1:-}---1----2----3----4-│{11: 2 }----1----2----3----4|
{11: 6 }----1----2----3----4-│{11: 3 }----1----2----3----4|
@@ -401,7 +421,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <S-ScrollWheelDown> in inactive window
feed_data('\027[<69;48;1M')
if esc then
feed_data('\027[<69;48;1M')
else
meths.input_mouse('wheel', 'down', 'S', 0, 0, 47)
end
screen:expect([[
{11: 5 }{1:-}---1----2----3----4-│{11: 5 }----1----2----3----4|
{11: 6 }----1----2----3----4-│{11: 6 }----1----2----3----4|
@@ -412,7 +436,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <S-ScrollWheelRight> in active window
feed_data('\027[<71;8;1M')
if esc then
feed_data('\027[<71;8;1M')
else
meths.input_mouse('wheel', 'right', 'S', 0, 0, 7)
end
screen:expect([[
{11: 5 }{1:-}---6----7----8----9 │{11: 5 }----1----2----3----4|
{11: 6 }----6----7----8----9 │{11: 6 }----1----2----3----4|
@@ -423,7 +451,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <S-ScrollWheelRight> in inactive window
feed_data('\027[<71;48;1M')
if esc then
feed_data('\027[<71;48;1M')
else
meths.input_mouse('wheel', 'right', 'S', 0, 0, 47)
end
screen:expect([[
{11: 5 }{1:-}---6----7----8----9 │{11: 5 }5----6----7----8----|
{11: 6 }----6----7----8----9 │{11: 6 }5----6----7----8----|
@@ -434,7 +466,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <ScrollWheelUp> in active window
feed_data('\027[<64;8;1M')
if esc then
feed_data('\027[<64;8;1M')
else
meths.input_mouse('wheel', 'up', '', 0, 0, 7)
end
screen:expect([[
{11: 4 }----6----7----8----9 │{11: 5 }5----6----7----8----|
{11: 5 }{1:-}---6----7----8----9 │{11: 6 }5----6----7----8----|
@@ -445,7 +481,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <ScrollWheelUp> in inactive window
feed_data('\027[<64;48;1M')
if esc then
feed_data('\027[<64;48;1M')
else
meths.input_mouse('wheel', 'up', '', 0, 0, 47)
end
screen:expect([[
{11: 4 }----6----7----8----9 │{11: 4 }5----6----7----8----|
{11: 5 }{1:-}---6----7----8----9 │{11: 5 }5----6----7----8----|
@@ -456,7 +496,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <ScrollWheelLeft> in active window
feed_data('\027[<66;8;1M')
if esc then
feed_data('\027[<66;8;1M')
else
meths.input_mouse('wheel', 'left', '', 0, 0, 7)
end
screen:expect([[
{11: 4 }5----6----7----8----9│{11: 4 }5----6----7----8----|
{11: 5 }5{1:-}---6----7----8----9│{11: 5 }5----6----7----8----|
@@ -467,7 +511,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <ScrollWheelLeft> in inactive window
feed_data('\027[<66;48;1M')
if esc then
feed_data('\027[<66;48;1M')
else
meths.input_mouse('wheel', 'left', '', 0, 0, 47)
end
screen:expect([[
{11: 4 }5----6----7----8----9│{11: 4 }-5----6----7----8---|
{11: 5 }5{1:-}---6----7----8----9│{11: 5 }-5----6----7----8---|
@@ -478,7 +526,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <S-ScrollWheelUp> in active window
feed_data('\027[<68;8;1M')
if esc then
feed_data('\027[<68;8;1M')
else
meths.input_mouse('wheel', 'up', 'S', 0, 0, 7)
end
screen:expect([[
{11: 1 }5----6----7----8----9│{11: 4 }-5----6----7----8---|
{11: 2 }5----6----7----8----9│{11: 5 }-5----6----7----8---|
@@ -489,7 +541,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <S-ScrollWheelUp> in inactive window
feed_data('\027[<68;48;1M')
if esc then
feed_data('\027[<68;48;1M')
else
meths.input_mouse('wheel', 'up', 'S', 0, 0, 47)
end
screen:expect([[
{11: 1 }5----6----7----8----9│{11: 1 }-5----6----7----8---|
{11: 2 }5----6----7----8----9│{11: 2 }-5----6----7----8---|
@@ -500,7 +556,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <S-ScrollWheelLeft> in active window
feed_data('\027[<70;8;1M')
if esc then
feed_data('\027[<70;8;1M')
else
meths.input_mouse('wheel', 'left', 'S', 0, 0, 7)
end
screen:expect([[
{11: 1 }0----1----2----3----4│{11: 1 }-5----6----7----8---|
{11: 2 }0----1----2----3----4│{11: 2 }-5----6----7----8---|
@@ -511,7 +571,11 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
-- <S-ScrollWheelLeft> in inactive window
feed_data('\027[<70;48;1M')
if esc then
feed_data('\027[<70;48;1M')
else
meths.input_mouse('wheel', 'left', 'S', 0, 0, 47)
end
screen:expect([[
{11: 1 }0----1----2----3----4│{11: 1 }0----1----2----3----|
{11: 2 }0----1----2----3----4│{11: 2 }0----1----2----3----|
@@ -521,6 +585,136 @@ describe('TUI', function()
|
{3:-- TERMINAL --} |
]])
end
describe('accepts mouse wheel events', function()
it('(mouse events sent to host)', function()
test_mouse_wheel(false)
end)
it('(escape sequences sent to child)', function()
test_mouse_wheel(true)
end)
end)
local function test_mouse_popup(esc)
child_session:request('nvim_exec2', [[
call setline(1, 'popup menu test')
set mouse=a mousemodel=popup
aunmenu PopUp
menu PopUp.foo :let g:menustr = 'foo'<CR>
menu PopUp.bar :let g:menustr = 'bar'<CR>
menu PopUp.baz :let g:menustr = 'baz'<CR>
highlight Pmenu ctermbg=NONE ctermfg=NONE cterm=underline,reverse
highlight PmenuSel ctermbg=NONE ctermfg=NONE cterm=underline,reverse,bold
]], {})
if esc then
feed_data('\027[<2;5;1M')
else
meths.input_mouse('right', 'press', '', 0, 0, 4)
end
screen:expect([[
{1:p}opup menu test |
{4:~ }{13: foo }{4: }|
{4:~ }{13: bar }{4: }|
{4:~ }{13: baz }{4: }|
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
]])
if esc then
feed_data('\027[<2;5;1m')
else
meths.input_mouse('right', 'release', '', 0, 0, 4)
end
screen:expect_unchanged()
if esc then
feed_data('\027[<35;7;4M')
else
meths.input_mouse('move', '', '', 0, 3, 6)
end
screen:expect([[
{1:p}opup menu test |
{4:~ }{13: foo }{4: }|
{4:~ }{13: bar }{4: }|
{4:~ }{14: baz }{4: }|
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
]])
if esc then
feed_data('\027[<0;7;3M')
else
meths.input_mouse('left', 'press', '', 0, 2, 6)
end
screen:expect([[
{1:p}opup menu test |
{4:~ }|
{4:~ }|
{4:~ }|
{5:[No Name] [+] }|
:let g:menustr = 'bar' |
{3:-- TERMINAL --} |
]])
if esc then
feed_data('\027[<0;7;3m')
else
meths.input_mouse('left', 'release', '', 0, 2, 6)
end
screen:expect_unchanged()
if esc then
feed_data('\027[<2;45;3M')
else
meths.input_mouse('right', 'press', '', 0, 2, 44)
end
screen:expect([[
{1:p}opup menu test |
{4:~ }|
{4:~ }|
{4:~ }{13: foo }{4: }|
{5:[No Name] [+] }{13: bar }{5: }|
:let g:menustr = 'bar' {13: baz } |
{3:-- TERMINAL --} |
]])
if esc then
feed_data('\027[<34;48;6M')
else
meths.input_mouse('right', 'drag', '', 0, 5, 47)
end
screen:expect([[
{1:p}opup menu test |
{4:~ }|
{4:~ }|
{4:~ }{13: foo }{4: }|
{5:[No Name] [+] }{13: bar }{5: }|
:let g:menustr = 'bar' {14: baz } |
{3:-- TERMINAL --} |
]])
if esc then
feed_data('\027[<2;48;6m')
else
meths.input_mouse('right', 'release', '', 0, 5, 47)
end
screen:expect([[
{1:p}opup menu test |
{4:~ }|
{4:~ }|
{4:~ }|
{5:[No Name] [+] }|
:let g:menustr = 'baz' |
{3:-- TERMINAL --} |
]])
end
describe('mouse events work with right-click menu', function()
it('(mouse events sent to host)', function()
test_mouse_popup(false)
end)
it('(escape sequences sent to child)', function()
test_mouse_popup(true)
end)
end)
it('accepts keypad keys from kitty keyboard protocol #19180', function()
@@ -719,54 +913,6 @@ describe('TUI', function()
]])
end)
it('mouse events work with right-click menu', function()
child_session:request('nvim_exec2', [[
call setline(1, 'popup menu test')
set mouse=a mousemodel=popup
aunmenu PopUp
menu PopUp.foo :let g:menustr = 'foo'<CR>
menu PopUp.bar :let g:menustr = 'bar'<CR>
menu PopUp.baz :let g:menustr = 'baz'<CR>
highlight Pmenu ctermbg=NONE ctermfg=NONE cterm=underline,reverse
highlight PmenuSel ctermbg=NONE ctermfg=NONE cterm=underline,reverse,bold
]], {})
meths.input_mouse('right', 'press', '', 0, 0, 4)
screen:expect([[
{1:p}opup menu test |
{4:~ }{13: foo }{4: }|
{4:~ }{13: bar }{4: }|
{4:~ }{13: baz }{4: }|
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
]])
meths.input_mouse('right', 'release', '', 0, 0, 4)
screen:expect_unchanged()
meths.input_mouse('move', '', '', 0, 3, 6)
screen:expect([[
{1:p}opup menu test |
{4:~ }{13: foo }{4: }|
{4:~ }{13: bar }{4: }|
{4:~ }{14: baz }{4: }|
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
]])
meths.input_mouse('left', 'press', '', 0, 2, 6)
screen:expect([[
{1:p}opup menu test |
{4:~ }|
{4:~ }|
{4:~ }|
{5:[No Name] [+] }|
:let g:menustr = 'bar' |
{3:-- TERMINAL --} |
]])
meths.input_mouse('left', 'release', '', 0, 2, 6)
screen:expect_unchanged()
end)
it('paste: Insert mode', function()
-- "bracketed paste"
feed_data('i""\027i\027[200~')