Skip to content

Conversation

aymanbagabas
Copy link
Member

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>
Copy link

@Copilot Copilot AI left a comment

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

@aymanbagabas
Copy link
Member 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
Copy link
Member

caarlos0 commented Jul 7, 2025

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
13 checks passed
@aymanbagabas aymanbagabas deleted the padchar branch July 7, 2025 17:35
@aymanbagabas
Copy link
Member 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.

3 participants