fix(terminal): scroll alt-screen apps with wheel/touchpad; respect Select-to-Copy (#50)#53
Merged
Merged
Conversation
…t Select-to-Copy (#50) Two terminal fixes reported in #50: - Wheel/touchpad scroll did nothing in full-screen apps (nano/less/vim). These run in the alternate screen buffer, where xterm has no scrollback to move; its built-in translation also dampens sub-50px touchpad deltas to zero, so scrolling was effectively a no-op. Add a custom wheel handler that translates the delta into Up/Down arrow presses, carrying the sub-row remainder so touchpads (many tiny pixel deltas) scroll smoothly, and clamping a fling to one page. It stays out of the way when the app tracks the mouse itself (e.g. vim `set mouse=a`) and in the normal buffer (native scrollback unchanged). Synthesized arrows route through the same broadcast path as typed input, and the row math lives in a pure, unit-tested core (terminalWheelCore). - Copy-on-select ignored the "Select to Copy" toggle: mouseup copied the selection unconditionally while only the feedback badge honored the setting. Gate the clipboard write on the toggle; explicit Ctrl+Shift+C still copies regardless.
Contributor
Author
✅ Manual e2e validation (headless dev build, tauri-driver)Drove the live debug app and exercised both fixes through real DOM/pointer input in a 1. Alt-screen wheel / touchpad scrollOpened
2. Select-to-Copy respects the toggleSet a clipboard sentinel, then drag-selected a line of terminal output.
So with the toggle off the selection is still made but nothing is copied — the reported bug is fixed, and copy-on-select still works when the toggle is on. Validation only — no code changed since the reviewed commit. |
`files` is already declared `mut` at the top of the function, so the `let mut files = files;` rebinding is a no-op that fails CI's `cargo clippy -- -D warnings` (redundant_locals). Pre-existing on dev (introduced in #43); removing it unblocks the build check for this PR.
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.
Fixes the two terminal issues reported in #50.
1. Wheel / touchpad scroll does nothing in full-screen apps (nano/less/vim)
These programs run in xterm's alternate screen buffer, where there's no scrollback to move. xterm 6.0 has no built-in alternate-scroll option, and its internal wheel path dampens sub-50px touchpad deltas toward zero — so touchpad scrolling in
nanowas effectively a no-op (the exact symptom in the issue).Fix: a custom wheel handler (
useTerminal.ts) that, when the alt buffer is active and the app isn't tracking the mouse, translates the wheel delta intoUp/Downarrow presses:true); apps that track the mouse (e.g. vimset mouse=a) keep getting real mouse events;applicationCursorKeysModeis honored so DECCKM apps getESC O A/B.preventDefaultso the gesture doesn't also scroll an ancestor.The row math is a pure, unit-tested core (
terminalWheelCore.ts) covering pixel/line/page modes, carry accumulation, direction reversal, the fling clamp, and degenerate inputs.2. Selecting text always copies, even with "Select to Copy" off
handleMouseUpinterminalClipboard.tswrote the selection to the clipboard unconditionally — only the feedback badge checked the toggle (defaulttrue). So a user who turned the setting off still got copy-on-select.Fix: gate the clipboard write on
getToggle("select-to-copy"). ExplicitCtrl+Shift+Cstill copies regardless.Testing
terminalWheelCore.test.ts(pure core).tsc --noEmitclean.🤖 Generated with Claude Code