Repository navigation
feat: add a table that fits the terminal width - #4
Merged
Merged
Conversation
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.
Requested by mau
Before: tools lined up columns by hand. relay-cards lays out an HTTP request as a row of
Box gaptexts, which drifts out of alignment from card to card and has no way to shrink when the terminal is narrow.After:
Tabledraws a header, a rule and rows with columns that line up. Columns start as wide as their widest cell; when the table is wider thanwidth, the widest columns shrink first down to a minimum and cut text with…at the end or, for paths and URLs, in the middle. Cells can be right or center aligned, computed withvalue, and colored per row (the gallery colors status codes).selectedIndexhighlights a row andmaxRowsshows a window that follows the selection with ↑/↓ counts of hidden rows.How: widths are measured with
string-width(already a dependency of Ink, same range), so CJK text and emoji count as two columns, and truncation cuts on grapheme boundaries. Each row is oneTextline padded to exact widths rather than flex boxes, so alignment does not depend on Ink's layout. The layout helpers are exported for tools that need them. Stacked on #3; merge after it.