move to last line shortcut

pull/5/head
Miguel Mota 6 years ago
parent 5514446c86
commit 3339e83db0

@ -50,36 +50,39 @@ $ cointop
List of shortcuts:
|Key|Action|
|----|------|
|`<up>`|navigate up|
|`<down>`|navigate down|
|`<right>`|next page|
|`<left>`|previous page|
|`<enter>`|visit highlighted coin on CoinMarketCap|
|`<esc>`|alias to quit|
|`<space>`|alias to `<enter>`|
|`<ctrl-c>`|alias to quit|
|`<ctrl-d>`|page down|
|`<ctrl-n>`|alias to next page|
|`<ctrl-u>`|page up|
|`<ctrl-p>`|alias to previous page|
|`<ctrl-r>`|force refresh|
|`1`|sort by *[1] hour change*|
|`2`|sort by *[2]4 hour change*|
|`7`|sort by *[7] day change*|
|`a`|sort by *[a]vailable supply*|
|`j`|alias to `<down>`|
|`k`|alias to `<up>`|
|`l`|sort by *[l]ast updated*|
|`m`|sort by *[m]arket cap*|
|`n`|sort by *[n]ame*|
|`p`|sort by *[p]rice*|
|`r`|sort by *[r]ank*|
|`s`|sort by *[s]ymbol*|
|`t`|sort by *[t]otal supply*|
|`v`|sort by *24 hour [v]olume*|
|`q`|[q]uit|
Key|Action
----|------
`<up>`|navigate up
`<down>`|navigate down
`<right>`|next page
`<left>`|previous page
`<enter>`|visit highlighted coin on CoinMarketCap
`<esc>`|alias to quit
`<space>`|alias to `<enter>`
`<ctrl-c>`|alias to quit
`<ctrl-d>`|page down
`<ctrl-n>`|alias to next page
`<ctrl-p>`|alias to previous page
`<ctrl-r>`|force refresh
`<ctrl-u>`|page up
`1`|sort by *[1] hour change*
`2`|sort by *[2]4 hour change*
`7`|sort by *[7] day change*
`a`|sort by *[a]vailable supply*
`G`|navigate to last line
`h`|alias to previous page
`j`|alias to `<down>`
`k`|alias to `<up>`
`l`|alias to next page
`m`|sort by *[m]arket cap*
`n`|sort by *[n]ame*
`p`|sort by *[p]rice*
`r`|sort by *[r]ank*
`s`|sort by *[s]ymbol*
`t`|sort by *[t]otal supply*
`u`|sort by *last [u]pdated*
`v`|sort by *24 hour [v]olume*
`q`|[q]uit
<!--
|`h`|toggle [h]elp|

@ -21,34 +21,37 @@ func (ct *Cointop) setKeybinding(key interface{}, callback func(g *gocui.Gui, v
}
func (ct *Cointop) keybindings(g *gocui.Gui) error {
ct.setKeybinding(gocui.KeyArrowUp, ct.cursorUp)
ct.setKeybinding(gocui.KeyArrowDown, ct.cursorDown)
ct.setKeybinding(gocui.KeyArrowLeft, ct.prevPage)
ct.setKeybinding(gocui.KeyArrowRight, ct.nextPage)
ct.setKeybinding(gocui.KeyEnter, ct.enter)
ct.setKeybinding(gocui.KeyEsc, ct.quit)
ct.setKeybinding(gocui.KeySpace, ct.enter)
ct.setKeybinding(gocui.KeyCtrlC, ct.quit)
ct.setKeybinding(gocui.KeyCtrlD, ct.pageDown)
ct.setKeybinding(gocui.KeyCtrlN, ct.nextPage)
ct.setKeybinding(gocui.KeyArrowLeft, ct.prevPage)
ct.setKeybinding(gocui.KeyCtrlP, ct.prevPage)
ct.setKeybinding(gocui.KeyArrowDown, ct.cursorDown)
ct.setKeybinding('j', ct.cursorDown)
ct.setKeybinding(gocui.KeyArrowUp, ct.cursorUp)
ct.setKeybinding('k', ct.cursorUp)
ct.setKeybinding(gocui.KeyCtrlD, ct.pageDown)
ct.setKeybinding(gocui.KeyCtrlR, ct.refresh)
ct.setKeybinding(gocui.KeyCtrlU, ct.pageUp)
ct.setKeybinding('r', ct.sortfn("rank", false))
ct.setKeybinding('n', ct.sortfn("name", true))
ct.setKeybinding('s', ct.sortfn("symbol", false))
ct.setKeybinding('p', ct.sortfn("price", true))
ct.setKeybinding('m', ct.sortfn("marketcap", true))
ct.setKeybinding('v', ct.sortfn("24hvolume", true))
ct.setKeybinding('1', ct.sortfn("1hchange", true))
ct.setKeybinding('2', ct.sortfn("24hchange", true))
ct.setKeybinding('7', ct.sortfn("7dchange", true))
ct.setKeybinding('t', ct.sortfn("totalsupply", true))
ct.setKeybinding('a', ct.sortfn("availablesupply", true))
ct.setKeybinding('l', ct.sortfn("lastupdated", true))
ct.setKeybinding(gocui.KeyCtrlR, ct.refresh)
ct.setKeybinding(gocui.KeyEnter, ct.enter)
ct.setKeybinding(gocui.KeySpace, ct.enter)
ct.setKeybinding(gocui.KeyCtrlC, ct.quit)
ct.setKeybinding('G', ct.navigateLastLine)
ct.setKeybinding('h', ct.prevPage)
ct.setKeybinding('j', ct.cursorDown)
ct.setKeybinding('k', ct.cursorUp)
ct.setKeybinding('l', ct.nextPage)
ct.setKeybinding('m', ct.sortfn("marketcap", true))
ct.setKeybinding('n', ct.sortfn("name", true))
ct.setKeybinding('p', ct.sortfn("price", true))
ct.setKeybinding('r', ct.sortfn("rank", false))
ct.setKeybinding('s', ct.sortfn("symbol", false))
ct.setKeybinding('t', ct.sortfn("totalsupply", true))
ct.setKeybinding('u', ct.sortfn("lastupdated", true))
ct.setKeybinding('v', ct.sortfn("24hvolume", true))
ct.setKeybinding('q', ct.quit)
ct.setKeybinding(gocui.KeyEsc, ct.quit)
return nil
}

@ -91,6 +91,25 @@ func (ct *Cointop) pageUp(g *gocui.Gui, v *gocui.View) error {
return nil
}
func (ct *Cointop) navigateLastLine(g *gocui.Gui, v *gocui.View) error {
if ct.tableview == nil {
return nil
}
ox, _ := ct.tableview.Origin()
cx, _ := ct.tableview.Cursor()
_, sy := ct.tableview.Size()
l := len(ct.coins)
k := l - sy
if err := ct.tableview.SetOrigin(ox, k); err != nil {
return err
}
if err := ct.tableview.SetCursor(cx, sy-1); err != nil {
return err
}
ct.rowChanged()
return nil
}
func (ct *Cointop) prevPage(g *gocui.Gui, v *gocui.View) error {
if (ct.page - 1) >= 0 {
ct.page = ct.page - 1

Loading…
Cancel
Save