Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cointop/coins_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (ct *Cointop) GetCoinsTable() *table.Table {
star := " "
rankcolor := ct.colorscheme.TableRow
if coin.Favorite {
star = "*"
star = ct.State.favoriteChar
rankcolor = ct.colorscheme.TableRowFavorite
}
rank := fmt.Sprintf("%s%6v ", star, coin.Rank)
Expand Down
5 changes: 5 additions & 0 deletions cointop/cointop.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type State struct {

favorites map[string]bool
favoritesTableColumns []string
favoriteChar string
helpVisible bool
hideMarketbar bool
hideChart bool
Expand Down Expand Up @@ -207,6 +208,9 @@ var DefaultCacheDir = filecache.DefaultCacheDir
// DefaultColorsDir ...
var DefaultColorsDir = fmt.Sprintf("%s/colors", DefaultConfigFilepath)

// DefaultFavoriteChar ...
var DefaultFavoriteChar = "*"

// NewCointop initializes cointop
func NewCointop(config *Config) (*Cointop, error) {
if os.Getenv("DEBUG") != "" {
Expand Down Expand Up @@ -257,6 +261,7 @@ func NewCointop(config *Config) (*Cointop, error) {
favoritesBySymbol: make(map[string]bool),
favorites: make(map[string]bool),
favoritesTableColumns: DefaultCoinTableHeaders,
favoriteChar: DefaultFavoriteChar,
hideMarketbar: config.HideMarketbar,
hideChart: config.HideChart,
hideTable: config.HideTable,
Expand Down
9 changes: 9 additions & 0 deletions cointop/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func (ct *Cointop) ConfigToToml() ([]byte, error) {

var favoritesColumnsIfc interface{} = ct.State.favoritesTableColumns
favoritesMapIfc["columns"] = favoritesColumnsIfc
favoritesMapIfc["character"] = ct.State.favoriteChar

portfolioIfc := map[string]interface{}{}
var holdingsIfc [][]string
Expand Down Expand Up @@ -507,6 +508,14 @@ func (ct *Cointop) loadAPIChoiceFromConfig() error {
func (ct *Cointop) loadFavoritesFromConfig() error {
log.Debug("loadFavoritesFromConfig()")
for k, valueIfc := range ct.config.Favorites {
if k == "character" {
if favoriteChar, ok := valueIfc.(string); ok {
if len(favoriteChar) != 1 {
return fmt.Errorf("invalid favorite-character. Must be one-character")
}
ct.State.favoriteChar = favoriteChar
}
}
ifcs, ok := valueIfc.([]interface{})
if !ok {
continue
Expand Down
2 changes: 1 addition & 1 deletion cointop/portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (ct *Cointop) GetPortfolioTable() *table.Table {
case "rank":
star := ct.colorscheme.TableRow(" ")
if coin.Favorite {
star = ct.colorscheme.TableRowFavorite("*")
star = ct.colorscheme.TableRowFavorite(ct.State.favoriteChar)
}
rank := fmt.Sprintf("%s%v", star, ct.colorscheme.TableRow(fmt.Sprintf("%6v ", coin.Rank)))
ct.SetTableColumnWidth(header, 8)
Expand Down