Skip to content

feat: add a table that fits the terminal width - #4

Merged
autoantohaki merged 4 commits into
mainfrom
feat/table
Oct 22, 2026
Merged

autoantohaki merged 4 commits into
mainfrom
feat/table

Conversation

@autoantohaki

Copy link
Copy Markdown
Member

Requested by mau

Before: tools lined up columns by hand. relay-cards lays out an HTTP request as a row of Box gap texts, which drifts out of alignment from card to card and has no way to shrink when the terminal is narrow.

After: Table draws a header, a rule and rows with columns that line up. Columns start as wide as their widest cell; when the table is wider than width, 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 with value, and colored per row (the gallery colors status codes). selectedIndex highlights a row and maxRows shows 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 one Text line 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.

@autoantohaki
autoantohaki merged commit 469bba1 into main Oct 22, 2026
12 checks 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