display page count

Former-commit-id: ba08541779f1c0448d4564d24e0b3e61ca9ca981 [formerly ba08541779f1c0448d4564d24e0b3e61ca9ca981 [formerly 7cf32aba5fac5019735f836c22abfec268894326 [formerly 3f311f0c39]]]
Former-commit-id: ce2a56059ddd4b3cc10e8aece59edac70e75b52b
Former-commit-id: b1f8a33e1f4ee6de1d0217ebb7186667e40dcce9 [formerly b091c940648243c553937b36731874ae38e084ce]
Former-commit-id: 904051694cddddac7cc6229a77708a98c9d8c395
pull/15/head
Miguel Mota 6 years ago
parent 52bdafac47
commit 6e00f2044b

@ -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)
}

@ -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, " "))
})
}

Loading…
Cancel
Save