Skip to content

Commit

Permalink
fix: combining both conditional and unconditional wrapping (#275)
Browse files Browse the repository at this point in the history
* feat: switch to term/ansi for text manipulation

Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: muesli/reflow#71
Fixes: #258
Fixes: #220

* fix: combining both conditional and unconditional wrapping

Uses `ansi.SmartWrap` charmbracelet/x#57

Fixes: muesli/reflow#43

* chore: update deps

* Update get.go
  • Loading branch information
aymanbagabas committed Mar 29, 2024
1 parent f6f9334 commit 2434fda
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -5,7 +5,7 @@ retract v0.7.0 // v0.7.0 introduces a bug that causes some apps to freeze.
go 1.18

require (
github.com/charmbracelet/x/exp/term v0.0.0-20240328150354-ab9afc214dfd
github.com/charmbracelet/x/exp/term v0.0.0-20240329185201-62a6965a9fad
github.com/muesli/termenv v0.15.2
github.com/rivo/uniseg v0.4.7
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
@@ -1,7 +1,7 @@
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/charmbracelet/x/exp/term v0.0.0-20240328150354-ab9afc214dfd h1:HqBjkSFXXfW4IgX3TMKipWoPEN08T3Pi4SA/3DLss/U=
github.com/charmbracelet/x/exp/term v0.0.0-20240328150354-ab9afc214dfd/go.mod h1:6GZ13FjIP6eOCqWU4lqgveGnYxQo9c3qBzHPeFu4HBE=
github.com/charmbracelet/x/exp/term v0.0.0-20240329185201-62a6965a9fad h1:ixybSpyIZys0qK4JF0asuuxdr9fMXHrOQa7/G9eO+nc=
github.com/charmbracelet/x/exp/term v0.0.0-20240329185201-62a6965a9fad/go.mod h1:6GZ13FjIP6eOCqWU4lqgveGnYxQo9c3qBzHPeFu4HBE=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
Expand Down
3 changes: 1 addition & 2 deletions style.go
Expand Up @@ -308,8 +308,7 @@ func (s Style) Render(strs ...string) string {
// Word wrap
if !inline && width > 0 {
wrapAt := width - leftPadding - rightPadding
str = ansi.Wordwrap(str, wrapAt, "")
str = ansi.Wrap(str, wrapAt, false) // force-wrap long strings
str = ansi.Wrap(str, wrapAt, "")
}

// Render core text
Expand Down

0 comments on commit 2434fda

Please sign in to comment.