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