2
0
mirror of https://github.com/miguelmota/cointop synced 2024-11-05 00:00:14 +00:00

open link help

This commit is contained in:
Miguel Mota 2018-04-05 13:18:51 -07:00
parent cdd896a765
commit fe1a3bcebe
4 changed files with 26 additions and 9 deletions

View File

@ -78,6 +78,9 @@ Key|Action
<kbd>Ctrl</kbd>+<kbd>p</kbd>|Go to previous page (vim style)
<kbd>Ctrl</kbd>+<kbd>r</kbd>|Force refresh
<kbd>Ctrl</kbd>+<kbd>u</kbd>|Jump page up (vim style)
<kbd>Alt</kbd>+<kbd></kbd>|Sort next column to the left
<kbd>Alt</kbd>+<kbd></kbd>|Sort next column to the right
<kbd>F1</kbd>|Show help|
<kbd>0</kbd>|Go to first page (vim style)
<kbd>1</kbd>|Sort table by *[1] hour change*
<kbd>2</kbd>|Sort table by *[2]4 hour change*
@ -102,11 +105,7 @@ Key|Action
<kbd>v</kbd>|Sort table by *24 hour [v]olume*
<kbd>q</kbd>|[q]uit
<kbd>$</kbd>|Go to last page (vim style)
<!--
|`h`|toggle [h]elp|
|`?`|alias to help|
-->
<kbd>?</kbd>|Show help|
## FAQ

16
cointop/help.go Normal file
View File

@ -0,0 +1,16 @@
package cointop
import (
"os/exec"
"github.com/jroimartin/gocui"
)
func (ct *Cointop) openHelp(g *gocui.Gui, v *gocui.View) error {
exec.Command("open", ct.helpLink()).Output()
return nil
}
func (ct *Cointop) helpLink() string {
return "https://github.com/miguelmota/cointop"
}

View File

@ -42,9 +42,9 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error {
ct.setKeybinding(gocui.KeyPgup, ct.pageUp)
ct.setKeybinding(gocui.KeyHome, ct.navigateFirstLine)
ct.setKeybinding(gocui.KeyEnd, ct.navigateLastLine)
ct.setKeybinding(gocui.KeyEnter, ct.enter)
ct.setKeybinding(gocui.KeyEnter, ct.openLink)
ct.setKeybinding(gocui.KeyEsc, ct.quit)
ct.setKeybinding(gocui.KeySpace, ct.enter)
ct.setKeybinding(gocui.KeySpace, ct.openLink)
ct.setKeybinding(gocui.KeyCtrlC, ct.quit)
ct.setKeybinding(gocui.KeyCtrlD, ct.pageDown)
ct.setKeybinding(gocui.KeyCtrlN, ct.nextPage)
@ -53,6 +53,7 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error {
ct.setKeybinding(gocui.KeyCtrlU, ct.pageUp)
ct.setKeybindingMod(gocui.KeyArrowLeft, gocui.ModAlt, ct.sortPrevCol)
ct.setKeybindingMod(gocui.KeyArrowRight, gocui.ModAlt, ct.sortNextCol)
ct.setKeybinding(gocui.KeyF1, ct.openHelp)
ct.setKeybinding('0', ct.firstPage)
ct.setKeybinding('1', ct.sortfn("1hchange", true))
ct.setKeybinding('2', ct.sortfn("24hchange", true))
@ -77,6 +78,7 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error {
ct.setKeybinding('v', ct.sortfn("24hvolume", true))
ct.setKeybinding('q', ct.quit)
ct.setKeybinding('$', ct.lastPage)
ct.setKeybinding('?', ct.openHelp)
return nil
}
@ -85,7 +87,7 @@ func (ct *Cointop) refresh(g *gocui.Gui, v *gocui.View) error {
return nil
}
func (ct *Cointop) enter(g *gocui.Gui, v *gocui.View) error {
func (ct *Cointop) openLink(g *gocui.Gui, v *gocui.View) error {
exec.Command("open", ct.rowLink()).Output()
return nil
}

View File

@ -12,7 +12,7 @@ func (ct *Cointop) updateStatusbar(s string) {
ct.statusbarview.Clear()
currpage := ct.getCurrentPage()
totalpages := ct.getTotalPages()
fmt.Fprintln(ct.statusbarview, pad.Right(fmt.Sprintf("[q]uit [h]elp [← →]page %v/%v %s", currpage, totalpages, s), maxX, " "))
fmt.Fprintln(ct.statusbarview, pad.Right(fmt.Sprintf("[q]uit [?]help [← →]page %v/%v %s", currpage, totalpages, s), maxX, " "))
})
}