mirror of
https://github.com/mark3labs/kit.git
synced 2026-06-14 03:30:26 +00:00
4fa5775974
Implement crush-style mouse text selection with character-level precision, replacing the previously disabled stub implementation. Architecture: - New selection package (internal/ui/selection/) handles all coordinate math, word boundary detection, and cell-level ANSI text manipulation - ScrollList upgraded with proper mouse down/drag/up flow supporting single click (character drag), double click (word), triple click (line) - Model.go wires BubbleTea mouse events through to ScrollList with proper viewport Y-offset adjustment for the scrollback area Key features: - Character-level selection using ultraviolet ScreenBuffer for ANSI-aware cell parsing — correctly handles styled text, emoji, CJK wide chars - Word selection via UAX#29 Unicode segmentation (clipperhouse/uax29) - Display-width-aware columns via clipperhouse/displaywidth (not bytes) - Dual clipboard: OSC 52 (remote terminals) + native (atotto/clipboard) - Multi-click detection with 400ms threshold and 2px tolerance - Mouse event throttling via existing MouseModeCellMotion - Selection cleared on any keypress for clean UX Dependencies (all already indirect in go.mod): - github.com/charmbracelet/ultraviolet (ScreenBuffer, cell manipulation) - github.com/charmbracelet/x/ansi (ANSI strip, StringWidth) - github.com/clipperhouse/displaywidth (grapheme display width) - github.com/clipperhouse/uax29/v2 (Unicode word segmentation)