NHDaly / tmux-better-mouse-mode

A tmux plugin to better manage and configure the mouse.
MIT License
910 stars 27 forks source link

Emulate scrolling when in alternate buffer that doesn't support the mouse #15

Closed giddie closed 8 years ago

giddie commented 8 years ago

This fixes scrolling in less, for instance. This is only enabled when prevent-scroll-for-fullscreen-alternate-buffer is enabled.

giddie commented 8 years ago

Sorry, I've snuck a couple of other commits in there, which I realise is a bit cheeky. I'll create separate branches if you're not keen on merging the lot.

NHDaly commented 8 years ago

Hey, thanks for sending this along! I love it. :)

No, I actually appreciate having multiple commits, but I would ask you a favor: can you instead separate it into the commits that add behavior and the commits that refactor and/or format the code?

It's really difficult to tell, for example, what you changed in the second commit to fix the scroll-up/enter copy-mode vs what is just a refactoring/formatting change.

Thanks for sending this along though! I think overall it looks great.

NHDaly commented 8 years ago

Regarding testing, I've tested it on my Mac (10.11.4) and on Ubuntu (14.04). Can anyone out there with a POSIX OS check this over before I check it in? @corv89, would you mind helping out again? Thanks.

To do that you would

git checkout -b giddie-master master
git pull git://github.com/giddie/tmux-scroll-copy-mode.git master

# Commen out the plugin from .tmux.conf.
# TPM clean
# Add your local copy of the plugin + TPM install.
# Test.

Thanks!!

giddie commented 8 years ago

OK, I've refactored the changeset to introduce the whitespace changes first, so the alterations to the binding logic should be a bit clearer.

NHDaly commented 8 years ago

Love it. This looks great. Thanks so much again! Exciting change. It might be worth renaming the option now, since it's not really "prevent-scroll-for-fullscreen-alternate-buffer," but actually more like emulate scroll.

NHDaly commented 8 years ago

Also, are there any alternate screen buffers where up/down might be problematic? I tried other things that don't have a concept of scrolling, like top, but everything seemed okay. Is there anything else we should be worried about?

giddie commented 8 years ago

Yes, it could be worth renaming the option to something like emulate-scroll-for-mouse-unaware-alternate-buffers, although that's quite a mouthful!

I don't think there are likely to be any programs that have an issue with this: most programs that don't support some kind of up/down motion with the keyboard arrows will simply ignore those events. It might cause some odd behaviour in e.g. console-based games that don't support mouse events. Those might do something unexpected if they receive a lot of up and down keys, but the solution is simply to not use the mouse when using a program like that :p

FYI, this is the behaviour that Konsole uses, which is exactly why I want tmux to have the same behaviour. I originally helped figure out a patch for tmux to produce this behaviour in 2014, but it was put on hold because Nicholas was planning the new mouse binding feature that permits this kind of scripting. I only just got around to looking into it again :)

NHDaly commented 8 years ago

:) Haha, okay sounds great! Yeah I really love this. I've tested it on my mac and ubuntu, and it works great. I'll merge this in now! Thanks again for your help!

NHDaly commented 8 years ago

I've opened #16 to track changing the name of that option (and to add this to the README). I'm currently thinking @emulate-scroll-for-no-mouse-alternate-buffer. It's actually shorter than the old option name! :p

Please add any comments you have there, otherwise i'll just go ahead and change it to something like that at some point. :) Thanks again!