Skip to content

Commit

Permalink
chore: merge remote-tracking branch 'origin/windows-cp'
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Nov 4, 2024
2 parents 1690f77 + 68e6666 commit 35bda6a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion env.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ func envColorProfile(env map[string]string) (p Profile) {
p = ANSI
}

if ti, err := terminfo.Load(term); err == nil {
ti, err := terminfo.Load(term)
if err == nil {

Check failure on line 167 in env.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

`if err == nil` has complex nested blocks (complexity: 7) (nestif)

Check failure on line 167 in env.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

`if err == nil` has complex nested blocks (complexity: 7) (nestif)

Check failure on line 167 in env.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

`if err == nil` has complex nested blocks (complexity: 7) (nestif)

Check failure on line 167 in env.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

`if err == nil` has complex nested blocks (complexity: 7) (nestif)

Check failure on line 167 in env.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

`if err == nil` has complex nested blocks (complexity: 7) (nestif)

Check failure on line 167 in env.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

`if err == nil` has complex nested blocks (complexity: 7) (nestif)
extbools := ti.ExtBoolCapsShort()
if _, ok := extbools["RGB"]; ok {
p = TrueColor
Expand Down
2 changes: 1 addition & 1 deletion examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ require (
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/sys v0.26.0 // indirect
)
4 changes: 2 additions & 2 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavM
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
12 changes: 6 additions & 6 deletions profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (
type Profile byte

const (
// TrueColor, 24-bit color profile
// TrueColor, 24-bit color profile.
TrueColor Profile = iota
// ANSI256, 8-bit color profile
// ANSI256, 8-bit color profile.
ANSI256
// ANSI, 4-bit color profile
// ANSI, 4-bit color profile.
ANSI
// Ascii, uncolored profile
Ascii // nolint: revive
// NoTTY, not a terminal profile
// Ascii, uncolored profile.
Ascii //nolint:revive
// NoTTY, not a terminal profile.
NoTTY
)

Expand Down
5 changes: 5 additions & 0 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ func (w *Writer) Write(p []byte) (int, error) {
return w.Forward.Write(p)
case NoTTY:
return io.WriteString(w.Forward, ansi.Strip(string(p)))
default:
return w.downsample(p)
}
}

// downsample downgrades the given text to the appropriate color profile.
func (w *Writer) downsample(p []byte) (int, error) {
var buf bytes.Buffer
var state byte

Expand Down

0 comments on commit 35bda6a

Please sign in to comment.