1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-03 13:21:56 +02:00

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
This commit is contained in:
Sam Burville 2021-09-29 12:53:31 +01:00 committed by Jesse Duffield
parent 663c036ca5
commit c5f7ad5adb
5 changed files with 25 additions and 11 deletions

View File

@ -36,6 +36,10 @@ gui:
- default
selectedRangeBgColor:
- blue
cherryPickedCommitBgColor:
- blue
cherryPickedCommitFgColor:
- cyan
commitLength:
show: true
mouseEvents: true

View File

@ -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,

View File

@ -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 := ""

View File

@ -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())

View File

@ -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)