diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2018-08-18 13:53:58 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2018-08-18 13:53:58 +1000 |
commit | 284c53425102dba89164aa4363441caf71402114 (patch) | |
tree | f2cd2d34f169e5236a69b82e9a1c88e1d412a217 /pkg/gui/theme.go | |
parent | 10fdb5a609f8edcb426f01611179718235c4d4a0 (diff) |
user configurable border colors
Diffstat (limited to 'pkg/gui/theme.go')
-rw-r--r-- | pkg/gui/theme.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/pkg/gui/theme.go b/pkg/gui/theme.go new file mode 100644 index 000000000..25f5f8dc0 --- /dev/null +++ b/pkg/gui/theme.go @@ -0,0 +1,46 @@ +package gui + +import ( + "github.com/jesseduffield/gocui" +) + +// GetAttribute gets the gocui color attribute from the string +func (gui *Gui) 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, + } + value, present := colorMap[key] + if present { + return value + } + return gocui.ColorWhite +} + +// GetColor bitwise OR's a list of attributes obtained via the given keys +func (gui *Gui) GetColor(keys []string) gocui.Attribute { + var attribute gocui.Attribute + for _, key := range keys { + attribute = attribute | gui.GetAttribute(key) + } + return attribute +} + +// SetColorScheme sets the color scheme for the app based on the user config +func (gui *Gui) SetColorScheme() error { + activeBorderColor := gui.Config.GetUserConfig().GetStringSlice("gui.activeBorderColor") + inactiveBorderColor := gui.Config.GetUserConfig().GetStringSlice("gui.inactiveBorderColor") + gui.g.FgColor = gui.GetColor(inactiveBorderColor) + gui.g.SelFgColor = gui.GetColor(activeBorderColor) + return nil +} |