Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format texti input as '\e]4;1;%s\a\e[0;41m \e[m' "$1" to show color text directly #1021

Open
wellcomez opened this issue Sep 2, 2024 · 2 comments

Comments

@wellcomez
Copy link

wellcomez commented Sep 2, 2024

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)
}
@wellcomez wellcomez changed the title use textinput like '\e]4;1;%s\a\e[0;41m \e[m' "$1" to show color text directly format texti input as '\e]4;1;%s\a\e[0;41m \e[m' "$1" to show color text directly Sep 2, 2024
@kivattt
Copy link
Contributor

kivattt commented Sep 2, 2024

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

@rivo
Copy link
Owner

rivo commented Sep 2, 2024

In addition to @kivattt, I should note that you can use the ANSIWriter or TranslateANSI to translate ANSI escape codes to style tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants