You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lntop/ui/ui.go

36 lines
514 B
Go

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