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/views/header.go

41 lines
669 B
Go

package views
import (
"fmt"
"github.com/edouardparis/lntop/ui/color"
"github.com/jroimartin/gocui"
)
const (
HEADER = "myheader"
)
type Header struct {
alias string
kind string
version string
}
func (h *Header) Set(g *gocui.Gui, x0, y0, x1, y1 int) error {
v, err := g.SetView(HEADER, x0, y0, x1, y0+2)
if err != nil {
if err != gocui.ErrUnknownView {
return err
}
}
v.Frame = false
fmt.Fprintln(v, color.Cyan(fmt.Sprintf("[%s %s %s]", h.alias, h.kind, h.version)))
return nil
}
func (h *Header) Update(alias, kind, version string) {
h.alias = alias
h.kind = kind
h.version = version
}
func NewHeader() *Header {
return &Header{}
}