gocui/_demos/demo2.go

39 lines
625 B
Go
Raw Normal View History

2014-01-03 01:34:58 +08:00
package main
import (
"log"
"github.com/jroimartin/gocui"
)
2014-01-04 09:50:49 +08:00
func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
if _, err := g.AddView("side", -1, -1, 30, maxY-5); err != nil {
return err
}
if _, err := g.AddView("main", 30, -1, maxX, maxY-5); err != nil {
return err
}
if _, err := g.AddView("cmdline", -1, maxY-5, maxX, maxY); err != nil {
return err
}
return nil
}
2014-01-03 01:34:58 +08:00
func main() {
var err error
g := gocui.NewGui()
if err := g.Init(); err != nil {
log.Panicln(err)
}
defer g.Close()
2014-01-04 09:50:49 +08:00
g.Layout = layout
2014-01-03 01:34:58 +08:00
err = g.MainLoop()
if err != nil && err != gocui.ErrorQuit {
log.Panicln(err)
}
}