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

display page count

This commit is contained in:
Miguel Mota 2018-04-05 12:50:28 -07:00
parent 2c98d6b5d9
commit 3f311f0c39
2 changed files with 17 additions and 3 deletions

View File

@ -174,7 +174,7 @@ func (ct *Cointop) prevPage(g *gocui.Gui, v *gocui.View) error {
}
func (ct *Cointop) nextPage(g *gocui.Gui, v *gocui.View) error {
if ((ct.page + 1) * ct.perpage) <= len(ct.allcoins) {
if ((ct.page + 1) * ct.perpage) <= ct.getListCount() {
ct.page = ct.page + 1
}
ct.updateTable()
@ -190,8 +190,20 @@ func (ct *Cointop) firstPage(g *gocui.Gui, v *gocui.View) error {
}
func (ct *Cointop) lastPage(g *gocui.Gui, v *gocui.View) error {
ct.page = len(ct.allcoins) / ct.perpage
ct.page = ct.getListCount() / ct.perpage
ct.updateTable()
ct.rowChanged()
return nil
}
func (ct *Cointop) getCurrentPage() int {
return ct.page + 1
}
func (ct *Cointop) getTotalPages() int {
return (ct.getListCount() / ct.perpage) + 1
}
func (ct *Cointop) getListCount() int {
return len(ct.allcoins)
}

View File

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