yes it works

pull/1/head
Edouard Paris 5 years ago
parent 02ca67595c
commit fc38de8e7f

@ -38,7 +38,7 @@ func (u *Ui) Run() error {
func (u *Ui) layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
return u.channels.Set(g, 0, maxY/2, maxX-1, maxY/2+2)
return u.channels.Set(g, 0, maxY/8, maxX-1, maxY-1)
}
func quit(g *gocui.Gui, v *gocui.View) error {

@ -27,16 +27,31 @@ func (c *Channels) Set(g *gocui.Gui, x0, y0, x1, y1 int) error {
}
}
c.View.Frame = false
err = c.Update(context.Background())
err = c.Refresh(g)
if err != nil {
return err
}
c.Display()
return nil
}
func (c *Channels) Update(ctx context.Context) error {
func (c *Channels) Refresh(g *gocui.Gui) error {
var err error
c.View, err = g.View(CHANNELS)
if err != nil {
return err
}
err = c.update(context.Background())
if err != nil {
return err
}
c.display()
return nil
}
func (c *Channels) update(ctx context.Context) error {
channels, err := c.network.ListChannels(ctx)
if err != nil {
return err
@ -46,9 +61,15 @@ func (c *Channels) Update(ctx context.Context) error {
return nil
}
func (c *Channels) Display() {
for i := range c.items {
fmt.Fprintln(c.View, fmt.Sprintf("%d", c.items[i].ID))
func (c *Channels) display() {
for _, item := range c.items {
line := fmt.Sprintf("%d %9d %9d %s",
item.ID,
item.LocalBalance,
item.Capacity,
item.RemotePubKey,
)
fmt.Fprintln(c.View, line)
}
}

Loading…
Cancel
Save