From 27f1fff6f5e0402d6e6548f8299e53d6bba6f726 Mon Sep 17 00:00:00 2001 From: Bartlomiej Komendarczuk Date: Sun, 3 Nov 2024 20:43:54 +0100 Subject: [PATCH] Graph highlight color depends on userconfig property Added to config CommitTreeGraphHighlightColor property --- docs/Config.md | 4 ++++ pkg/config/user_config.go | 3 +++ pkg/gui/presentation/graph/graph.go | 3 ++- pkg/gui/style/basic_styles.go | 1 + pkg/theme/theme.go | 4 ++++ schema/config.json | 12 ++++++++++++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/Config.md b/docs/Config.md index 432e701863e..93765944c57 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -152,6 +152,10 @@ gui: defaultFgColor: - default + # Color for commit tree graph + commitTreeGraphHighlightColor: + - lightwhite + # Config relating to the commit length indicator commitLength: # If true, show an indicator of commit message length diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 2a8778ef9db..a9b90b7d69a 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -197,6 +197,8 @@ type ThemeConfig struct { UnstagedChangesColor []string `yaml:"unstagedChangesColor" jsonschema:"minItems=1,uniqueItems=true"` // Default text color DefaultFgColor []string `yaml:"defaultFgColor" jsonschema:"minItems=1,uniqueItems=true"` + // Color for commit tree graph + CommitTreeGraphHighlightColor []string `yaml:"commitTreeGraphHighlightColor" jsonschema:"minItems=1,uniqueItems=true"` } type CommitLengthConfig struct { @@ -704,6 +706,7 @@ func GetDefaultConfig() *UserConfig { MarkedBaseCommitFgColor: []string{"blue"}, UnstagedChangesColor: []string{"red"}, DefaultFgColor: []string{"default"}, + CommitTreeGraphHighlightColor: []string{"lightwhite"}, }, CommitLength: CommitLengthConfig{Show: true}, SkipNoStagedFilesWarning: false, diff --git a/pkg/gui/presentation/graph/graph.go b/pkg/gui/presentation/graph/graph.go index 7f3eb8a2726..0e8281af046 100644 --- a/pkg/gui/presentation/graph/graph.go +++ b/pkg/gui/presentation/graph/graph.go @@ -8,6 +8,7 @@ import ( "github.com/jesseduffield/generics/set" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/style" + "github.com/jesseduffield/lazygit/pkg/theme" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" "golang.org/x/exp/slices" @@ -30,7 +31,7 @@ type Pipe struct { style style.TextStyle } -var highlightStyle = style.FgLightWhite.SetBold() +var highlightStyle = theme.CommitTreeGraphHighlightColor.SetBold() func ContainsCommitHash(pipes []*Pipe, hash string) bool { for _, pipe := range pipes { diff --git a/pkg/gui/style/basic_styles.go b/pkg/gui/style/basic_styles.go index 59bd907ff1e..8ea7a4ef3cb 100644 --- a/pkg/gui/style/basic_styles.go +++ b/pkg/gui/style/basic_styles.go @@ -48,6 +48,7 @@ var ( "magenta": {FgMagenta, BgMagenta}, "cyan": {FgCyan, BgCyan}, "white": {FgWhite, BgWhite}, + "lightwhite": {FgLightWhite, BgWhite}, } ) diff --git a/pkg/theme/theme.go b/pkg/theme/theme.go index acd8ebf7161..52a1cd8ffdf 100644 --- a/pkg/theme/theme.go +++ b/pkg/theme/theme.go @@ -45,6 +45,8 @@ var ( DiffTerminalColor = style.FgMagenta UnstagedChangesColor = style.New() + + CommitTreeGraphHighlightColor = style.New() ) // UpdateTheme updates all theme variables @@ -73,4 +75,6 @@ func UpdateTheme(themeConfig config.ThemeConfig) { DefaultTextColor = GetTextStyle(themeConfig.DefaultFgColor, false) GocuiDefaultTextColor = GetGocuiStyle(themeConfig.DefaultFgColor) + + CommitTreeGraphHighlightColor = GetTextStyle(themeConfig.CommitTreeGraphHighlightColor, false) } diff --git a/schema/config.json b/schema/config.json index 78e932f9d3e..ec16a0d9ff6 100644 --- a/schema/config.json +++ b/schema/config.json @@ -265,6 +265,18 @@ "default": [ "default" ] + }, + "commitTreeGraphHighlightColor": { + "items": { + "type": "string" + }, + "type": "array", + "minItems": 1, + "uniqueItems": true, + "description": "Color for commit tree graph", + "default": [ + "lightwhite" + ] } }, "additionalProperties": false,