diff options
author | Sam Burville <Sam.Burville@GlobalProcessing.com> | 2021-09-29 12:53:31 +0100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-09-30 01:26:05 +1000 |
commit | c5f7ad5adb00b73acd44a086687ffbe5d7705aa2 (patch) | |
tree | 15948daa416d8e5adaff4105241304acbb859d5b | |
parent | 663c036ca5c5639c772a3f37ccef50ff03979337 (diff) |
Make cherry pick commit color customisable
Two new settings in the config, which allow the cherry picked
foreground and background to be custom colors.
Issue #856
-rw-r--r-- | docs/Config.md | 4 | ||||
-rw-r--r-- | pkg/config/user_config.go | 16 | ||||
-rw-r--r-- | pkg/gui/presentation/commits.go | 6 | ||||
-rw-r--r-- | pkg/gui/presentation/reflog_commits.go | 2 | ||||
-rw-r--r-- | pkg/theme/theme.go | 8 |
5 files changed, 25 insertions, 11 deletions
diff --git a/docs/Config.md b/docs/Config.md index 920d83ebf..51cf02ce5 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -36,6 +36,10 @@ gui: - default selectedRangeBgColor: - blue + cherryPickedCommitBgColor: + - blue + cherryPickedCommitFgColor: + - cyan commitLength: show: true mouseEvents: true diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 7b5145a47..a1e85401d 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -44,12 +44,14 @@ type GuiConfig struct { } type ThemeConfig struct { - LightTheme bool `yaml:"lightTheme"` - ActiveBorderColor []string `yaml:"activeBorderColor"` - InactiveBorderColor []string `yaml:"inactiveBorderColor"` - OptionsTextColor []string `yaml:"optionsTextColor"` - SelectedLineBgColor []string `yaml:"selectedLineBgColor"` - SelectedRangeBgColor []string `yaml:"selectedRangeBgColor"` + LightTheme bool `yaml:"lightTheme"` + ActiveBorderColor []string `yaml:"activeBorderColor"` + InactiveBorderColor []string `yaml:"inactiveBorderColor"` + OptionsTextColor []string `yaml:"optionsTextColor"` + SelectedLineBgColor []string `yaml:"selectedLineBgColor"` + SelectedRangeBgColor []string `yaml:"selectedRangeBgColor"` + CherryPickedCommitBgColor []string `yaml:"cherryPickedCommitBgColor"` + CherryPickedCommitFgColor []string `yaml:"cherryPickedCommitFgColor"` } type CommitLengthConfig struct { @@ -319,6 +321,8 @@ func GetDefaultConfig() *UserConfig { OptionsTextColor: []string{"blue"}, SelectedLineBgColor: []string{"default"}, SelectedRangeBgColor: []string{"blue"}, + CherryPickedCommitBgColor: []string{"blue"}, + CherryPickedCommitFgColor: []string{"cyan"}, }, CommitLength: CommitLengthConfig{Show: true}, SkipNoStagedFilesWarning: false, diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index 0743fd14e..de1d168dc 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -10,8 +10,6 @@ import ( "github.com/kyokomi/emoji/v2" ) -var cherryPickedCommitTextStyle = style.FgCyan.MergeStyle(style.BgBlue) - func GetCommitListDisplayStrings(commits []*models.Commit, fullDescription bool, cherryPickedCommitShaMap map[string]bool, diffName string, parseEmoji bool) [][]string { lines := make([][]string, len(commits)) @@ -51,7 +49,7 @@ func getFullDescriptionDisplayStringsForCommit(c *models.Commit, cherryPickedCom // for some reason, setting the background to blue pads out the other commits // horizontally. For the sake of accessibility I'm considering this a feature, // not a bug - shaColor = cherryPickedCommitTextStyle + shaColor = theme.CherryPickedCommitTextStyle } tagString := "" @@ -98,7 +96,7 @@ func getDisplayStringsForCommit(c *models.Commit, cherryPickedCommitShaMap map[s // for some reason, setting the background to blue pads out the other commits // horizontally. For the sake of accessibility I'm considering this a feature, // not a bug - shaColor = cherryPickedCommitTextStyle + shaColor = theme.CherryPickedCommitTextStyle } actionString := "" diff --git a/pkg/gui/presentation/reflog_commits.go b/pkg/gui/presentation/reflog_commits.go index b6b21e90f..fd843d884 100644 --- a/pkg/gui/presentation/reflog_commits.go +++ b/pkg/gui/presentation/reflog_commits.go @@ -29,7 +29,7 @@ func GetReflogCommitListDisplayStrings(commits []*models.Commit, fullDescription func coloredReflogSha(c *models.Commit, cherryPickedCommitShaMap map[string]bool) string { shaColor := style.FgBlue if cherryPickedCommitShaMap[c.Sha] { - shaColor = cherryPickedCommitTextStyle + shaColor = theme.CherryPickedCommitTextStyle } return shaColor.Sprint(c.ShortSha()) diff --git a/pkg/theme/theme.go b/pkg/theme/theme.go index b19af5e54..ba2848254 100644 --- a/pkg/theme/theme.go +++ b/pkg/theme/theme.go @@ -32,6 +32,9 @@ var ( // SelectedRangeBgColor is the background color of the selected range of lines SelectedRangeBgColor = style.New() + + // CherryPickedCommitColor is the text style when cherry picking a commit + CherryPickedCommitTextStyle = style.New() OptionsFgColor = style.New() @@ -44,6 +47,11 @@ func UpdateTheme(themeConfig config.ThemeConfig) { InactiveBorderColor = GetGocuiStyle(themeConfig.InactiveBorderColor) SelectedLineBgColor = GetTextStyle(themeConfig.SelectedLineBgColor, true) SelectedRangeBgColor = GetTextStyle(themeConfig.SelectedRangeBgColor, true) + + var cherryPickedCommitBgTextStyle = GetTextStyle(themeConfig.CherryPickedCommitBgColor, true) + var cherryPickedCommitFgTextStyle = GetTextStyle(themeConfig.CherryPickedCommitFgColor, false) + CherryPickedCommitTextStyle = cherryPickedCommitBgTextStyle.MergeStyle(cherryPickedCommitFgTextStyle) + GocuiSelectedLineBgColor = GetGocuiStyle(themeConfig.SelectedLineBgColor) OptionsColor = GetGocuiStyle(themeConfig.OptionsTextColor) OptionsFgColor = GetTextStyle(themeConfig.OptionsTextColor, false) |