feat(table): add configurable table border toggles - #564
Open
nguyenvanduocit wants to merge 1 commit into
Open
Conversation
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.
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.
Closes #563.
What
Adds seven optional
*booltoggles toansi.StyleTable—HeaderBorder,RowBorder,ColumnBorder,TopBorder,BottomBorder,LeftBorder,RightBorder(JSON:header_border,row_border, …) — mapping onto the corresponding lipgloss table border switches.setBordersnow 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 runnableExample, and documents the toggles instyles/README.md.Example (
row_border: true, ASCII style):