diff --git a/ui/color/color.go b/ui/color/color.go index 29e61d8..a503b71 100644 --- a/ui/color/color.go +++ b/ui/color/color.go @@ -5,6 +5,7 @@ import "github.com/fatih/color" type Color color.Color var ( + Yellow = color.New(color.FgYellow).SprintFunc() Green = color.New(color.FgGreen).SprintFunc() GreenBg = color.New(color.BgGreen, color.FgBlack).SprintFunc() Red = color.New(color.FgRed).SprintFunc() diff --git a/ui/controller.go b/ui/controller.go index 2755967..eac568a 100644 --- a/ui/controller.go +++ b/ui/controller.go @@ -22,12 +22,12 @@ func (c *controller) layout(g *gocui.Gui) error { return err } - err = c.summary.Set(g, 0, 2, maxX, 10) + err = c.summary.Set(g, 0, 2, maxX, 7) if err != nil { return err } - return c.channels.Set(g, 0, 10, maxX-1, maxY-1) + return c.channels.Set(g, 0, 7, maxX-1, maxY-1) } func cursorDown(g *gocui.Gui, v *gocui.View) error { @@ -62,6 +62,11 @@ func (c *controller) Update(ctx context.Context) error { return err } c.header.Update(info.Alias, "lnd", info.Version) + c.summary.UpdateChannelsStats( + info.NumPendingChannels, + info.NumActiveChannels, + info.NumInactiveChannels, + ) channels, err := c.app.Network.ListChannels(ctx) if err != nil { diff --git a/ui/views/channels.go b/ui/views/channels.go index 3f7d43f..be64dc6 100644 --- a/ui/views/channels.go +++ b/ui/views/channels.go @@ -69,12 +69,13 @@ func (c *Channels) Update(items []*models.Channel) { func (c *Channels) display() { c.Clear() for _, item := range c.items { - line := fmt.Sprintf("%s %s %s %12d %5d", + line := fmt.Sprintf("%s %s %s %12d %5d %100s", active(item), gauge(item), color.Cyan(fmt.Sprintf("%12d", item.LocalBalance)), item.Capacity, len(item.PendingHTLC), + "", ) fmt.Fprintln(c.View, line) } diff --git a/ui/views/header.go b/ui/views/header.go index 929c822..de56aa3 100644 --- a/ui/views/header.go +++ b/ui/views/header.go @@ -3,6 +3,7 @@ package views import ( "fmt" + "github.com/edouardparis/lntop/ui/color" "github.com/jroimartin/gocui" ) @@ -24,7 +25,7 @@ func (h *Header) Set(g *gocui.Gui, x0, y0, x1, y1 int) error { } } v.Frame = false - fmt.Fprintln(v, fmt.Sprintf("[%s %s %s]", h.alias, h.kind, h.version)) + fmt.Fprintln(v, color.Cyan(fmt.Sprintf("[%s %s %s]", h.alias, h.kind, h.version))) return nil } diff --git a/ui/views/summary.go b/ui/views/summary.go index 4470711..b266616 100644 --- a/ui/views/summary.go +++ b/ui/views/summary.go @@ -25,7 +25,7 @@ type Summary struct { 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, x1/2, y1) + s.left, err = g.SetView(SUMMARY_LEFT, x0, y0, x0+40, y1) if err != nil { if err != gocui.ErrUnknownView { return err @@ -33,7 +33,7 @@ func (s *Summary) Set(g *gocui.Gui, x0, y0, x1, y1 int) error { } s.left.Frame = false - s.right, err = g.SetView(SUMMARY_RIGHT, x1/2, y0, x1, y1) + s.right, err = g.SetView(SUMMARY_RIGHT, x0+40, y0, x1, y1) if err != nil { if err != gocui.ErrUnknownView { return err @@ -44,16 +44,20 @@ func (s *Summary) Set(g *gocui.Gui, x0, y0, x1, y1 int) error { return nil } -func (s *Summary) Update() { - +func (s *Summary) UpdateChannelsStats(numPendingChannels, numActiveChannels, numInactiveChannels uint32) { + s.NumActiveChannels = numActiveChannels + s.NumInactiveChannels = numInactiveChannels + s.NumPendingChannels = numPendingChannels } func (s *Summary) display() { s.left.Clear() fmt.Fprintln(s.left, color.Green("[ Channels ]")) - fmt.Fprintln(s.left, fmt.Sprintf("%s %4d", color.Cyan("Pending: "), s.NumPendingChannels)) - fmt.Fprintln(s.left, fmt.Sprintf("%s %4d", color.Cyan("Active: "), s.NumActiveChannels)) - fmt.Fprintln(s.left, fmt.Sprintf("%s %4d", color.Cyan("Inactive:"), s.NumInactiveChannels)) + fmt.Fprintln(s.left, fmt.Sprintf("%d %s %d %s %d %s", + s.NumPendingChannels, color.Yellow("pending"), + s.NumActiveChannels, color.Green("active"), + s.NumInactiveChannels, color.Red("inactive"), + )) s.right.Clear() fmt.Fprintln(s.right, color.Green("[ Network ]"))