1
0
forked from aniani/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 #6363)
This commit is contained in:
Bram Moolenaar
2020-07-01 15:49:29 +02:00
parent ef8c617b9c
commit d58d4f90ae
6 changed files with 89 additions and 22 deletions

View File

@@ -169,4 +169,20 @@ func MouseWheelDown(row, col)
call feedkeys(MouseWheelDownCode(a:row, a:col), 'Lx!')
endfunc
func MouseWheelLeftCode(row, col)
return TerminalEscapeCode(0x42, a:row, a:col, 'M')
endfunc
func MouseWheelLeft(row, col)
call feedkeys(MouseWheelLeftCode(a:row, a:col), 'Lx!')
endfunc
func MouseWheelRightCode(row, col)
return TerminalEscapeCode(0x43, a:row, a:col, 'M')
endfunc
func MouseWheelRight(row, col)
call feedkeys(MouseWheelRightCode(a:row, a:col), 'Lx!')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -194,9 +194,10 @@ 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
call setline(1, range(1, 100))
set mouse=a term=xterm nowrap
call setline(1, range(100000000000000, 100000000000100))
for ttymouse_val in g:Ttymouse_values
let msg = 'ttymouse=' .. ttymouse_val
@@ -220,10 +221,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