Skip to content

Commit

Permalink
chore: use the latest version of ansi package from vt
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Nov 14, 2024
1 parent 37d661c commit 030630a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/charmbracelet/colorprofile
go 1.18

require (
github.com/charmbracelet/x/ansi v0.4.5
github.com/charmbracelet/x/ansi v0.4.6-0.20241114164159-aea15a2cc929
github.com/charmbracelet/x/term v0.2.1
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/charmbracelet/x/ansi v0.4.5 h1:LqK4vwBNaXw2AyGIICa5/29Sbdq58GbGdFngSexTdRM=
github.com/charmbracelet/x/ansi v0.4.5/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/charmbracelet/x/ansi v0.4.6-0.20241114164159-aea15a2cc929 h1:CxDzlAZwEEcq5DNjRlx+RQ0acLKBg/J5ZmvW+db9kAc=
github.com/charmbracelet/x/ansi v0.4.6-0.20241114164159-aea15a2cc929/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
Expand Down
14 changes: 7 additions & 7 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func (w *Writer) WriteString(s string) (n int, err error) {
func handleSgr(w *Writer, p *ansi.Parser, buf *bytes.Buffer) {
var style ansi.Style
for i := 0; i < p.ParamsLen; i++ {
param := ansi.Param(p.Params[i])
param := ansi.Parameter(p.Params[i])

switch param := param.Param(); param {
switch param := param.Param(0); param {
case -1:
// SGR default parameter is 0. We use an empty string to reduce the
// number of bytes written to the buffer.
Expand Down Expand Up @@ -162,23 +162,23 @@ func readColor(idxp *int, params []int) (c ansi.Color) {
return
}
// Note: we accept both main and subparams here
switch param := ansi.Param(params[i+1]); param.Param() {
switch param := ansi.Parameter(params[i+1]); param.Param(0) {
case 2: // RGB
if i > paramsLen-4 {
return
}
c = color.RGBA{
R: uint8(ansi.Param(params[i+2]).Param()), //nolint:gosec
G: uint8(ansi.Param(params[i+3]).Param()), //nolint:gosec
B: uint8(ansi.Param(params[i+4]).Param()), //nolint:gosec
R: uint8(ansi.Parameter(params[i+2]).Param(0)), //nolint:gosec
G: uint8(ansi.Parameter(params[i+3]).Param(0)), //nolint:gosec
B: uint8(ansi.Parameter(params[i+4]).Param(0)), //nolint:gosec
A: 0xff,
}
*idxp += 4
case 5: // 256 colors
if i > paramsLen-2 {
return
}
c = ansi.ExtendedColor(ansi.Param(params[i+2]).Param()) //nolint:gosec
c = ansi.ExtendedColor(ansi.Parameter(params[i+2]).Param(0)) //nolint:gosec
*idxp += 2
}
return
Expand Down

0 comments on commit 030630a

Please sign in to comment.