Skip to content

TUI polish: aligned tables, char-precise selection, /mouse toggle#106

Merged
davidrhodus merged 3 commits into
mainfrom
tui-polish
Jul 16, 2026
Merged

TUI polish: aligned tables, char-precise selection, /mouse toggle#106
davidrhodus merged 3 commits into
mainfrom
tui-polish

Conversation

@davidrhodus

Copy link
Copy Markdown
Contributor

The three deferred TUI loose ends

Closes out the loose ends flagged during the TUI restyle.

1. Aligned markdown tables

Consecutive pipe-table rows are now buffered during streaming commit and rendered as one aligned block: columns padded to the widest cell, :--/--:/:--: alignment honored, header bolded, a ruled ├─┼─┤ separator. Previously each row rendered line-locally, so columns didn't line up. The line-local renderer stays for the live (in-progress) preview.

2. Character-precise selection within a line

Drag-selection now carries a column, so a drag inside a single non-wrapped line copies (and highlights) exactly those characters — grab a filename or a value, not the whole line. Multi-line selections, or selections on a wrapped line (where a screen column can't be mapped to a character unambiguously), keep the robust whole-line behavior. highlight_char_range splits spans at the range boundaries to paint only the selected glyphs.

Design note: full char-precision on wrapped lines would require reproducing ratatui's word-wrapper (and keeping it exactly consistent with the render path, or the mapping drifts). Gating precision to single-row lines keeps it correct with no wrap-mapping risk, and covers the common case.

3. /mouse capture toggle

/mouse [on|off] toggles crossterm mouse capture at runtime. Off releases the mouse to the terminal's own native text selection (at the cost of scroll-wheel, click-to-fold, and drag-copy); on restores app control. For terminals where you'd rather use native selection than hold ⌥/Shift.

Tests & gates

  • render_table aligns columns / bolds the header / rules the separator; a streamed table stays buffered until it ends then commits aligned; a single-line drag selects the exact character range; extending across lines falls back to whole-line; /mouse parses (and has a plain-CLI arm). 169 hi-tui tests pass.
  • cargo fmt --all --check, full clippy (-D warnings) across all crates, and the file-size ratchet all pass.

David and others added 3 commits July 16, 2026 10:00
Two TUI polish items:

- Aligned tables: consecutive pipe-table rows are buffered during streaming
  commit and rendered as one block with columns padded to the widest cell in
  each column, honoring :--/--:/:--: alignment, bolding the header, and drawing a
  ruled ├─┼─┤ separator. The line-local renderer stays for the live preview.
- /mouse [on|off]: toggle crossterm mouse capture at runtime. Off releases the
  mouse to the terminal's native text selection (losing scroll-wheel, click-fold,
  and drag-copy); on restores app control. New Command::Mouse + handler that runs
  Enable/DisableMouseCapture and reports the new state.

Tests: render_table aligns columns / bolds header / rules the separator; a
streamed table stays buffered until it ends then commits aligned; /mouse parses.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Drag-selection now carries a column, so a drag within a single non-wrapped line
copies (and highlights) just those characters — grab a filename or value, not the
whole line. Selections that span multiple lines, or land on a wrapped line (where
a screen column can't be mapped to a character unambiguously), keep whole-line
behavior. A new highlight_char_range splits spans at the range boundaries to
paint only the selected glyphs.

Tests: a single-line drag selects the exact character range and copies it;
extending across lines falls back to whole-line selection.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The new /mouse command needs an arm in the --plain CLI dispatcher; it's a
TUI-only feature, so it prints the same "TUI only" notice as /theme.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@davidrhodus
davidrhodus merged commit c73d697 into main Jul 16, 2026
1 check passed
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.

1 participant