v0.1.9 inline: ansi 16 colors, terminals without size
This commit is contained in:
3 files changed
+11
-9
No files matched your search
@@ -3,7 +3,7 @@ module github.com/lixenwraith/terminal
|
||||
go 1.27.1
|
||||
|
||||
require (
|
||||
github.com/lixenwraith/color v0.0.0-20260719094342-615e11bc7897
|
||||
github.com/lixenwraith/color v0.1.3
|
||||
golang.org/x/sys v0.48.0
|
||||
golang.org/x/term v0.46.0
|
||||
)
|
||||
@@ -1,5 +1,7 @@
|
||||
github.com/lixenwraith/color v0.0.0-20260719094342-615e11bc7897 h1:YkTK1vIzG6sqKRKaeUdkPyMT2laithY1d8tCqyId77U=
|
||||
github.com/lixenwraith/color v0.0.0-20260719094342-615e11bc7897/go.mod h1:p02MsAGqlmZu3sc6BPYCKmaedF+lqBoijnuu5cOrYeo=
|
||||
github.com/lixenwraith/color v0.0.0-20261004042426-912b93708f95 h1:64BAixbU3RAsDacvCDgxMKKddPuMxL0h2KKsqsG9iWU=
|
||||
github.com/lixenwraith/color v0.0.0-20261004042426-912b93708f95/go.mod h1:p02MsAGqlmZu3sc6BPYCKmaedF+lqBoijnuu5cOrYeo=
|
||||
github.com/lixenwraith/color v0.1.3 h1:vSuvtU4zh1mIZS/7UGHmMdsTr+a7eCjUYGbou7kzFn4=
|
||||
github.com/lixenwraith/color v0.1.3/go.mod h1:L/I3Vxp6pqslAIzWyZGgKCm2lyStHCA4vKaUoMUm7bU=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/term v0.46.0 h1:3+OXuTbaKDgwk8jTi3aSLHRlmWqHEUDUtxnbFigO4YE=
|
||||
|
||||
+6
-6
@@ -23,6 +23,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/lixenwraith/color"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// Internal color capability representation
|
||||
@@ -53,14 +54,13 @@ type Printer struct {
|
||||
drawn int // lines currently on screen (may be clamped below len(live))
|
||||
}
|
||||
|
||||
// New creates a Printer for w. Terminal detection via size probe;
|
||||
// styling defaults on for terminals with NO_COLOR unset and TERM not dumb.
|
||||
// New creates a Printer for w. A terminal that reports no size, a serial
|
||||
// line, is still one, at 80x24; styling defaults on for terminals with
|
||||
// NO_COLOR unset and TERM not dumb.
|
||||
func New(w io.Writer) *Printer {
|
||||
p := &Printer{w: bufio.NewWriter(w)}
|
||||
if f, isFile := w.(*os.File); isFile {
|
||||
if _, _, ok := windowSize(f); ok {
|
||||
p.tty = f
|
||||
}
|
||||
if f, isFile := w.(*os.File); isFile && term.IsTerminal(int(f.Fd())) {
|
||||
p.tty = f
|
||||
}
|
||||
p.color = p.tty != nil && os.Getenv("NO_COLOR") == "" && os.Getenv("TERM") != "dumb"
|
||||
p.mode = detectColorMode()
|
||||
|
||||
Reference in new issue
Block a user