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

63 lines
1.5 KiB
Go

package cointop
import (
"fmt"
"github.com/miguelmota/cointop/cointop/common/open"
5 years ago
"github.com/miguelmota/cointop/cointop/common/pad"
)
func (ct *Cointop) updateStatusbar(s string) error {
5 years ago
if ct.Views.Statusbar.Backing == nil {
return nil
}
5 years ago
currpage := ct.currentDisplayPage()
5 years ago
totalpages := ct.totalPagesDisplay()
5 years ago
var quitText string
var favoritesText string
var portfolioText string
5 years ago
if ct.State.portfolioVisible || ct.State.filterByFavorites {
5 years ago
quitText = "Return"
} else {
quitText = "Quit"
}
5 years ago
if ct.State.portfolioVisible {
5 years ago
portfolioText = "[E]Edit"
} else {
portfolioText = "[P]Portfolio"
}
5 years ago
if ct.State.filterByFavorites {
5 years ago
favoritesText = "[Space]Unfavorite"
} else {
favoritesText = "[F]Favorites"
}
ct.update(func() {
5 years ago
if ct.Views.Statusbar.Backing == nil {
return
}
5 years ago
ct.Views.Statusbar.Backing.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]")
5 years ago
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
5 years ago
fmt.Fprintln(ct.Views.Statusbar.Backing, str)
})
return nil
}
func (ct *Cointop) refreshRowLink() error {
var shortcut string
if !open.CommandExists() {
shortcut = "[O]Open "
}
5 years ago
url := ct.rowLinkShort()
ct.updateStatusbar(fmt.Sprintf("%s%s", shortcut, url))
return nil
}