mirror of
https://github.com/vim/vim.git
synced 2025-10-07 05:54:16 -04:00
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.
This commit is contained in:
@@ -3792,7 +3792,7 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
|
||||
if (!dangerous)
|
||||
++ex_normal_busy;
|
||||
exec_normal(TRUE, FALSE, TRUE);
|
||||
exec_normal(TRUE, lowlevel, TRUE);
|
||||
if (!dangerous)
|
||||
--ex_normal_busy;
|
||||
|
||||
|
@@ -10487,12 +10487,15 @@ exec_normal_cmd(char_u *cmd, int remap, int silent)
|
||||
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();
|
||||
|
@@ -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 \
|
||||
|
47
src/testdir/test_termcodes.vim
Normal file
47
src/testdir/test_termcodes.vim
Normal file
@@ -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
|
||||
|
@@ -771,6 +771,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1136,
|
||||
/**/
|
||||
1135,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user