Mercurial > vim
changeset 16263:d3377393e3d9 v8.1.1136
patch 8.1.1136: decoding of mouse click escape sequence is not tested
commit https://github.com/vim/vim/commit/905dd905debfde403b2a18178ccc1f8e118f4f2b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 7 14:21:47 2019 +0200
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Problem: Decoding of mouse click escape sequence is not tested.
Solution: Add a test for xterm and SGR using low-level input. Make
low-level input execution with feedkeys() work.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 07 Apr 2019 14:30:06 +0200 |
parents | b7cd0dd5cad2 |
children | c9aaabbfa627 |
files | src/evalfunc.c src/ex_docmd.c src/testdir/Make_all.mak src/testdir/test_termcodes.vim src/version.c |
diffstat | 5 files changed, 57 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3792,7 +3792,7 @@ f_feedkeys(typval_T *argvars, typval_T * if (!dangerous) ++ex_normal_busy; - exec_normal(TRUE, FALSE, TRUE); + exec_normal(TRUE, lowlevel, TRUE); if (!dangerous) --ex_normal_busy;
--- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -10487,12 +10487,15 @@ exec_normal_cmd(char_u *cmd, int remap, exec_normal(int was_typed, int use_vpeekc, int may_use_terminal_loop UNUSED) { oparg_T oa; - + int c; + + // When calling vpeekc() from feedkeys() it will return Ctrl_C when there + // is nothing to get, so also check for Ctrl_C. clear_oparg(&oa); finish_op = FALSE; while ((!stuff_empty() || ((was_typed || !typebuf_typed()) && typebuf.tb_len > 0) - || (use_vpeekc && vpeekc() != NUL)) + || (use_vpeekc && (c = vpeekc()) != NUL && c != Ctrl_C)) && !got_int) { update_topline_cursor();
--- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -250,6 +250,7 @@ NEW_TESTS = \ test_taglist \ test_tcl \ test_termencoding \ + test_termcodes \ test_terminal \ test_terminal_fail \ test_textformat \ @@ -402,6 +403,7 @@ NEW_TESTS_RES = \ test_tab.res \ test_tcl.res \ test_termencoding.res \ + test_termcodes.res \ test_terminal.res \ test_terminal_fail.res \ test_textformat.res \
new file mode 100644 --- /dev/null +++ b/src/testdir/test_termcodes.vim @@ -0,0 +1,47 @@ +" Tests for decoding escape sequences sent by the terminal. + +" This only works for Unix in a terminal +if has('gui_running') || !has('unix') + finish +endif + +func Test_xterm_mouse_click() + new + let save_mouse = &mouse + let save_term = &term + let save_ttymouse = &ttymouse + set mouse=a + set term=xterm + call setline(1, ['line 1', 'line 2', 'line 3 is a bit longer']) + redraw + + " Xterm mouse click + set ttymouse=xterm + let button = 0x20 " left down + let row = 2 + 32 + let col = 6 + 32 + call feedkeys("\<Esc>[M" .. list2str([button, col, row]), 'Lx!') + + let button = 0x23 " release + call feedkeys("\<Esc>[M" .. list2str([button, col, row]), 'Lx!') + + call assert_equal([0, 2, 6, 0], getpos('.')) + + " SGR mouse click + set ttymouse=sgr + let button = 0 " left down + let row = 3 + let col = 9 + call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!') + + let button = 3 " release + call feedkeys(printf("\<Esc>[<%d;%d;%dm", button, col, row), 'Lx!') + + call assert_equal([0, 3, 9, 0], getpos('.')) + + let &mouse = save_mouse + let &term = save_term + let &ttymouse = save_ttymouse + bwipe! +endfunc +