Added terminal detection

This commit is contained in:
2024-03-12 00:25:20 +01:00
parent 393a9ebf17
commit 6a802c3ad8
12 changed files with 37 additions and 79 deletions

View File

@ -2,7 +2,6 @@ package ansi
import (
"fmt"
"io"
"git.akyoto.dev/go/color"
)
@ -10,16 +9,6 @@ import (
// Code represents an ANSI escape code.
type Code int
// Fprint writes the text in the given color to the writer.
func (code Code) Fprint(writer io.Writer, args ...any) {
if !color.Terminal {
fmt.Fprint(writer, args...)
return
}
fmt.Fprintf(writer, "\x1b[%dm%s\x1b[0m", code, fmt.Sprint(args...))
}
// Print writes the text in the given color to standard output.
func (code Code) Print(args ...any) {
if !color.Terminal {