From 99c053115e5644f7c764483f0da62b9f4ba73847 Mon Sep 17 00:00:00 2001 From: raul Date: Fri, 5 Apr 2024 12:11:12 +0200 Subject: [PATCH] Practice using coordinates for adding textboxes --- gocui-practice/main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gocui-practice/main.go b/gocui-practice/main.go index eda67f1..232e183 100644 --- a/gocui-practice/main.go +++ b/gocui-practice/main.go @@ -27,12 +27,21 @@ func main() { func layout(g *gocui.Gui) error { maxX, maxY := g.Size() - if v, err := g.SetView("hello", maxX/2-7, maxY/2, maxX/2+7, maxY/2+2); err != nil { + if v, err := g.SetView("hello", maxX/2-20, maxY/2-15, maxX/2+20, maxY/2-5); err != nil { if err != gocui.ErrUnknownView { return err } - fmt.Fprintln(v, "Hello world!") + fmt.Fprintln(v, "This is a reaaaaaaaally long message") + fmt.Fprintln(v, "Hello!") } + + if v, err := g.SetView("anotherone", maxX/2-20, maxY/2, maxX/2+20, maxY/2+2); err != nil { + if err != gocui.ErrUnknownView { + return err + } + fmt.Fprintln(v, "Hola!") + } + return nil }