pager: add opt-in mouse wheel scrolling to streampager - #1366
Open
DurhamG wants to merge 1 commit into
Open
Conversation
Summary: This adds a `pager.mouse` config option, off by default, that turns mouse reporting on and scrolls the output three lines per wheel click. It is off by default because it interferes with normal terminal selection and copying behavior. The option is named `pager.mouse` even though it only affects streampager, because that is what the existing options do. `pager.scroll-past-eof`, `pager.wrapping-mode`, `pager.interface` and `pager.separate-stderr` are all streampager-only and all live under `pager.`, each documented as "Only affects streampager". There is no separate config section for streampager. The display event loop turns a wheel event into the same scroll actions the key bindings already use. That loop checks the config option rather than relying on mouse events not arriving at all, because on Windows termwiz always puts the console into mouse-input mode, so wheel events show up even when the user did not ask us to handle the mouse. Sapling passes the option in when it builds the pager rather than through a setter, because the value decides which terminal capabilities the pager is created with. streampager also reads the option from an SP_MOUSE environment variable for use outside Sapling, matching the existing SP_INTERFACE_MODE and SP_SCROLL_PAST_EOF. Tested by hand on Windows and macOS with `sl help config --config pager.mouse=true` and `sl help config --config pager.mouse=false`, confirming the wheel scrolls only when it is on.
Contributor
Author
|
AI was used in the making of this commit. |
|
This pull request has been imported. If you are a Meta employee, you can view this in D113281664. (Because this pull request was imported automatically, there will not be any future comments.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
This adds a
pager.mouseconfig option, off by default, that turns mouse reporting on and scrolls the output three lines per wheel click.It is off by default because it interferes with normal terminal selection and copying behavior.
The option is named
pager.mouseeven though it only affects streampager, because that is what the existing options do (pager.wrapping-mode,pager.interface, etc). The new config is documented as "Only affects streampager".The display event loop turns a wheel event into the same scroll actions the key bindings already use. That loop checks the config option rather than relying on mouse events not arriving at all, because on Windows termwiz always puts the console into mouse-input mode, so wheel events show up even when the user did not ask us to handle the mouse.
Sapling passes the option in when it builds the pager rather than through a setter, because the value decides which terminal capabilities the pager is created with. streampager also reads the option from an SP_MOUSE environment variable for use outside Sapling, matching the existing SP_INTERFACE_MODE and SP_SCROLL_PAST_EOF.
Tested by hand on Windows and macOS with
sl help config --config pager.mouse=trueandsl help config --config pager.mouse=false, confirming the wheel scrolls only when it is on.