Patch 9.0.0918
Problem: MS-Windows: modifier keys do not work with mouse scroll events.
Solution: Use K_SPECIAL instead of CSI for the modifier keys. (Christopher
Plewright, closes #11587)
Files: src/getchar.c, src/os_win32.c, src/term.c
*** ../vim-9.0.0917/src/getchar.c 2022-11-19 19:02:33.957452667 +0000
--- src/getchar.c 2022-11-22 12:51:11.522610007 +0000
***************
*** 1743,1753 ****
--allow_keys;
}
! // Get two extra bytes for special keys
if (c == K_SPECIAL
! #if defined(FEAT_GUI) || defined(MSWIN)
! // GUI codes start with CSI; MS-Windows sends mouse scroll
! // events with CSI.
|| c == CSI
#endif
)
--- 1743,1751 ----
--allow_keys;
}
! // Get two extra bytes for special keys, handle modifiers.
if (c == K_SPECIAL
! #ifdef FEAT_GUI
|| c == CSI
#endif
)
***************
*** 2520,2551 ****
&& State != MODE_CONFIRM
&& !at_ins_compl_key())
{
! #if defined(FEAT_GUI) || defined(MSWIN)
! if (tb_c1 == CSI
! # if !defined(MSWIN)
! && gui.in_use
! # endif
! && typebuf.tb_len >= 2
! && (typebuf.tb_buf[typebuf.tb_off + 1] == KS_MODIFIER
! # if defined(MSWIN)
! || (typebuf.tb_len >= 3
! # ifdef FEAT_GUI
! && !gui.in_use
! # endif
! && typebuf.tb_buf[typebuf.tb_off + 1] == KS_EXTRA
! && (typebuf.tb_buf[typebuf.tb_off + 2] == KE_MOUSEUP
! || typebuf.tb_buf[typebuf.tb_off + 2] == KE_MOUSEDOWN
! || typebuf.tb_buf[typebuf.tb_off + 2] == KE_MOUSELEFT
! || typebuf.tb_buf[typebuf.tb_off + 2] == KE_MOUSERIGHT)
! )
! # endif
! )
! )
{
// The GUI code sends CSI KS_MODIFIER {flags}, but mappings expect
// K_SPECIAL KS_MODIFIER {flags}.
- // MS-Windows sends mouse scroll events CSI KS_EXTRA {what}, but
- // non-GUI mappings expect K_SPECIAL KS_EXTRA {what}.
tb_c1 = K_SPECIAL;
}
#endif
--- 2518,2529 ----
&& State != MODE_CONFIRM
&& !at_ins_compl_key())
{
! #ifdef FEAT_GUI
! if (gui.in_use && tb_c1 == CSI && typebuf.tb_len >= 2
! && typebuf.tb_buf[typebuf.tb_off + 1] == KS_MODIFIER)
{
// The GUI code sends CSI KS_MODIFIER {flags}, but mappings expect
// K_SPECIAL KS_MODIFIER {flags}.
tb_c1 = K_SPECIAL;
}
#endif
*** ../vim-9.0.0917/src/os_win32.c 2022-11-14 15:31:04.041587447 +0000
--- src/os_win32.c 2022-11-22 12:53:21.278629757 +0000
***************
*** 2047,2053 ****
{
if (modifiers > 0)
{
! typeahead[typeaheadlen++] = CSI;
typeahead[typeaheadlen++] = KS_MODIFIER;
typeahead[typeaheadlen++] = modifiers;
}
--- 2047,2054 ----
{
if (modifiers > 0)
{
! // use K_SPECIAL instead of CSI to make mappings work
! typeahead[typeaheadlen++] = K_SPECIAL;
typeahead[typeaheadlen++] = KS_MODIFIER;
typeahead[typeaheadlen++] = modifiers;
}
*** ../vim-9.0.0917/src/term.c 2022-11-18 21:20:21.811312017 +0000
--- src/term.c 2022-11-22 12:54:35.294639504 +0000
***************
*** 5125,5131 ****
csi_len, offset, buf, bufsize, buflen);
}
! // Key without modifier (bad Kitty may send this):
// {lead}{key}u
else if (argc == 1 && trail == 'u')
{
--- 5125,5131 ----
csi_len, offset, buf, bufsize, buflen);
}
! // Key without modifier (Kitty sends this for Esc):
// {lead}{key}u
else if (argc == 1 && trail == 'u')
{
***************
*** 5456,5461 ****
--- 5456,5478 ----
}
else
#endif // FEAT_GUI
+ #ifdef MSWIN
+ if (len >= 3 && tp[0] == CSI && tp[1] == KS_EXTRA
+ && (tp[2] == KE_MOUSEUP
+ || tp[2] == KE_MOUSEDOWN
+ || tp[2] == KE_MOUSELEFT
+ || tp[2] == KE_MOUSERIGHT))
+ {
+ // MS-Windows console sends mouse scroll events encoded:
+ // - CSI
+ // - KS_EXTRA
+ // - {KE_MOUSE[UP|DOWN|LEFT|RIGHT]}
+ slen = 3;
+ key_name[0] = tp[1];
+ key_name[1] = tp[2];
+ }
+ else
+ #endif
{
int mouse_index_found = -1;
*** ../vim-9.0.0917/src/version.c 2022-11-22 12:40:44.066427878 +0000
--- src/version.c 2022-11-22 12:49:35.230592687 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 918,
/**/
--
hundred-and-one symptoms of being an internet addict:
106. When told to "go to your room" you inform your parents that you
can't...because you were kicked out and banned.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///