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

wheel scrolling doesn't work in tmux / linux #174

Open
Canop opened this issue Mar 3, 2024 · 6 comments
Open

wheel scrolling doesn't work in tmux / linux #174

Canop opened this issue Mar 3, 2024 · 6 comments

Comments

@Canop
Copy link
Owner

Canop commented Mar 3, 2024

Reported by @willhansen in #153 and confirmed.

@Canop
Copy link
Owner Author

Canop commented Mar 3, 2024

Related: crossterm-rs/crossterm#401
(bacon uses crossterm for event detection)

@jyn514
Copy link
Contributor

jyn514 commented Aug 15, 2024

fwiw this works around the issue:

bind-key -n WheelUpPane {
  if-shell -F '#{mouse_any_flag}' {
      send-keys -M
  } {
    if-shell -F '#{alternate_on}' {
      send-keys Up
    } {
      copy-mode -e
    }
  }
}
bind-key -n WheelDownPane {
  if-shell -F '#{mouse_any_flag}' {
      send-keys -M
  } {
      send-keys Down
  }
}

(see also tmux/tmux#3705)

you can duplicate send-keys more times to increase the scroll speed.

note that all of this only has an effect if set mouse on is enabled; otherwise all mouse events are passed through unchanged.

@jyn514
Copy link
Contributor

jyn514 commented Aug 15, 2024

strangely scrolling works fine in vim and helix. i wonder if crossterm isn't telling the terminal emulator it can accept mouse events (mouse_any_flag). i notice ead2e05 only enables mouse events on windows - do you know why that was done?

@jyn514
Copy link
Contributor

jyn514 commented Aug 15, 2024

ok yes - if i uncomment those cfgs, mouse scrolling works fine in tmux. the problem from #191 also appears; i suspect it is not actually platform specific and bacon needs to set some config that tells the terminal emulator to handle text selection itself.

@jyn514
Copy link
Contributor

jyn514 commented Aug 15, 2024

ok, i think i have figured out what's going on.

  1. by default, the terminal emulator does not send any mouse events to the active process (i.e. the one with the "controlling terminal"); instead it scrolls up in the history.
  2. when the "alternate screen buffer" is active, the terminal emulator turns mouse scroll events into up and down arrow keys: https://stackoverflow.com/a/71373998. this happens even if the process has not requested to be in mouse mode. click + drag is still processed by the terminal emulator. this is the "happy path" and how bacon currently behaves on linux.
  3. processes can request to be in mouse mode, which is what fix: 🐛 Fix scroll in terminals on Windows #156 enabled on Windows. in this mode both scroll events and click and drag are passed through to the process. this is why Inconsistent terminal behaviour on windows #191 is broken; the terminal emulator expects the events to be handled by bacon.

there are two independent bugs here, excluding anything bacon does.

i suspect @Adham-A has some broken environment.

given all that, my suggestion is to revert #156, tell tmux users to use the workaround i posted above, and have Adham debug their environment further - i do not think capturing the mouse is a good tradeoff for bacon since it breaks click+drag for selecting text.

@jyn514
Copy link
Contributor

jyn514 commented Aug 15, 2024

whatever was going on in #153

oh - i think this is a bug in vscode. running tput smcup in its integrated terminal fails to translate scroll events to up and down keys.

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

2 participants