Skip to content

feat: visual select mode (v) for native text selection#129

Open
vertti wants to merge 2 commits into
dlvhdr:mainfrom
vertti:feat/toggle-mouse-capture
Open

feat: visual select mode (v) for native text selection#129
vertti wants to merge 2 commits into
dlvhdr:mainfrom
vertti:feat/toggle-mouse-capture

Conversation

@vertti
Copy link
Copy Markdown
Contributor

@vertti vertti commented May 4, 2026

Summary

Adds v to toggle bubbletea's mouse capture between AllMotion and None — a "visual select mode" that releases the mouse so the terminal can do its native click-and-drag selection. Useful for copying lines from the diff (e.g. when reviewing edits via --watch and pasting feedback elsewhere).

A small visual select indicator appears in the footer (mirroring the existing watching: label) so the mode change is discoverable.

Why

With tea.MouseModeAllMotion always on, every drag is captured by the app and terminal-native text selection is suppressed. There was no way to copy a snippet from the diff. Toggling capture is the standard TUI answer (lazygit, k9s, etc.) and keeps all existing mouse UX (sidebar drag, scroll wheel, zone clicks) intact when the mode is off.

Notes

  • Bound to v for the vim "visual select" mnemonic; a single keystroke that doesn't overlap with other bindings.
  • MouseModeNone is read by bubbletea v2 in View() each frame; the renderer emits the right CSI sequences when the mode changes, so toggling is instant.
  • In side-by-side view, native selection spans both columns + divider. Two workarounds (no extra code): switch to unified with s first, or use the terminal's block-select modifier (Option+drag in iTerm2 / Terminal.app, Alt+drag in many Linux terminals). Both are documented in the README.
  • Most terminals already support Shift+drag to bypass mouse capture without toggling — also mentioned in the README for users who don't want to leave a sustained selection mode.
  • In-flight draggingSidebar state is cleared on toggle to avoid orphaned drag state.

Bind M to flip the bubbletea MouseMode between AllMotion and None.
While off, the terminal regains native click-and-drag selection so
users can copy diff lines (e.g. when reviewing changes via --watch).
A "mouse off" indicator is shown in the footer alongside the
existing watch label.
@vertti vertti marked this pull request as draft May 4, 2026 11:34
Switches the toggle from M (awkward shift+m next to lowercase m for
commit info) to v, mirroring vim's visual-select mnemonic. Renames the
footer indicator from 'mouse off' to 'visual select' since users press
the key to *enable* mouse-driven text selection — 'mouse off' described
the underlying capture state but read as a regression.
@vertti vertti changed the title feat: toggle mouse capture with M to enable text selection feat: visual select mode (v) for native text selection May 4, 2026
@vertti vertti marked this pull request as ready for review May 4, 2026 11:48
@dlvhdr
Copy link
Copy Markdown
Owner

dlvhdr commented May 15, 2026

Hey @vertti , does this also work with tmux?

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

Successfully merging this pull request may close these issues.

2 participants