From 070131c7fd7b159c0292b8f9fb8331d064e06d75 Mon Sep 17 00:00:00 2001 From: Lixen Wraith Date: Sun, 4 Oct 2026 02:56:31 -0400 Subject: [PATCH] v0.1.9 inline: ansi 16 colors, terminals without size --- go.mod | 2 +- go.sum | 6 ++++-- inline/inline.go | 12 ++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 1d928ab..b385354 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 62f4163..ea6ed8a 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/inline/inline.go b/inline/inline.go index 1b3ba85..ca9e986 100644 --- a/inline/inline.go +++ b/inline/inline.go @@ -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()