tview
tview copied to clipboard
format texti input as '\e]4;1;%s\a\e[0;41m \e[m' "$1" to show color text directly
I find bash can use e]xxx ..... e[m to define text color directly. This way is more flexisible than using ui style.
add api:
func colortext(s txt,color tcell.color)string{
colorbeign:= getcolorbegin(color)
colorend:=getclororend(color)
return fmt.sprintf("%s %s %s ",colorbegin, txt,colorend)
}
You can use a style tag string with tcell's color.String() for this:
"default color [" + tcell.ColorRed.String() + "]red foreground[-:-:-:-] default color"
https://pkg.go.dev/github.com/rivo/tview#hdr-Styles__Colors__and_Hyperlinks
In addition to @kivattt, I should note that you can use the ANSIWriter or TranslateANSI to translate ANSI escape codes to style tags.