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.