mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
* WTF-730 Fix missing color key config error Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Add Subheading color formatting to modules Users can now set a `subheading` color in their config to change the color of subheadings in widget display. Defaults to `red`. Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix oustanding color issues Clean up missing color config changes not addressed in earlier commits. Signed-off-by: Chris Cummer <chriscummer@me.com> * Remove unused dependency Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Base cleanup Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix a few bugs related to color config changes Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix issues with PagerDuty subheading display Signed-off-by: Chris Cummer <chriscummer@me.com> * WTF-730 Fix bug with Todo list colour rendering Signed-off-by: Chris Cummer <chriscummer@me.com>
107 lines
2.1 KiB
Go
107 lines
2.1 KiB
Go
package cfg
|
|
|
|
import (
|
|
"github.com/olebedev/config"
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
// BorderTheme defines the default color scheme for drawing widget borders
|
|
type BorderTheme struct {
|
|
Focusable string
|
|
Focused string
|
|
Unfocusable string
|
|
}
|
|
|
|
// CheckboxTheme defines the default color scheme for drawing checkable rows in widgets
|
|
type CheckboxTheme struct {
|
|
Checked string
|
|
}
|
|
|
|
// RowTheme defines the default color scheme for row text
|
|
type RowTheme struct {
|
|
EvenBackground string
|
|
EvenForeground string
|
|
|
|
OddBackground string
|
|
OddForeground string
|
|
|
|
HighlightedBackground string
|
|
HighlightedForeground string
|
|
}
|
|
|
|
// TextTheme defines the default color scheme for text rendering
|
|
type TextTheme struct {
|
|
Subheading string
|
|
Text string
|
|
Title string
|
|
}
|
|
|
|
type WidgetTheme struct {
|
|
Background string
|
|
}
|
|
|
|
// ColorTheme is an alamgam of all the default color settings
|
|
type ColorTheme struct {
|
|
BorderTheme
|
|
CheckboxTheme
|
|
RowTheme
|
|
TextTheme
|
|
WidgetTheme
|
|
}
|
|
|
|
// NewDefaultColorTheme creates and returns an instance of DefaultColorTheme
|
|
func NewDefaultColorTheme() ColorTheme {
|
|
defaultTheme := ColorTheme{
|
|
BorderTheme: BorderTheme{
|
|
Focusable: "blue",
|
|
Focused: "orange",
|
|
Unfocusable: "gray",
|
|
},
|
|
|
|
CheckboxTheme: CheckboxTheme{
|
|
Checked: "gray",
|
|
},
|
|
|
|
RowTheme: RowTheme{
|
|
EvenBackground: "transparent",
|
|
EvenForeground: "white",
|
|
|
|
OddBackground: "transparent",
|
|
OddForeground: "lightblue",
|
|
|
|
HighlightedForeground: "black",
|
|
HighlightedBackground: "green",
|
|
},
|
|
|
|
TextTheme: TextTheme{
|
|
Subheading: "red",
|
|
Text: "white",
|
|
Title: "green",
|
|
},
|
|
|
|
WidgetTheme: WidgetTheme{
|
|
Background: "transparent",
|
|
},
|
|
}
|
|
|
|
return defaultTheme
|
|
}
|
|
|
|
// NewDefaultColorConfig creates and returns a config.Config-compatible configuration struct
|
|
// using a DefaultColorTheme to pre-populate all the relevant values
|
|
func NewDefaultColorConfig() (*config.Config, error) {
|
|
colorTheme := NewDefaultColorTheme()
|
|
|
|
yamlBytes, err := yaml.Marshal(colorTheme)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
cfg, err := config.ParseYamlBytes(yamlBytes)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return cfg, nil
|
|
}
|