vim-patch:8.2.1108: mouse left-right scroll is not supported in terminal window

Problem:    Mouse left-right scroll is not supported in terminal window.
Solution:   Implement mouse codes 6 and 7. (Trygve Aaberge, closes vim/vim#6363)

d58d4f90ae
This commit is contained in:
zeertzjq 2023-04-28 17:09:40 +08:00
parent d8cc98caae
commit 0c5b03d83a
2 changed files with 37 additions and 3 deletions

View File

@ -70,4 +70,16 @@ func MouseWheelDown(row, col)
call feedkeys('', 'x!')
endfunc
func MouseWheelLeft(row, col)
call nvim_input_mouse('wheel', 'left', '', 0, a:row - 1, a:col - 1)
call getchar(1)
call feedkeys('', 'x!')
endfunc
func MouseWheelRight(row, col)
call nvim_input_mouse('wheel', 'right', '', 0, a:row - 1, a:col - 1)
call getchar(1)
call feedkeys('', 'x!')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -199,10 +199,11 @@ func Test_1xterm_mouse_wheel()
new
let save_mouse = &mouse
let save_term = &term
let save_wrap = &wrap
" let save_ttymouse = &ttymouse
" set mouse=a term=xterm
set mouse=a
call setline(1, range(1, 100))
" set mouse=a term=xterm nowrap
set mouse=a nowrap
call setline(1, range(100000000000000, 100000000000100))
for ttymouse_val in g:Ttymouse_values
let msg = 'ttymouse=' .. ttymouse_val
@ -226,10 +227,31 @@ func Test_1xterm_mouse_wheel()
call MouseWheelUp(1, 1)
call assert_equal(1, line('w0'), msg)
call assert_equal([0, 7, 1, 0], getpos('.'), msg)
if has('gui')
" Horizontal wheel scrolling currently only works when vim is
" compiled with gui enabled.
call MouseWheelRight(1, 1)
call assert_equal(7, 1 + virtcol(".") - wincol(), msg)
call assert_equal([0, 7, 7, 0], getpos('.'), msg)
call MouseWheelRight(1, 1)
call assert_equal(13, 1 + virtcol(".") - wincol(), msg)
call assert_equal([0, 7, 13, 0], getpos('.'), msg)
call MouseWheelLeft(1, 1)
call assert_equal(7, 1 + virtcol(".") - wincol(), msg)
call assert_equal([0, 7, 13, 0], getpos('.'), msg)
call MouseWheelLeft(1, 1)
call assert_equal(1, 1 + virtcol(".") - wincol(), msg)
call assert_equal([0, 7, 13, 0], getpos('.'), msg)
endif
endfor
let &mouse = save_mouse
" let &term = save_term
let &wrap = save_wrap
" let &ttymouse = save_ttymouse
bwipe!
endfunc