New table parameter and many fixes
Hi all! This release gives tables a new feature. They can now size themselves to their content and still respect a maximum width. It also comes with a big batch of fixes, many of them from first-time contributors. Let's go!
Fit Content on tables
Until now, setting Width on a table meant it would always stretch to fill that width, even if it only had three short words in it. Now there's FitContent():
t := table.
Width(72).
FitContent().
Headers("LANGUAGE", "FORMAL", "INFORMAL").
Rows(rows...)With FitContent, the table renders at the width its content actually needs. Width becomes a ceiling, if the content is wider than that, the table is held to the maximum and wraps like before.
Perfect for sidebars, popups, and anywhere a table shouldn't go far. Thanks, @pete-woods!
Darker Darks, Lighter Lights
Lip Gloss now decides whether a color is dark using CIELAB lightness instead of HSL. In simple words, it now judges dark and light the way your eyes do, so saturated blues and purples are no longer mistaken for light colors. LightDark and friends will pick the right side more often. Thanks, @janearc!
Full-Fidelity RGB
RGBColor channels are now 16 bits, so colors survive the round trip through color.Color without losing precision. Thanks, @MokiMeow!
Faster Wrapping
Wrap now sizes its buffer up front and copies bytes in runs instead of one at a time. Thanks, @taciturnaxolotl!
That's all for now,
Charm XX 💫
Changelog
New!
- 6a419c6: feat: add
FitContentproperty to table renderer (#697) (@pete-woods)
Fixed
- e3f0511: fix(color): expand RGBColor channels to 16 bits (#757) (@MokiMeow)
- 092b7f4: fix(compat): honor NO_COLOR in init-time background query (#692) (@jadb)
- 19f011f: fix(luminance): detect dark colors by Lab, not HSL (#752) (@janearc)
- 8c6bfaf: fix(table): prevent panic when YOffset is set to a negative value (#727) (@bunlongheng)
- 03215bc: fix(tree): handle nil values (#738) (@Charlie-Wang-03)
- 4da0bdd: fix(tree): stop swapping Offset start and end (#676) (@c-tonneslan)
- 2a70d4e: fix: alphabet enumerator producing non-letters for large lists (#715) (@winklemad)
- ce49a2a: fix: don't mangle embedded ANSI when styling spaces (#708) (@larrasket)
- 0599726: fix: infinite loop with zero-width characters (#670) (@Spuxy)
- 4b8c667: fix: store bool props in a 64-bit field (#732) (@QuentinouLeTwist)
- 3ab3b5f: fix: terminate margin background on each line (#711) (@c-tonneslan)
- 0f0a984: fix: unset underline style rule (#686) (@abnormal749)
Other stuff
- 6860635: Fix order of calling w.Close in Wrap (#689) (@neomantra)
- 4a8c4de: Inline: replace newlines with a space, not empty string (#665) (@MukundaKatta)
- 77047a8: ci: sync dependabot config (#728) (@charmcli)
- c7d9f35: perf(wrap): forward bytes in runs instead of one at a time (@taciturnaxolotl)
- 868e8b5: perf(wrap): size the buffer in Wrap up front (@taciturnaxolotl)
- ff16a4e: v2.1.0 (@andrinoff)
Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.