NHDaly / tmux-better-mouse-mode

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

Highlighting text with the mouse and letting go causes copy mode to exit and the buffer to scroll to the bottom. #5

Closed twof closed 8 years ago

twof commented 8 years ago

Other than this, everything seems to be working fine. Thanks for the plugin! I'm happy to provide any more info.

NHDaly commented 8 years ago

:) Thanks for filing the bug. This behavior bothers me as well...

I have filed a bug with tmux here: https://github.com/tmux/tmux/issues/140, but apparently this is actually the intended behavior. It took me a while to understand, but what's happening is that it's actually copying the selection you highlighted. You can then hit ] to paste the line you highlighted. This is neat, but I most of the time find it bothersome.

I would like there to be an option to disable this behavior. Please file a bug with tmux or comment on my bug to let them know about your problem.

Or, if you can come up with a clever way of disabling it through the plugin, let me know! :)

twof commented 8 years ago

Thanks for getting back to me! You're right. That does seem like odd default behaviour. I'll go ahead and add a comment to your bug. An option to change that would be really nice.

I'll look into a workaround too when I get the chance.

twof commented 8 years ago

I'm not super familiar with scripting tmux, so maybe there's no way to do this, but maybe something like this?:

#Hold the number of lines has been scrolled up
export scrollNum=0
#increment scrollNum so that the number of lines that's been scrolled is kept track of
tmux bind-key -n WheelUpPane if-shell -F -t = "${export scrollNum=$(($scrollNum+"$scroll_speed_num_lines_per_scroll"))}" /*The rest of this line*/
#would have to reset scrollNum once we reach the bottom and make sure we don't keep deincrementing #if we scroll down at the bottom
tmux bind-key -n WheelDownPane if-shell -F -t = "${export scrollNum=$(($scrollNum-"$scroll_speed_num_lines_per_scroll"))} /*The rest of this line*/

#This puts us in copy-mode then sends scroll up commands until the buffer is in the same place it was #before the highlighting happened.
#You'd still lose the highlight though
#Really hacky I'm so sorry.
#Not sure how you'd do click and drag. 
#Maybe chain together some bind-key/unbind-key commands as part of the block that executes on click.
#Something like (bind-key MouseDrag1 (bind-key MouseUp1 doThing())
#As part of doThing, we'd need to unbind/rebind the keys to what they were previously so we don't 
#overwrite their original functionality
tmux bind-key -n <clickAndDrag> if-shell -F -t =  "if -Ft= '#{pane_in_mode}' \"$select_moused_over_pane_cmd $enter_copy_mode_cmd\" "$for i in `seq 1 "$scrollNum"` ;do send_keys_to_tmux_cmd=$send_keys_to_tmux_cmd"send-keys -M ; " done

This is a really crappy, probably syntactically wrong work around. I don't know. Maybe this helps.

NHDaly commented 8 years ago

Huh! That's an interesting idea. Thanks! I'm not sure if that would work either.

I had previously filed this bug when I tried to do something similar and it didn't seem promising: https://github.com/tmux/tmux/issues/147

But maybe now that I know more about tmux scripting maybe we could figure something out. I dunno! I don't have time to try playing around with this now, but it's a cool idea. I'll let you know if I get the time to try it out.

NHDaly commented 8 years ago

Closing this for now as it's not a problem with this plugin.