TUI polish: aligned tables, char-precise selection, /mouse toggle#106
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_rangesplits 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.
/mousecapture 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_tablealigns 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;/mouseparses (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.