`Profile.TickerColors` => `Profile.Colors`

master
joce 3 years ago
parent dbd989c894
commit d6b0039c90
  1. 6
      markup.go
  2. 26
      profile.go

@ -55,9 +55,9 @@ func NewMarkup(profile *Profile) *Markup {
markup.tags[`r`] = termbox.AttrReverse markup.tags[`r`] = termbox.AttrReverse
// Semantic markups // Semantic markups
markup.tags[`gain`] = markup.tags[profile.TickerColors.Gain] markup.tags[`gain`] = markup.tags[profile.Colors.Gain]
markup.tags[`loss`] = markup.tags[profile.TickerColors.Loss] markup.tags[`loss`] = markup.tags[profile.Colors.Loss]
markup.tags[`tag`] = markup.tags[profile.TickerColors.Tag] markup.tags[`tag`] = markup.tags[profile.Colors.Tag]
markup.regex = markup.supportedTags() // Once we have the hash we could build the regex. markup.regex = markup.supportedTags() // Once we have the hash we could build the regex.

@ -28,7 +28,7 @@ type Profile struct {
Ascending bool // True when sort order is ascending. Ascending bool // True when sort order is ascending.
Grouped bool // True when stocks are grouped by advancing/declining. Grouped bool // True when stocks are grouped by advancing/declining.
Filter string // Filter in human form Filter string // Filter in human form
TickerColors struct { // Ticker colors Colors struct { // User defined colors
Gain string Gain string
Loss string Loss string
Tag string Tag string
@ -67,26 +67,26 @@ func NewProfile(filename string) *Profile {
profile.SortColumn = 0 // Stock quotes are sorted by ticker name. profile.SortColumn = 0 // Stock quotes are sorted by ticker name.
profile.Ascending = true // A to Z. profile.Ascending = true // A to Z.
profile.Filter = "" profile.Filter = ""
profile.TickerColors.Gain = defaultGainColor profile.Colors.Gain = defaultGainColor
profile.TickerColors.Loss = defaultLossColor profile.Colors.Loss = defaultLossColor
profile.TickerColors.Tag = defaultTagColor profile.Colors.Tag = defaultTagColor
profile.Save() profile.Save()
} else { } else {
json.Unmarshal(data, profile) json.Unmarshal(data, profile)
profile.TickerColors.Gain = strings.ToLower(profile.TickerColors.Gain) profile.Colors.Gain = strings.ToLower(profile.Colors.Gain)
if !IsSupportedColor(profile.TickerColors.Gain) { if !IsSupportedColor(profile.Colors.Gain) {
profile.TickerColors.Gain = defaultGainColor profile.Colors.Gain = defaultGainColor
} }
profile.TickerColors.Loss = strings.ToLower(profile.TickerColors.Loss) profile.Colors.Loss = strings.ToLower(profile.Colors.Loss)
if !IsSupportedColor(profile.TickerColors.Loss) { if !IsSupportedColor(profile.Colors.Loss) {
profile.TickerColors.Loss = defaultLossColor profile.Colors.Loss = defaultLossColor
} }
profile.TickerColors.Tag = strings.ToLower(profile.TickerColors.Tag) profile.Colors.Tag = strings.ToLower(profile.Colors.Tag)
if !IsSupportedColor(profile.TickerColors.Tag) { if !IsSupportedColor(profile.Colors.Tag) {
profile.TickerColors.Tag = defaultTagColor profile.Colors.Tag = defaultTagColor
} }
profile.SetFilter(profile.Filter) profile.SetFilter(profile.Filter)

Loading…
Cancel
Save