From e2cff7b391e21596c97121dca433b1954a209487 Mon Sep 17 00:00:00 2001 From: Gregory 'Rudi' Rudolph Date: Tue, 17 Sep 2019 09:45:13 -0400 Subject: [PATCH] Func to print to view --- main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index d6f1018..11cc1b0 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ func main() { defer kbtui.Close() kbtui.SetManagerFunc(layout) + printToView(kbtui, "Chat", "Test updating chat window") if err := kbtui.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil { log.Panicln(err) @@ -24,6 +25,18 @@ func main() { } } +func printToView(kbtui *gocui.Gui, viewName string, message string) { + kbtui.Update(func(g *gocui.Gui) error { + inputView, err := kbtui.View(viewName) + if err != nil { + return err + } else { + _, _ = fmt.Fprintf(inputView, message) + } + return nil + }) +} + func layout(g *gocui.Gui) error { maxX, maxY := g.Size() if feedView, err := g.SetView("Feed", 12, 0, maxX-1, maxY/5); err != nil { @@ -48,7 +61,7 @@ func layout(g *gocui.Gui) error { if err4 != gocui.ErrUnknownView { return err4 } - fmt.Fprintln(listView, "Lists") + fmt.Fprintf(listView, "Lists\nWindow") } return nil }