tcellansi is a package for converting tcell styles to ANSI escape sequences.
- For tcell v3, use the latest
mainbranch of this repository. - For tcell v2, use the
v0.3.1tag:
go get github.com/noborus/tcellansi@v0.3.1To install the package, run:
go get github.com/noborus/tcellansiHere is a simple example of how to use tcellansi:
package main
import (
"github.com/gdamore/tcell/v3"
"github.com/noborus/tcellansi"
)
func main() {
// Initialize tcell screen
screen, _ := tcell.NewScreen()
screen.Init()
// Create a style
style := tcell.StyleDefault.Foreground(tcell.ColorRed).Background(tcell.ColorBlack)
// Convert the style to ANSI escape sequence
ansiSeq := tcellansi.ToAnsi(style)
screen.Fini()
println(ansiSeq + "Hello world!")
}This project is licensed under the MIT License. See the LICENSE file for details.