tmux 2.1 and mouse scrolling

1,471 views
Skip to first unread message

John Whitley

unread,
Oct 22, 2015, 5:23:29 PM10/22/15
to tmux-...@googlegroups.com

I’ve switched to the new tmux 2.1 mouse settings, but I’m finding the lack of first-class scrolling support is a big loss.

Specifically, I tried the settings proposed by Thomas Sattler in the earlier thread:

bind -n WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
bind -n WheelDownPane select-pane -t= \; send-keys -M

I’m not in love with this, as the one-line scrolling is a lot slower. It can be sped up by using "send-keys -M” multiple times in a binding:

set -g mouse on
bind -n WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M \; send-keys -M \; send-keys -M
bind -n WheelDownPane select-pane -t= \; send-keys -M \; send-keys -M \; send-keys -M

This still seems to have more jank than tmux 2.0, but it’s better IMO than the one-line scrolling.

But the worst part is how this plays with passing through mouse scrolling events to mouse-aware applications like vim.

In tmux 2.0:

* When at a shell prompt, I could scroll up to see and interact the tmux history, and scroll down to return to the interactive prompt.
* When in vim, scrolling was passed through to scroll the active vim pane.

Basically, everything “just worked” in that scrolling up interacted correctly with tmux or a mouse-aware application in a very sensible manner.

In tmux 2.1:

* The shell prompt works similarly with the bindings provided above.
* When in vim, scrolling down works to scroll the editor pane, but scrolling up *enters tmux backscroll*.

This is a big regression for my workflow. Scrolling up is broken when using the bindings above to emulate the old behavior. It means that I get mouse-scroll to work for tmux history XOR I get to scroll mouse-scroll-aware apps, which is pretty unfortunate.

I’m not really up on the background of the mouse code refactoring, but I can’t see any way in tmux 2.1 to emulate the (ideal, IMO) old behavior. Perhaps if the “bind -n …” calls could be context-aware to only be active when a mouse-aware app was not running in that pane?

— John


Suraj N. Kurapati

unread,
Oct 22, 2015, 5:42:43 PM10/22/15
to John Whitley, tmux-...@googlegroups.com
On Thu, 22 Oct 2015 14:23:27 -0700, John Whitley wrote:
> Perhaps if the “bind -n …” calls could be context-aware to only be
> active when a mouse-aware app was not running in that pane?

That's exactly how it's solved: making wheel bindings context-aware!

See https://groups.google.com/d/msg/tmux-users/XTrSVUR15Zk/3iyJLMyQ7PwJ

bind-key -T root WheelUpPane \
if-shell -Ft= '#{mouse_any_flag}' 'send-keys -M' \
'if-shell -Ft= "#{pane_in_mode}" "send-keys -M" "copy-mode"'

bind-key -T root WheelDownPane \
if-shell -Ft= '#{mouse_any_flag}' 'send-keys -M' \
'if-shell -Ft= "#{pane_in_mode}" "send-keys -M"'

Cheers.

Nathan Daly

unread,
Oct 22, 2015, 6:52:32 PM10/22/15
to Suraj N. Kurapati, John Whitley, tmux-...@googlegroups.com
Following a discussion on this bug, it looks like they are going to change this behavior to be the default binding again. :)




--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To post to this group, send an email to tmux-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cam Hutchison

unread,
Oct 22, 2015, 7:25:12 PM10/22/15
to tmux-...@googlegroups.com
John Whitley <bangpa...@gmail.com> writes:


>I’ve switched to the new tmux 2.1 mouse settings, but I’m finding the lack of first-class scrolling support is a big loss.

>Specifically, I tried the settings proposed by Thomas Sattler in the earlier thread:

> bind -n WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
> bind -n WheelDownPane select-pane -t= \; send-keys -M

>I’m not in love with this, as the one-line scrolling is a lot slower. It can be sped up by using "send-keys -M” multiple times in a binding:

All send-keys -M does is cause the mouse event to pass through to be
processed by the copy-mode binding. If you want different scrolling,
change the copy-mode binding for Wheel{Up,Down}Pane to scroll how much
you want it to.

For instance:
bind-key -t vi-copy WheelUpPane halfpage-up
bind-key -t vi-copy WheelDownPane halfpage-down

This will make the mouse wheel scroll half a page at a time.

John Whitley

unread,
Oct 26, 2015, 2:25:50 PM10/26/15
to tmux-...@googlegroups.com
Thanks for the feedback, everyone.  It's nice to learn that tmux provides that depth of customization, and I'm glad to see the defaults restored.  The method that Suraj posted is fine for advanced users tweaking things, but seems like a high (and poorly documented, atm) bar for users to enable basic scrolling.

To Cam's note about binding copy mode: thanks, I hugely prefer that approach.  However, it seems inflexible.  I haven't found a way to bind WheelUpPane to "scroll up N lines".  scroll-up/halfpage-up, etc. don't take parameters to customize the scrolling amount.  Some experimenting suggests that tmux doesn't allow multiple commands in copy mode bindings, so the "scroll-scroll-scroll" hack doesn't work either.

ideally something like:

# scroll up three lines
bind-key -t vi-copy WheelUpPane scroll-up -l 3

and/or an optional percentage parameter on halfpage-{up,down} would be great. 
 
Reply all
Reply to author
Forward
0 new messages