Patch 8.2.3727
Problem: In a gnome terminal keys are recognized as mouse events.
Solution: Only recognize DEC mouse events when four numbers are following.
(closes #9256)
Files: src/term.c, src/testdir/test_termcodes.vim
*** ../vim-8.2.3726/src/term.c 2021-11-29 20:39:06.682101619 +0000
--- src/term.c 2021-12-03 13:19:16.371806797 +0000
***************
*** 5412,5417 ****
--- 5412,5419 ----
if (STRNCMP(termcodes[idx].code, tp,
(size_t)(slen > len ? len : slen)) == 0)
{
+ int looks_like_mouse_start = FALSE;
+
if (len < slen) // got a partial sequence
return -1; // need to get more chars
***************
*** 5434,5448 ****
}
}
- // The mouse termcode "ESC [" is also the prefix of
- // "ESC [ I" (focus gained). Only use it when there is
- // no other match. Do use it when a digit is following to
- // avoid waiting for more bytes.
if (slen == 2 && len > 2
&& termcodes[idx].code[0] == ESC
! && termcodes[idx].code[1] == '['
! && !isdigit(tp[2]))
{
if (mouse_index_found < 0)
mouse_index_found = idx;
}
--- 5436,5483 ----
}
}
if (slen == 2 && len > 2
&& termcodes[idx].code[0] == ESC
! && termcodes[idx].code[1] == '[')
! {
! // The mouse termcode "ESC [" is also the prefix of
! // "ESC [ I" (focus gained) and other keys. Check some
! // more bytes to find out.
! if (!isdigit(tp[2]))
! {
! // ESC [ without number following: Only use it when
! // there is no other match.
! looks_like_mouse_start = TRUE;
! }
! else if (termcodes[idx].name[0] == KS_DEC_MOUSE)
! {
! char_u *nr = tp + 2;
! int count = 0;
!
! // If a digit is following it could be a key with
! // modifier, e.g., ESC [ 1;2P. Can be confused
! // with DEC_MOUSE, which requires four numbers
! // following. If not then it can't be a DEC_MOUSE
! // code.
! for (;;)
! {
! ++count;
! (void)getdigits(&nr);
! if (nr >= tp + len)
! return -1; // partial sequence
! if (*nr != ';')
! break;
! ++nr;
! if (nr >= tp + len)
! return -1; // partial sequence
! }
! if (count < 4)
! continue; // no match
! }
! }
! if (looks_like_mouse_start)
{
+ // Only use it when there is no other match.
if (mouse_index_found < 0)
mouse_index_found = idx;
}
*** ../vim-8.2.3726/src/testdir/test_termcodes.vim 2021-11-21
11:35:59.460938795 +0000
--- src/testdir/test_termcodes.vim 2021-12-03 13:18:22.583653488 +0000
***************
*** 2039,2044 ****
--- 2039,2066 ----
set timeoutlen&
endfunc
+ " Check that when DEC mouse codes are recognized a special key is handled.
+ func Test_ignore_dec_mouse()
+
+ new
+ let save_mouse = &mouse
+ let save_term = &term
+ let save_ttymouse = &ttymouse
+ call test_override('no_query_mouse', 1)
+ set mouse=a term=gnome ttymouse=
+
+ execute "set <xF1>=\<Esc>[1;*P"
+ nnoremap <S-F1> agot it<Esc>
+ call feedkeys("\<Esc>[1;2P", 'Lx!')
+ call assert_equal('got it', getline(1))
+
+ let &mouse = save_mouse
+ let &term = save_term
+ let &ttymouse = save_ttymouse
+ call test_override('no_query_mouse', 0)
+ bwipe!
+ endfunc
+
func RunTest_mapping_shift(key, func)
call setline(1, '')
if a:key == '|'
*** ../vim-8.2.3726/src/version.c 2021-12-03 11:43:59.194666803 +0000
--- src/version.c 2021-12-03 13:19:57.307910558 +0000
***************
*** 755,756 ****
--- 755,758 ----
{ /* Add new patch number below this line */
+ /**/
+ 3727,
/**/
--
Scientists decoded the first message from an alien civilization:
SIMPLY SEND 6 TIMES 10 TO THE 50 ATOMS OF HYDROGEN TO THE STAR
SYSTEM AT THE TOP OF THE LIST, CROSS OFF THAT STAR SYSTEM, THEN PUT
YOUR STAR SYSTEM AT THE BOTTOM OF THE LIST AND SEND IT TO 100 OTHER
STAR SYSTEMS. WITHIN ONE TENTH GALACTIC ROTATION YOU WILL RECEIVE
ENOUGH HYDROGREN TO POWER YOUR CIVILIZATION UNTIL ENTROPY REACHES ITS
MAXIMUM! IT REALLY WORKS!
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20211203132103.B91561C290B%40moolenaar.net.