added ansi example

This commit is contained in:
Kashif Shah 2023-05-21 21:33:27 +00:00
parent c079a800f6
commit 410099e314
1 changed files with 29 additions and 0 deletions

29
gotansi/gotansi.go Normal file
View File

@ -0,0 +1,29 @@
package main
import (
"io"
"os"
"github.com/rivo/tview"
)
func main() {
app := tview.NewApplication().
EnableMouse(true)
textView := tview.NewTextView().
SetDynamicColors(true).
SetChangedFunc(func() {
app.Draw()
})
textView.SetBorder(true).SetTitle("Stdin")
go func() {
w := tview.ANSIWriter(textView)
if _, err := io.Copy(w, os.Stdin); err != nil {
panic(err)
}
}()
if err := app.SetRoot(textView, true).Run(); err != nil {
panic(err)
}
}