Commit Graph

24 Commits

Author SHA1 Message Date
Unseen Daan
96795629c1
fix: always render horizontal border edge when enabled (#211)
When a style has a border set and an empty string is rendered, it should
still render the border. When the left border is set, width is
incremented by 1, so in most cases the width will not be 0.

When we render an empty string, with a double border and no left border
we expect the following:
╗
║
╝
But if we don't render a horizontal edge when the string width is less
than 1 we see this:

║

The string width can't be lower than 0, so we can safely remove the
(width < 1) check to create the expected behavior.

Co-authored-by: Daan Schoone <daaschoone@gmail.com>
2024-03-14 11:12:23 -04:00
Michael Lorant
2745d8a3d8
Improve maximum width of characters in a string (#257)
The function `maxRuneWidth` was using a flawed approach by only
evaluating strings based on each rune. The `uniseg` package provides a
more accurate method based on grapheme clusters.

This change switches over to the improved implementation which should
achieve better results when determining the maximum width of all
grapheme clusters in a string.

Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
2024-02-13 10:03:24 -05:00
Michael Lorant
59874c2afa
chore: apply gofumpt to all files (#255)
Apply gofumpt to all files to correct minor formatting issues.

Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
2024-01-30 17:44:00 -05:00
Maas Lalani
408dcf3b9e
feat: add Middle borders (#230) 2023-10-05 12:26:16 -04:00
mieubrisse
4c3e61d4d1 Fix bugs with border size calculation 2023-05-01 09:37:20 -04: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
Ayman Bagabas
31ab45f810 feat: instantiate lipgloss renderers
* Use lipgloss instances instead of a singleton global instance
* Deprecate (s Style).Render & (s Style).String
* Deprecate the Stringer interface
* Update README and godocs
* Update example
2023-02-09 11:59:54 -05:00
nervo
1c1240fd65
docs: fix various typos (#156) 2022-11-08 10:55:11 +01:00
Victor/Alyx Bersy
9ee8b6e19f
feat: add BlockBorder, OuterHalfBlockBorder, and InnerHalfBlockBorder border styles (#120) 2022-10-27 15:02:57 -04:00
Christian Rocha
514fa059f3 Fix and generally improve various doc comments 2022-02-14 11:43:23 -05:00
Christian Rocha
7f051d0e92 Add HiddenBorder(), which renders a border comprised of spaces
HiddenBorder() can be useful if you want to remove a border but maintain
layout positioning. This said, you can still apply a background color to
a hidden border.
2021-08-19 15:36:14 -04:00
Christian Rocha
a9b894aa07 Add Style.GetFrameSize(), improve border method naming 2021-08-19 15:26:30 -04:00
Christian Rocha
3b4907dffe Simplify how border styles are queried 2021-08-19 15:26:30 -04:00
Christian Rocha
adee683da4 Add methods to query border widths 2021-08-19 15:26:30 -04:00
Christian Rocha
d9fae9f03a For now, limit corners on border to a single rune 2021-04-29 09:59:44 -04:00
Christian Rocha
6064d52be1 Support for multi-rune borders 2021-04-29 09:59:44 -04:00
Christian Rocha
bb42143109 Remove 'Color' suffix from border FG/BG API methods
This makes the border API better match the rest of the API. Also, the
'Color' part is implicit.
2021-04-07 12:23:36 -04:00
Christian Rocha
b3875326a3 Don't check color profile and terminal darkness until absolutely necessary 2021-04-05 10:43:01 -04:00
Christian Rocha
9b77d4607b
Rename ColorType to TerminalColor 2021-03-30 22:19:38 -04:00
Christian Rocha
5ec7baa707
Fix width of borders when they're horizontal only 2021-03-30 10:18:38 -04:00
Christian Rocha
82393c2d95
Fix bug where top border was being rendered on the bottom 2021-03-26 18:15:16 -04:00
Christian Rocha
d7bd9ebc4f
Borders are back 2021-03-25 20:43:40 -04:00
Christian Rocha
6bfa4297a0
Style.Inline and Style.MaxWidth no longer mutate the style 2021-03-17 14:27:09 -04:00
Christian Rocha
303947c10c
Implement the Stringer interface for the Style type 2021-03-17 14:27:09 -04:00