@@ -45,3 +45,69 @@ func Test_xterm_mouse_click()
4545 bwipe!
4646endfunc
4747
48+ func Test_xterm_mouse_wheel ()
49+ new
50+ let save_mouse = &mouse
51+ let save_term = &term
52+ let save_ttymouse = &ttymouse
53+ set mouse = a
54+ set term = xterm
55+ call setline (1 , range (1 , 100 ))
56+
57+ " Test Xterm mouse wheel.
58+ set ttymouse = xterm
59+ let button = 0x41 " wheel down.
60+ let row = 1 + 32 " cursor position for mouse wheel is not relevant.
61+ let col = 1 + 32
62+
63+ call assert_equal (1 , line (' w0' ))
64+ call assert_equal ([0 , 1 , 1 , 0 ], getpos (' .' ))
65+ call feedkeys (" \<Esc> [M" .. list2str ([button, col , row]), ' Lx!' )
66+ call assert_equal (4 , line (' w0' ))
67+ call assert_equal ([0 , 4 , 1 , 0 ], getpos (' .' ))
68+ call feedkeys (" \<Esc> [M" .. list2str ([button, col , row]), ' Lx!' )
69+ call assert_equal (7 , line (' w0' ))
70+ call assert_equal ([0 , 7 , 1 , 0 ], getpos (' .' ))
71+
72+ let button = 0x40 " wheel up.
73+
74+ call feedkeys (" \<Esc> [M" .. list2str ([button, col , row]), ' Lx!' )
75+ call assert_equal (4 , line (' w0' ))
76+ call assert_equal ([0 , 7 , 1 , 0 ], getpos (' .' ))
77+ call feedkeys (" \<Esc> [M" .. list2str ([button, col , row]), ' Lx!' )
78+ call assert_equal (1 , line (' w0' ))
79+ call assert_equal ([0 , 7 , 1 , 0 ], getpos (' .' ))
80+
81+ " Test SGR mouse wheel.
82+ set ttymouse = sgr
83+ go
84+ let button = 0x41 " wheel down.
85+ let row = 1 " cursor position for mouse wheel is not relevant.
86+ let col = 1
87+
88+ call assert_equal (1 , line (' w0' ))
89+ call assert_equal ([0 , 1 , 1 , 0 ], getpos (' .' ))
90+ call feedkeys (printf (" \<Esc> [<%d;%d;%dM" , button, col , row), ' Lx!' )
91+ call assert_equal (4 , line (' w0' ))
92+ call assert_equal ([0 , 4 , 1 , 0 ], getpos (' .' ))
93+ call feedkeys (printf (" \<Esc> [<%d;%d;%dM" , button, col , row), ' Lx!' )
94+ call assert_equal (7 , line (' w0' ))
95+ call assert_equal ([0 , 7 , 1 , 0 ], getpos (' .' ))
96+
97+ let button = 0x40 " wheel up.
98+
99+ call feedkeys (printf (" \<Esc> [<%d;%d;%dM" , button, col , row), ' Lx!' )
100+ call assert_equal (4 , line (' w0' ))
101+ call assert_equal ([0 , 7 , 1 , 0 ], getpos (' .' ))
102+ call feedkeys (printf (" \<Esc> [<%d;%d;%dM" , button, col , row), ' Lx!' )
103+ call assert_equal (1 , line (' w0' ))
104+ call assert_equal ([0 , 7 , 1 , 0 ], getpos (' .' ))
105+ call feedkeys (printf (" \<Esc> [<%d;%d;%dM" , button, col , row), ' Lx!' )
106+ call assert_equal (1 , line (' w0' ))
107+ call assert_equal ([0 , 7 , 1 , 0 ], getpos (' .' ))
108+
109+ let &mouse = save_mouse
110+ let &term = save_term
111+ let &ttymouse = save_ttymouse
112+ bwipe!
113+ endfunc
0 commit comments