Skip to content

feat(core): double/triple word/line select + click-drag word snap #887

Open
phall1 wants to merge 1 commit intoanomalyco:mainfrom
phall1:feat/click-count-word-line-selection
Open

feat(core): double/triple word/line select + click-drag word snap #887
phall1 wants to merge 1 commit intoanomalyco:mainfrom
phall1:feat/click-count-word-line-selection

Conversation

@phall1
Copy link
Copy Markdown

@phall1 phall1 commented Mar 28, 2026

Multi-click text selection (double-click word, triple-click line, word-snap drag)

Add standard terminal/editor selection behavior to OpenTUI: double-click selects a word, triple-click selects a line, and dragging after double-click expands by whole words.

The renderer now tracks click sequences and exposes MouseEvent.clickCount, then uses that in mouse handling to trigger word/line selection paths. Word boundaries are computed with Unicode grapheme segmentation (Intl.Segmenter) so emoji clusters, CJK, and combining marks select correctly. I also extracted the selection probing logic into shared primitives to remove duplication between text/edit buffer renderables.

One important behavioral fix included here: word-snap drag updates no longer prematurely end selection state during drag; selection finalization now happens correctly on mouse-up.

resolves #744

…lick-drag word snap

Wire up multi-click selection in the renderer's mouse event pipeline:
- Double-click selects the word under the cursor
- Triple-click selects the full visual line
- Double-click-drag extends selection by whole word boundaries

Add grapheme-aware word boundary detection (selection-primitives.ts)
using Intl.Segmenter with support for CJK, emoji clusters, decomposed
accents, and punctuation boundaries. Extract shared visual line probing
behind a SelectionProbeView interface to eliminate duplication between
EditBufferRenderable and TextBufferRenderable.
@phall1 phall1 marked this pull request as ready for review March 28, 2026 06:28
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.

Feature: Click count tracking + word/line selection primitives

1 participant