Mercurial > vim
comparison src/testdir/test_termcodes.vim @ 18307:176fa195b95d v8.1.2148
patch 8.1.2148: no test for right click extending Visual area
Commit: https://github.com/vim/vim/commit/6aa7523b9642a752ab879131d4b159635207d9f2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 13 21:01:34 2019 +0200
patch 8.1.2148: no test for right click extending Visual area
Problem: No test for right click extending Visual area.
Solution: Add a test. (Dominique Pelle, closes https://github.com/vim/vim/issues/5018)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 13 Oct 2019 21:15:03 +0200 |
parents | 506bf60a30a0 |
children | 60fce48438e2 |
comparison
equal
deleted
inserted
replaced
18306:9307e77908be | 18307:176fa195b95d |
---|---|
70 else | 70 else |
71 call TerminalEscapeCode(1, a:row, a:col, 'M') | 71 call TerminalEscapeCode(1, a:row, a:col, 'M') |
72 endif | 72 endif |
73 endfunc | 73 endfunc |
74 | 74 |
75 func MouseRightClick(row, col) | |
76 if &ttymouse ==# 'dec' | |
77 call DecEscapeCode(6, 1, a:row, a:col) | |
78 else | |
79 call TerminalEscapeCode(2, a:row, a:col, 'M') | |
80 endif | |
81 endfunc | |
82 | |
75 func MouseCtrlLeftClick(row, col) | 83 func MouseCtrlLeftClick(row, col) |
76 let ctrl = 0x10 | 84 let ctrl = 0x10 |
77 call TerminalEscapeCode(0 + ctrl, a:row, a:col, 'M') | 85 call TerminalEscapeCode(0 + ctrl, a:row, a:col, 'M') |
78 endfunc | 86 endfunc |
79 | 87 |
99 call TerminalEscapeCode(3, a:row, a:col, 'm') | 107 call TerminalEscapeCode(3, a:row, a:col, 'm') |
100 endif | 108 endif |
101 endfunc | 109 endfunc |
102 | 110 |
103 func MouseRightRelease(row, col) | 111 func MouseRightRelease(row, col) |
104 call TerminalEscapeCode(3, a:row, a:col, 'm') | 112 if &ttymouse ==# 'dec' |
113 call DecEscapeCode(7, 0, a:row, a:col) | |
114 else | |
115 call TerminalEscapeCode(3, a:row, a:col, 'm') | |
116 endif | |
105 endfunc | 117 endfunc |
106 | 118 |
107 func MouseLeftDrag(row, col) | 119 func MouseLeftDrag(row, col) |
108 if &ttymouse ==# 'dec' | 120 if &ttymouse ==# 'dec' |
109 call DecEscapeCode(1, 4, a:row, a:col) | 121 call DecEscapeCode(1, 4, a:row, a:col) |
137 let row = 2 | 149 let row = 2 |
138 let col = 6 | 150 let col = 6 |
139 call MouseLeftClick(row, col) | 151 call MouseLeftClick(row, col) |
140 call MouseLeftRelease(row, col) | 152 call MouseLeftRelease(row, col) |
141 call assert_equal([0, 2, 6, 0], getpos('.'), msg) | 153 call assert_equal([0, 2, 6, 0], getpos('.'), msg) |
154 endfor | |
155 | |
156 let &mouse = save_mouse | |
157 let &term = save_term | |
158 let &ttymouse = save_ttymouse | |
159 call test_override('no_query_mouse', 0) | |
160 bwipe! | |
161 endfunc | |
162 | |
163 func Test_xterm_mouse_right_click_extends_visual() | |
164 if has('mac') | |
165 throw "Skipped: test right click in visual mode does not work on macOs (why?)" | |
166 endif | |
167 let save_mouse = &mouse | |
168 let save_term = &term | |
169 let save_ttymouse = &ttymouse | |
170 call test_override('no_query_mouse', 1) | |
171 set mouse=a term=xterm | |
172 | |
173 for visual_mode in ["v", "V", "\<C-V>"] | |
174 for ttymouse_val in s:ttymouse_values + s:ttymouse_dec | |
175 let msg = 'visual=' .. visual_mode .. ' ttymouse=' .. ttymouse_val | |
176 exe 'set ttymouse=' .. ttymouse_val | |
177 | |
178 call setline(1, repeat([repeat('-', 7)], 7)) | |
179 call MouseLeftClick(4, 4) | |
180 call MouseLeftRelease(4, 4) | |
181 exe "norm! " .. visual_mode | |
182 | |
183 " Right click extends top left of visual area. | |
184 call MouseRightClick(2, 2) | |
185 call MouseRightRelease(2, 2) | |
186 | |
187 " Right click extends bottom bottom right of visual area. | |
188 call MouseRightClick(6, 6) | |
189 call MouseRightRelease(6, 6) | |
190 norm! r1gv | |
191 | |
192 " Right click shrinks top left of visual area. | |
193 call MouseRightClick(3, 3) | |
194 call MouseRightRelease(3, 3) | |
195 | |
196 " Right click shrinks bottom right of visual area. | |
197 call MouseRightClick(5, 5) | |
198 call MouseRightRelease(5, 5) | |
199 norm! r2 | |
200 | |
201 if visual_mode ==# 'v' | |
202 call assert_equal(['-------', | |
203 \ '-111111', | |
204 \ '1122222', | |
205 \ '2222222', | |
206 \ '2222211', | |
207 \ '111111-', | |
208 \ '-------'], getline(1, '$'), msg) | |
209 elseif visual_mode ==# 'V' | |
210 call assert_equal(['-------', | |
211 \ '1111111', | |
212 \ '2222222', | |
213 \ '2222222', | |
214 \ '2222222', | |
215 \ '1111111', | |
216 \ '-------'], getline(1, '$'), msg) | |
217 else | |
218 call assert_equal(['-------', | |
219 \ '-11111-', | |
220 \ '-12221-', | |
221 \ '-12221-', | |
222 \ '-12221-', | |
223 \ '-11111-', | |
224 \ '-------'], getline(1, '$'), msg) | |
225 endif | |
226 endfor | |
142 endfor | 227 endfor |
143 | 228 |
144 let &mouse = save_mouse | 229 let &mouse = save_mouse |
145 let &term = save_term | 230 let &term = save_term |
146 let &ttymouse = save_ttymouse | 231 let &ttymouse = save_ttymouse |