Patch 8.2.2428
Problem: FocusGained does not work when 'ttymouse' is empty.
Solution: Don't use the short mouse code if there is a longer matching code.
(closes #7755) Add a test.
Files: src/term.c, src/testdir/test_termcodes.vim
*** ../vim-8.2.2427/src/term.c 2021-01-16 20:20:59.650487081 +0100
--- src/term.c 2021-01-30 14:32:23.719550409 +0100
***************
*** 5339,5344 ****
--- 5339,5346 ----
else
#endif // FEAT_GUI
{
+ int mouse_index_found = -1;
+
for (idx = 0; idx < tc_len; ++idx)
{
/*
***************
*** 5376,5384 ****
}
}
! key_name[0] = termcodes[idx].name[0];
! key_name[1] = termcodes[idx].name[1];
! break;
}
/*
--- 5378,5401 ----
}
}
! // 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;
! }
! else
! {
! key_name[0] = termcodes[idx].name[0];
! key_name[1] = termcodes[idx].name[1];
! break;
! }
}
/*
***************
*** 5389,5395 ****
* When there is a modifier the * matches a number.
* When there is no modifier the ;* or * is omitted.
*/
! if (termcodes[idx].modlen > 0)
{
int at_code;
--- 5406,5412 ----
* When there is a modifier the * matches a number.
* When there is no modifier the ;* or * is omitted.
*/
! if (termcodes[idx].modlen > 0 && mouse_index_found < 0)
{
int at_code;
***************
*** 5442,5447 ****
--- 5459,5469 ----
}
}
}
+ if (idx == tc_len && mouse_index_found >= 0)
+ {
+ key_name[0] = termcodes[mouse_index_found].name[0];
+ key_name[1] = termcodes[mouse_index_found].name[1];
+ }
}
#ifdef FEAT_TERMRESPONSE
*** ../vim-8.2.2427/src/testdir/test_termcodes.vim 2021-01-26
22:42:17.694836803 +0100
--- src/testdir/test_termcodes.vim 2021-01-30 14:35:41.018756476 +0100
***************
*** 1868,1873 ****
--- 1868,1901 ----
call test_override('term_props', 0)
endfunc
+ func Test_focus_events()
+ let save_term = &term
+ let save_ttymouse = &ttymouse
+ set term=xterm ttymouse=xterm2
+
+ au FocusGained * let g:focus_gained += 1
+ au FocusLost * let g:focus_lost += 1
+ let g:focus_gained = 0
+ let g:focus_lost = 0
+
+ call feedkeys("\<Esc>[O", "Lx!")
+ call assert_equal(1, g:focus_lost)
+ call feedkeys("\<Esc>[I", "Lx!")
+ call assert_equal(1, g:focus_gained)
+
+ " still works when 'ttymouse' is empty
+ set ttymouse=
+ call feedkeys("\<Esc>[O", "Lx!")
+ call assert_equal(2, g:focus_lost)
+ call feedkeys("\<Esc>[I", "Lx!")
+ call assert_equal(2, g:focus_gained)
+
+ au! FocusGained
+ au! FocusLost
+ let &term = save_term
+ let &ttymouse = save_ttymouse
+ endfunc
+
func Test_get_termcode()
try
let k1 = &t_k1
***************
*** 2261,2267 ****
endfunc
" Test for translation of special key codes (<xF1>, <xF2>, etc.)
! func Test_Keycode_Tranlsation()
let keycodes = [
\ ["<xUp>", "<Up>"],
\ ["<xDown>", "<Down>"],
--- 2289,2295 ----
endfunc
" Test for translation of special key codes (<xF1>, <xF2>, etc.)
! func Test_Keycode_Translation()
let keycodes = [
\ ["<xUp>", "<Up>"],
\ ["<xDown>", "<Down>"],
*** ../vim-8.2.2427/src/version.c 2021-01-29 21:47:20.485738910 +0100
--- src/version.c 2021-01-30 14:07:02.402998210 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2428,
/**/
--
Women are probably the main cause of free software starvation.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ 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/202101301441.10UEfTHI658671%40masaka.moolenaar.net.