Skip to content

feat(table): add configurable table border toggles - #564

Open
nguyenvanduocit wants to merge 1 commit into
charmbracelet:mainfrom
nguyenvanduocit:feat/configurable-table-borders
Open

feat(table): add configurable table border toggles#564
nguyenvanduocit wants to merge 1 commit into
charmbracelet:mainfrom
nguyenvanduocit:feat/configurable-table-borders

Conversation

@nguyenvanduocit

Copy link
Copy Markdown

Closes #563.

What

Adds seven optional *bool toggles to ansi.StyleTableHeaderBorder, RowBorder, ColumnBorder, TopBorder, BottomBorder, LeftBorder, RightBorder (JSON: header_border, row_border, …) — mapping onto the corresponding lipgloss table border switches. setBorders now honors them.

Why

Border visibility was hardcoded in setBorders, so a style could pick separator characters but not whether row dividers or an outer frame were drawn. There was no way to render a horizontal divider between table rows. See #563.

Backward compatibility

Each toggle is a pointer; an unset field keeps glamour's historical default — header rule and column separators on, outer frame and inter-row dividers off. Styles that don't set the fields render byte-for-byte as before, so the existing golden tests pass unchanged.

Tests / docs

Adds tests pinning the default (one separator line) and RowBorder (a divider between body rows), a runnable Example, and documents the toggles in styles/README.md.

Example (row_border: true, ASCII style):

 #  | Quyết định      | ...
----+-----------------+----
 D1 | ...             | ...
----+-----------------+----
 D2 | ...             | ...

Tables previously always rendered with the header rule and column
separators only; the outer frame and inter-row dividers were hardcoded
off in setBorders, with no way to change them through a style. This adds
seven optional *bool toggles to ansi.StyleTable — HeaderBorder, RowBorder,
ColumnBorder, TopBorder, BottomBorder, LeftBorder and RightBorder — that
map onto the corresponding lipgloss table border switches.

Each toggle is a pointer so an unset field keeps glamour's historical
default (header rule and column separators on; outer frame and row
dividers off), making the change fully backward compatible: styles that
do not set the fields render byte-for-byte as before. Setting RowBorder
draws a divider between every row; the four frame toggles box the table.

Adds tests pinning the default (one separator line) and the RowBorder
behavior (a divider between body rows), plus a runnable example, and
documents the toggles in styles/README.md.
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.

Tables cannot draw row dividers or an outer frame — border visibility is hardcoded

1 participant