• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revision25f6c7f77c700f98a45d1636c3025b445d4723c6 (tree)
Time2022-11-22 22:00:04
AuthorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 9.0.0918: MS-Windows: modifier keys do not work with mouse scroll event

Commit: https://github.com/vim/vim/commit/0319306f20d2a5989d1f5639a47d77cebeac2f29
Author: Christopher Plewright <chris@createng.com>
Date: Tue Nov 22 12:58:27 2022 +0000

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)

Change Summary

Incremental Difference

diff -r 8cf717ffd0de -r 25f6c7f77c70 src/getchar.c
--- a/src/getchar.c Tue Nov 22 13:45:06 2022 +0100
+++ b/src/getchar.c Tue Nov 22 14:00:04 2022 +0100
@@ -1743,11 +1743,9 @@
17431743 --allow_keys;
17441744 }
17451745
1746- // Get two extra bytes for special keys
1746+ // Get two extra bytes for special keys, handle modifiers.
17471747 if (c == K_SPECIAL
1748-#if defined(FEAT_GUI) || defined(MSWIN)
1749- // GUI codes start with CSI; MS-Windows sends mouse scroll
1750- // events with CSI.
1748+#ifdef FEAT_GUI
17511749 || c == CSI
17521750 #endif
17531751 )
@@ -2520,32 +2518,12 @@
25202518 && State != MODE_CONFIRM
25212519 && !at_ins_compl_key())
25222520 {
2523-#if defined(FEAT_GUI) || defined(MSWIN)
2524- if (tb_c1 == CSI
2525-# if !defined(MSWIN)
2526- && gui.in_use
2527-# endif
2528- && typebuf.tb_len >= 2
2529- && (typebuf.tb_buf[typebuf.tb_off + 1] == KS_MODIFIER
2530-# if defined(MSWIN)
2531- || (typebuf.tb_len >= 3
2532-# ifdef FEAT_GUI
2533- && !gui.in_use
2534-# endif
2535- && typebuf.tb_buf[typebuf.tb_off + 1] == KS_EXTRA
2536- && (typebuf.tb_buf[typebuf.tb_off + 2] == KE_MOUSEUP
2537- || typebuf.tb_buf[typebuf.tb_off + 2] == KE_MOUSEDOWN
2538- || typebuf.tb_buf[typebuf.tb_off + 2] == KE_MOUSELEFT
2539- || typebuf.tb_buf[typebuf.tb_off + 2] == KE_MOUSERIGHT)
2540- )
2541-# endif
2542- )
2543- )
2521+#ifdef FEAT_GUI
2522+ if (gui.in_use && tb_c1 == CSI && typebuf.tb_len >= 2
2523+ && typebuf.tb_buf[typebuf.tb_off + 1] == KS_MODIFIER)
25442524 {
25452525 // The GUI code sends CSI KS_MODIFIER {flags}, but mappings expect
25462526 // K_SPECIAL KS_MODIFIER {flags}.
2547- // MS-Windows sends mouse scroll events CSI KS_EXTRA {what}, but
2548- // non-GUI mappings expect K_SPECIAL KS_EXTRA {what}.
25492527 tb_c1 = K_SPECIAL;
25502528 }
25512529 #endif
diff -r 8cf717ffd0de -r 25f6c7f77c70 src/os_win32.c
--- a/src/os_win32.c Tue Nov 22 13:45:06 2022 +0100
+++ b/src/os_win32.c Tue Nov 22 14:00:04 2022 +0100
@@ -2047,7 +2047,8 @@
20472047 {
20482048 if (modifiers > 0)
20492049 {
2050- typeahead[typeaheadlen++] = CSI;
2050+ // use K_SPECIAL instead of CSI to make mappings work
2051+ typeahead[typeaheadlen++] = K_SPECIAL;
20512052 typeahead[typeaheadlen++] = KS_MODIFIER;
20522053 typeahead[typeaheadlen++] = modifiers;
20532054 }
diff -r 8cf717ffd0de -r 25f6c7f77c70 src/term.c
--- a/src/term.c Tue Nov 22 13:45:06 2022 +0100
+++ b/src/term.c Tue Nov 22 14:00:04 2022 +0100
@@ -5125,7 +5125,7 @@
51255125 csi_len, offset, buf, bufsize, buflen);
51265126 }
51275127
5128- // Key without modifier (bad Kitty may send this):
5128+ // Key without modifier (Kitty sends this for Esc):
51295129 // {lead}{key}u
51305130 else if (argc == 1 && trail == 'u')
51315131 {
@@ -5456,6 +5456,23 @@
54565456 }
54575457 else
54585458 #endif // FEAT_GUI
5459+#ifdef MSWIN
5460+ if (len >= 3 && tp[0] == CSI && tp[1] == KS_EXTRA
5461+ && (tp[2] == KE_MOUSEUP
5462+ || tp[2] == KE_MOUSEDOWN
5463+ || tp[2] == KE_MOUSELEFT
5464+ || tp[2] == KE_MOUSERIGHT))
5465+ {
5466+ // MS-Windows console sends mouse scroll events encoded:
5467+ // - CSI
5468+ // - KS_EXTRA
5469+ // - {KE_MOUSE[UP|DOWN|LEFT|RIGHT]}
5470+ slen = 3;
5471+ key_name[0] = tp[1];
5472+ key_name[1] = tp[2];
5473+ }
5474+ else
5475+#endif
54595476 {
54605477 int mouse_index_found = -1;
54615478
diff -r 8cf717ffd0de -r 25f6c7f77c70 src/version.c
--- a/src/version.c Tue Nov 22 13:45:06 2022 +0100
+++ b/src/version.c Tue Nov 22 14:00:04 2022 +0100
@@ -696,6 +696,8 @@
696696 static int included_patches[] =
697697 { /* Add new patch number below this line */
698698 /**/
699+ 918,
700+/**/
699701 917,
700702 /**/
701703 916,
Show on old repository browser