How to disable the mouse scrolling?

I have the following line in my kakrc and yet when I scroll my mouse with the terminal in focus, the screen moves around.

set -add global ui_options terminal_enable_mouse=0

How can I disable the mouse scrolling?

That’s definitely the way to disable Kakoune’s mouse-event support.

If the running application does not ask the terminal for mouse events, and the terminal receives a scroll event from the mouse, it may send the application “up arrow” and “down arrow” events instead.

If mouse scrolling works in less, then that’s what’s going on.

I suppose you could map the up and down arrows to some do-nothing sequence to eat them, but it’s probably better to make the change in the terminal configuration.

Yes, screen scrolls in less. I use mate-terminal, any idea where I can suppress that scroll behavior?

You should be able to suppress it in a single terminal by running this shell command:

printf '\e[?1007l'

You can enable it with a similar command:

printf '\e[?1007h'

I don’t know if mate-terminal exposes that as a configuration option. xterm does, foot does, gnome-terminal does not, lxterminal does not, QTerminal does not (and does not respect the “disable” escape sequence), pterm does not (and doesn’t seem to support the feature at all).

printf '\e[?1007l'

Whoa, that works. Thanks. Where did you learn about these arcane magic incantation to bend the kernel to your will?

I’d heard of that scroll-makes-arrow-presses feature, and if it was configurable anywhere it would be configurable in xterm so I checked out the xterm man page and found:

   alternateScroll (class ScrollCond)
           If “true”, the scroll-back and scroll-forw actions send  cursor-up  and
           -down  keys when xterm is displaying the alternate screen.  The default
           is “false”.

           The alternateScroll state can also be set using a control sequence.

If xterm has a control sequence, it would be in the Xterm Control Sequences documentation, so I searched for “alternateScroll” there and found:

CSI ? Pm h
      DEC Private Mode Set (DECSET).
      [...]
      Ps = 1 0 0 7  ⇒  Enable Alternate Scroll Mode, xterm.  This
      corresponds to the alternateScroll resource.

 [...]

CSI ? Pm l
      DEC Private Mode Reset (DECRST).
      [...]
      Ps = 1 0 0 7  ⇒  Disable Alternate Scroll Mode, xterm.  This
      corresponds to the alternateScroll resource.

I happen to know that CSI is \e[ for printf, so I could guess that printf '\e[?1007h' and printf '\e[?1007l' would turn it on and off.

xterm is kind of the grandaddy of all modern terminals, so I’m not surprised that same control sequence worked in a bunch of other terminals too.

1 Like