diff options
-rw-r--r-- | Gopkg.lock | 18 | ||||
-rw-r--r-- | docs/Config.md | 39 | ||||
-rw-r--r-- | pkg/config/app_config.go | 34 | ||||
-rw-r--r-- | pkg/gui/gui.go | 4 | ||||
-rw-r--r-- | pkg/gui/theme.go | 12 |
5 files changed, 80 insertions, 27 deletions
diff --git a/Gopkg.lock b/Gopkg.lock index b8bb00dba..662a9c28d 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -156,6 +156,14 @@ revision = "58046073cbffe2f25d425fe1331102f55cf719de" [[projects]] + branch = "master" + digest = "1:5fe20cfe4ef484c237cec9f947b2a6fa90bad4b8610fd014f0e4211e13d82d5d" + name = "github.com/mitchellh/mapstructure" + packages = ["."] + pruneopts = "NUT" + revision = "f15292f7a699fcc1a38a80977f80a046874ba8ac" + +[[projects]] digest = "1:2c34c77bf3ec848da26e48af58fc511ed52750961fa848399d122882b8890928" name = "github.com/nicksnyder/go-i18n" packages = [ @@ -169,14 +177,6 @@ [[projects]] branch = "master" - digest = "1:5fe20cfe4ef484c237cec9f947b2a6fa90bad4b8610fd014f0e4211e13d82d5d" - name = "github.com/mitchellh/mapstructure" - packages = ["."] - pruneopts = "NUT" - revision = "f15292f7a699fcc1a38a80977f80a046874ba8ac" - -[[projects]] - branch = "master" digest = "1:34d9354c2c5d916c05864327553047df59fc10e86ff1f408e4136eba0a25a5ec" name = "github.com/nsf/termbox-go" packages = ["."] @@ -438,9 +438,9 @@ "github.com/golang-collections/collections/stack", "github.com/jesseduffield/gocui", "github.com/mgutz/str", + "github.com/nicksnyder/go-i18n/v2/i18n", "github.com/shibukawa/configdir", "github.com/spf13/viper", - "github.com/nicksnyder/go-i18n/v2/i18n", "github.com/tcnksm/go-gitconfig", "golang.org/x/text/language", "gopkg.in/src-d/go-git.v4", diff --git a/docs/Config.md b/docs/Config.md new file mode 100644 index 000000000..e6e2c3974 --- /dev/null +++ b/docs/Config.md @@ -0,0 +1,39 @@ +# User Config: + +## Default: + +``` + gui: + # stuff relating to the UI + scrollHeight: 2 # how many lines you scroll by + theme: + activeBorderColor: + - white + - bold + inactiveBorderColor: + - white + optionsTextColor: + - blue + git: + # stuff relating to git + os: + # stuff relating to the OS +``` + +## Color Attributes: + +For color attributes you can choose an array of attributes (with max one color attribute) +The available attributes are: + +- default +- black +- red +- green +- yellow +- blue +- magenta +- cyan +- white +- bold +- reverse # useful for high-contrast +- underline diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 6276a6afa..9f258d4a6 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -2,8 +2,6 @@ package config import ( "bytes" - "log" - "os/user" "github.com/shibukawa/configdir" "github.com/spf13/viper" @@ -117,7 +115,9 @@ func LoadUserConfigFromFile(v *viper.Viper) error { if folder == nil { // create the file as an empty config and load it folders := configDirs.QueryFolders(configdir.Global) - folders[0].WriteFile("config.yml", []byte{}) + if err := folders[0].WriteFile("config.yml", []byte{}); err != nil { + return err + } folder = configDirs.QueryFolderContainsFile("config.yml") } v.AddConfigPath(folder.Path) @@ -150,11 +150,14 @@ func getDefaultConfig() []byte { gui: ## stuff relating to the UI scrollHeight: 2 - activeBorderColor: - - white - - bold - inactiveBorderColor: - - white + theme: + activeBorderColor: + - white + - bold + inactiveBorderColor: + - white + optionsTextColor: + - blue git: # stuff relating to git os: @@ -163,10 +166,11 @@ func getDefaultConfig() []byte { `) } -func homeDirectory() string { - usr, err := user.Current() - if err != nil { - log.Fatal(err) - } - return usr.HomeDir -} +// // commenting this out until we use it again +// func homeDirectory() string { +// usr, err := user.Current() +// if err != nil { +// log.Fatal(err) +// } +// return usr.HomeDir +// } diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 71ba255a8..05d0a1ae0 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -231,8 +231,10 @@ func (gui *Gui) layout(g *gocui.Gui) error { if err != gocui.ErrUnknownView { return err } - v.FgColor = gocui.ColorBlue v.Frame = false + if v.FgColor, err = gui.GetOptionsPanelTextColor(); err != nil { + return err + } } if gui.getCommitMessageView(g) == nil { diff --git a/pkg/gui/theme.go b/pkg/gui/theme.go index 25f5f8dc0..dbc8b904b 100644 --- a/pkg/gui/theme.go +++ b/pkg/gui/theme.go @@ -36,10 +36,18 @@ func (gui *Gui) GetColor(keys []string) gocui.Attribute { return attribute } +// GetOptionsPanelTextColor gets the color of the options panel text +func (gui *Gui) GetOptionsPanelTextColor() (gocui.Attribute, error) { + userConfig := gui.Config.GetUserConfig() + optionsColor := userConfig.GetStringSlice("gui.theme.optionsTextColor") + return gui.GetColor(optionsColor), nil +} + // 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") + userConfig := gui.Config.GetUserConfig() + activeBorderColor := userConfig.GetStringSlice("gui.theme.activeBorderColor") + inactiveBorderColor := userConfig.GetStringSlice("gui.theme.inactiveBorderColor") gui.g.FgColor = gui.GetColor(inactiveBorderColor) gui.g.SelFgColor = gui.GetColor(activeBorderColor) return nil |