fix(tui): disable mouse capture to restore native text selection#348
Open
coder-movers wants to merge 1 commit into
Open
fix(tui): disable mouse capture to restore native text selection#348coder-movers wants to merge 1 commit into
coder-movers wants to merge 1 commit into
Conversation
EnableMouseCapture is still run on TUI startup and reactivation, which makes the terminal forward mouse events to the process and disables native drag-to-select and copy. The scroll-wheel-to-arrow mapping that previously consumed those events was already removed (ff9dfb2), so the capture now has no consumer yet still blocks selection. Drop EnableMouseCapture and DisableMouseCapture from the terminal enter and restore paths. Closes SaladDay#347
878c843 to
37337a3
Compare
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.
What
Stop enabling mouse capture when the TUI starts (and when it is reactivated after a handoff). Terminal-native drag-to-select and copy work again while the TUI is running.
Why
TuiTerminal::newandactivate_best_effortinsrc/cli/tui/terminal.rsrunEnableMouseCapturealongsideEnterAlternateScreen. While capture is active the terminal emulator forwards mouse events to the process instead of performing native selection, so users could not select or copy any on-screen text from within the TUI.The scroll-wheel-to-arrow mapping that previously consumed those events was already removed in ff9dfb2 (
fix(tui): prevent long-list scroll stalls), soEnableMouseCapturenow has no consumer yet still blocks selection. This PR drops the capture calls from the terminal enter/restore paths.Why not keep capture and implement in-app selection instead: an app-drawn selection highlight is just rendered cells, not the terminal's selection, so
Ctrl+C/Ctrl+Shift+Cwould still copy nothing useful. The app would have to write the clipboard itself (a new dependency or per-OS shell-out, with WSL2 needingclip.exe). Terminal-native selection is the only way to get copy via the terminal's existing keybindings without that cost, and it requires capture off.Closes #347.
Change
src/cli/tui/terminal.rs: remove thecrossterm::event::{DisableMouseCapture, EnableMouseCapture}import and the fourEnableMouseCapture/DisableMouseCapturearguments from theexecute!calls innew,restore_stdout_best_effort,restore_best_effort, andactivate_best_effort.EnterAlternateScreen/LeaveAlternateScreen, raw mode, and cursor show/hide are unchanged.No change to
mod.rsortests.rsis needed on top ofmain: theEvent::Mousearm and theMouseEventKindimport inmod.rswere already removed by ff9dfb2, andtests.rsalready importsMouseEventKinddirectly.Tradeoff
This is the opposite direction from #342, which requests mouse click support and needs
EnableMouseCapturekept. Under crossterm, capture is all-or-nothing: in-app click hit-testing and terminal-native selection cannot coexist. This PR prioritizes copy-paste; if #342 is implemented later it should be opt-in rather than the default, or accept that selection is unavailable while active.Testing
cargo fmt --checkis clean.