Browse Source

Func to print to view

pull/1/head
Gregory 'Rudi' Rudolph 5 years ago
parent
commit
e2cff7b391
  1. 15
      main.go

15
main.go

@ -14,6 +14,7 @@ func main() {
defer kbtui.Close() defer kbtui.Close()
kbtui.SetManagerFunc(layout) kbtui.SetManagerFunc(layout)
printToView(kbtui, "Chat", "Test updating chat window")
if err := kbtui.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil { if err := kbtui.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
log.Panicln(err) 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 { func layout(g *gocui.Gui) error {
maxX, maxY := g.Size() maxX, maxY := g.Size()
if feedView, err := g.SetView("Feed", 12, 0, maxX-1, maxY/5); err != nil { 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 { if err4 != gocui.ErrUnknownView {
return err4 return err4
} }
fmt.Fprintln(listView, "Lists") fmt.Fprintf(listView, "Lists\nWindow")
} }
return nil return nil
} }

Loading…
Cancel
Save