forked from aniani/vim
patch 9.0.0918: MS-Windows: modifier keys do not work with mouse scroll event
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)
This commit is contained in:
parent
35fc61cb5b
commit
0319306f20
@ -1743,11 +1743,9 @@ vgetc(void)
|
|||||||
--allow_keys;
|
--allow_keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get two extra bytes for special keys
|
// Get two extra bytes for special keys, handle modifiers.
|
||||||
if (c == K_SPECIAL
|
if (c == K_SPECIAL
|
||||||
#if defined(FEAT_GUI) || defined(MSWIN)
|
#ifdef FEAT_GUI
|
||||||
// GUI codes start with CSI; MS-Windows sends mouse scroll
|
|
||||||
// events with CSI.
|
|
||||||
|| c == CSI
|
|| c == CSI
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
@ -2520,32 +2518,12 @@ handle_mapping(
|
|||||||
&& State != MODE_CONFIRM
|
&& State != MODE_CONFIRM
|
||||||
&& !at_ins_compl_key())
|
&& !at_ins_compl_key())
|
||||||
{
|
{
|
||||||
#if defined(FEAT_GUI) || defined(MSWIN)
|
#ifdef FEAT_GUI
|
||||||
if (tb_c1 == CSI
|
if (gui.in_use && tb_c1 == CSI && typebuf.tb_len >= 2
|
||||||
# if !defined(MSWIN)
|
&& typebuf.tb_buf[typebuf.tb_off + 1] == KS_MODIFIER)
|
||||||
&& 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
|
// The GUI code sends CSI KS_MODIFIER {flags}, but mappings expect
|
||||||
// K_SPECIAL KS_MODIFIER {flags}.
|
// 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;
|
tb_c1 = K_SPECIAL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2047,7 +2047,8 @@ mch_inchar(
|
|||||||
{
|
{
|
||||||
if (modifiers > 0)
|
if (modifiers > 0)
|
||||||
{
|
{
|
||||||
typeahead[typeaheadlen++] = CSI;
|
// use K_SPECIAL instead of CSI to make mappings work
|
||||||
|
typeahead[typeaheadlen++] = K_SPECIAL;
|
||||||
typeahead[typeaheadlen++] = KS_MODIFIER;
|
typeahead[typeaheadlen++] = KS_MODIFIER;
|
||||||
typeahead[typeaheadlen++] = modifiers;
|
typeahead[typeaheadlen++] = modifiers;
|
||||||
}
|
}
|
||||||
|
19
src/term.c
19
src/term.c
@ -5125,7 +5125,7 @@ handle_csi(
|
|||||||
csi_len, offset, buf, bufsize, buflen);
|
csi_len, offset, buf, bufsize, buflen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key without modifier (bad Kitty may send this):
|
// Key without modifier (Kitty sends this for Esc):
|
||||||
// {lead}{key}u
|
// {lead}{key}u
|
||||||
else if (argc == 1 && trail == 'u')
|
else if (argc == 1 && trail == 'u')
|
||||||
{
|
{
|
||||||
@ -5456,6 +5456,23 @@ check_termcode(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif // FEAT_GUI
|
#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;
|
int mouse_index_found = -1;
|
||||||
|
|
||||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
918,
|
||||||
/**/
|
/**/
|
||||||
917,
|
917,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user