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

Enable alternate scroll mode by default #13187

Closed
jaminthorns opened this issue May 27, 2022 · 13 comments · Fixed by #16535
Closed

Enable alternate scroll mode by default #13187

jaminthorns opened this issue May 27, 2022 · 13 comments · Fixed by #16535
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Area-VT Virtual Terminal sequence support good first issue This is a fix that might be easier for someone to do as a first contribution In-PR This issue has a related PR Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Milestone

Comments

@jaminthorns
Copy link

I was really pleased to see that proper support for the alt screen buffer has landed in the latest preview release (thanks to #12569). Would you consider enabling this behavior by default? I realize that you could just add a printf "\e[?1007h" to your shell startup script, but most terminals that I use have this mode enabled by default. This issue in the foot repository summarizes the issue nicely.

@jaminthorns jaminthorns added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label May 27, 2022
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels May 27, 2022
@zadjii-msft
Copy link
Member

I don't think I have much reluctance to enabling this by default. I'll refer to @j4james as our resident VT (and compatibility) expert. It's not like an app that didn't request that mode is going to get anything particularly bad by getting up/down keystrokes. IDK it seems pretty sensible.

We could easily make it an opt-out behavior as well, or opt in if there's more compat issues that I'm not aware of.

@zadjii-msft zadjii-msft added Area-VT Virtual Terminal sequence support Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. Issue-Task It's a feature request, but it doesn't really need a major design. good first issue This is a fix that might be easier for someone to do as a first contribution labels May 27, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 27, 2022
@zadjii-msft zadjii-msft added this to the Backlog milestone May 27, 2022
@j4james
Copy link
Collaborator

j4james commented May 28, 2022

Every terminal I've tested that has support for alternate scroll also has it enabled by default, except for XTerm, and even XTerm has an option for that. So yeah, I'm definitely in favour of doing this. And now that the alt buffer doesn't show the scrollback, there's nothing else the scroll wheel can do anyway.

That said, if an application has a mouse tracking mode enabled (e.g. mode 1003) at the same time as alternate scroll, that mouse tracking should take precedence (or at least the most recent mode should take precedence). I don't think we're currently doing that, so it's important that we fix that first.

@zadjii-msft zadjii-msft removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Jun 9, 2022
@phil-blain
Copy link

I'm not sure if I should open a new issue, but I seem to notice that alternate scroll is noticeably slower than normal scrolling (e.g. scrolling in Vim is slower than scrolling the scrollback in the shell). Is this known / expected ?

@zadjii-msft
Copy link
Member

That intuitively makes sense to me - if you're using alternate scroll mode, then I'd suspect we send one ^[[A per wheel click, resulting in one line scrolled. In normal scrollback, we're usually scrolling about four lines per wheel click (depending on various settings)

@DHowett
Copy link
Member

DHowett commented Jun 13, 2022

Right. Windows defaults to scrolling 3 lines per wheel detent, but if we translated a single wheel scroll event into three up/down events we would risk overshooting in cases where the wheel is being used to scroll things that aren't linear text buffers.

This will also manifest in applications that take over full mouse control rather than the partial control offered by alternate scroll mode: vim, for example, will scroll one line when it receives one "button 5" event (wheel).

@jaminthorns
Copy link
Author

@zadjii-msft This is pretty commonly configurable:

  • Kitty: Configured by the wheel_scroll_multiplier setting.
  • Alacritty: Configured by the scrolling.multiplier setting.
  • VS Code Terminal: Configured by the terminal.integrated.mouseWheelScrollSensitivity setting.

@DHowett What I've usually seen is that alternate scroll mode is consistent with the scrollback behavior (usually more than 1 line per wheel click), and when an application takes over full mouse control, then it's usually 1 line per wheel click (probably because that's easiest to implement). I'm not sure how other terminals handle "overshooting".

@DHowett
Copy link
Member

DHowett commented Jun 14, 2022

Ah dang, you're totally right. We should make this configurable! Thanks!

@eugenov
Copy link

eugenov commented Nov 1, 2022

By the way, how to add printf "\e[?1007h" to powershell startup?

@tomsri01
Copy link

If alternate buffer isn't enabled by default what is required to turn it on or make it turn on by default for all shell sessions?

@xdhmoore
Copy link

xdhmoore commented Apr 7, 2023

It sounds like in bash you enable this with printf "\e[?1007h". Is it possible to enable it in powershell?

@zadjii-msft
Copy link
Member

In pwsh (7), I believe a write-host `e[?1007h will work. The syntax in earlier versions of powershell (powershell.exe) is... more annoying

@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Jan 7, 2024
DHowett pushed a commit that referenced this issue Jan 9, 2024
This PR enables alternate scroll mode by default, and also fixes the
precedence so if there is any other mouse tracking mode enabled, that
will take priority.

## Validation Steps Performed

I've manually tested by viewing a file with `less`, and confirmed that
it can now scroll using the mouse wheel by default. Also tested mouse
mouse in vim and confirmed that still works.

## PR Checklist
Closes #13187
@github-project-automation github-project-automation bot moved this from Should be written to Done in Terminal Walkthroughs Jan 9, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Jan 9, 2024
@determin1st
Copy link

determin1st commented Apr 9, 2024

@phil-blain why not opening the issue in the vim repo? terminal user is able to translate wheel events to any number of lines 3 4 5 10 1, so it shall be a user configuration, not terminal.

i dont really understand what alternate scroll 1007 does, seem like a poor design to me, similar to 1005

@avih
Copy link

avih commented Jun 17, 2024

Right. Windows defaults to scrolling 3 lines per wheel detent, but if we translated a single wheel scroll event into three up/down events we would risk overshooting in cases where the wheel is being used to scroll things that aren't linear text buffers.

I'd think the typical use case for this is to scroll or navigate in a linear text buffer, like in "less", or "nano" or other terminal editors, which, even if they support mouse mode, might not be enabled by default and/or not obvious how to configure, or might have some tradeoffs which the user prefers to avoid.

For instance, enabling mouse at the application (rightly) disables terminal selection by mouse drag (even if shift-drag still works, but less convenient), so the user might prefer to rely on alt-terminal-scroll and keep the mouse disabled at the app, so that they can select text without shift.

It's certainly possible that the user prefers one-line-at-a-time, or having other use cases (which I can't think of) where multiple-lines are counter productive, which is why it would be useful to have the number of lines configurable.

But I don't think it can be argued that scrolling one line per wheel event is great when the user prefers 3 or 5 lines at a time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Area-VT Virtual Terminal sequence support good first issue This is a fix that might be easier for someone to do as a first contribution In-PR This issue has a related PR Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

10 participants