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/summary.go

58 lines
1.1 KiB
Go

5 years ago
package views
import (
"fmt"
"github.com/edouardparis/lntop/ui/color"
5 years ago
"github.com/edouardparis/lntop/ui/models"
5 years ago
"github.com/jroimartin/gocui"
)
const (
SUMMARY_LEFT = "summary_left"
SUMMARY_RIGHT = "summary_right"
)
type Summary struct {
5 years ago
left *gocui.View
right *gocui.View
info *models.Info
5 years ago
}
func (s *Summary) Set(g *gocui.Gui, x0, y0, x1, y1 int) error {
var err error
s.left, err = g.SetView(SUMMARY_LEFT, x0, y0, x0+40, y1)
5 years ago
if err != nil {
if err != gocui.ErrUnknownView {
return err
}
}
s.left.Frame = false
s.right, err = g.SetView(SUMMARY_RIGHT, x0+40, y0, x1, y1)
5 years ago
if err != nil {
if err != gocui.ErrUnknownView {
return err
}
}
s.right.Frame = false
s.display()
return nil
}
func (s *Summary) display() {
s.left.Clear()
fmt.Fprintln(s.left, color.Green("[ Channels ]"))
fmt.Fprintln(s.left, fmt.Sprintf("%d %s %d %s %d %s",
5 years ago
s.info.NumPendingChannels, color.Yellow("pending"),
s.info.NumActiveChannels, color.Green("active"),
s.info.NumInactiveChannels, color.Red("inactive"),
))
5 years ago
s.right.Clear()
}
5 years ago
func NewSummary(info *models.Info) *Summary {
return &Summary{info: info}
5 years ago
}