Skip to content

Fix TUI sizing: borders, input width, wrapping, wide runes - #32

Merged
archlemon merged 1 commit into
mainfrom
fix/tui-sizing
Nov 28, 2026
Merged

archlemon merged 1 commit into
mainfrom
fix/tui-sizing

Conversation

@archlemon

Copy link
Copy Markdown
Member

Summary

Fixes #27, from the TUI audit.

  • Borders count toward Width/Height, as in the browser. lipgloss draws the border outside the size it's given, so a bordered Width: 20 Box or Text was 22 cells, and a bordered Fill box overflowed the terminal. styleToLipgloss subtracts the border, and Box inner sizes account for it.
  • Input with Style.Width sets the textinput width, so a long value scrolls instead of wrapping onto 3 rows.
  • TextArea wraps long lines before clipping to Rows, so it keeps its height.
  • Card titles longer than Style.Width are truncated instead of widening the card.
  • Unsized Divider spans its pane (availWidth), not the terminal. It used to break Split and Sidebar rows.
  • Collapsed wrapping Row (Sidebar on a narrow terminal) re-renders its children at the column width, so a Responsive pane picks the variant for the space it actually has. Button focus numbering restarts for the re-render, so focus keys stay consistent.
  • Wide glyphs: the status bar and divider labels measure and truncate by display cells (x/ansi, already an indirect dependency, now direct), so CJK and emoji no longer push the frame past the terminal.

Test plan

  • New sizing_test.go, one test per item. All seven fail on main.
  • Kitchen-sink TUI render unchanged for unbordered and unsized elements
  • go test -race ./..., make e2e, both vets

- Style Width and Height include the border, as in the browser: a
  bordered Width 20 Box or Text is 20 cells, and a bordered Fill box no
  longer overflows the terminal. Box inner sizes subtract the border.
- An Input with Style.Width scrolls its value within the width instead
  of wrapping onto extra rows.
- TextArea wraps long lines before clipping to Rows, so it keeps its
  height.
- A Card title longer than Style.Width is truncated instead of
  widening the card.
- An unsized Divider spans its pane, not the terminal, so it no longer
  breaks Split and Sidebar rows.
- A wrapping Row that collapses re-renders its children at the column
  width, so Responsive content picks the variant for the space it has.
- The status bar and divider labels measure and truncate by display
  cells, so wide glyphs no longer push the frame past the terminal.

Closes #27
@archlemon
archlemon merged commit 8225ecd into main Nov 28, 2026
2 checks passed
@archlemon
archlemon deleted the fix/tui-sizing branch November 28, 2026 07:05
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.

TUI sizing bugs: borders, input width, wide runes

1 participant