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

40 lines
594 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"
"github.com/edouardparis/lntop/events"
5 years ago
)
func Run(ctx context.Context, app *app.App, sub chan *events.Event) 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)
5 years ago
err = ctrl.SetModels(ctx)
if err != nil {
5 years ago
return err
}
5 years ago
g.SetManagerFunc(ctrl.layout)
err = ctrl.setKeyBinding(g)
5 years ago
if err != nil {
return err
}
go ctrl.Listen(ctx, g, sub)
err = g.MainLoop()
close(sub)
5 years ago
return err
}