From 410099e3147bfefbe29c7efee79a62d77cc7bd13 Mon Sep 17 00:00:00 2001 From: Kashif Shah Date: Sun, 21 May 2023 21:33:27 +0000 Subject: [PATCH] added ansi example --- gotansi/gotansi.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 gotansi/gotansi.go diff --git a/gotansi/gotansi.go b/gotansi/gotansi.go new file mode 100644 index 0000000..80769db --- /dev/null +++ b/gotansi/gotansi.go @@ -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) + } +}