summaryrefslogtreecommitdiffstats
path: root/pkg/theme
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-02-23 11:57:12 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-02-23 18:37:19 +1100
commitfabdda0492c36bca691176485add9e013680f4dd (patch)
tree2b0123a014ed80d23e040e618c8503105aeb98f9 /pkg/theme
parent6fc3290a05a76f3e68fcbf5500c29a0c6f13da02 (diff)
allow customizing background color in staging mode
Diffstat (limited to 'pkg/theme')
-rw-r--r--pkg/theme/theme.go94
1 files changed, 65 insertions, 29 deletions
diff --git a/pkg/theme/theme.go b/pkg/theme/theme.go
index 0b4179cce..c5e49accd 100644
--- a/pkg/theme/theme.go
+++ b/pkg/theme/theme.go
@@ -20,12 +20,16 @@ var (
// InactiveBorderColor is the border color of the inactive active frames
InactiveBorderColor gocui.Attribute
+
+ // SelectedLineBgColor is the background color for the selected line
+ SelectedLineBgColor color.Attribute
)
// UpdateTheme updates all theme variables
func UpdateTheme(userConfig *viper.Viper) {
- ActiveBorderColor = getColor(userConfig.GetStringSlice("gui.theme.activeBorderColor"))
- InactiveBorderColor = getColor(userConfig.GetStringSlice("gui.theme.inactiveBorderColor"))
+ ActiveBorderColor = GetGocuiColor(userConfig.GetStringSlice("gui.theme.activeBorderColor"))
+ InactiveBorderColor = GetGocuiColor(userConfig.GetStringSlice("gui.theme.inactiveBorderColor"))
+ SelectedLineBgColor = GetBgColor(userConfig.GetStringSlice("gui.theme.selectedLineBgColor"))
isLightTheme := userConfig.GetBool("gui.theme.lightTheme")
if isLightTheme {
@@ -39,8 +43,8 @@ func UpdateTheme(userConfig *viper.Viper) {
}
}
-// getAttribute gets the gocui color attribute from the string
-func getAttribute(key string) gocui.Attribute {
+// GetAttribute gets the gocui color attribute from the string
+func GetGocuiAttribute(key string) gocui.Attribute {
colorMap := map[string]gocui.Attribute{
"default": gocui.ColorDefault,
"black": gocui.ColorBlack,
@@ -62,43 +66,75 @@ func getAttribute(key string) gocui.Attribute {
return gocui.ColorWhite
}
-// getColor bitwise OR's a list of attributes obtained via the given keys
-func getColor(keys []string) gocui.Attribute {
- var attribute gocui.Attribute
- for _, key := range keys {
- attribute |= getAttribute(key)
+// GetFgAttribute gets the color foreground attribute from the string
+func GetFgAttribute(key string) color.Attribute {
+ colorMap := map[string]color.Attribute{
+ "default": color.FgWhite,
+ "black": color.FgBlack,
+ "red": color.FgRed,
+ "green": color.FgGreen,
+ "yellow": color.FgYellow,
+ "blue": color.FgBlue,
+ "magenta": color.FgMagenta,
+ "cyan": color.FgCyan,
+ "white": color.FgWhite,
+ "bold": color.Bold,
+ "reverse": color.ReverseVideo,
+ "underline": color.Underline,
}
- return attribute
+ value, present := colorMap[key]
+ if present {
+ return value
+ }
+ return color.FgWhite
}
-// GetAttribute gets the gocui color attribute from the string
-func GetAttribute(key string) gocui.Attribute {
- colorMap := map[string]gocui.Attribute{
- "default": gocui.ColorDefault,
- "black": gocui.ColorBlack,
- "red": gocui.ColorRed,
- "green": gocui.ColorGreen,
- "yellow": gocui.ColorYellow,
- "blue": gocui.ColorBlue,
- "magenta": gocui.ColorMagenta,
- "cyan": gocui.ColorCyan,
- "white": gocui.ColorWhite,
- "bold": gocui.AttrBold,
- "reverse": gocui.AttrReverse,
- "underline": gocui.AttrUnderline,
+// GetBgAttribute gets the color background attribute from the string
+func GetBgAttribute(key string) color.Attribute {
+ colorMap := map[string]color.Attribute{
+ "default": color.BgWhite,
+ "black": color.BgBlack,
+ "red": color.BgRed,
+ "green": color.BgGreen,
+ "yellow": color.BgYellow,
+ "blue": color.BgBlue,
+ "magenta": color.BgMagenta,
+ "cyan": color.BgCyan,
+ "white": color.BgWhite,
+ "bold": color.Bold,
+ "reverse": color.ReverseVideo,
+ "underline": color.Underline,
}
value, present := colorMap[key]
if present {
return value
}
- return gocui.ColorWhite
+ return color.FgWhite
}
-// GetColor bitwise OR's a list of attributes obtained via the given keys
-func GetColor(keys []string) gocui.Attribute {
+// GetGocuiColor bitwise OR's a list of attributes obtained via the given keys
+func GetGocuiColor(keys []string) gocui.Attribute {
var attribute gocui.Attribute
for _, key := range keys {
- attribute |= GetAttribute(key)
+ attribute |= GetGocuiAttribute(key)
+ }
+ return attribute
+}
+
+// GetColor bitwise OR's a list of attributes obtained via the given keys
+func GetBgColor(keys []string) color.Attribute {
+ var attribute color.Attribute
+ for _, key := range keys {
+ attribute |= GetBgAttribute(key)
+ }
+ return attribute
+}
+
+// GetColor bitwise OR's a list of attributes obtained via the given keys
+func GetFgColor(keys []string) color.Attribute {
+ var attribute color.Attribute
+ for _, key := range keys {
+ attribute |= GetFgAttribute(key)
}
return attribute
}