mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Clean up TextWidget by simplifying the view creation
This commit is contained in:
@@ -55,9 +55,10 @@ type Common struct {
|
||||
Sigils
|
||||
|
||||
Enabled bool
|
||||
FocusChar int
|
||||
RefreshInterval int
|
||||
Title string
|
||||
|
||||
focusChar int
|
||||
}
|
||||
|
||||
func NewCommonSettingsFromYAML(name, configKey string, ymlConfig *config.Config) *Common {
|
||||
@@ -93,9 +94,10 @@ func NewCommonSettingsFromYAML(name, configKey string, ymlConfig *config.Config)
|
||||
},
|
||||
|
||||
Enabled: ymlConfig.UBool(modulePath+".enabled", false),
|
||||
FocusChar: ymlConfig.UInt(modulePath+".focusChar", -1),
|
||||
RefreshInterval: ymlConfig.UInt(modulePath+".refreshInterval", 300),
|
||||
Title: ymlConfig.UString(modulePath+".title", name),
|
||||
|
||||
focusChar: ymlConfig.UInt(modulePath+".focusChar", -1),
|
||||
}
|
||||
|
||||
common.Colors.Rows.Even = ymlConfig.UString(modulePath+".colors.rows.even", ymlConfig.UString(colorsPath+".rows.even", "white"))
|
||||
@@ -118,6 +120,15 @@ func (common *Common) DefaultRowColor() string {
|
||||
return fmt.Sprintf("%s:%s", common.Colors.Foreground, common.Colors.Background)
|
||||
}
|
||||
|
||||
func (common *Common) FocusChar() string {
|
||||
focusChar := string('0' + common.focusChar)
|
||||
if common.focusChar == -1 {
|
||||
focusChar = ""
|
||||
}
|
||||
|
||||
return focusChar
|
||||
}
|
||||
|
||||
func (common *Common) RowColor(idx int) string {
|
||||
if idx%2 == 0 {
|
||||
return common.Colors.Rows.Even
|
||||
|
||||
Reference in New Issue
Block a user