Commit Graph

14 Commits

Author SHA1 Message Date
Ayman Bagabas
387f2d73e8
refactor: replace props map with struct fields
Use an int to store property existence and style struct fields to store
the actual values for each non-bool property.

Fixes: https://github.com/charmbracelet/lipgloss/pull/139
Fixes: https://github.com/charmbracelet/lipgloss/pull/141
2024-03-28 17:47:40 -04:00
Christian Rocha
b71dd12664 fix: transform shouldn't operate on ANSI sequences 2024-03-22 16:19:39 -04:00
Michael Lorant
04def9df3e
fix: the empty string can have padding on the right (#253)
An empty string could not have padding applied on the right side.

Issue: #252

Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
2024-01-30 17:38:39 -05:00
Christian Rocha
d354842a40
feat: Style.Transform for altering strings at render time (#232)
* feat: Style.Transform for altering strings at render time

* feat: add `UnsetTransform`

---------

Co-authored-by: Maas Lalani <maas@lalani.dev>
2023-11-27 14:33:38 -05:00
Ayman Bagabas
ac8231edce
fix: renderer race condition (#210)
Guard accessing the underlying Termenv output behind a mutex. Multiple goroutines can set/get the dark background color causing a race condition.

Needs: https://github.com/muesli/termenv/pull/146
2023-08-01 08:23:15 -04:00
Christian Rocha
df8b3fa1f2
feat: convert tabs to spaces with Style.TabWidth(int) (#204)
* feat: convert tabs to spaces with Style.TabWidth(int)

By default tabs will be converted to 4 spaces. To disable tab
conversion set Style.TabWidth(NoTabConversion).
2023-07-24 11:22:48 -04:00
Glenn Gonda
53cc780a5a chore: use io pkg for Discard 2023-03-12 05:26:34 +01:00
Ayman Bagabas
c5382b35ef ref(renderer): change renderer impl 2023-03-08 09:54:27 -08:00
Christian Muehlhaeuser
a74950e6da fix: don't concurrently change output profiles
Multiple lipgloss renderer instances can end up using the same default
termenv.Output. This leads to a race condition when manipulating the
ColorProfile concurrently.

We could mutex protect the standard output in termenv, but it feels like
a weak promise, as the rest of the Output wouldn't (and probably
shouldn't) get protected. Protecting it in lipgloss itself would require
a global lock however.

I can't come up with a proper use-case for this scenario, and therefore
we shift this responsibility to the user.
2023-02-22 17:28:33 +01:00
Ayman Bagabas
cb0f2fd931 chore(tests): add more style tests 2023-02-09 11:59:54 -05:00
Ayman Bagabas
b9c2626fe7 feat(renderer): use style renderer
lipgloss.Style now takes a renderer instance to be used to detect styles
and colors based on its termenv.Output and terminal
2023-02-09 11:59:54 -05:00
Carlos A Becker
14eeaa6ffa fix: reduce dependencies
Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
2023-02-03 12:14:45 +01:00
Christian Muehlhaeuser
681d473622 test: add Style tests 2022-09-30 05:14:18 +02:00
Christian Muehlhaeuser
a86f21a0ae ci: add benchmark test for Style.Render 2022-04-07 04:02:10 +02:00