2
0
mirror of https://github.com/edouardparis/lntop synced 2024-11-16 00:12:44 +00:00
lntop/ui/ui.go
2019-03-29 12:38:09 +01:00

39 lines
545 B
Go

package ui
import (
"context"
"github.com/jroimartin/gocui"
"github.com/edouardparis/lntop/app"
)
func Run(ctx context.Context, app *app.App) error {
g, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
return err
}
defer g.Close()
g.Cursor = true
ctrl := newController(app)
err = ctrl.SetModels(ctx)
if err != nil {
return err
}
g.SetManagerFunc(ctrl.layout)
err = ctrl.setKeyBinding(g)
if err != nil {
return err
}
err = g.MainLoop()
if err != nil && err != gocui.ErrQuit {
return err
}
return err
}