From f16ea2bdcb882155b70b05ca92fed6024e712eac Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 14 Mar 2024 22:19:53 -0400 Subject: [PATCH] feat(table): replace stripansi with ansi.Strip Use term/ansi to strip out ANSI sequences --- go.mod | 4 ++-- go.sum | 12 ++++++++---- table/table_test.go | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 7dcd467b..3b6dbedb 100644 --- a/go.mod +++ b/go.mod @@ -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/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d + github.com/charmbracelet/x/exp/term v0.0.0-20240315000626-435a7f02d93f github.com/muesli/reflow v0.3.0 github.com/muesli/termenv v0.15.2 github.com/rivo/uniseg v0.4.7 @@ -16,5 +16,5 @@ require ( github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-isatty v0.0.18 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect - golang.org/x/sys v0.12.0 // indirect + golang.org/x/sys v0.18.0 // indirect ) diff --git a/go.sum b/go.sum index 02fd2915..a79fd2be 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,8 @@ -github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= -github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= 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-20240315000626-435a7f02d93f h1:e1L6gJufLxUL0V8AnquQT4VoS4j8tGc3fu56A5fGs1Q= +github.com/charmbracelet/x/exp/term v0.0.0-20240315000626-435a7f02d93f/go.mod h1:madZtB2OVDOG+ZnLruGITVZceYy047W+BLQ1MNQzbWg= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 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= @@ -13,10 +14,13 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/table/table_test.go b/table/table_test.go index 31f30104..47efdfbc 100644 --- a/table/table_test.go +++ b/table/table_test.go @@ -5,8 +5,8 @@ import ( "testing" "unicode" - "github.com/acarl005/stripansi" "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/exp/term/ansi" ) var TableStyle = func(row, col int) lipgloss.Style { @@ -981,7 +981,7 @@ func debug(s string) string { } func stripString(str string) string { - s := stripansi.Strip(str) + s := ansi.Strip(str) ss := strings.Split(s, "\n") var lines []string