Releases: charmbracelet/lipgloss
v0.4.0
Quality-of-Life Updates
This release includes a menagerie of small but useful and handy improvements.
Automatic Wrapping for Long Words
Occasionally you’ll have a word (often a URL or a path) that runs wider than the Width()
you set on a style:
// style.Width(5)
╭───────────╮
│Schnurrbart│
╰───────────╯
// ... that is definitely more than 5 cells wide
Such words will now automatically wrap:
// style.Width(5)
╭─────╮
│Schnu│
│rrbar│
│t │
╰─────╯
// There we go
For details, see the corresponding PR.
Query Borders and Whitespace
Sometimes you need to measure borders and whitespace when calculating your layouts and you end up with code like this:
const horizontalPadding = 6
style.Copy().Width(windowWidth-horizontalPadding)
This update includes a multitude of methods for querying your styles so you can do away with unnecessary constants and magic numbers. For example:
style.Copy().Width(windowWidth-style.GetHorizontalPadding())
The most useful of these methods are perhaps the ones that let you query margins, borders and padding all at once:
Style.GetFrameSize() (x, y int)
Style.GetVerticalFrameSize() int
Style.GetHorizontalFrameSize() int
For details see the changelog below.
Improved Automatic Color Degradation
- Better color conversions when automatically degrading a color profile (for example, when coercing from TrueColor to ANSI256).
The Mystical Hidden Border
At first glance a hidden border seems silly. Hidden borders can be useful, however, if you want to remove a border but maintain layout positioning in, say, an interactive TUI. Also note that you can still apply a background color to a hidden border.
To make a hidden border simply call lipgloss.HiddenBorder()
.
Changelog
Changed
- Words wider than a style’s
Width()
now wrap automatically - Update termenv for improved color space for color profile conversions (it now uses the excellent HSLuv color space)
New
HiddenBorder()
, which renders a border comprised of spaces- Style-level methods for querying borders and whitespace:
- Borders:
Style.GetBorderTopSize() int
Style.GetBorderRightSize() int
Style.GetBorderBottomSize() int
Style.GetBorderLeftSize() int
Style.GetHorizontalBorderSize() int
Style.GetVerticalBorderSize() int
- Margins:
Style.GetMarginTop() int
Style.GetMarginRight() int
Style.GetMarginBottom() int
Style.GetMarginLeft() int
Style.GetHorizontalMargins() int
Style.GetVerticalMargins() int
- Padding:
Style.GetPaddingTop() int
Style.GetPaddingRight() int
Style.GetPaddingBottom() int
Style.GetPaddingLeft() int
Style.GetHorizontalPadding() int
Style.GetVerticalPadding() int
- Get horizontal margins, padding, and border widths all at once:
Style.GetVerticalFrameSize() int
Style.GetHorizontalFrameSize() int
Style.GetFrameSize() (x, y int)
- Borders:
- Border-level size querying methods:
Border.GetTopSize() int
Border.GetRightSize() int
Border.GetBottomSize() int
Border.GetLeftSize() int
Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse or right here in GitHub Discussions.
v0.3.0
Utility Functions
This release adds two utility functions to the Lip Gloss tool belt:
-
StyleRunes
can apply styling to runes at specific indices in a string, perfect for highlighting matched characters in a fuzzy search result, marking a hotkey on a button and so on. -
SetColorProfile
sets the color profile on a package-wide basis, which is very useful in testing. Note that outside of testing you probably don’t want to set the color profile as the best available option will be automatically chosen.
Changelog
New
StyleRunes
: applying styling to specific runes in a stringSetColorProfile
: set the color profile on a package-wide context
Changed
- Bump
go-runewidth
to v0.0.13 for improved emoji rendering
Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse or right here in GitHub Discussions.
v0.2.1
Border Fantasy
This PR adds support for fancier borders, fixes some bugs, and adds a helper function for measuring text blocks.
With the new border support, it's possible to construct borders from multiple runes, such as this:
New
- Support for multi-rune borders
- Added
Size() (int, int)
for returning the width and the height of a block in one go
Fixed
- Bump go-runewidth to fix some emoji mis-measuring
- Fix a panic that could happen in custom borders
Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse or right here in GitHub Discussions.
v0.2.0
Getters
This PR adds getters for all style rules, enabling you to query your style rules. This can be handy when building layouts, particularly when styles are variable, such as a component. For example:
if headerStyle.GetMarginLeft() > lipgloss.Width(spinner) + lipgloss.Width(gap) {
// jam the spinner in the left gutter
} else {
// just put the spinner on the right
}
For details on the getter API, check out the docs.
Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse or right here in GitHub Discussions.
v0.1.3
Data Race
This bugfix fixes a potential data race when querying for the background color internally for the first time.
Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse or right here in GitHub Discussions.
v0.1.2
Border Color API Adjustments
This update makes the border color API more consistent with the other color-related potions of the API by dropping the Color suffix in color-related border methods.
Changes to border foreground methods:
BorderForegroundColor
is nowBorderForeground
BorderTopForegroundColor
is nowBorderTopForeground
BorderRightForegroundColor
is nowBorderRightForeground
BorderBottomForegroundColor
is nowBorderBottomForeground
BorderLeftForegroundColor
is nowBorderLeftForeground
Changes to border background methods:
BorderBackgroundColor
is nowBorderBackground
BorderTopBackgroundColor
is nowBorderTopBackground
BorderRightBackgroundColor
is nowBorderRightBackground
BorderBottomBackgroundColor
is nowBorderBottomBackground
BorderLeftBackgroundColor
is nowBorderLeftBackground
Also:
UnsetBorderColor
has been removed. To unset border colors useUnsetBorderForeground
andUnsetBorderBackground
.
We hope you’re enjoying Lip Gloss!
Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse or right here in GitHub Discussions.
v0.1.1
Windows Legacy
This release includes support for the Windows 10 legacy command console, which includes cmd.exe and the standalone PowerShell application on Windows. Lip Gloss should now "just work" on those consoles.
Note that ANSI already works by default in Windows Terminal.
Thoughts? Questions? Feel free to reach out on Twitter, The Fediverse or right here in GitHub Discussions. We love hearing from you.
v0.1.0
Hello World
We’re excited to present Lip Gloss, a new declarative terminal styling library built with TUIs in mind. We made this library after seeing design patterns emerge while building Bubble Tea projects such as Glow.
Lip Gloss does not replace Bubble Tea. Rather, it is a Bubble Tea companion. It was designed to make building terminal user interfaces—and general terminal rendering—as simple and fun as possible, allowing you to focus on building your application rather than concerning yourself with the nuts and bolts of layout details.
Let us know what you think. Feel free to reach out on Twitter, The Fediverse or right here in GitHub Discussions. We love hearing from you.