Mercurial > vim
changeset 16487:a4732cdcfaaf v8.1.1247
patch 8.1.1247: urxvt mouse codes are not tested
commit https://github.com/vim/vim/commit/d0621d85a6ceb17e1e6fb17415c3f94a755aaafa
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu May 2 21:12:19 2019 +0200
patch 8.1.1247: urxvt mouse codes are not tested
Problem: Urxvt mouse codes are not tested.
Solution: Also set 'ttymouse' to "urxvt" in the termcodes test.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 02 May 2019 21:15:05 +0200 |
parents | 2a84ef3a5cde |
children | 08a98bd701fd |
files | src/testdir/test_termcodes.vim src/version.c |
diffstat | 2 files changed, 41 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_termcodes.vim +++ b/src/testdir/test_termcodes.vim @@ -7,11 +7,17 @@ endif source shared.vim +" xterm2 and sgr always work, urxvt is optional. +let s:test_ttymouse = ['xterm2', 'sgr'] +if has('mouse_urxvt') + call add(s:test_ttymouse, 'urxvt') +endif + " Helper function to emit a terminal escape code. -func TerminalEscapeCode(code_xterm, code_sgr, row, col, m) +func TerminalEscapeCode(code, row, col, m) if &ttymouse ==# 'xterm2' " need to use byte encoding here. - let str = list2str([a:code_xterm, a:col + 0x20, a:row + 0x20]) + let str = list2str([a:code + 0x20, a:col + 0x20, a:row + 0x20]) if has('iconv') let bytes = iconv(str, 'utf-8', 'latin1') else @@ -20,50 +26,52 @@ func TerminalEscapeCode(code_xterm, code endif call feedkeys("\<Esc>[M" .. bytes, 'Lx!') elseif &ttymouse ==# 'sgr' - call feedkeys(printf("\<Esc>[<%d;%d;%d%s", a:code_sgr, a:col, a:row, a:m), 'Lx!') + call feedkeys(printf("\<Esc>[<%d;%d;%d%s", a:code, a:col, a:row, a:m), 'Lx!') + elseif &ttymouse ==# 'urxvt' + call feedkeys(printf("\<Esc>[%d;%d;%dM", a:code + 0x20, a:col, a:row), 'Lx!') endif endfunc func MouseLeftClick(row, col) - call TerminalEscapeCode(0x20, 0, a:row, a:col, 'M') + call TerminalEscapeCode(0, a:row, a:col, 'M') endfunc func MouseMiddleClick(row, col) - call TerminalEscapeCode(0x21, 1, a:row, a:col, 'M') + call TerminalEscapeCode(1, a:row, a:col, 'M') endfunc func MouseCtrlLeftClick(row, col) let ctrl = 0x10 - call TerminalEscapeCode(0x20 + ctrl, 0 + ctrl, a:row, a:col, 'M') + call TerminalEscapeCode(0 + ctrl, a:row, a:col, 'M') endfunc func MouseCtrlRightClick(row, col) let ctrl = 0x10 - call TerminalEscapeCode(0x22 + ctrl, 2 + ctrl, a:row, a:col, 'M') + call TerminalEscapeCode(2 + ctrl, a:row, a:col, 'M') endfunc func MouseLeftRelease(row, col) - call TerminalEscapeCode(0x23, 3, a:row, a:col, 'm') + call TerminalEscapeCode(3, a:row, a:col, 'm') endfunc func MouseMiddleRelease(row, col) - call TerminalEscapeCode(0x23, 3, a:row, a:col, 'm') + call TerminalEscapeCode(3, a:row, a:col, 'm') endfunc func MouseRightRelease(row, col) - call TerminalEscapeCode(0x23, 3, a:row, a:col, 'm') + call TerminalEscapeCode(3, a:row, a:col, 'm') endfunc func MouseLeftDrag(row, col) - call TerminalEscapeCode(0x43, 0x20, a:row, a:col, 'M') + call TerminalEscapeCode(0x20, a:row, a:col, 'M') endfunc func MouseWheelUp(row, col) - call TerminalEscapeCode(0x40, 0x40, a:row, a:col, 'M') + call TerminalEscapeCode(0x40, a:row, a:col, 'M') endfunc func MouseWheelDown(row, col) - call TerminalEscapeCode(0x41, 0x41, a:row, a:col, 'M') + call TerminalEscapeCode(0x41, a:row, a:col, 'M') endfunc func Test_xterm_mouse_left_click() @@ -74,7 +82,7 @@ func Test_xterm_mouse_left_click() set mouse=a term=xterm call setline(1, ['line 1', 'line 2', 'line 3 is a bit longer']) - for ttymouse_val in ['xterm2', 'sgr'] + for ttymouse_val in s:test_ttymouse let msg = 'ttymouse=' .. ttymouse_val exe 'set ttymouse=' .. ttymouse_val go @@ -99,7 +107,7 @@ func Test_xterm_mouse_ctrl_click() let save_ttymouse = &ttymouse set mouse=a term=xterm - for ttymouse_val in ['xterm2', 'sgr'] + for ttymouse_val in s:test_ttymouse let msg = 'ttymouse=' .. ttymouse_val exe 'set ttymouse=' .. ttymouse_val help @@ -138,7 +146,7 @@ func Test_xterm_mouse_middle_click() let @* = 'abc' set mouse=a term=xterm - for ttymouse_val in ['xterm2', 'sgr'] + for ttymouse_val in s:test_ttymouse let msg = 'ttymouse=' .. ttymouse_val exe 'set ttymouse=' .. ttymouse_val call setline(1, ['123456789', '123456789']) @@ -179,7 +187,7 @@ func Test_xterm_mouse_wheel() set mouse=a term=xterm call setline(1, range(1, 100)) - for ttymouse_val in ['xterm2', 'sgr'] + for ttymouse_val in s:test_ttymouse let msg = 'ttymouse=' .. ttymouse_val exe 'set ttymouse=' .. ttymouse_val go @@ -215,7 +223,7 @@ func Test_xterm_mouse_drag_window_separa let save_ttymouse = &ttymouse set mouse=a term=xterm - for ttymouse_val in ['xterm2', 'sgr'] + for ttymouse_val in s:test_ttymouse let msg = 'ttymouse=' .. ttymouse_val exe 'set ttymouse=' .. ttymouse_val @@ -272,7 +280,7 @@ func Test_xterm_mouse_drag_statusline() let save_laststatus = &laststatus set mouse=a term=xterm laststatus=2 - for ttymouse_val in ['xterm2', 'sgr'] + for ttymouse_val in s:test_ttymouse let msg = 'ttymouse=' .. ttymouse_val exe 'set ttymouse=' .. ttymouse_val @@ -313,7 +321,7 @@ func Test_xterm_mouse_click_tab() set mouse=a term=xterm let row = 1 - for ttymouse_val in ['xterm2', 'sgr'] + for ttymouse_val in s:test_ttymouse let msg = 'ttymouse=' .. ttymouse_val exe 'set ttymouse=' .. ttymouse_val e Xfoo @@ -361,7 +369,7 @@ func Test_xterm_mouse_click_X_to_close_t let row = 1 let col = &columns - for ttymouse_val in ['xterm2', 'sgr'] + for ttymouse_val in s:test_ttymouse if ttymouse_val ==# 'xterm2' && col > 223 " When 'ttymouse' is 'xterm2', row/col bigger than 223 are not supported. continue @@ -407,7 +415,7 @@ func Test_xterm_mouse_drag_to_move_tab() set mouse=a term=xterm mousetime=1 let row = 1 - for ttymouse_val in ['xterm2', 'sgr'] + for ttymouse_val in s:test_ttymouse let msg = 'ttymouse=' .. ttymouse_val exe 'set ttymouse=' .. ttymouse_val e Xtab1 @@ -456,12 +464,20 @@ func Test_xterm_mouse_double_click_to_cr let row = 1 let col = 10 - for ttymouse_val in ['xterm2', 'sgr'] + let round = 0 + for ttymouse_val in s:test_ttymouse let msg = 'ttymouse=' .. ttymouse_val exe 'set ttymouse=' .. ttymouse_val e Xtab1 tabnew Xtab2 + if round > 0 + " We need to sleep, or else the first MouseLeftClick() will be + " interpreted as a spurious triple-click. + sleep 100m + endif + let round += 1 + let a = split(execute(':tabs'), "\n") call assert_equal(['Tab page 1', \ ' Xtab1', @@ -485,11 +501,6 @@ func Test_xterm_mouse_double_click_to_cr \ 'Tab page 3', \ ' Xtab2'], a, msg) - if ttymouse_val !=# 'sgr' - " We need to sleep, or else MouseLeftClick() in next loop - " iteration will be interpreted as a spurious triple-click. - sleep 100m - endif %bwipe! endfor