Bram Moolenaar | 905dd90 | 2019-04-07 14:21:47 +0200 | [diff] [blame] | 1 | " Tests for decoding escape sequences sent by the terminal. |
| 2 | |
| 3 | " This only works for Unix in a terminal |
Bram Moolenaar | 8c5a278 | 2019-08-07 23:07:07 +0200 | [diff] [blame] | 4 | source check.vim |
| 5 | CheckNotGui |
| 6 | CheckUnix |
Bram Moolenaar | 905dd90 | 2019-04-07 14:21:47 +0200 | [diff] [blame] | 7 | |
Bram Moolenaar | 564344a | 2019-04-28 13:00:12 +0200 | [diff] [blame] | 8 | source shared.vim |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 9 | source mouse.vim |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 10 | |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 11 | func Test_term_mouse_left_click() |
Bram Moolenaar | 905dd90 | 2019-04-07 14:21:47 +0200 | [diff] [blame] | 12 | new |
| 13 | let save_mouse = &mouse |
| 14 | let save_term = &term |
| 15 | let save_ttymouse = &ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 16 | call test_override('no_query_mouse', 1) |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 17 | set mouse=a term=xterm |
Bram Moolenaar | 905dd90 | 2019-04-07 14:21:47 +0200 | [diff] [blame] | 18 | call setline(1, ['line 1', 'line 2', 'line 3 is a bit longer']) |
Bram Moolenaar | 905dd90 | 2019-04-07 14:21:47 +0200 | [diff] [blame] | 19 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 20 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec + g:Ttymouse_netterm |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 21 | let msg = 'ttymouse=' .. ttymouse_val |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 22 | exe 'set ttymouse=' .. ttymouse_val |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 23 | go |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 24 | call assert_equal([0, 1, 1, 0], getpos('.'), msg) |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 25 | let row = 2 |
| 26 | let col = 6 |
| 27 | call MouseLeftClick(row, col) |
| 28 | call MouseLeftRelease(row, col) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 29 | call assert_equal([0, 2, 6, 0], getpos('.'), msg) |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 30 | endfor |
Bram Moolenaar | 905dd90 | 2019-04-07 14:21:47 +0200 | [diff] [blame] | 31 | |
| 32 | let &mouse = save_mouse |
| 33 | let &term = save_term |
| 34 | let &ttymouse = save_ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 35 | call test_override('no_query_mouse', 0) |
Bram Moolenaar | 905dd90 | 2019-04-07 14:21:47 +0200 | [diff] [blame] | 36 | bwipe! |
| 37 | endfunc |
| 38 | |
Bram Moolenaar | 6aa7523 | 2019-10-13 21:01:34 +0200 | [diff] [blame] | 39 | func Test_xterm_mouse_right_click_extends_visual() |
| 40 | if has('mac') |
| 41 | throw "Skipped: test right click in visual mode does not work on macOs (why?)" |
| 42 | endif |
| 43 | let save_mouse = &mouse |
| 44 | let save_term = &term |
| 45 | let save_ttymouse = &ttymouse |
| 46 | call test_override('no_query_mouse', 1) |
| 47 | set mouse=a term=xterm |
| 48 | |
| 49 | for visual_mode in ["v", "V", "\<C-V>"] |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 50 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec |
Bram Moolenaar | 6aa7523 | 2019-10-13 21:01:34 +0200 | [diff] [blame] | 51 | let msg = 'visual=' .. visual_mode .. ' ttymouse=' .. ttymouse_val |
| 52 | exe 'set ttymouse=' .. ttymouse_val |
| 53 | |
| 54 | call setline(1, repeat([repeat('-', 7)], 7)) |
| 55 | call MouseLeftClick(4, 4) |
| 56 | call MouseLeftRelease(4, 4) |
| 57 | exe "norm! " .. visual_mode |
| 58 | |
| 59 | " Right click extends top left of visual area. |
| 60 | call MouseRightClick(2, 2) |
| 61 | call MouseRightRelease(2, 2) |
| 62 | |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 63 | " Right click extends bottom right of visual area. |
Bram Moolenaar | 6aa7523 | 2019-10-13 21:01:34 +0200 | [diff] [blame] | 64 | call MouseRightClick(6, 6) |
| 65 | call MouseRightRelease(6, 6) |
| 66 | norm! r1gv |
| 67 | |
| 68 | " Right click shrinks top left of visual area. |
| 69 | call MouseRightClick(3, 3) |
| 70 | call MouseRightRelease(3, 3) |
| 71 | |
| 72 | " Right click shrinks bottom right of visual area. |
| 73 | call MouseRightClick(5, 5) |
| 74 | call MouseRightRelease(5, 5) |
| 75 | norm! r2 |
| 76 | |
| 77 | if visual_mode ==# 'v' |
| 78 | call assert_equal(['-------', |
| 79 | \ '-111111', |
| 80 | \ '1122222', |
| 81 | \ '2222222', |
| 82 | \ '2222211', |
| 83 | \ '111111-', |
| 84 | \ '-------'], getline(1, '$'), msg) |
| 85 | elseif visual_mode ==# 'V' |
| 86 | call assert_equal(['-------', |
| 87 | \ '1111111', |
| 88 | \ '2222222', |
| 89 | \ '2222222', |
| 90 | \ '2222222', |
| 91 | \ '1111111', |
| 92 | \ '-------'], getline(1, '$'), msg) |
| 93 | else |
| 94 | call assert_equal(['-------', |
| 95 | \ '-11111-', |
| 96 | \ '-12221-', |
| 97 | \ '-12221-', |
| 98 | \ '-12221-', |
| 99 | \ '-11111-', |
| 100 | \ '-------'], getline(1, '$'), msg) |
| 101 | endif |
| 102 | endfor |
| 103 | endfor |
| 104 | |
| 105 | let &mouse = save_mouse |
| 106 | let &term = save_term |
| 107 | let &ttymouse = save_ttymouse |
| 108 | call test_override('no_query_mouse', 0) |
| 109 | bwipe! |
| 110 | endfunc |
| 111 | |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 112 | " Test that <C-LeftMouse> jumps to help tag and <C-RightMouse> jumps back. |
| 113 | func Test_xterm_mouse_ctrl_click() |
| 114 | let save_mouse = &mouse |
| 115 | let save_term = &term |
| 116 | let save_ttymouse = &ttymouse |
| 117 | set mouse=a term=xterm |
| 118 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 119 | for ttymouse_val in g:Ttymouse_values |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 120 | let msg = 'ttymouse=' .. ttymouse_val |
| 121 | exe 'set ttymouse=' .. ttymouse_val |
| 122 | help |
| 123 | /usr_02.txt |
| 124 | norm! zt |
| 125 | let row = 1 |
| 126 | let col = 1 |
| 127 | call MouseCtrlLeftClick(row, col) |
| 128 | call MouseLeftRelease(row, col) |
| 129 | call assert_match('usr_02.txt$', bufname('%'), msg) |
Bram Moolenaar | b4367b7 | 2019-10-01 14:19:07 +0200 | [diff] [blame] | 130 | call assert_equal('*usr_02.txt*', expand('<cWORD>'), msg) |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 131 | |
| 132 | call MouseCtrlRightClick(row, col) |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 133 | call MouseRightRelease(row, col) |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 134 | call assert_match('help.txt$', bufname('%'), msg) |
Bram Moolenaar | b4367b7 | 2019-10-01 14:19:07 +0200 | [diff] [blame] | 135 | call assert_equal('|usr_02.txt|', expand('<cWORD>'), msg) |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 136 | |
| 137 | helpclose |
| 138 | endfor |
| 139 | |
| 140 | let &mouse = save_mouse |
| 141 | let &term = save_term |
| 142 | let &ttymouse = save_ttymouse |
| 143 | endfunc |
| 144 | |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 145 | func Test_term_mouse_middle_click() |
Bram Moolenaar | 52992fe | 2019-08-12 14:20:33 +0200 | [diff] [blame] | 146 | CheckFeature clipboard_working |
Bram Moolenaar | 564344a | 2019-04-28 13:00:12 +0200 | [diff] [blame] | 147 | |
Bram Moolenaar | c1b8160 | 2019-04-27 19:11:35 +0200 | [diff] [blame] | 148 | new |
| 149 | let save_mouse = &mouse |
| 150 | let save_term = &term |
| 151 | let save_ttymouse = &ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 152 | call test_override('no_query_mouse', 1) |
Bram Moolenaar | c1b8160 | 2019-04-27 19:11:35 +0200 | [diff] [blame] | 153 | let save_quotestar = @* |
| 154 | let @* = 'abc' |
| 155 | set mouse=a term=xterm |
| 156 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 157 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec |
Bram Moolenaar | c1b8160 | 2019-04-27 19:11:35 +0200 | [diff] [blame] | 158 | let msg = 'ttymouse=' .. ttymouse_val |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 159 | exe 'set ttymouse=' .. ttymouse_val |
Bram Moolenaar | c1b8160 | 2019-04-27 19:11:35 +0200 | [diff] [blame] | 160 | call setline(1, ['123456789', '123456789']) |
| 161 | |
| 162 | " Middle-click in the middle of the line pastes text where clicked. |
| 163 | let row = 1 |
| 164 | let col = 6 |
| 165 | call MouseMiddleClick(row, col) |
| 166 | call MouseMiddleRelease(row, col) |
| 167 | call assert_equal(['12345abc6789', '123456789'], getline(1, '$'), msg) |
| 168 | |
| 169 | " Middle-click beyond end of the line pastes text at the end of the line. |
| 170 | let col = 20 |
| 171 | call MouseMiddleClick(row, col) |
| 172 | call MouseMiddleRelease(row, col) |
| 173 | call assert_equal(['12345abc6789abc', '123456789'], getline(1, '$'), msg) |
| 174 | |
| 175 | " Middle-click beyond the last line pastes in the last line. |
| 176 | let row = 5 |
| 177 | let col = 3 |
| 178 | call MouseMiddleClick(row, col) |
| 179 | call MouseMiddleRelease(row, col) |
| 180 | call assert_equal(['12345abc6789abc', '12abc3456789'], getline(1, '$'), msg) |
| 181 | endfor |
| 182 | |
| 183 | let &mouse = save_mouse |
| 184 | let &term = save_term |
| 185 | let &ttymouse = save_ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 186 | call test_override('no_query_mouse', 0) |
Bram Moolenaar | c1b8160 | 2019-04-27 19:11:35 +0200 | [diff] [blame] | 187 | let @* = save_quotestar |
| 188 | bwipe! |
| 189 | endfunc |
| 190 | |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 191 | " TODO: for unclear reasons this test fails if it comes after |
| 192 | " Test_xterm_mouse_ctrl_click() |
| 193 | func Test_1xterm_mouse_wheel() |
Bram Moolenaar | 049736f | 2019-04-07 21:55:07 +0200 | [diff] [blame] | 194 | new |
| 195 | let save_mouse = &mouse |
| 196 | let save_term = &term |
| 197 | let save_ttymouse = &ttymouse |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 198 | set mouse=a term=xterm |
Bram Moolenaar | 049736f | 2019-04-07 21:55:07 +0200 | [diff] [blame] | 199 | call setline(1, range(1, 100)) |
| 200 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 201 | for ttymouse_val in g:Ttymouse_values |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 202 | let msg = 'ttymouse=' .. ttymouse_val |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 203 | exe 'set ttymouse=' .. ttymouse_val |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 204 | go |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 205 | call assert_equal(1, line('w0'), msg) |
| 206 | call assert_equal([0, 1, 1, 0], getpos('.'), msg) |
Bram Moolenaar | 049736f | 2019-04-07 21:55:07 +0200 | [diff] [blame] | 207 | |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 208 | call MouseWheelDown(1, 1) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 209 | call assert_equal(4, line('w0'), msg) |
| 210 | call assert_equal([0, 4, 1, 0], getpos('.'), msg) |
Bram Moolenaar | 049736f | 2019-04-07 21:55:07 +0200 | [diff] [blame] | 211 | |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 212 | call MouseWheelDown(1, 1) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 213 | call assert_equal(7, line('w0'), msg) |
| 214 | call assert_equal([0, 7, 1, 0], getpos('.'), msg) |
Bram Moolenaar | 049736f | 2019-04-07 21:55:07 +0200 | [diff] [blame] | 215 | |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 216 | call MouseWheelUp(1, 1) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 217 | call assert_equal(4, line('w0'), msg) |
| 218 | call assert_equal([0, 7, 1, 0], getpos('.'), msg) |
Bram Moolenaar | 049736f | 2019-04-07 21:55:07 +0200 | [diff] [blame] | 219 | |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 220 | call MouseWheelUp(1, 1) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 221 | call assert_equal(1, line('w0'), msg) |
| 222 | call assert_equal([0, 7, 1, 0], getpos('.'), msg) |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 223 | endfor |
Bram Moolenaar | 049736f | 2019-04-07 21:55:07 +0200 | [diff] [blame] | 224 | |
| 225 | let &mouse = save_mouse |
| 226 | let &term = save_term |
| 227 | let &ttymouse = save_ttymouse |
| 228 | bwipe! |
| 229 | endfunc |
Bram Moolenaar | 3fb01a5 | 2019-04-09 21:52:02 +0200 | [diff] [blame] | 230 | |
Bram Moolenaar | b4367b7 | 2019-10-01 14:19:07 +0200 | [diff] [blame] | 231 | " Test that dragging beyond the window (at the bottom and at the top) |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 232 | " scrolls window content by the number of lines beyond the window. |
Bram Moolenaar | b4367b7 | 2019-10-01 14:19:07 +0200 | [diff] [blame] | 233 | func Test_term_mouse_drag_beyond_window() |
| 234 | let save_mouse = &mouse |
| 235 | let save_term = &term |
| 236 | let save_ttymouse = &ttymouse |
| 237 | call test_override('no_query_mouse', 1) |
| 238 | set mouse=a term=xterm |
| 239 | let col = 1 |
| 240 | call setline(1, range(1, 100)) |
| 241 | |
| 242 | " Split into 3 windows, and go into the middle window |
| 243 | " so we test dragging mouse below and above the window. |
| 244 | 2split |
| 245 | wincmd j |
| 246 | 2split |
| 247 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 248 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec |
Bram Moolenaar | b4367b7 | 2019-10-01 14:19:07 +0200 | [diff] [blame] | 249 | let msg = 'ttymouse=' .. ttymouse_val |
| 250 | exe 'set ttymouse=' .. ttymouse_val |
| 251 | |
| 252 | " Line #10 at the top. |
| 253 | norm! 10zt |
| 254 | redraw |
| 255 | call assert_equal(10, winsaveview().topline, msg) |
| 256 | call assert_equal(2, winheight(0), msg) |
| 257 | |
| 258 | let row = 4 |
| 259 | call MouseLeftClick(row, col) |
| 260 | call assert_equal(10, winsaveview().topline, msg) |
| 261 | |
| 262 | " Drag downwards. We're still in the window so topline should |
| 263 | " not change yet. |
| 264 | let row += 1 |
| 265 | call MouseLeftDrag(row, col) |
| 266 | call assert_equal(10, winsaveview().topline, msg) |
| 267 | |
| 268 | " We now leave the window at the bottom, so the window content should |
| 269 | " scroll by 1 line, then 2 lines (etc) as we drag further away. |
| 270 | let row += 1 |
| 271 | call MouseLeftDrag(row, col) |
| 272 | call assert_equal(11, winsaveview().topline, msg) |
| 273 | |
| 274 | let row += 1 |
| 275 | call MouseLeftDrag(row, col) |
| 276 | call assert_equal(13, winsaveview().topline, msg) |
| 277 | |
| 278 | " Now drag upwards. |
| 279 | let row -= 1 |
| 280 | call MouseLeftDrag(row, col) |
| 281 | call assert_equal(14, winsaveview().topline, msg) |
| 282 | |
| 283 | " We're now back in the window so the topline should not change. |
| 284 | let row -= 1 |
| 285 | call MouseLeftDrag(row, col) |
| 286 | call assert_equal(14, winsaveview().topline, msg) |
| 287 | |
| 288 | let row -= 1 |
| 289 | call MouseLeftDrag(row, col) |
| 290 | call assert_equal(14, winsaveview().topline, msg) |
| 291 | |
| 292 | " We now leave the window at the top so the window content should |
| 293 | " scroll by 1 line, then 2, then 3 (etc) in the opposite direction. |
| 294 | let row -= 1 |
| 295 | call MouseLeftDrag(row, col) |
| 296 | call assert_equal(13, winsaveview().topline, msg) |
| 297 | |
| 298 | let row -= 1 |
| 299 | call MouseLeftDrag(row, col) |
| 300 | call assert_equal(11, winsaveview().topline, msg) |
| 301 | |
| 302 | let row -= 1 |
| 303 | call MouseLeftDrag(row, col) |
| 304 | call assert_equal(8, winsaveview().topline, msg) |
| 305 | |
| 306 | call MouseLeftRelease(row, col) |
| 307 | call assert_equal(8, winsaveview().topline, msg) |
| 308 | call assert_equal(2, winheight(0), msg) |
| 309 | endfor |
| 310 | |
| 311 | let &mouse = save_mouse |
| 312 | let &term = save_term |
| 313 | let &ttymouse = save_ttymouse |
| 314 | call test_override('no_query_mouse', 0) |
| 315 | bwipe! |
| 316 | endfunc |
| 317 | |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 318 | func Test_term_mouse_drag_window_separator() |
Bram Moolenaar | 3fb01a5 | 2019-04-09 21:52:02 +0200 | [diff] [blame] | 319 | let save_mouse = &mouse |
| 320 | let save_term = &term |
| 321 | let save_ttymouse = &ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 322 | call test_override('no_query_mouse', 1) |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 323 | set mouse=a term=xterm |
Bram Moolenaar | 3fb01a5 | 2019-04-09 21:52:02 +0200 | [diff] [blame] | 324 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 325 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 326 | let msg = 'ttymouse=' .. ttymouse_val |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 327 | exe 'set ttymouse=' .. ttymouse_val |
Bram Moolenaar | 3fb01a5 | 2019-04-09 21:52:02 +0200 | [diff] [blame] | 328 | |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 329 | " Split horizontally and test dragging the horizontal window separator. |
| 330 | split |
| 331 | let rowseparator = winheight(0) + 1 |
| 332 | let row = rowseparator |
| 333 | let col = 1 |
Bram Moolenaar | c8b3dda | 2019-04-12 21:42:52 +0200 | [diff] [blame] | 334 | |
Bram Moolenaar | 2b00b9b | 2019-04-17 17:08:27 +0200 | [diff] [blame] | 335 | " When 'ttymouse' is 'xterm2', row/col bigger than 223 are not supported. |
| 336 | if ttymouse_val !=# 'xterm2' || row <= 223 |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 337 | call MouseLeftClick(row, col) |
| 338 | let row -= 1 |
| 339 | call MouseLeftDrag(row, col) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 340 | call assert_equal(rowseparator - 1, winheight(0) + 1, msg) |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 341 | let row += 1 |
| 342 | call MouseLeftDrag(row, col) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 343 | call assert_equal(rowseparator, winheight(0) + 1, msg) |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 344 | call MouseLeftRelease(row, col) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 345 | call assert_equal(rowseparator, winheight(0) + 1, msg) |
Bram Moolenaar | c8b3dda | 2019-04-12 21:42:52 +0200 | [diff] [blame] | 346 | endif |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 347 | bwipe! |
Bram Moolenaar | 3fb01a5 | 2019-04-09 21:52:02 +0200 | [diff] [blame] | 348 | |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 349 | " Split vertically and test dragging the vertical window separator. |
| 350 | vsplit |
| 351 | let colseparator = winwidth(0) + 1 |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 352 | let row = 1 |
| 353 | let col = colseparator |
Bram Moolenaar | 3fb01a5 | 2019-04-09 21:52:02 +0200 | [diff] [blame] | 354 | |
Bram Moolenaar | 2b00b9b | 2019-04-17 17:08:27 +0200 | [diff] [blame] | 355 | " When 'ttymouse' is 'xterm2', row/col bigger than 223 are not supported. |
| 356 | if ttymouse_val !=# 'xterm2' || col <= 223 |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 357 | call MouseLeftClick(row, col) |
| 358 | let col -= 1 |
| 359 | call MouseLeftDrag(row, col) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 360 | call assert_equal(colseparator - 1, winwidth(0) + 1, msg) |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 361 | let col += 1 |
| 362 | call MouseLeftDrag(row, col) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 363 | call assert_equal(colseparator, winwidth(0) + 1, msg) |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 364 | call MouseLeftRelease(row, col) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 365 | call assert_equal(colseparator, winwidth(0) + 1, msg) |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 366 | endif |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 367 | bwipe! |
| 368 | endfor |
Bram Moolenaar | 3fb01a5 | 2019-04-09 21:52:02 +0200 | [diff] [blame] | 369 | |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 370 | let &mouse = save_mouse |
| 371 | let &term = save_term |
| 372 | let &ttymouse = save_ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 373 | call test_override('no_query_mouse', 0) |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 374 | endfunc |
Bram Moolenaar | 3fb01a5 | 2019-04-09 21:52:02 +0200 | [diff] [blame] | 375 | |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 376 | func Test_term_mouse_drag_statusline() |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 377 | let save_mouse = &mouse |
| 378 | let save_term = &term |
| 379 | let save_ttymouse = &ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 380 | call test_override('no_query_mouse', 1) |
Bram Moolenaar | ca57ab5 | 2019-04-13 14:53:16 +0200 | [diff] [blame] | 381 | let save_laststatus = &laststatus |
| 382 | set mouse=a term=xterm laststatus=2 |
Bram Moolenaar | 3fb01a5 | 2019-04-09 21:52:02 +0200 | [diff] [blame] | 383 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 384 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 385 | let msg = 'ttymouse=' .. ttymouse_val |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 386 | exe 'set ttymouse=' .. ttymouse_val |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 387 | |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 388 | call assert_equal(1, &cmdheight, msg) |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 389 | let rowstatusline = winheight(0) + 1 |
| 390 | let row = rowstatusline |
| 391 | let col = 1 |
Bram Moolenaar | c8b3dda | 2019-04-12 21:42:52 +0200 | [diff] [blame] | 392 | |
Bram Moolenaar | 2b00b9b | 2019-04-17 17:08:27 +0200 | [diff] [blame] | 393 | if ttymouse_val ==# 'xterm2' && row > 223 |
| 394 | " When 'ttymouse' is 'xterm2', row/col bigger than 223 are not supported. |
Bram Moolenaar | c8b3dda | 2019-04-12 21:42:52 +0200 | [diff] [blame] | 395 | continue |
| 396 | endif |
| 397 | |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 398 | call MouseLeftClick(row, col) |
| 399 | let row -= 1 |
| 400 | call MouseLeftDrag(row, col) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 401 | call assert_equal(2, &cmdheight, msg) |
| 402 | call assert_equal(rowstatusline - 1, winheight(0) + 1, msg) |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 403 | let row += 1 |
| 404 | call MouseLeftDrag(row, col) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 405 | call assert_equal(1, &cmdheight, msg) |
| 406 | call assert_equal(rowstatusline, winheight(0) + 1, msg) |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 407 | call MouseLeftRelease(row, col) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 408 | call assert_equal(1, &cmdheight, msg) |
| 409 | call assert_equal(rowstatusline, winheight(0) + 1, msg) |
Bram Moolenaar | 3fbd2d7 | 2019-04-11 23:56:16 +0200 | [diff] [blame] | 410 | endfor |
| 411 | |
Bram Moolenaar | 3fb01a5 | 2019-04-09 21:52:02 +0200 | [diff] [blame] | 412 | let &mouse = save_mouse |
| 413 | let &term = save_term |
| 414 | let &ttymouse = save_ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 415 | call test_override('no_query_mouse', 0) |
Bram Moolenaar | ca57ab5 | 2019-04-13 14:53:16 +0200 | [diff] [blame] | 416 | let &laststatus = save_laststatus |
| 417 | endfunc |
| 418 | |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 419 | func Test_term_mouse_click_tab() |
Bram Moolenaar | ca57ab5 | 2019-04-13 14:53:16 +0200 | [diff] [blame] | 420 | let save_mouse = &mouse |
| 421 | let save_term = &term |
| 422 | let save_ttymouse = &ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 423 | call test_override('no_query_mouse', 1) |
Bram Moolenaar | ca57ab5 | 2019-04-13 14:53:16 +0200 | [diff] [blame] | 424 | set mouse=a term=xterm |
| 425 | let row = 1 |
| 426 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 427 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec + g:Ttymouse_netterm |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 428 | let msg = 'ttymouse=' .. ttymouse_val |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 429 | exe 'set ttymouse=' .. ttymouse_val |
Bram Moolenaar | ca57ab5 | 2019-04-13 14:53:16 +0200 | [diff] [blame] | 430 | e Xfoo |
| 431 | tabnew Xbar |
| 432 | |
| 433 | let a = split(execute(':tabs'), "\n") |
| 434 | call assert_equal(['Tab page 1', |
| 435 | \ ' Xfoo', |
| 436 | \ 'Tab page 2', |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 437 | \ '> Xbar'], a, msg) |
Bram Moolenaar | ca57ab5 | 2019-04-13 14:53:16 +0200 | [diff] [blame] | 438 | |
| 439 | " Test clicking on tab names in the tabline at the top. |
| 440 | let col = 2 |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 441 | redraw |
Bram Moolenaar | ca57ab5 | 2019-04-13 14:53:16 +0200 | [diff] [blame] | 442 | call MouseLeftClick(row, col) |
| 443 | call MouseLeftRelease(row, col) |
| 444 | let a = split(execute(':tabs'), "\n") |
| 445 | call assert_equal(['Tab page 1', |
| 446 | \ '> Xfoo', |
| 447 | \ 'Tab page 2', |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 448 | \ ' Xbar'], a, msg) |
Bram Moolenaar | ca57ab5 | 2019-04-13 14:53:16 +0200 | [diff] [blame] | 449 | |
| 450 | let col = 9 |
| 451 | call MouseLeftClick(row, col) |
| 452 | call MouseLeftRelease(row, col) |
| 453 | let a = split(execute(':tabs'), "\n") |
| 454 | call assert_equal(['Tab page 1', |
| 455 | \ ' Xfoo', |
| 456 | \ 'Tab page 2', |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 457 | \ '> Xbar'], a, msg) |
Bram Moolenaar | ca57ab5 | 2019-04-13 14:53:16 +0200 | [diff] [blame] | 458 | |
| 459 | %bwipe! |
| 460 | endfor |
| 461 | |
| 462 | let &mouse = save_mouse |
| 463 | let &term = save_term |
| 464 | let &ttymouse = save_ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 465 | call test_override('no_query_mouse', 0) |
Bram Moolenaar | 3fb01a5 | 2019-04-09 21:52:02 +0200 | [diff] [blame] | 466 | endfunc |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 467 | |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 468 | func Test_term_mouse_click_X_to_close_tab() |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 469 | let save_mouse = &mouse |
| 470 | let save_term = &term |
| 471 | let save_ttymouse = &ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 472 | call test_override('no_query_mouse', 1) |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 473 | set mouse=a term=xterm |
| 474 | let row = 1 |
| 475 | let col = &columns |
| 476 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 477 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec + g:Ttymouse_netterm |
Bram Moolenaar | 2b00b9b | 2019-04-17 17:08:27 +0200 | [diff] [blame] | 478 | if ttymouse_val ==# 'xterm2' && col > 223 |
| 479 | " When 'ttymouse' is 'xterm2', row/col bigger than 223 are not supported. |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 480 | continue |
| 481 | endif |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 482 | let msg = 'ttymouse=' .. ttymouse_val |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 483 | exe 'set ttymouse=' .. ttymouse_val |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 484 | e Xtab1 |
| 485 | tabnew Xtab2 |
| 486 | tabnew Xtab3 |
| 487 | tabn 2 |
| 488 | |
| 489 | let a = split(execute(':tabs'), "\n") |
| 490 | call assert_equal(['Tab page 1', |
| 491 | \ ' Xtab1', |
| 492 | \ 'Tab page 2', |
| 493 | \ '> Xtab2', |
| 494 | \ 'Tab page 3', |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 495 | \ ' Xtab3'], a, msg) |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 496 | |
| 497 | " Click on "X" in tabline to close current tab i.e. Xtab2. |
| 498 | redraw |
| 499 | call MouseLeftClick(row, col) |
| 500 | call MouseLeftRelease(row, col) |
| 501 | let a = split(execute(':tabs'), "\n") |
| 502 | call assert_equal(['Tab page 1', |
| 503 | \ ' Xtab1', |
| 504 | \ 'Tab page 2', |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 505 | \ '> Xtab3'], a, msg) |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 506 | |
| 507 | %bwipe! |
| 508 | endfor |
| 509 | |
| 510 | let &mouse = save_mouse |
| 511 | let &term = save_term |
| 512 | let &ttymouse = save_ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 513 | call test_override('no_query_mouse', 0) |
Bram Moolenaar | 39f76c6 | 2019-04-13 22:13:23 +0200 | [diff] [blame] | 514 | endfunc |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 515 | |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 516 | func Test_term_mouse_drag_to_move_tab() |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 517 | let save_mouse = &mouse |
| 518 | let save_term = &term |
| 519 | let save_ttymouse = &ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 520 | call test_override('no_query_mouse', 1) |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 521 | " Set 'mousetime' to 1 to avoid recognizing a double-click in the loop |
| 522 | set mouse=a term=xterm mousetime=1 |
| 523 | let row = 1 |
| 524 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 525 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 526 | let msg = 'ttymouse=' .. ttymouse_val |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 527 | exe 'set ttymouse=' .. ttymouse_val |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 528 | e Xtab1 |
| 529 | tabnew Xtab2 |
| 530 | |
| 531 | let a = split(execute(':tabs'), "\n") |
| 532 | call assert_equal(['Tab page 1', |
| 533 | \ ' Xtab1', |
| 534 | \ 'Tab page 2', |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 535 | \ '> Xtab2'], a, msg) |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 536 | redraw |
| 537 | |
| 538 | " Click in tab2 and drag it to tab1. |
| 539 | " Check getcharmod() to verify that click is not |
| 540 | " interpreted as a spurious double-click. |
| 541 | call MouseLeftClick(row, 10) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 542 | call assert_equal(0, getcharmod(), msg) |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 543 | for col in [9, 8, 7, 6] |
| 544 | call MouseLeftDrag(row, col) |
| 545 | endfor |
| 546 | call MouseLeftRelease(row, col) |
| 547 | let a = split(execute(':tabs'), "\n") |
| 548 | call assert_equal(['Tab page 1', |
| 549 | \ '> Xtab2', |
| 550 | \ 'Tab page 2', |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 551 | \ ' Xtab1'], a, msg) |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 552 | |
Bram Moolenaar | f36a2c7 | 2019-11-16 18:57:16 +0100 | [diff] [blame] | 553 | " Click elsewhere so that click in next iteration is not |
| 554 | " interpreted as unwanted double-click. |
| 555 | call MouseLeftClick(row, 11) |
| 556 | call MouseLeftRelease(row, 11) |
| 557 | |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 558 | %bwipe! |
| 559 | endfor |
| 560 | |
| 561 | let &mouse = save_mouse |
| 562 | let &term = save_term |
| 563 | let &ttymouse = save_ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 564 | call test_override('no_query_mouse', 0) |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 565 | set mousetime& |
| 566 | endfunc |
| 567 | |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 568 | func Test_term_mouse_double_click_to_create_tab() |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 569 | let save_mouse = &mouse |
| 570 | let save_term = &term |
| 571 | let save_ttymouse = &ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 572 | call test_override('no_query_mouse', 1) |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 573 | " Set 'mousetime' to a small value, so that double-click works but we don't |
| 574 | " have to wait long to avoid a triple-click. |
Bram Moolenaar | f36a2c7 | 2019-11-16 18:57:16 +0100 | [diff] [blame] | 575 | set mouse=a term=xterm mousetime=200 |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 576 | let row = 1 |
| 577 | let col = 10 |
| 578 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 579 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 580 | let msg = 'ttymouse=' .. ttymouse_val |
Bram Moolenaar | 1ee36d6 | 2019-05-01 23:13:56 +0200 | [diff] [blame] | 581 | exe 'set ttymouse=' .. ttymouse_val |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 582 | e Xtab1 |
| 583 | tabnew Xtab2 |
| 584 | |
| 585 | let a = split(execute(':tabs'), "\n") |
| 586 | call assert_equal(['Tab page 1', |
| 587 | \ ' Xtab1', |
| 588 | \ 'Tab page 2', |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 589 | \ '> Xtab2'], a, msg) |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 590 | |
| 591 | redraw |
| 592 | call MouseLeftClick(row, col) |
| 593 | " Check getcharmod() to verify that first click is not |
| 594 | " interpreted as a spurious double-click. |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 595 | call assert_equal(0, getcharmod(), msg) |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 596 | call MouseLeftRelease(row, col) |
| 597 | call MouseLeftClick(row, col) |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 598 | call assert_equal(32, getcharmod(), msg) " double-click |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 599 | call MouseLeftRelease(row, col) |
| 600 | let a = split(execute(':tabs'), "\n") |
| 601 | call assert_equal(['Tab page 1', |
| 602 | \ ' Xtab1', |
| 603 | \ 'Tab page 2', |
| 604 | \ '> [No Name]', |
| 605 | \ 'Tab page 3', |
Bram Moolenaar | 4945219 | 2019-04-17 16:27:02 +0200 | [diff] [blame] | 606 | \ ' Xtab2'], a, msg) |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 607 | |
Bram Moolenaar | f36a2c7 | 2019-11-16 18:57:16 +0100 | [diff] [blame] | 608 | " Click elsewhere so that click in next iteration is not |
| 609 | " interpreted as unwanted double click. |
| 610 | call MouseLeftClick(row, col + 1) |
| 611 | call MouseLeftRelease(row, col + 1) |
| 612 | |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 613 | %bwipe! |
| 614 | endfor |
| 615 | |
| 616 | let &mouse = save_mouse |
| 617 | let &term = save_term |
| 618 | let &ttymouse = save_ttymouse |
Bram Moolenaar | 92fd599 | 2019-05-02 23:00:22 +0200 | [diff] [blame] | 619 | call test_override('no_query_mouse', 0) |
Bram Moolenaar | e3e3828 | 2019-04-15 20:55:31 +0200 | [diff] [blame] | 620 | set mousetime& |
| 621 | endfunc |
Bram Moolenaar | 696d637 | 2019-04-17 16:33:46 +0200 | [diff] [blame] | 622 | |
Bram Moolenaar | f36a2c7 | 2019-11-16 18:57:16 +0100 | [diff] [blame] | 623 | " Test double/triple/quadruple click in normal mode to visually select. |
| 624 | func Test_term_mouse_multiple_clicks_to_visually_select() |
| 625 | let save_mouse = &mouse |
| 626 | let save_term = &term |
| 627 | let save_ttymouse = &ttymouse |
| 628 | call test_override('no_query_mouse', 1) |
| 629 | set mouse=a term=xterm mousetime=200 |
| 630 | new |
| 631 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 632 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec |
Bram Moolenaar | f36a2c7 | 2019-11-16 18:57:16 +0100 | [diff] [blame] | 633 | let msg = 'ttymouse=' .. ttymouse_val |
| 634 | exe 'set ttymouse=' .. ttymouse_val |
| 635 | call setline(1, ['foo [foo bar] foo', 'foo']) |
| 636 | |
| 637 | " Double-click on word should visually select the word. |
| 638 | call MouseLeftClick(1, 2) |
| 639 | call assert_equal(0, getcharmod(), msg) |
| 640 | call MouseLeftRelease(1, 2) |
| 641 | call MouseLeftClick(1, 2) |
| 642 | call assert_equal(32, getcharmod(), msg) " double-click |
| 643 | call MouseLeftRelease(1, 2) |
| 644 | call assert_equal('v', mode(), msg) |
| 645 | norm! r1 |
| 646 | call assert_equal(['111 [foo bar] foo', 'foo'], getline(1, '$'), msg) |
| 647 | |
| 648 | " Double-click on opening square bracket should visually |
| 649 | " select the whole [foo bar]. |
| 650 | call MouseLeftClick(1, 5) |
| 651 | call assert_equal(0, getcharmod(), msg) |
| 652 | call MouseLeftRelease(1, 5) |
| 653 | call MouseLeftClick(1, 5) |
| 654 | call assert_equal(32, getcharmod(), msg) " double-click |
| 655 | call MouseLeftRelease(1, 5) |
| 656 | call assert_equal('v', mode(), msg) |
| 657 | norm! r2 |
| 658 | call assert_equal(['111 222222222 foo', 'foo'], getline(1, '$'), msg) |
| 659 | |
| 660 | " Triple-click should visually select the whole line. |
| 661 | call MouseLeftClick(1, 3) |
| 662 | call assert_equal(0, getcharmod(), msg) |
| 663 | call MouseLeftRelease(1, 3) |
| 664 | call MouseLeftClick(1, 3) |
| 665 | call assert_equal(32, getcharmod(), msg) " double-click |
| 666 | call MouseLeftRelease(1, 3) |
| 667 | call MouseLeftClick(1, 3) |
| 668 | call assert_equal(64, getcharmod(), msg) " triple-click |
| 669 | call MouseLeftRelease(1, 3) |
| 670 | call assert_equal('V', mode(), msg) |
| 671 | norm! r3 |
| 672 | call assert_equal(['33333333333333333', 'foo'], getline(1, '$'), msg) |
| 673 | |
| 674 | " Quadruple-click should start visual block select. |
| 675 | call MouseLeftClick(1, 2) |
| 676 | call assert_equal(0, getcharmod(), msg) |
| 677 | call MouseLeftRelease(1, 2) |
| 678 | call MouseLeftClick(1, 2) |
| 679 | call assert_equal(32, getcharmod(), msg) " double-click |
| 680 | call MouseLeftRelease(1, 2) |
| 681 | call MouseLeftClick(1, 2) |
| 682 | call assert_equal(64, getcharmod(), msg) " triple-click |
| 683 | call MouseLeftRelease(1, 2) |
| 684 | call MouseLeftClick(1, 2) |
| 685 | call assert_equal(96, getcharmod(), msg) " quadruple-click |
| 686 | call MouseLeftRelease(1, 2) |
| 687 | call assert_equal("\<c-v>", mode(), msg) |
| 688 | norm! r4 |
| 689 | call assert_equal(['34333333333333333', 'foo'], getline(1, '$'), msg) |
| 690 | endfor |
| 691 | |
| 692 | let &mouse = save_mouse |
| 693 | let &term = save_term |
| 694 | let &ttymouse = save_ttymouse |
| 695 | set mousetime& |
| 696 | call test_override('no_query_mouse', 0) |
| 697 | bwipe! |
| 698 | endfunc |
| 699 | |
Bram Moolenaar | 696d637 | 2019-04-17 16:33:46 +0200 | [diff] [blame] | 700 | func Test_xterm_mouse_click_in_fold_columns() |
| 701 | new |
| 702 | let save_mouse = &mouse |
| 703 | let save_term = &term |
| 704 | let save_ttymouse = &ttymouse |
| 705 | let save_foldcolumn = &foldcolumn |
Bram Moolenaar | 2b00b9b | 2019-04-17 17:08:27 +0200 | [diff] [blame] | 706 | set mouse=a term=xterm foldcolumn=3 ttymouse=xterm2 |
Bram Moolenaar | 696d637 | 2019-04-17 16:33:46 +0200 | [diff] [blame] | 707 | |
| 708 | " Create 2 nested folds. |
| 709 | call setline(1, range(1, 7)) |
| 710 | 2,6fold |
| 711 | norm! zR |
| 712 | 4,5fold |
| 713 | call assert_equal([-1, -1, -1, 4, 4, -1, -1], |
| 714 | \ map(range(1, 7), 'foldclosed(v:val)')) |
| 715 | |
| 716 | " Click in "+" of inner fold in foldcolumn should open it. |
| 717 | redraw |
| 718 | let row = 4 |
| 719 | let col = 2 |
| 720 | call MouseLeftClick(row, col) |
| 721 | call MouseLeftRelease(row, col) |
| 722 | call assert_equal([-1, -1, -1, -1, -1, -1, -1], |
| 723 | \ map(range(1, 7), 'foldclosed(v:val)')) |
| 724 | |
| 725 | " Click in "-" of outer fold in foldcolumn should close it. |
| 726 | redraw |
| 727 | let row = 2 |
| 728 | let col = 1 |
| 729 | call MouseLeftClick(row, col) |
| 730 | call MouseLeftRelease(row, col) |
| 731 | call assert_equal([-1, 2, 2, 2, 2, 2, -1], |
| 732 | \ map(range(1, 7), 'foldclosed(v:val)')) |
| 733 | norm! zR |
| 734 | |
| 735 | " Click in "|" of inner fold in foldcolumn should close it. |
| 736 | redraw |
| 737 | let row = 5 |
| 738 | let col = 2 |
| 739 | call MouseLeftClick(row, col) |
| 740 | call MouseLeftRelease(row, col) |
| 741 | call assert_equal([-1, -1, -1, 4, 4, -1, -1], |
| 742 | \ map(range(1, 7), 'foldclosed(v:val)')) |
| 743 | |
| 744 | let &foldcolumn = save_foldcolumn |
| 745 | let &ttymouse = save_ttymouse |
| 746 | let &term = save_term |
| 747 | let &mouse = save_mouse |
| 748 | bwipe! |
| 749 | endfunc |
Bram Moolenaar | 66761db | 2019-06-05 22:07:51 +0200 | [diff] [blame] | 750 | |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 751 | " Left or right click in Ex command line sets position of the cursor. |
| 752 | func Test_term_mouse_click_in_cmdline_to_set_pos() |
| 753 | let save_mouse = &mouse |
| 754 | let save_term = &term |
| 755 | let save_ttymouse = &ttymouse |
| 756 | call test_override('no_query_mouse', 1) |
| 757 | set mouse=a term=xterm |
| 758 | let row = &lines |
| 759 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 760 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec |
Bram Moolenaar | ab505b1 | 2020-03-23 19:28:44 +0100 | [diff] [blame] | 761 | " When 'ttymouse' is 'xterm2', row/col bigger than 223 are not supported. |
| 762 | if ttymouse_val !=# 'xterm2' || row <= 223 |
| 763 | let msg = 'ttymouse=' .. ttymouse_val |
| 764 | exe 'set ttymouse=' .. ttymouse_val |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 765 | |
Bram Moolenaar | ab505b1 | 2020-03-23 19:28:44 +0100 | [diff] [blame] | 766 | |
| 767 | call feedkeys(':"3456789' |
| 768 | \ .. MouseLeftClickCode(row, 7) |
| 769 | \ .. MouseLeftReleaseCode(row, 7) .. 'L' |
| 770 | \ .. MouseRightClickCode(row, 4) |
| 771 | \ .. MouseRightReleaseCode(row, 4) .. 'R' |
| 772 | \ .. "\<CR>", 'Lx!') |
| 773 | call assert_equal('"3R456L789', @:, msg) |
| 774 | endif |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 775 | endfor |
| 776 | |
| 777 | let &mouse = save_mouse |
| 778 | let &term = save_term |
| 779 | let &ttymouse = save_ttymouse |
| 780 | set mousetime& |
| 781 | call test_override('no_query_mouse', 0) |
| 782 | endfunc |
| 783 | |
| 784 | " Middle click in command line pastes at position of cursor. |
| 785 | func Test_term_mouse_middle_click_in_cmdline_to_paste() |
| 786 | CheckFeature clipboard_working |
| 787 | let save_mouse = &mouse |
| 788 | let save_term = &term |
| 789 | let save_ttymouse = &ttymouse |
| 790 | call test_override('no_query_mouse', 1) |
| 791 | set mouse=a term=xterm |
| 792 | let row = &lines |
| 793 | " Column values does not matter, paste is done at position of cursor. |
| 794 | let col = 1 |
| 795 | let @* = 'paste' |
| 796 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 797 | for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 798 | let msg = 'ttymouse=' .. ttymouse_val |
| 799 | exe 'set ttymouse=' .. ttymouse_val |
| 800 | |
| 801 | call feedkeys(":\"->" |
| 802 | \ .. MouseMiddleReleaseCode(row, col) |
| 803 | \ .. MouseMiddleClickCode(row, col) |
| 804 | \ .. "<-" |
| 805 | \ .. MouseMiddleReleaseCode(row, col) |
| 806 | \ .. MouseMiddleClickCode(row, col) |
| 807 | \ .. "\<CR>", 'Lx!') |
| 808 | call assert_equal('"->paste<-paste', @:, msg) |
| 809 | endfor |
| 810 | |
| 811 | let &mouse = save_mouse |
| 812 | let &term = save_term |
| 813 | let &ttymouse = save_ttymouse |
| 814 | let @* = '' |
| 815 | call test_override('no_query_mouse', 0) |
| 816 | endfunc |
| 817 | |
Bram Moolenaar | 0eabd4d | 2020-03-15 16:13:53 +0100 | [diff] [blame] | 818 | " Test for displaying the popup menu using the right mouse click |
| 819 | func Test_mouse_popup_menu() |
| 820 | CheckFeature menu |
| 821 | new |
| 822 | call setline(1, 'popup menu test') |
| 823 | let save_mouse = &mouse |
| 824 | let save_term = &term |
| 825 | let save_ttymouse = &ttymouse |
| 826 | let save_mousemodel = &mousemodel |
| 827 | call test_override('no_query_mouse', 1) |
| 828 | set mouse=a term=xterm mousemodel=popup |
| 829 | |
| 830 | menu PopUp.foo :let g:menustr = 'foo'<CR> |
| 831 | menu PopUp.bar :let g:menustr = 'bar'<CR> |
| 832 | menu PopUp.baz :let g:menustr = 'baz'<CR> |
| 833 | |
Bram Moolenaar | 515545e | 2020-03-22 14:08:59 +0100 | [diff] [blame] | 834 | for ttymouse_val in g:Ttymouse_values |
Bram Moolenaar | 0eabd4d | 2020-03-15 16:13:53 +0100 | [diff] [blame] | 835 | exe 'set ttymouse=' .. ttymouse_val |
| 836 | let g:menustr = '' |
| 837 | call feedkeys(MouseRightClickCode(1, 4) |
| 838 | \ .. MouseRightReleaseCode(1, 4) .. "\<Down>\<Down>\<CR>", "x") |
| 839 | call assert_equal('bar', g:menustr) |
| 840 | endfor |
| 841 | |
| 842 | unmenu PopUp |
| 843 | let &mouse = save_mouse |
| 844 | let &term = save_term |
| 845 | let &ttymouse = save_ttymouse |
| 846 | let &mousemodel = save_mousemodel |
| 847 | call test_override('no_query_mouse', 0) |
| 848 | close! |
| 849 | endfunc |
| 850 | |
Bram Moolenaar | 66761db | 2019-06-05 22:07:51 +0200 | [diff] [blame] | 851 | " This only checks if the sequence is recognized. |
Bram Moolenaar | 66761db | 2019-06-05 22:07:51 +0200 | [diff] [blame] | 852 | func Test_term_rgb_response() |
| 853 | set t_RF=x |
| 854 | set t_RB=y |
| 855 | |
| 856 | " response to t_RF, 4 digits |
| 857 | let red = 0x12 |
| 858 | let green = 0x34 |
| 859 | let blue = 0x56 |
| 860 | let seq = printf("\<Esc>]10;rgb:%02x00/%02x00/%02x00\x07", red, green, blue) |
| 861 | call feedkeys(seq, 'Lx!') |
| 862 | call assert_equal(seq, v:termrfgresp) |
| 863 | |
| 864 | " response to t_RF, 2 digits |
| 865 | let red = 0x78 |
| 866 | let green = 0x9a |
| 867 | let blue = 0xbc |
| 868 | let seq = printf("\<Esc>]10;rgb:%02x/%02x/%02x\x07", red, green, blue) |
| 869 | call feedkeys(seq, 'Lx!') |
| 870 | call assert_equal(seq, v:termrfgresp) |
| 871 | |
Bram Moolenaar | 32e1977 | 2019-06-05 22:57:04 +0200 | [diff] [blame] | 872 | " response to t_RB, 4 digits, dark |
| 873 | set background=light |
Bram Moolenaar | ce90e36 | 2019-09-08 18:58:44 +0200 | [diff] [blame] | 874 | eval 'background'->test_option_not_set() |
Bram Moolenaar | 32e1977 | 2019-06-05 22:57:04 +0200 | [diff] [blame] | 875 | let red = 0x29 |
| 876 | let green = 0x4a |
| 877 | let blue = 0x6b |
| 878 | let seq = printf("\<Esc>]11;rgb:%02x00/%02x00/%02x00\x07", red, green, blue) |
| 879 | call feedkeys(seq, 'Lx!') |
| 880 | call assert_equal(seq, v:termrbgresp) |
| 881 | call assert_equal('dark', &background) |
| 882 | |
| 883 | " response to t_RB, 4 digits, light |
| 884 | set background=dark |
| 885 | call test_option_not_set('background') |
| 886 | let red = 0x81 |
| 887 | let green = 0x63 |
Bram Moolenaar | 66761db | 2019-06-05 22:07:51 +0200 | [diff] [blame] | 888 | let blue = 0x65 |
| 889 | let seq = printf("\<Esc>]11;rgb:%02x00/%02x00/%02x00\x07", red, green, blue) |
| 890 | call feedkeys(seq, 'Lx!') |
| 891 | call assert_equal(seq, v:termrbgresp) |
Bram Moolenaar | 32e1977 | 2019-06-05 22:57:04 +0200 | [diff] [blame] | 892 | call assert_equal('light', &background) |
Bram Moolenaar | 66761db | 2019-06-05 22:07:51 +0200 | [diff] [blame] | 893 | |
Bram Moolenaar | 32e1977 | 2019-06-05 22:57:04 +0200 | [diff] [blame] | 894 | " response to t_RB, 2 digits, dark |
| 895 | set background=light |
| 896 | call test_option_not_set('background') |
| 897 | let red = 0x47 |
| 898 | let green = 0x59 |
| 899 | let blue = 0x5b |
Bram Moolenaar | 66761db | 2019-06-05 22:07:51 +0200 | [diff] [blame] | 900 | let seq = printf("\<Esc>]11;rgb:%02x/%02x/%02x\x07", red, green, blue) |
| 901 | call feedkeys(seq, 'Lx!') |
| 902 | call assert_equal(seq, v:termrbgresp) |
Bram Moolenaar | 32e1977 | 2019-06-05 22:57:04 +0200 | [diff] [blame] | 903 | call assert_equal('dark', &background) |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 904 | |
Bram Moolenaar | 32e1977 | 2019-06-05 22:57:04 +0200 | [diff] [blame] | 905 | " response to t_RB, 2 digits, light |
| 906 | set background=dark |
| 907 | call test_option_not_set('background') |
| 908 | let red = 0x83 |
| 909 | let green = 0xa4 |
| 910 | let blue = 0xc2 |
| 911 | let seq = printf("\<Esc>]11;rgb:%02x/%02x/%02x\x07", red, green, blue) |
| 912 | call feedkeys(seq, 'Lx!') |
| 913 | call assert_equal(seq, v:termrbgresp) |
| 914 | call assert_equal('light', &background) |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 915 | |
Bram Moolenaar | 66761db | 2019-06-05 22:07:51 +0200 | [diff] [blame] | 916 | set t_RF= t_RB= |
| 917 | endfunc |
| 918 | |
| 919 | " This only checks if the sequence is recognized. |
Bram Moolenaar | 1a4cbb1 | 2019-10-12 13:25:44 +0200 | [diff] [blame] | 920 | " This must be after other tests, because it has side effects to xterm |
| 921 | " properties. |
| 922 | func Test_xx01_term_style_response() |
Bram Moolenaar | 66761db | 2019-06-05 22:07:51 +0200 | [diff] [blame] | 923 | " Termresponse is only parsed when t_RV is not empty. |
| 924 | set t_RV=x |
| 925 | |
| 926 | " send the termresponse to trigger requesting the XT codes |
| 927 | let seq = "\<Esc>[>41;337;0c" |
| 928 | call feedkeys(seq, 'Lx!') |
| 929 | call assert_equal(seq, v:termresponse) |
| 930 | |
| 931 | let seq = "\<Esc>P1$r2 q\<Esc>\\" |
| 932 | call feedkeys(seq, 'Lx!') |
| 933 | call assert_equal(seq, v:termstyleresp) |
| 934 | |
| 935 | set t_RV= |
| 936 | endfunc |
Bram Moolenaar | de6dbb4 | 2019-06-06 11:59:18 +0200 | [diff] [blame] | 937 | |
Bram Moolenaar | 89577b3 | 2019-10-18 21:26:05 +0200 | [diff] [blame] | 938 | " This checks the iTerm2 version response. |
| 939 | " This must be after other tests, because it has side effects to xterm |
| 940 | " properties. |
| 941 | func Test_xx02_iTerm2_response() |
| 942 | " Termresponse is only parsed when t_RV is not empty. |
| 943 | set t_RV=x |
| 944 | |
| 945 | " Old versions of iTerm2 used a different style term response. |
| 946 | set ttymouse=xterm |
| 947 | call test_option_not_set('ttymouse') |
| 948 | let seq = "\<Esc>[>0;95;c" |
| 949 | call feedkeys(seq, 'Lx!') |
| 950 | call assert_equal(seq, v:termresponse) |
| 951 | call assert_equal('xterm', &ttymouse) |
| 952 | |
| 953 | set ttymouse=xterm |
| 954 | call test_option_not_set('ttymouse') |
| 955 | let seq = "\<Esc>[>0;95;0c" |
| 956 | call feedkeys(seq, 'Lx!') |
| 957 | call assert_equal(seq, v:termresponse) |
| 958 | call assert_equal('sgr', &ttymouse) |
| 959 | |
| 960 | set t_RV= |
| 961 | endfunc |
| 962 | |
Bram Moolenaar | 1a4cbb1 | 2019-10-12 13:25:44 +0200 | [diff] [blame] | 963 | " This checks the libvterm version response. |
| 964 | " This must be after other tests, because it has side effects to xterm |
| 965 | " properties. |
Bram Moolenaar | 89577b3 | 2019-10-18 21:26:05 +0200 | [diff] [blame] | 966 | func Test_xx03_libvterm_response() |
Bram Moolenaar | 1a4cbb1 | 2019-10-12 13:25:44 +0200 | [diff] [blame] | 967 | " Termresponse is only parsed when t_RV is not empty. |
| 968 | set t_RV=x |
Bram Moolenaar | 03b0047 | 2019-10-14 22:22:03 +0200 | [diff] [blame] | 969 | |
Bram Moolenaar | 1a4cbb1 | 2019-10-12 13:25:44 +0200 | [diff] [blame] | 970 | set ttymouse=xterm |
| 971 | call test_option_not_set('ttymouse') |
Bram Moolenaar | 1a4cbb1 | 2019-10-12 13:25:44 +0200 | [diff] [blame] | 972 | let seq = "\<Esc>[>0;100;0c" |
| 973 | call feedkeys(seq, 'Lx!') |
| 974 | call assert_equal(seq, v:termresponse) |
| 975 | call assert_equal('sgr', &ttymouse) |
| 976 | |
| 977 | set t_RV= |
| 978 | endfunc |
| 979 | |
Bram Moolenaar | 89577b3 | 2019-10-18 21:26:05 +0200 | [diff] [blame] | 980 | " This checks the Mac Terminal.app version response. |
| 981 | " This must be after other tests, because it has side effects to xterm |
| 982 | " properties. |
| 983 | func Test_xx04_Mac_Terminal_response() |
| 984 | " Termresponse is only parsed when t_RV is not empty. |
| 985 | set t_RV=x |
| 986 | |
| 987 | set ttymouse=xterm |
| 988 | call test_option_not_set('ttymouse') |
| 989 | let seq = "\<Esc>[>1;95;0c" |
| 990 | call feedkeys(seq, 'Lx!') |
| 991 | call assert_equal(seq, v:termresponse) |
| 992 | call assert_equal('sgr', &ttymouse) |
| 993 | |
| 994 | " Reset is_not_xterm and is_mac_terminal. |
| 995 | set t_RV= |
| 996 | set term=xterm |
| 997 | set t_RV=x |
| 998 | endfunc |
| 999 | |
| 1000 | " This checks the mintty version response. |
| 1001 | " This must be after other tests, because it has side effects to xterm |
| 1002 | " properties. |
| 1003 | func Test_xx05_mintty_response() |
| 1004 | " Termresponse is only parsed when t_RV is not empty. |
| 1005 | set t_RV=x |
| 1006 | |
| 1007 | set ttymouse=xterm |
| 1008 | call test_option_not_set('ttymouse') |
| 1009 | let seq = "\<Esc>[>77;20905;0c" |
| 1010 | call feedkeys(seq, 'Lx!') |
| 1011 | call assert_equal(seq, v:termresponse) |
| 1012 | call assert_equal('sgr', &ttymouse) |
| 1013 | |
| 1014 | set t_RV= |
| 1015 | endfunc |
| 1016 | |
| 1017 | " This checks the screen version response. |
| 1018 | " This must be after other tests, because it has side effects to xterm |
| 1019 | " properties. |
| 1020 | func Test_xx06_screen_response() |
| 1021 | " Termresponse is only parsed when t_RV is not empty. |
| 1022 | set t_RV=x |
| 1023 | |
| 1024 | " Old versions of screen don't support SGR mouse mode. |
| 1025 | set ttymouse=xterm |
| 1026 | call test_option_not_set('ttymouse') |
| 1027 | let seq = "\<Esc>[>83;40500;0c" |
| 1028 | call feedkeys(seq, 'Lx!') |
| 1029 | call assert_equal(seq, v:termresponse) |
| 1030 | call assert_equal('xterm', &ttymouse) |
| 1031 | |
| 1032 | " screen supports SGR mouse mode starting in version 4.7. |
| 1033 | set ttymouse=xterm |
| 1034 | call test_option_not_set('ttymouse') |
| 1035 | let seq = "\<Esc>[>83;40700;0c" |
| 1036 | call feedkeys(seq, 'Lx!') |
| 1037 | call assert_equal(seq, v:termresponse) |
| 1038 | call assert_equal('sgr', &ttymouse) |
| 1039 | |
| 1040 | set t_RV= |
| 1041 | endfunc |
| 1042 | |
Bram Moolenaar | 03b0047 | 2019-10-14 22:22:03 +0200 | [diff] [blame] | 1043 | " This checks the xterm version response. |
| 1044 | " This must be after other tests, because it has side effects to xterm |
| 1045 | " properties. |
Bram Moolenaar | 89577b3 | 2019-10-18 21:26:05 +0200 | [diff] [blame] | 1046 | func Test_xx07_xterm_response() |
Bram Moolenaar | 03b0047 | 2019-10-14 22:22:03 +0200 | [diff] [blame] | 1047 | " Termresponse is only parsed when t_RV is not empty. |
| 1048 | set t_RV=x |
| 1049 | |
Bram Moolenaar | 3cea8a9 | 2019-10-17 21:55:24 +0200 | [diff] [blame] | 1050 | " Do Terminal.app first to check that is_mac_terminal is reset. |
| 1051 | set ttymouse=xterm |
| 1052 | call test_option_not_set('ttymouse') |
| 1053 | let seq = "\<Esc>[>1;95;0c" |
| 1054 | call feedkeys(seq, 'Lx!') |
| 1055 | call assert_equal(seq, v:termresponse) |
| 1056 | call assert_equal('sgr', &ttymouse) |
| 1057 | |
Bram Moolenaar | 03b0047 | 2019-10-14 22:22:03 +0200 | [diff] [blame] | 1058 | " xterm < 95: "xterm" (actually unmodified) |
Bram Moolenaar | 3cea8a9 | 2019-10-17 21:55:24 +0200 | [diff] [blame] | 1059 | set t_RV= |
| 1060 | set term=xterm |
| 1061 | set t_RV=x |
Bram Moolenaar | 03b0047 | 2019-10-14 22:22:03 +0200 | [diff] [blame] | 1062 | set ttymouse=xterm |
| 1063 | call test_option_not_set('ttymouse') |
| 1064 | let seq = "\<Esc>[>0;94;0c" |
| 1065 | call feedkeys(seq, 'Lx!') |
| 1066 | call assert_equal(seq, v:termresponse) |
| 1067 | call assert_equal('xterm', &ttymouse) |
| 1068 | |
| 1069 | " xterm >= 95 < 277 "xterm2" |
| 1070 | set ttymouse=xterm |
| 1071 | call test_option_not_set('ttymouse') |
| 1072 | let seq = "\<Esc>[>0;267;0c" |
| 1073 | call feedkeys(seq, 'Lx!') |
| 1074 | call assert_equal(seq, v:termresponse) |
| 1075 | call assert_equal('xterm2', &ttymouse) |
| 1076 | |
| 1077 | " xterm >= 277: "sgr" |
| 1078 | set ttymouse=xterm |
| 1079 | call test_option_not_set('ttymouse') |
| 1080 | let seq = "\<Esc>[>0;277;0c" |
| 1081 | call feedkeys(seq, 'Lx!') |
| 1082 | call assert_equal(seq, v:termresponse) |
| 1083 | call assert_equal('sgr', &ttymouse) |
| 1084 | |
| 1085 | set t_RV= |
| 1086 | endfunc |
| 1087 | |
Bram Moolenaar | de6dbb4 | 2019-06-06 11:59:18 +0200 | [diff] [blame] | 1088 | func Test_get_termcode() |
Bram Moolenaar | eb66328 | 2019-10-06 12:02:15 +0200 | [diff] [blame] | 1089 | try |
| 1090 | let k1 = &t_k1 |
| 1091 | catch /E113/ |
| 1092 | throw 'Skipped: Unable to query termcodes' |
| 1093 | endtry |
Bram Moolenaar | de6dbb4 | 2019-06-06 11:59:18 +0200 | [diff] [blame] | 1094 | set t_k1= |
| 1095 | set t_k1& |
| 1096 | call assert_equal(k1, &t_k1) |
Bram Moolenaar | 9aeb336 | 2019-06-06 12:36:15 +0200 | [diff] [blame] | 1097 | |
| 1098 | " use external termcap first |
| 1099 | set nottybuiltin |
| 1100 | set t_k1= |
| 1101 | set t_k1& |
| 1102 | " when using external termcap may get something else, but it must not be |
| 1103 | " empty, since we would fallback to the builtin one. |
| 1104 | call assert_notequal('', &t_k1) |
| 1105 | |
| 1106 | if &term =~ 'xterm' |
| 1107 | " use internal termcap first |
| 1108 | let term_save = &term |
| 1109 | let &term = 'builtin_' .. &term |
| 1110 | set t_k1= |
| 1111 | set t_k1& |
| 1112 | call assert_equal(k1, &t_k1) |
| 1113 | let &term = term_save |
| 1114 | endif |
| 1115 | |
| 1116 | set ttybuiltin |
Bram Moolenaar | de6dbb4 | 2019-06-06 11:59:18 +0200 | [diff] [blame] | 1117 | endfunc |
Bram Moolenaar | 18a79a6 | 2019-10-12 15:36:11 +0200 | [diff] [blame] | 1118 | |
| 1119 | func GetEscCodeCSI27(key, modifier) |
| 1120 | let key = printf("%d", char2nr(a:key)) |
| 1121 | let mod = printf("%d", a:modifier) |
| 1122 | return "\<Esc>[27;" .. mod .. ';' .. key .. '~' |
| 1123 | endfunc |
| 1124 | |
| 1125 | func GetEscCodeCSIu(key, modifier) |
| 1126 | let key = printf("%d", char2nr(a:key)) |
| 1127 | let mod = printf("%d", a:modifier) |
| 1128 | return "\<Esc>[" .. key .. ';' .. mod .. 'u' |
| 1129 | endfunc |
| 1130 | |
| 1131 | " This checks the CSI sequences when in modifyOtherKeys mode. |
| 1132 | " The mode doesn't need to be enabled, the codes are always detected. |
| 1133 | func RunTest_modifyOtherKeys(func) |
| 1134 | new |
Bram Moolenaar | 459fd78 | 2019-10-13 16:43:39 +0200 | [diff] [blame] | 1135 | set timeoutlen=10 |
Bram Moolenaar | 18a79a6 | 2019-10-12 15:36:11 +0200 | [diff] [blame] | 1136 | |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 1137 | " Shift-X is sent as 'X' with the shift modifier |
Bram Moolenaar | 18a79a6 | 2019-10-12 15:36:11 +0200 | [diff] [blame] | 1138 | call feedkeys('a' .. a:func('X', 2) .. "\<Esc>", 'Lx!') |
| 1139 | call assert_equal('X', getline(1)) |
| 1140 | |
| 1141 | " Ctrl-i is Tab |
| 1142 | call setline(1, '') |
| 1143 | call feedkeys('a' .. a:func('i', 5) .. "\<Esc>", 'Lx!') |
| 1144 | call assert_equal("\t", getline(1)) |
| 1145 | |
| 1146 | " Ctrl-I is also Tab |
| 1147 | call setline(1, '') |
| 1148 | call feedkeys('a' .. a:func('I', 5) .. "\<Esc>", 'Lx!') |
| 1149 | call assert_equal("\t", getline(1)) |
| 1150 | |
| 1151 | " Alt-x is ø |
| 1152 | call setline(1, '') |
| 1153 | call feedkeys('a' .. a:func('x', 3) .. "\<Esc>", 'Lx!') |
| 1154 | call assert_equal("ø", getline(1)) |
| 1155 | |
| 1156 | " Meta-x is also ø |
| 1157 | call setline(1, '') |
| 1158 | call feedkeys('a' .. a:func('x', 9) .. "\<Esc>", 'Lx!') |
| 1159 | call assert_equal("ø", getline(1)) |
| 1160 | |
| 1161 | " Alt-X is Ø |
| 1162 | call setline(1, '') |
| 1163 | call feedkeys('a' .. a:func('X', 3) .. "\<Esc>", 'Lx!') |
| 1164 | call assert_equal("Ø", getline(1)) |
| 1165 | |
| 1166 | " Meta-X is ø |
| 1167 | call setline(1, '') |
| 1168 | call feedkeys('a' .. a:func('X', 9) .. "\<Esc>", 'Lx!') |
| 1169 | call assert_equal("Ø", getline(1)) |
| 1170 | |
Bram Moolenaar | 828ffd5 | 2019-11-21 23:24:00 +0100 | [diff] [blame] | 1171 | " Ctrl-6 is Ctrl-^ |
| 1172 | split aaa |
| 1173 | edit bbb |
| 1174 | call feedkeys(a:func('6', 5), 'Lx!') |
| 1175 | call assert_equal("aaa", bufname()) |
| 1176 | bwipe aaa |
| 1177 | bwipe bbb |
| 1178 | |
Bram Moolenaar | 18a79a6 | 2019-10-12 15:36:11 +0200 | [diff] [blame] | 1179 | bwipe! |
| 1180 | set timeoutlen& |
| 1181 | endfunc |
| 1182 | |
Bram Moolenaar | 459fd78 | 2019-10-13 16:43:39 +0200 | [diff] [blame] | 1183 | func Test_modifyOtherKeys_basic() |
Bram Moolenaar | 18a79a6 | 2019-10-12 15:36:11 +0200 | [diff] [blame] | 1184 | call RunTest_modifyOtherKeys(function('GetEscCodeCSI27')) |
Bram Moolenaar | 18a79a6 | 2019-10-12 15:36:11 +0200 | [diff] [blame] | 1185 | call RunTest_modifyOtherKeys(function('GetEscCodeCSIu')) |
| 1186 | endfunc |
Bram Moolenaar | d1e2f39 | 2019-10-12 18:22:50 +0200 | [diff] [blame] | 1187 | |
Bram Moolenaar | 38571a0 | 2019-11-26 14:28:15 +0100 | [diff] [blame] | 1188 | func Test_modifyOtherKeys_no_mapping() |
| 1189 | set timeoutlen=10 |
| 1190 | |
| 1191 | let @a = 'aaa' |
| 1192 | call feedkeys(":let x = '" .. GetEscCodeCSI27('R', 5) .. GetEscCodeCSI27('R', 5) .. "a'\<CR>", 'Lx!') |
| 1193 | call assert_equal("let x = 'aaa'", @:) |
| 1194 | |
| 1195 | new |
| 1196 | call feedkeys("a" .. GetEscCodeCSI27('R', 5) .. GetEscCodeCSI27('R', 5) .. "a\<Esc>", 'Lx!') |
| 1197 | call assert_equal("aaa", getline(1)) |
| 1198 | bwipe! |
| 1199 | |
| 1200 | new |
| 1201 | call feedkeys("axx\<CR>yy" .. GetEscCodeCSI27('G', 5) .. GetEscCodeCSI27('K', 5) .. "a\<Esc>", 'Lx!') |
| 1202 | call assert_equal("axx", getline(1)) |
| 1203 | call assert_equal("yy", getline(2)) |
| 1204 | bwipe! |
| 1205 | |
| 1206 | set timeoutlen& |
| 1207 | endfunc |
| 1208 | |
Bram Moolenaar | d1e2f39 | 2019-10-12 18:22:50 +0200 | [diff] [blame] | 1209 | func RunTest_mapping_shift(key, func) |
| 1210 | call setline(1, '') |
| 1211 | if a:key == '|' |
| 1212 | exe 'inoremap \| xyz' |
| 1213 | else |
| 1214 | exe 'inoremap ' .. a:key .. ' xyz' |
| 1215 | endif |
| 1216 | call feedkeys('a' .. a:func(a:key, 2) .. "\<Esc>", 'Lx!') |
| 1217 | call assert_equal("xyz", getline(1)) |
| 1218 | if a:key == '|' |
| 1219 | exe 'iunmap \|' |
| 1220 | else |
| 1221 | exe 'iunmap ' .. a:key |
| 1222 | endif |
| 1223 | endfunc |
| 1224 | |
| 1225 | func RunTest_mapping_works_with_shift(func) |
| 1226 | new |
Bram Moolenaar | 459fd78 | 2019-10-13 16:43:39 +0200 | [diff] [blame] | 1227 | set timeoutlen=10 |
Bram Moolenaar | d1e2f39 | 2019-10-12 18:22:50 +0200 | [diff] [blame] | 1228 | |
| 1229 | call RunTest_mapping_shift('@', a:func) |
| 1230 | call RunTest_mapping_shift('A', a:func) |
| 1231 | call RunTest_mapping_shift('Z', a:func) |
| 1232 | call RunTest_mapping_shift('^', a:func) |
| 1233 | call RunTest_mapping_shift('_', a:func) |
| 1234 | call RunTest_mapping_shift('{', a:func) |
| 1235 | call RunTest_mapping_shift('|', a:func) |
| 1236 | call RunTest_mapping_shift('}', a:func) |
| 1237 | call RunTest_mapping_shift('~', a:func) |
| 1238 | |
| 1239 | bwipe! |
| 1240 | set timeoutlen& |
| 1241 | endfunc |
| 1242 | |
Bram Moolenaar | 459fd78 | 2019-10-13 16:43:39 +0200 | [diff] [blame] | 1243 | func Test_mapping_works_with_shift_plain() |
Bram Moolenaar | d1e2f39 | 2019-10-12 18:22:50 +0200 | [diff] [blame] | 1244 | call RunTest_mapping_works_with_shift(function('GetEscCodeCSI27')) |
| 1245 | call RunTest_mapping_works_with_shift(function('GetEscCodeCSIu')) |
| 1246 | endfunc |
Bram Moolenaar | 459fd78 | 2019-10-13 16:43:39 +0200 | [diff] [blame] | 1247 | |
| 1248 | func RunTest_mapping_mods(map, key, func, code) |
| 1249 | call setline(1, '') |
| 1250 | exe 'inoremap ' .. a:map .. ' xyz' |
| 1251 | call feedkeys('a' .. a:func(a:key, a:code) .. "\<Esc>", 'Lx!') |
| 1252 | call assert_equal("xyz", getline(1)) |
| 1253 | exe 'iunmap ' .. a:map |
| 1254 | endfunc |
| 1255 | |
| 1256 | func RunTest_mapping_works_with_mods(func, mods, code) |
| 1257 | new |
| 1258 | set timeoutlen=10 |
| 1259 | |
| 1260 | if a:mods !~ 'S' |
| 1261 | " Shift by itself has no effect |
| 1262 | call RunTest_mapping_mods('<' .. a:mods .. '-@>', '@', a:func, a:code) |
| 1263 | endif |
| 1264 | call RunTest_mapping_mods('<' .. a:mods .. '-A>', 'A', a:func, a:code) |
| 1265 | call RunTest_mapping_mods('<' .. a:mods .. '-Z>', 'Z', a:func, a:code) |
| 1266 | if a:mods !~ 'S' |
| 1267 | " with Shift code is always upper case |
| 1268 | call RunTest_mapping_mods('<' .. a:mods .. '-a>', 'a', a:func, a:code) |
| 1269 | call RunTest_mapping_mods('<' .. a:mods .. '-z>', 'z', a:func, a:code) |
| 1270 | endif |
| 1271 | if a:mods != 'A' |
| 1272 | " with Alt code is not in upper case |
| 1273 | call RunTest_mapping_mods('<' .. a:mods .. '-a>', 'A', a:func, a:code) |
| 1274 | call RunTest_mapping_mods('<' .. a:mods .. '-z>', 'Z', a:func, a:code) |
| 1275 | endif |
| 1276 | call RunTest_mapping_mods('<' .. a:mods .. '-á>', 'á', a:func, a:code) |
| 1277 | if a:mods !~ 'S' |
| 1278 | " Shift by itself has no effect |
| 1279 | call RunTest_mapping_mods('<' .. a:mods .. '-^>', '^', a:func, a:code) |
| 1280 | call RunTest_mapping_mods('<' .. a:mods .. '-_>', '_', a:func, a:code) |
| 1281 | call RunTest_mapping_mods('<' .. a:mods .. '-{>', '{', a:func, a:code) |
| 1282 | call RunTest_mapping_mods('<' .. a:mods .. '-\|>', '|', a:func, a:code) |
| 1283 | call RunTest_mapping_mods('<' .. a:mods .. '-}>', '}', a:func, a:code) |
| 1284 | call RunTest_mapping_mods('<' .. a:mods .. '-~>', '~', a:func, a:code) |
| 1285 | endif |
| 1286 | |
| 1287 | bwipe! |
| 1288 | set timeoutlen& |
| 1289 | endfunc |
| 1290 | |
| 1291 | func Test_mapping_works_with_shift() |
| 1292 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSI27'), 'S', 2) |
| 1293 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSIu'), 'S', 2) |
| 1294 | endfunc |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 1295 | |
Bram Moolenaar | 459fd78 | 2019-10-13 16:43:39 +0200 | [diff] [blame] | 1296 | func Test_mapping_works_with_ctrl() |
| 1297 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSI27'), 'C', 5) |
| 1298 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSIu'), 'C', 5) |
| 1299 | endfunc |
| 1300 | |
| 1301 | func Test_mapping_works_with_shift_ctrl() |
| 1302 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSI27'), 'C-S', 6) |
| 1303 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSIu'), 'C-S', 6) |
| 1304 | endfunc |
| 1305 | |
| 1306 | " Below we also test the "u" code with Alt, This works, but libvterm would not |
| 1307 | " send the Alt key like this but by prefixing an Esc. |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 1308 | |
Bram Moolenaar | 459fd78 | 2019-10-13 16:43:39 +0200 | [diff] [blame] | 1309 | func Test_mapping_works_with_alt() |
| 1310 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSI27'), 'A', 3) |
| 1311 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSIu'), 'A', 3) |
| 1312 | endfunc |
| 1313 | |
| 1314 | func Test_mapping_works_with_shift_alt() |
| 1315 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSI27'), 'S-A', 4) |
| 1316 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSIu'), 'S-A', 4) |
| 1317 | endfunc |
| 1318 | |
| 1319 | func Test_mapping_works_with_ctrl_alt() |
| 1320 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSI27'), 'C-A', 7) |
| 1321 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSIu'), 'C-A', 7) |
| 1322 | endfunc |
| 1323 | |
| 1324 | func Test_mapping_works_with_shift_ctrl_alt() |
| 1325 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSI27'), 'C-S-A', 8) |
| 1326 | call RunTest_mapping_works_with_mods(function('GetEscCodeCSIu'), 'C-S-A', 8) |
| 1327 | endfunc |
Bram Moolenaar | fc4ea2a | 2019-11-26 19:33:22 +0100 | [diff] [blame] | 1328 | |
| 1329 | func Test_insert_literal() |
| 1330 | set timeoutlen=10 |
| 1331 | new |
| 1332 | " CTRL-V CTRL-X inserts a ^X |
| 1333 | call feedkeys('a' .. GetEscCodeCSIu('V', '5') .. GetEscCodeCSIu('X', '5') .. "\<Esc>", 'Lx!') |
| 1334 | call assert_equal("\<C-X>", getline(1)) |
| 1335 | |
| 1336 | call setline(1, '') |
| 1337 | call feedkeys('a' .. GetEscCodeCSI27('V', '5') .. GetEscCodeCSI27('X', '5') .. "\<Esc>", 'Lx!') |
| 1338 | call assert_equal("\<C-X>", getline(1)) |
| 1339 | |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 1340 | " CTRL-SHIFT-V CTRL-X inserts escape sequence |
Bram Moolenaar | fc4ea2a | 2019-11-26 19:33:22 +0100 | [diff] [blame] | 1341 | call setline(1, '') |
| 1342 | call feedkeys('a' .. GetEscCodeCSIu('V', '6') .. GetEscCodeCSIu('X', '5') .. "\<Esc>", 'Lx!') |
| 1343 | call assert_equal("\<Esc>[88;5u", getline(1)) |
| 1344 | |
| 1345 | call setline(1, '') |
| 1346 | call feedkeys('a' .. GetEscCodeCSI27('V', '6') .. GetEscCodeCSI27('X', '5') .. "\<Esc>", 'Lx!') |
| 1347 | call assert_equal("\<Esc>[27;5;88~", getline(1)) |
| 1348 | |
| 1349 | bwipe! |
| 1350 | set timeoutlen& |
| 1351 | endfunc |
| 1352 | |
| 1353 | func Test_cmdline_literal() |
| 1354 | set timeoutlen=10 |
| 1355 | |
| 1356 | " CTRL-V CTRL-Y inserts a ^Y |
| 1357 | call feedkeys(':' .. GetEscCodeCSIu('V', '5') .. GetEscCodeCSIu('Y', '5') .. "\<C-B>\"\<CR>", 'Lx!') |
| 1358 | call assert_equal("\"\<C-Y>", @:) |
| 1359 | |
| 1360 | call feedkeys(':' .. GetEscCodeCSI27('V', '5') .. GetEscCodeCSI27('Y', '5') .. "\<C-B>\"\<CR>", 'Lx!') |
| 1361 | call assert_equal("\"\<C-Y>", @:) |
| 1362 | |
Bram Moolenaar | f19f8d1 | 2019-12-18 19:36:23 +0100 | [diff] [blame] | 1363 | " CTRL-SHIFT-V CTRL-Y inserts escape sequence |
Bram Moolenaar | fc4ea2a | 2019-11-26 19:33:22 +0100 | [diff] [blame] | 1364 | call feedkeys(':' .. GetEscCodeCSIu('V', '6') .. GetEscCodeCSIu('Y', '5') .. "\<C-B>\"\<CR>", 'Lx!') |
| 1365 | call assert_equal("\"\<Esc>[89;5u", @:) |
| 1366 | |
| 1367 | call setline(1, '') |
| 1368 | call feedkeys(':' .. GetEscCodeCSI27('V', '6') .. GetEscCodeCSI27('Y', '5') .. "\<C-B>\"\<CR>", 'Lx!') |
| 1369 | call assert_equal("\"\<Esc>[27;5;89~", @:) |
| 1370 | |
| 1371 | set timeoutlen& |
| 1372 | endfunc |
Bram Moolenaar | 0eabd4d | 2020-03-15 16:13:53 +0100 | [diff] [blame] | 1373 | |
Bram Moolenaar | 0ff5ded | 2020-05-07 18:43:44 +0200 | [diff] [blame] | 1374 | " Test for translation of special key codes (<xF1>, <xF2>, etc.) |
| 1375 | func Test_Keycode_Tranlsation() |
| 1376 | let keycodes = [ |
| 1377 | \ ["<xUp>", "<Up>"], |
| 1378 | \ ["<xDown>", "<Down>"], |
| 1379 | \ ["<xLeft>", "<Left>"], |
| 1380 | \ ["<xRight>", "<Right>"], |
| 1381 | \ ["<xHome>", "<Home>"], |
| 1382 | \ ["<xEnd>", "<End>"], |
| 1383 | \ ["<zHome>", "<Home>"], |
| 1384 | \ ["<zEnd>", "<End>"], |
| 1385 | \ ["<xF1>", "<F1>"], |
| 1386 | \ ["<xF2>", "<F2>"], |
| 1387 | \ ["<xF3>", "<F3>"], |
| 1388 | \ ["<xF4>", "<F4>"], |
| 1389 | \ ["<S-xF1>", "<S-F1>"], |
| 1390 | \ ["<S-xF2>", "<S-F2>"], |
| 1391 | \ ["<S-xF3>", "<S-F3>"], |
| 1392 | \ ["<S-xF4>", "<S-F4>"]] |
| 1393 | for [k1, k2] in keycodes |
| 1394 | exe "nnoremap " .. k1 .. " 2wx" |
| 1395 | call assert_true(maparg(k1, 'n', 0, 1).lhs == k2) |
| 1396 | exe "nunmap " .. k1 |
| 1397 | endfor |
| 1398 | endfunc |
| 1399 | |
Bram Moolenaar | 0eabd4d | 2020-03-15 16:13:53 +0100 | [diff] [blame] | 1400 | " vim: shiftwidth=2 sts=2 expandtab |