Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emulate-scroll-for-no-mouse-alternate-buffer not working? #40

Open
jocap opened this issue Oct 7, 2018 · 4 comments
Open

emulate-scroll-for-no-mouse-alternate-buffer not working? #40

jocap opened this issue Oct 7, 2018 · 4 comments

Comments

@jocap
Copy link

jocap commented Oct 7, 2018

Hi!

I installed this plugin today, but unfortunately, the option @emulate-scroll-for-no-mouse-alternate-buffer is not working properly for me. Here is my configuration:

run-shell ~/config/tmux/plugins/tmux-better-mouse-mode/scroll_copy_mode.tmux
set -g mouse on
set -g @emulate-scroll-for-no-mouse-alternate-buffer on

I'd like to be able to scroll in less using my mouse wheel, but it doesn't work.

Here's the output of tmux list-keys -T root:

bind-key -T root MouseDown1Pane   select-pane -t = ; send-keys -M
bind-key -T root MouseDown1Status select-window -t =
bind-key -T root MouseDown3Pane   if-shell -F -t = "#{mouse_any_flag}" "select-pane -t=; send-keys -M" "select-pane -mt="
bind-key -T root MouseDrag1Pane   if-shell -F -t = "#{mouse_any_flag}" "if -Ft= \"#{pane_in_mode}\" \"copy-mode -M\" \"send-keys -M\"" "copy-mode -M"
bind-key -T root MouseDrag1Border resize-pane -M
bind-key -T root WheelUpPane      if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "         if -Ft= ''           \"send-keys -t= up ; send-keys -t= up ; send-keys -t= up ; \"           \"             select-pane -t= ;             if -Ft= '#{pane_in_mode}'               'send-keys -M ; send-keys -M ; send-keys -M ; '               'copy-mode -e ; send-keys -M ; send-keys -M ; send-keys -M ; '           \"       "
bind-key -T root WheelUpStatus    previous-window
bind-key -T root WheelDownPane    if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "         if -Ft= \"\"           \"send-keys -t= down ; send-keys -t= down ; send-keys -t= down ; \"           \"select-pane -t= ; send-keys -M ; send-keys -M ; send-keys -M ; \"       "
bind-key -T root WheelDownStatus  next-window

Have I missed something? I'm running OpenBSD 6.3.

@NHDaly
Copy link
Owner

NHDaly commented Oct 8, 2018

Hmm, let's start with some small questions: which version of tmux do you have?

@jocap
Copy link
Author

jocap commented Oct 8, 2018 via email

@gregflynn
Copy link

I have the same issue, here are all my deets:
Arch Linux (4.18.16.arch1-1)
tmux 2.8-1
terminal emulator: alacritty 0.2.1-1

relevant bits from ~/.tmux.conf

set -g @plugin 'tmux-plugins/tpm'
set -g mouse on
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
set -g @scroll-without-changing-pane "on"
set -g @emulate-scroll-for-no-mouse-alternate-buffer "on"
set -g @scroll-speed-num-lines-per-scroll "3"
$ tmux list-keys -T root
bind-key -T root MouseDown1Pane   select-pane -t = ; send-keys -M
bind-key -T root MouseDown1Status select-window -t =
bind-key -T root MouseDown3Pane   if-shell -F -t = "#{mouse_any_flag}" "select-pane -t=; send-keys -M" "select-pane -mt="
bind-key -T root MouseDrag1Pane   if-shell -F -t = "#{mouse_any_flag}" "if -Ft= \"#{pane_in_mode}\" \"copy-mode -M\" \"send-keys -M\"" "copy-mode -M"
bind-key -T root MouseDrag1Border resize-pane -M
bind-key -T root WheelUpPane      if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= \"#{pane_in_mode}\" \"send-keys -M\" \"copy-mode -et=\""
bind-key -T root WheelUpStatus    previous-window
bind-key -T root WheelDownStatus  next-window
bind-key -T root M-Up             select-pane -U
bind-key -T root M-Down           select-pane -D
bind-key -T root M-Left           select-pane -L
bind-key -T root M-Right          select-pane -R

Hopefully I'm just doing something dumb

@pappasam
Copy link

pappasam commented Aug 22, 2019

Solution!

OS: Linux Mint 19.x
Tmux version: 2.9
Less version: 551

I found the solution (at least for myself on Linux Mint 19.x). I was using an older version of less and was using the following option in my LESS environment variable (set in zshrc):

 -X or --no-init
                Disables sending the termcap initialization  and  deinitializa‐
                tion  strings  to the terminal.  This is sometimes desirable if
                the deinitialization string does  something  unnecessary,  like
                clearing the screen.

I was doing this for a good reason (that I can't quite remember now), but it made it so less was not sent to an alternate buffer (alternate_on didn't register less as a valid alt process).

Luckily, the latest version of less has mouse support! You just need to do the following:

  1. Install latest version of less from source (551 at this time): http://www.greenwoodsoftware.com/less/download.html
  2. Update LESS config in zshrc to do what you want
  3. Have the correct config in tmux.conf

I'll let you figure out 1 for yourself.

For LESS, here's my config:

LESS="--ignore-case --status-column --LONG-PROMPT --RAW-CONTROL-CHARS"
LESS="$LESS --HILITE-UNREAD --tabs=4 --quit-if-one-screen"
export LESS
export LESS_TERMCAP_mb=$'\E[1;31m'     # begin bold
export LESS_TERMCAP_md=$'\E[1;36m'     # begin blink
export LESS_TERMCAP_me=$'\E[0m'        # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;44;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m'        # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m'     # begin underline
export LESS_TERMCAP_ue=$'\E[0m'        # reset underline
export PAGER=less

For tmux, here's the relevant config (assuming you've already configured your mouse correctly)

# Options for: nhdaly/tmux-better-mouse-mode
set -g @scroll-down-exit-copy-mode "on"
set -g @scroll-without-changing-pane "on"
set -g @scroll-in-moused-over-pane "on"
set -g @scroll-speed-num-lines-per-scroll "3"
set -g @emulate-scroll-for-no-mouse-alternate-buffer "on"

set -g @plugin 'nhdaly/tmux-better-mouse-mode'

iloveitaly added a commit to iloveitaly/dotfiles that referenced this issue May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants