|
|
|
@ -16,6 +16,9 @@ import ( |
|
|
|
|
const defaultGainColor = "green" |
|
|
|
|
const defaultLossColor = "red" |
|
|
|
|
const defaultTagColor = "yellow" |
|
|
|
|
const defaultHeaderColor = "lightgray" |
|
|
|
|
const defaultTimeColor = "lightgray" |
|
|
|
|
const defaultColor = "lightgray" |
|
|
|
|
|
|
|
|
|
// Profile manages Mop program settings as defined by user (ex. list of
|
|
|
|
|
// stock tickers). The settings are serialized using JSON and saved in
|
|
|
|
@ -32,6 +35,9 @@ type Profile struct { |
|
|
|
|
Gain string |
|
|
|
|
Loss string |
|
|
|
|
Tag string |
|
|
|
|
Header string |
|
|
|
|
Time string |
|
|
|
|
Default string |
|
|
|
|
} |
|
|
|
|
filterExpression *govaluate.EvaluableExpression // The filter as a govaluate expression
|
|
|
|
|
selectedColumn int // Stores selected column number when the column editor is active.
|
|
|
|
@ -78,13 +84,19 @@ func NewProfile(filename string) *Profile { |
|
|
|
|
profile.Colors.Gain = defaultGainColor |
|
|
|
|
profile.Colors.Loss = defaultLossColor |
|
|
|
|
profile.Colors.Tag = defaultTagColor |
|
|
|
|
profile.Colors.Header = defaultHeaderColor |
|
|
|
|
profile.Colors.Time = defaultTimeColor |
|
|
|
|
profile.Colors.Default = defaultColor |
|
|
|
|
profile.Save() |
|
|
|
|
} else { |
|
|
|
|
json.Unmarshal(data, profile) |
|
|
|
|
|
|
|
|
|
InitColor(profile.Colors.Gain, defaultGainColor) |
|
|
|
|
InitColor(profile.Colors.Loss, defaultLossColor) |
|
|
|
|
InitColor(profile.Colors.Tag, defaultTagColor) |
|
|
|
|
InitColor(&profile.Colors.Gain, defaultGainColor) |
|
|
|
|
InitColor(&profile.Colors.Loss, defaultLossColor) |
|
|
|
|
InitColor(&profile.Colors.Tag, defaultTagColor) |
|
|
|
|
InitColor(&profile.Colors.Header, defaultHeaderColor) |
|
|
|
|
InitColor(&profile.Colors.Time, defaultTimeColor) |
|
|
|
|
InitColor(&profile.Colors.Default, defaultColor) |
|
|
|
|
|
|
|
|
|
profile.SetFilter(profile.Filter) |
|
|
|
|
} |
|
|
|
@ -93,10 +105,10 @@ func NewProfile(filename string) *Profile { |
|
|
|
|
return profile |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func InitColor(color string, defaultValue string) { |
|
|
|
|
color = strings.ToLower(color) |
|
|
|
|
if !IsSupportedColor(color) { |
|
|
|
|
color = defaultValue; |
|
|
|
|
func InitColor(color *string, defaultValue string) { |
|
|
|
|
*color = strings.ToLower(*color) |
|
|
|
|
if !IsSupportedColor(*color) { |
|
|
|
|
*color = defaultValue |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|