]> granicus.if.org Git - vim/commitdiff
patch 8.1.1137: xterm mouse wheel escape sequence is not tested v8.1.1137
authorBram Moolenaar <Bram@vim.org>
Sun, 7 Apr 2019 19:55:07 +0000 (21:55 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 7 Apr 2019 19:55:07 +0000 (21:55 +0200)
Problem:    Xterm mouse wheel escape sequence is not tested.
Solution:   Add a test using low-level input. (Dominique Pelle, closes #4221)

src/testdir/test_termcodes.vim
src/version.c

index bd2729d3e3b45c58ba5c5dfcce602abad5446ffc..0bee55abe12b6146518482d459a28b971165870f 100644 (file)
@@ -45,3 +45,69 @@ func Test_xterm_mouse_click()
   bwipe!
 endfunc
 
+func Test_xterm_mouse_wheel()
+  new
+  let save_mouse = &mouse
+  let save_term = &term
+  let save_ttymouse = &ttymouse
+  set mouse=a
+  set term=xterm
+  call setline(1, range(1, 100))
+
+  " Test Xterm mouse wheel.
+  set ttymouse=xterm
+  let button = 0x41 " wheel down.
+  let row = 1 + 32  " cursor position for mouse wheel is not relevant.
+  let col = 1 + 32
+
+  call assert_equal(1, line('w0'))
+  call assert_equal([0, 1, 1, 0], getpos('.'))
+  call feedkeys("\<Esc>[M" .. list2str([button, col, row]), 'Lx!')
+  call assert_equal(4, line('w0'))
+  call assert_equal([0, 4, 1, 0], getpos('.'))
+  call feedkeys("\<Esc>[M" .. list2str([button, col, row]), 'Lx!')
+  call assert_equal(7, line('w0'))
+  call assert_equal([0, 7, 1, 0], getpos('.'))
+
+  let button = 0x40  " wheel up.
+
+  call feedkeys("\<Esc>[M" .. list2str([button, col, row]), 'Lx!')
+  call assert_equal(4, line('w0'))
+  call assert_equal([0, 7, 1, 0], getpos('.'))
+  call feedkeys("\<Esc>[M" .. list2str([button, col, row]), 'Lx!')
+  call assert_equal(1, line('w0'))
+  call assert_equal([0, 7, 1, 0], getpos('.'))
+
+  " Test SGR mouse wheel.
+  set ttymouse=sgr
+  go
+  let button = 0x41 " wheel down.
+  let row = 1       " cursor position for mouse wheel is not relevant.
+  let col = 1
+
+  call assert_equal(1, line('w0'))
+  call assert_equal([0, 1, 1, 0], getpos('.'))
+  call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
+  call assert_equal(4, line('w0'))
+  call assert_equal([0, 4, 1, 0], getpos('.'))
+  call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
+  call assert_equal(7, line('w0'))
+  call assert_equal([0, 7, 1, 0], getpos('.'))
+
+  let button = 0x40  " wheel up.
+
+  call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
+  call assert_equal(4, line('w0'))
+  call assert_equal([0, 7, 1, 0], getpos('.'))
+  call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
+  call assert_equal(1, line('w0'))
+  call assert_equal([0, 7, 1, 0], getpos('.'))
+  call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
+  call assert_equal(1, line('w0'))
+  call assert_equal([0, 7, 1, 0], getpos('.'))
+
+  let &mouse = save_mouse
+  let &term = save_term
+  let &ttymouse = save_ttymouse
+  bwipe!
+endfunc
index 6b428b48a266070fd90d1f9e2a8d499753f3aacd..d2da9fcca02e29bcaf4d6d14989efee6dc3136a2 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1137,
 /**/
     1136,
 /**/