Merge pull request #15 from edouardparis/v0.0.2

V0.0.2
pull/21/head v0.0.2
Edouard 5 years ago committed by GitHub
commit d073bf206c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,7 +15,7 @@ import (
"github.com/edouardparis/lntop/ui"
)
const version = "v0.0.1"
const version = "v0.0.2"
// New creates a new cli app.
func New() *cli.App {

@ -171,8 +171,8 @@ func (c *controller) OnEnter(g *gocui.Gui, v *gocui.View) error {
switch view.Name() {
case views.CHANNELS:
c.views.SetPrevious(view)
_, cy := v.Cursor()
err := c.models.SetCurrentChannel(context.Background(), cy)
index := c.views.Channels.Index()
err := c.models.SetCurrentChannel(context.Background(), index)
if err != nil {
return err
}
@ -214,6 +214,11 @@ func (c *controller) setKeyBinding(g *gocui.Gui) error {
return err
}
err = g.SetKeybinding("", 'q', gocui.ModNone, quit)
if err != nil {
return err
}
err = g.SetKeybinding("", gocui.KeyArrowUp, gocui.ModNone, c.cursorUp)
if err != nil {
return err
@ -244,6 +249,11 @@ func (c *controller) setKeyBinding(g *gocui.Gui) error {
return err
}
err = g.SetKeybinding("", 'h', gocui.ModNone, c.Help)
if err != nil {
return err
}
return nil
}

@ -16,6 +16,10 @@ func (c *Channels) List() []*models.Channel {
return c.list
}
func (c *Channels) Len() int {
return len(c.list)
}
func (c *Channels) Get(index int) *models.Channel {
if index < 0 || index > len(c.list)-1 {
return nil

@ -67,7 +67,7 @@ func (m *Models) RefreshChannels(ctx context.Context) error {
channels[i].Node, err = m.network.GetNode(ctx,
channels[i].RemotePubKey)
if err != nil {
m.logger.Error("refreshChannels: cannot find Node",
m.logger.Debug("refreshChannels: cannot find Node",
logging.String("pubkey", channels[i].RemotePubKey))
}
}

@ -64,7 +64,7 @@ func (c *Channel) Set(g *gocui.Gui, x0, y0, x1, y1 int) error {
header.Clear()
fmt.Fprintln(header, "Channel")
v, err := g.SetView(CHANNEL, x0-1, y0+1, x1+2, y1-2)
v, err := g.SetView(CHANNEL, x0-1, y0+1, x1+2, y1-1)
if err != nil {
if err != gocui.ErrUnknownView {
return err

@ -20,11 +20,16 @@ const (
)
type Channels struct {
index int
columns *gocui.View
view *gocui.View
channels *models.Channels
}
func (c Channels) Index() int {
return c.index
}
func (c Channels) Name() string {
return CHANNELS
}
@ -35,10 +40,17 @@ func (c *Channels) Wrap(v *gocui.View) view {
}
func (c *Channels) CursorDown() error {
if c.channels.Len() <= c.index+1 {
return nil
}
c.index++
return cursorDown(c.view, 1)
}
func (c *Channels) CursorUp() error {
if c.index > 0 {
c.index--
}
return cursorUp(c.view, 1)
}
@ -166,7 +178,9 @@ func channelID(c *netmodels.Channel) string {
func alias(c *netmodels.Channel) string {
if c.Node == nil || c.Node.Alias == "" {
return c.RemotePubKey[:19]
return c.RemotePubKey[:24]
} else if len(c.Node.Alias) > 25 {
return c.Node.Alias[:24]
}
return c.Node.Alias

@ -9,7 +9,7 @@ import (
)
const (
version = "v0.0.1"
version = "v0.0.2"
HELP = "help"
)
@ -54,8 +54,10 @@ func (h Help) Set(g *gocui.Gui, x0, y0, x1, y1 int) error {
fmt.Fprintln(h.view, fmt.Sprintf("lntop %s - (C) 2019 Edouard Paris", version))
fmt.Fprintln(h.view, "Released under the MIT License")
fmt.Fprintln(h.view, "")
fmt.Fprintln(h.view, fmt.Sprintf("%5s %s",
color.Cyan("F1 h:"), "show this help screen"))
fmt.Fprintln(h.view, fmt.Sprintf("%6s %s",
color.Cyan("F1 h:"), "show/close this help screen"))
fmt.Fprintln(h.view, fmt.Sprintf("%6s %s",
color.Cyan("F10 q:"), "quit"))
_, err = g.SetCurrentView(HELP)
return err
}

Loading…
Cancel
Save