The only place in vim source code where the internal int
constants for left and right mouse scroll wheel events (KE_MOUSELEFT
and KE_MOUSERIGHT
) are set is for the GUI (gui.c).
Specifically: the code for xterm never produces these events.
BTW: Out of interest, the xterm code does produce mouse scroll wheel up/down events (KE_MOUSEUP
, KE_MOUSEDOWN
). It is a little difficult to follow in the source, because of all the preprocessor conditionals, but for SGR
DECSET 1006, I already know the code for up/down is 64/65 (hex 40
/41
- does not appear in vim source). Vim adds 32 (hex 20
), then later tests for => hex 60
, to interpret wheel_code
as a wheel_code
. Finally, it produces KE_MOUSEUP
or KE_MOUSEDOWN
by masking for the lowest bit. (term.c:5739).
I haven't traced this up/down
event for other terminal settings (e.g. set ttymouse=xterm
also works), but the code looks like to handles many inputs in this section (it converts concrete mouse events into an internal standard of psuedo-mouse events, and then works with that).
It would be nice for vim to extend the standards with escape codes for left/right scroll wheel events, but it looks like it wouldn't fit neatly into the present code base (perhaps needing an extra variable).
Motivation: It's useful for vim on phones (using terminal-ide or termux) with limited screen size. Turn off onscreen keyboard to double the available screen. Then rotate device to portrait mode to increases the number of lines, and turn off line wrapping (:set nowrap
) to increase the number of lines much further. Most lines will fit on the screen... but viewing long lines is where a touch screen swipe (sending a horizontal mouse scroll wheel event) comes in handy, because it doesn't require the on-screen keyboard.
It's possible that over time, viewing code on smartphones may become more common.
MOUSE_6
andMOUSE_7
toKE_MOUSELEFT
andKE_MOUSERIGHT
ingui.c
). And the help mentions making up your own escape sequences for xterm-mouse-wheel. So maybe that's all there is.