Added ANSI colors for old terminals
This commit is contained in:
parent
0e7bc76a0c
commit
082164c2a1
6
Color.go
6
Color.go
@ -13,7 +13,7 @@ type Color struct {
|
||||
|
||||
// Print writes the text in the given color to standard output.
|
||||
func (c Color) Print(args ...any) {
|
||||
if !Terminal {
|
||||
if !Terminal || !TrueColor {
|
||||
fmt.Print(args...)
|
||||
return
|
||||
}
|
||||
@ -23,7 +23,7 @@ func (c Color) Print(args ...any) {
|
||||
|
||||
// Printf formats according to a format specifier and writes the text in the given color to standard output.
|
||||
func (c Color) Printf(format string, args ...any) {
|
||||
if !Terminal {
|
||||
if !Terminal || !TrueColor {
|
||||
fmt.Printf(format, args...)
|
||||
return
|
||||
}
|
||||
@ -33,7 +33,7 @@ func (c Color) Printf(format string, args ...any) {
|
||||
|
||||
// Println writes the text in the given color to standard output and appends a newline.
|
||||
func (c Color) Println(args ...any) {
|
||||
if !Terminal {
|
||||
if !Terminal || !TrueColor {
|
||||
fmt.Println(args...)
|
||||
return
|
||||
}
|
||||
|
@ -6,5 +6,8 @@ import (
|
||||
"git.akyoto.dev/go/color/tty"
|
||||
)
|
||||
|
||||
// Terminal is a boolean that indicates if we're in a terminal with truecolor support.
|
||||
var Terminal = tty.IsTerminal(os.Stdout.Fd()) && os.Getenv("COLORTERM") == "truecolor"
|
||||
// Terminal indicates if we're in a terminal with truecolor support.
|
||||
var Terminal = tty.IsTerminal(os.Stdout.Fd())
|
||||
|
||||
// TrueColor indicates if the terminal has 24-bit color support.
|
||||
var TrueColor = os.Getenv("COLORTERM") == "truecolor"
|
||||
|
Loading…
Reference in New Issue
Block a user