1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
// +build !windows
package ct
import (
"fmt"
)
func resetColor() {
fmt.Print("\x1b[0m")
}
func changeColor(fg Color, fgBright bool, bg Color, bgBright bool) {
if fg == None && bg == None {
return
} // if
s := ""
if fg != None {
s = fmt.Sprintf("%s%d", s, 30+(int)(fg-Black))
if fgBright {
s += ";1"
} // if
} // if
if bg != None {
if s != "" {
s += ";"
} // if
s = fmt.Sprintf("%s%d", s, 40+(int)(bg-Black))
} // if
s = "\x1b[0;" + s + "m"
fmt.Print(s)
}
|