From 7f7bc1fc72af415dc6d663a2d43d89d34bb4f39e Mon Sep 17 00:00:00 2001 From: Edouard Paris Date: Mon, 29 Apr 2019 09:13:47 +0200 Subject: [PATCH 1/6] fix view channels: truncate node alias issue #12 --- ui/views/channels.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/views/channels.go b/ui/views/channels.go index 3ca6d91..394dd98 100644 --- a/ui/views/channels.go +++ b/ui/views/channels.go @@ -166,7 +166,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 From 392fc9676bc4069e03c3f9f744b1d3bbdba590fc Mon Sep 17 00:00:00 2001 From: Edouard Paris Date: Mon, 29 Apr 2019 09:18:32 +0200 Subject: [PATCH 2/6] fix view channel: wrong layout issue #12 --- ui/views/channel.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/views/channel.go b/ui/views/channel.go index f87f734..09755c5 100644 --- a/ui/views/channel.go +++ b/ui/views/channel.go @@ -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 From a4252ffdfbf627d5fac086f30f13b6fd1c08fcc9 Mon Sep 17 00:00:00 2001 From: Edouard Paris Date: Mon, 29 Apr 2019 09:44:55 +0200 Subject: [PATCH 3/6] fix view channels: wrong current channel issue #11 --- ui/controller.go | 4 ++-- ui/models/channels.go | 4 ++++ ui/views/channels.go | 12 ++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ui/controller.go b/ui/controller.go index e0cf8a5..ee6776d 100644 --- a/ui/controller.go +++ b/ui/controller.go @@ -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 } diff --git a/ui/models/channels.go b/ui/models/channels.go index 71b95db..fac7d07 100644 --- a/ui/models/channels.go +++ b/ui/models/channels.go @@ -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 diff --git a/ui/views/channels.go b/ui/views/channels.go index 394dd98..a235d8e 100644 --- a/ui/views/channels.go +++ b/ui/views/channels.go @@ -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) } From 884616fe4007d322826d55878f40e32699f3c8d1 Mon Sep 17 00:00:00 2001 From: Edouard Paris Date: Mon, 29 Apr 2019 13:20:38 +0200 Subject: [PATCH 4/6] change version --- cli/cli.go | 2 +- ui/views/help.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index 2df2ae6..ac25280 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -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 { diff --git a/ui/views/help.go b/ui/views/help.go index 58bdc60..3a3a9d9 100644 --- a/ui/views/help.go +++ b/ui/views/help.go @@ -9,7 +9,7 @@ import ( ) const ( - version = "v0.0.1" + version = "v0.0.2" HELP = "help" ) From 0453b712f5d20ebec52903a297093ef6d514a59c Mon Sep 17 00:00:00 2001 From: Edouard Paris Date: Mon, 29 Apr 2019 13:33:06 +0200 Subject: [PATCH 5/6] controller: add keybindings --- ui/controller.go | 10 ++++++++++ ui/views/help.go | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ui/controller.go b/ui/controller.go index ee6776d..519de62 100644 --- a/ui/controller.go +++ b/ui/controller.go @@ -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 } diff --git a/ui/views/help.go b/ui/views/help.go index 3a3a9d9..9f0f36c 100644 --- a/ui/views/help.go +++ b/ui/views/help.go @@ -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 } From fd0fb6d49340e7be445cc5cb1121a774c7c80bdb Mon Sep 17 00:00:00 2001 From: Edouard Paris Date: Mon, 29 Apr 2019 13:39:23 +0200 Subject: [PATCH 6/6] models refreshChannels: Debug log --- ui/models/models.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/models/models.go b/ui/models/models.go index 6864b2b..4b17e1d 100644 --- a/ui/models/models.go +++ b/ui/models/models.go @@ -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)) } }