From 4f0eb3060634a5c46f39c4f4bef7e67d922f2729 Mon Sep 17 00:00:00 2001 From: Miguel Mota Date: Tue, 3 Apr 2018 16:35:30 -0700 Subject: [PATCH] navigate to first line key --- README.md | 1 + cointop/keybindings.go | 1 + cointop/navigation.go | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 7f7d63a..1a90556 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ Key|Action 2|sort by *[2]4 hour change* 7|sort by *[7] day change* a|sort by *[a]vailable supply* +g|navigate to first line G|navigate to last line h|alias to previous page j|alias to navigate down diff --git a/cointop/keybindings.go b/cointop/keybindings.go index e1db7e8..50b7e59 100644 --- a/cointop/keybindings.go +++ b/cointop/keybindings.go @@ -38,6 +38,7 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error { ct.setKeybinding('2', ct.sortfn("24hchange", true)) ct.setKeybinding('7', ct.sortfn("7dchange", true)) ct.setKeybinding('a', ct.sortfn("availablesupply", true)) + ct.setKeybinding('g', ct.navigateFirstLine) ct.setKeybinding('G', ct.navigateLastLine) ct.setKeybinding('h', ct.prevPage) ct.setKeybinding('j', ct.cursorDown) diff --git a/cointop/navigation.go b/cointop/navigation.go index bb3df5a..9beb02d 100644 --- a/cointop/navigation.go +++ b/cointop/navigation.go @@ -91,6 +91,22 @@ func (ct *Cointop) pageUp(g *gocui.Gui, v *gocui.View) error { return nil } +func (ct *Cointop) navigateFirstLine(g *gocui.Gui, v *gocui.View) error { + if ct.tableview == nil { + return nil + } + ox, _ := ct.tableview.Origin() + cx, _ := ct.tableview.Cursor() + if err := ct.tableview.SetOrigin(ox, 0); err != nil { + return err + } + if err := ct.tableview.SetCursor(cx, 0); err != nil { + return err + } + ct.rowChanged() + return nil +} + func (ct *Cointop) navigateLastLine(g *gocui.Gui, v *gocui.View) error { if ct.tableview == nil { return nil