Search code examples
vimxterm

What are the button codes for mouse scroll wheel left/right, in DECSET SGR 1006?


DECSET 1006

The encoding takes the form of CSI < Cb ; Cx ; Cy M when a button is pressed, and CSI < Cb ; Cx ; Cy m when a button is released, where:

Each field is encoded as an ASCII integer.
Cb is the button & keyboard modifiers.
Cx is the column.
Cy is the row.

(From https://github.com/chromium/hterm/blob/master/doc/ControlSequences.md - I've searched a lot, but this is the most detailed description I've. I might be searching it wrong)

What is the Cb button modifier for scroll wheel left and right?

It's 64/65 for scroll wheel up/down (i.e. buttons 1/2 + 64 xterm, wheel mice), and these work in vim. Scroll wheel left/right might be 66/67, but this doesn't work in vim.

Actually, I don't really need the correct numbers - just the ones that vim accepts...


Solution

  • Scroll wheel left/right aren't detected by xterm, hence undocumented: there's no predefined X event which corresponds to this (though some creative use may have been made for a particular device). If you're unsure about that, xev is useful for showing the events (though interpreting them can be hard).

    Regarding the link, it doesn't appear to be complete, unless you're using hterm. In any case, it's moved.

    On the other hand, xterm detects scroll wheel up/down by button 4/5, using the translations resource (see the default key-bindings in the manual). The names Btn4Up, etc., are predefined in the X ToolKit to correspond with X events and (having been introduced in X11 in 1987) predate by roughly ten years their use for wheel mouse encoding. While it's possible to extend those events, I haven't seen that it's been done (or used by vim, for that matter).