Skip to content

feat: add padding and margin character support - #546

Merged
aymanbagabas merged 5 commits into
v2-expfrom
padchar
Jul 7, 2025
Merged

aymanbagabas merged 5 commits into
v2-expfrom
padchar

Conversation

@aymanbagabas

Copy link
Copy Markdown
Contributor

This adds support for setting a padding and margin character in the Style struct. This allows users to specify a character that will be used for padding and margin and defaults to whitespace if not set.

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces configurable padding and margin characters in the Style struct, defaulting to whitespace when unset.

  • Added paddingChar and marginChar fields and corresponding property keys.
  • Updated Render and applyMargins to use the custom characters.
  • Added setter/getter methods for the new properties.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
style.go Defined new paddingCharKey/marginCharKey, struct fields, and applied defaults in rendering.
set.go Handled paddingCharKey and marginCharKey in set, setFrom, and created PaddingChar/MarginChar methods.
get.go Introduced GetPaddingChar, GetMarginChar, and getAsRune to retrieve the new properties.
Comments suppressed due to low confidence (2)

get.go:138

  • [nitpick] Add a comma after 'set' in the comment: 'If no value is set, 0 is returned.' to improve readability.
// GetPaddingChar returns the style's padding character. If no value is set

style.go:395

  • There are no tests covering the new paddingChar and marginChar behaviors in rendering. Consider adding unit tests to verify custom character defaults and overrides.
		padChar := s.paddingChar

Comment thread style.go Resolved
@aymanbagabas

Copy link
Copy Markdown
Contributor Author

CC/ @caarlos0 @meowgorithm

This adds support for setting a padding and margin character in the
Style struct. This allows users to specify a character that will be used
for padding and margin and defaults to whitespace if not set.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@caarlos0

caarlos0 commented Jul 7, 2025 •

Copy link
Copy Markdown
Contributor

superseedes #545
refs charmbracelet/fang#57
refs #534
refs #489

@aymanbagabas
aymanbagabas changed the base branch from nbsp to v2-exp July 7, 2025 17:31
@aymanbagabas
aymanbagabas merged commit 045a87b into v2-exp Jul 7, 2025
@aymanbagabas
aymanbagabas deleted the padchar branch July 7, 2025 17:35
@aymanbagabas

Copy link
Copy Markdown
Contributor Author

This is now merged into v2-exp. @andreynering We should update Glamour to use the new style.PaddingChar(lipgloss.NBSP) API.

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.

4 participants