summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authormjarkk <mkopenga@gmail.com>2019-10-19 11:39:18 +0200
committerJesse Duffield <jessedduffield@gmail.com>2019-10-20 12:32:57 +1100
commita045313e080d2c083425e89cfd8a004cbcf72ef7 (patch)
tree72e916f19a2b71e04dfa146823e5f0575cd8e855 /pkg
parent9bd2dc3050b5342ee708a7d189986eaf16b1c9ff (diff)
Removed the pkg/gui/theme.go file
Moved most functions to the new theme/theme.go
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/gui.go16
-rw-r--r--pkg/gui/theme.go56
-rw-r--r--pkg/theme/theme.go32
3 files changed, 46 insertions, 58 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 6430b19f7..e82beea03 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -444,7 +444,8 @@ func (gui *Gui) layout(g *gocui.Gui) error {
return err
}
v.Frame = false
- v.FgColor = gui.GetOptionsPanelTextColor()
+ userConfig := gui.Config.GetUserConfig()
+ v.FgColor = theme.GetColor(userConfig.GetStringSlice("gui.theme.optionsTextColor"))
}
if gui.getCommitMessageView() == nil {
@@ -650,7 +651,7 @@ func (gui *Gui) Run() error {
gui.g = g // TODO: always use gui.g rather than passing g around everywhere
- if err := gui.SetColorScheme(); err != nil {
+ if err := gui.setColorScheme(); err != nil {
return err
}
@@ -745,3 +746,14 @@ func (gui *Gui) handleDonate(g *gocui.Gui, v *gocui.View) error {
}
return gui.OSCommand.OpenLink("https://donorbox.org/lazygit")
}
+
+// setColorScheme sets the color scheme for the app based on the user config
+func (gui *Gui) setColorScheme() error {
+ userConfig := gui.Config.GetUserConfig()
+ theme.UpdateTheme(userConfig)
+
+ gui.g.FgColor = theme.InactiveBorderColor
+ gui.g.SelFgColor = theme.ActiveBorderColor
+
+ return nil
+}
diff --git a/pkg/gui/theme.go b/pkg/gui/theme.go
deleted file mode 100644
index d2341bbf3..000000000
--- a/pkg/gui/theme.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package gui
-
-import (
- "github.com/jesseduffield/gocui"
- "github.com/jesseduffield/lazygit/pkg/theme"
-)
-
-// 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 |= gui.GetAttribute(key)
- }
- return attribute
-}
-
-// GetOptionsPanelTextColor gets the color of the options panel text
-func (gui *Gui) GetOptionsPanelTextColor() gocui.Attribute {
- userConfig := gui.Config.GetUserConfig()
- optionsColor := userConfig.GetStringSlice("gui.theme.optionsTextColor")
- return gui.GetColor(optionsColor)
-}
-
-// SetColorScheme sets the color scheme for the app based on the user config
-func (gui *Gui) SetColorScheme() error {
- userConfig := gui.Config.GetUserConfig()
- theme.UpdateTheme(userConfig)
-
- gui.g.FgColor = theme.InactiveBorderColor
- gui.g.SelFgColor = theme.ActiveBorderColor
-
- return nil
-}
diff --git a/pkg/theme/theme.go b/pkg/theme/theme.go
index 4b2c0e9b2..a991db91a 100644
--- a/pkg/theme/theme.go
+++ b/pkg/theme/theme.go
@@ -66,3 +66,35 @@ func getColor(keys []string) gocui.Attribute {
}
return attribute
}
+
+// 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,
+ }
+ 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 GetColor(keys []string) gocui.Attribute {
+ var attribute gocui.Attribute
+ for _, key := range keys {
+ attribute |= GetAttribute(key)
+ }
+ return attribute
+}