You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cointop/cointop/statusbar.go

45 lines
1.2 KiB
Go

package cointop
import (
"fmt"
5 years ago
"github.com/miguelmota/cointop/cointop/common/pad"
)
func (ct *Cointop) updateStatusbar(s string) {
5 years ago
currpage := ct.currentDisplayPage()
5 years ago
totalpages := ct.totalPagesDisplay()
5 years ago
var quitText string
var favoritesText string
var portfolioText string
if ct.portfoliovisible || ct.filterByFavorites {
quitText = "Return"
} else {
quitText = "Quit"
}
if ct.portfoliovisible {
portfolioText = "[E]Edit"
} else {
portfolioText = "[P]Portfolio"
}
if ct.filterByFavorites {
favoritesText = "[Space]Unfavorite"
} else {
favoritesText = "[F]Favorites"
}
ct.update(func() {
ct.statusbarview.Clear()
5 years ago
base := fmt.Sprintf("%s%s %sHelp %sChart %sRange %sSearch %sConvert %s %s %sSave", "[Q]", quitText, "[?]", "[Enter]", "[[ ]]", "[/]", "[C]", favoritesText, portfolioText, "[CTRL-S]")
str := pad.Right(fmt.Sprintf("%v %sPage %v/%v %s", base, "[← →]", currpage, totalpages, s), ct.maxtablewidth, " ")
v := fmt.Sprintf("v%s", ct.version())
str = str[:len(str)-len(v)+2] + v
fmt.Fprintln(ct.statusbarview, str)
})
}
func (ct *Cointop) refreshRowLink() {
5 years ago
url := ct.rowLinkShort()
ct.updateStatusbar(fmt.Sprintf("%sOpen %s", "[O]", url))
}