github.com/wtfutil/wtf@v0.43.0/cfg/default_color_theme.go (about) 1 package cfg 2 3 import ( 4 "github.com/olebedev/config" 5 "gopkg.in/yaml.v2" 6 ) 7 8 // BorderTheme defines the default color scheme for drawing widget borders 9 type BorderTheme struct { 10 Focusable string 11 Focused string 12 Unfocusable string 13 } 14 15 // CheckboxTheme defines the default color scheme for drawing checkable rows in widgets 16 type CheckboxTheme struct { 17 Checked string 18 } 19 20 // RowTheme defines the default color scheme for row text 21 type RowTheme struct { 22 EvenBackground string 23 EvenForeground string 24 25 OddBackground string 26 OddForeground string 27 28 HighlightedBackground string 29 HighlightedForeground string 30 } 31 32 // TextTheme defines the default color scheme for text rendering 33 type TextTheme struct { 34 Label string 35 Subheading string 36 Text string 37 Title string 38 } 39 40 // WidgetTheme defines the default color scheme for the widget rect itself 41 type WidgetTheme struct { 42 Background string 43 } 44 45 // ColorTheme is an alamgam of all the default color settings 46 type ColorTheme struct { 47 BorderTheme 48 CheckboxTheme 49 RowTheme 50 TextTheme 51 WidgetTheme 52 } 53 54 // NewDefaultColorTheme creates and returns an instance of DefaultColorTheme 55 func NewDefaultColorTheme() ColorTheme { 56 defaultTheme := ColorTheme{ 57 BorderTheme: BorderTheme{ 58 Focusable: "blue", 59 Focused: "orange", 60 Unfocusable: "gray", 61 }, 62 63 CheckboxTheme: CheckboxTheme{ 64 Checked: "gray", 65 }, 66 67 RowTheme: RowTheme{ 68 EvenBackground: "transparent", 69 EvenForeground: "white", 70 71 OddBackground: "transparent", 72 OddForeground: "lightblue", 73 74 HighlightedForeground: "black", 75 HighlightedBackground: "green", 76 }, 77 78 TextTheme: TextTheme{ 79 Label: "lightblue", 80 Subheading: "red", 81 Text: "white", 82 Title: "green", 83 }, 84 85 WidgetTheme: WidgetTheme{ 86 Background: "transparent", 87 }, 88 } 89 90 return defaultTheme 91 } 92 93 // NewDefaultColorConfig creates and returns a config.Config-compatible configuration struct 94 // using a DefaultColorTheme to pre-populate all the relevant values 95 func NewDefaultColorConfig() (*config.Config, error) { 96 colorTheme := NewDefaultColorTheme() 97 98 yamlBytes, err := yaml.Marshal(colorTheme) 99 if err != nil { 100 return nil, err 101 } 102 103 cfg, err := config.ParseYamlBytes(yamlBytes) 104 if err != nil { 105 return nil, err 106 } 107 108 return cfg, nil 109 }