Skip to content

Commit

Permalink
chore: tidy and fix some lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Oct 31, 2024
1 parent 5de2f41 commit 68e6666
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion env.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,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 165 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 165 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 165 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 165 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 165 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 165 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
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 @@ -40,8 +40,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 68e6666

Please sign in to comment.