col sort asc/desc key

pull/5/head
Miguel Mota 6 years ago
parent 8e2244041c
commit 6352072050

@ -55,7 +55,7 @@ sudo curl -s "https://raw.githubusercontent.com/miguelmota/cointop/master/instal
$ cointop
```
### Cointop commands
### Shortcuts
List of default shortcuts:
@ -78,6 +78,8 @@ 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 current column in ascending order
<kbd>Alt</kbd>+<kbd></kbd>|Sort current column in descending order
<kbd>Alt</kbd>+<kbd></kbd>|Sort column to the left
<kbd>Alt</kbd>+<kbd></kbd>|Sort column to the right
<kbd>F1</kbd>|Show help|

@ -12,5 +12,5 @@ func (ct *Cointop) openHelp(g *gocui.Gui, v *gocui.View) error {
}
func (ct *Cointop) helpLink() string {
return "https://github.com/miguelmota/cointop"
return "https://github.com/miguelmota/cointop#shortcuts"
}

@ -51,6 +51,8 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error {
ct.setKeybinding(gocui.KeyCtrlP, ct.prevPage)
ct.setKeybinding(gocui.KeyCtrlR, ct.refresh)
ct.setKeybinding(gocui.KeyCtrlU, ct.pageUp)
ct.setKeybindingMod(gocui.KeyArrowUp, gocui.ModAlt, ct.sortAsc)
ct.setKeybindingMod(gocui.KeyArrowDown, gocui.ModAlt, ct.sortDesc)
ct.setKeybindingMod(gocui.KeyArrowLeft, gocui.ModAlt, ct.sortPrevCol)
ct.setKeybindingMod(gocui.KeyArrowRight, gocui.ModAlt, ct.sortNextCol)
ct.setKeybinding(gocui.KeyF1, ct.openHelp)

@ -78,13 +78,26 @@ func (ct *Cointop) sortfn(sortby string, desc bool) func(g *gocui.Gui, v *gocui.
}
}
func (ct *Cointop) getSortColIndex() int {
for i, col := range colorder {
if ct.sortby == col {
return i
}
}
return 0
func (ct *Cointop) sortAsc(g *gocui.Gui, v *gocui.View) error {
ct.sortdesc = false
ct.sort(ct.sortby, ct.sortdesc, ct.coins)
ct.Update(func() {
ct.tableview.Clear()
ct.updateTable()
})
ct.rowChanged()
return nil
}
func (ct *Cointop) sortDesc(g *gocui.Gui, v *gocui.View) error {
ct.sortdesc = true
ct.sort(ct.sortby, ct.sortdesc, ct.coins)
ct.Update(func() {
ct.tableview.Clear()
ct.updateTable()
})
ct.rowChanged()
return nil
}
func (ct *Cointop) sortPrevCol(g *gocui.Gui, v *gocui.View) error {
@ -121,3 +134,12 @@ func (ct *Cointop) sortNextCol(g *gocui.Gui, v *gocui.View) error {
ct.rowChanged()
return nil
}
func (ct *Cointop) getSortColIndex() int {
for i, col := range colorder {
if ct.sortby == col {
return i
}
}
return 0
}

Loading…
Cancel
Save