-
Notifications
You must be signed in to change notification settings - Fork 494
Feature: Click count tracking + word/line selection primitives #744
Description
Summary
The renderer's selection system currently operates at character-level granularity with coordinate-based APIs (startSelection, updateSelection, getSelection). There's no built-in support for multi-click selection (double-click word, triple-click line) or text-coordinate mapping, which means consumers can't implement standard text selection UX without reverse-engineering internal layout math.
Problem
MouseEvent has no clickCount property, and the renderer has no word/line-level selection methods. Implementing double-click-to-select-word requires:
- Userland click counting (easy, but should be framework-level)
- Mapping screen
(x, y)→ text content → word/line boundaries → back to screen(x, y)to callstartSelection/updateSelection
Step 2 is the blocker. Text layout (wrapping, padding, scroll offsets) is internal to each renderable. There's no public API to go from a character index in text to a screen coordinate, so consumers end up either hardcoding layout assumptions or reaching into renderable internals — both fragile.
Requested APIs
1. clickCount on MouseEvent
Track consecutive clicks at the same position within a time threshold (~400ms). This is standard in every GUI framework (DOM, Qt, GTK, etc.).
class MouseEvent {
readonly clickCount: number; // 1 = single, 2 = double, 3 = triple
// ... existing fields
}2. Word/line selection on renderer
Methods that handle the text↔coordinate mapping internally, where the layout knowledge already lives:
class CliRenderer {
// Select the word at screen position (x, y)
selectWord(x: number, y: number): void;
// Select the full line at screen position y
selectLine(x: number, y: number): void;
// During drag: snap selection extent to nearest word boundary
// (for word-snap dragging after double-click-drag)
updateSelectionWordSnap(x: number, y: number): void;
}The renderer already owns both the text layout and the selection state, so this is a natural extension of the existing selection system.
Use Case
Standard terminal text selection UX:
- Single click + drag: character-level selection (already works ✅)
- Double click: select word under cursor
- Triple click: select entire line (within a
<box>persumably) - Double click + drag: extend selection with word-level snapping