|
22 | 22 | InactiveBorderColor gocui.Attribute |
23 | 23 |
|
24 | 24 | // SelectedLineBgColor is the background color for the selected line |
25 | | - SelectedLineBgColor color.Attribute |
| 25 | + SelectedLineBgColor gocui.Attribute |
| 26 | + // SelectedLineFgColor is the foreground color for the selected line |
| 27 | + SelectedLineFgColor gocui.Attribute |
26 | 28 |
|
27 | 29 | OptionsFgColor color.Attribute |
28 | 30 |
|
|
35 | 37 | func UpdateTheme(userConfig *viper.Viper) { |
36 | 38 | ActiveBorderColor = GetGocuiColor(userConfig.GetStringSlice("gui.theme.activeBorderColor")) |
37 | 39 | InactiveBorderColor = GetGocuiColor(userConfig.GetStringSlice("gui.theme.inactiveBorderColor")) |
38 | | - SelectedLineBgColor = GetBgColor(userConfig.GetStringSlice("gui.theme.selectedLineBgColor")) |
| 40 | + SelectedLineBgColor = GetGocuiBgColor(userConfig.GetStringSlice("gui.theme.selectedLineBgColor")) |
| 41 | + selectedLineFgColor := userConfig.GetStringSlice("gui.theme.selectedLineFgColor") |
| 42 | + if len(selectedLineFgColor) == 0 { |
| 43 | + selectedLineFgColor = []string{"white", "bold"} |
| 44 | + } |
| 45 | + SelectedLineFgColor = GetGocuiColor(selectedLineFgColor) |
39 | 46 | OptionsColor = GetGocuiColor(userConfig.GetStringSlice("gui.theme.optionsTextColor")) |
40 | 47 | OptionsFgColor = GetFgColor(userConfig.GetStringSlice("gui.theme.optionsTextColor")) |
41 | 48 |
|
@@ -129,6 +136,29 @@ func GetGocuiColor(keys []string) gocui.Attribute { |
129 | 136 | return attribute |
130 | 137 | } |
131 | 138 |
|
| 139 | +// GetGocuiBgColor converts configured background colors to gocui attributes. |
| 140 | +func GetGocuiBgColor(keys []string) gocui.Attribute { |
| 141 | + colorMap := map[string]gocui.Attribute{ |
| 142 | + "default": gocui.ColorDefault, |
| 143 | + "black": gocui.ColorBlack, |
| 144 | + "red": gocui.ColorRed, |
| 145 | + "green": gocui.ColorGreen, |
| 146 | + "yellow": gocui.ColorYellow, |
| 147 | + "blue": gocui.ColorBlue, |
| 148 | + "magenta": gocui.ColorMagenta, |
| 149 | + "cyan": gocui.ColorCyan, |
| 150 | + "white": gocui.ColorWhite, |
| 151 | + "bold": gocui.AttrBold, |
| 152 | + } |
| 153 | + var attribute gocui.Attribute |
| 154 | + for _, key := range keys { |
| 155 | + if value, present := colorMap[key]; present { |
| 156 | + attribute |= value |
| 157 | + } |
| 158 | + } |
| 159 | + return attribute |
| 160 | +} |
| 161 | + |
132 | 162 | // GetColor bitwise OR's a list of attributes obtained via the given keys |
133 | 163 | func GetBgColor(keys []string) color.Attribute { |
134 | 164 | var attribute color.Attribute |
|
0 commit comments