diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-10-30 18:00:28 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-10-30 18:26:06 +1100 |
commit | c47c539e12df759b6a543dbd23e639f94fbd2e2d (patch) | |
tree | 72db5a63d330d49b68888a1b34693d73dc6b3931 | |
parent | c96496c3a7b3c327a515b6953055ef2b1b815c6c (diff) |
support user-configurable author colours
-rw-r--r-- | docs/Config.md | 2 | ||||
-rw-r--r-- | pkg/config/user_config.go | 1 | ||||
-rw-r--r-- | pkg/gui/gui.go | 3 | ||||
-rw-r--r-- | pkg/gui/presentation/authors/authors.go | 9 |
4 files changed, 15 insertions, 0 deletions
diff --git a/docs/Config.md b/docs/Config.md index 7b112aedc..e62bcb2ea 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -50,6 +50,8 @@ gui: showRandomTip: true showCommandLog: true commandLogSize: 8 + authorColors: # in case you're not happy with the randomly assigned colour + 'John Smith': '#ff0000' git: paging: colorArg: always diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index bbc08cdc3..485746c0f 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -24,6 +24,7 @@ type RefresherConfig struct { } type GuiConfig struct { + AuthorColors map[string]string `yaml:"authorColors"` ScrollHeight int `yaml:"scrollHeight"` ScrollPastBottom bool `yaml:"scrollPastBottom"` MouseEvents bool `yaml:"mouseEvents"` diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 4212d3dcd..cfd436090 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -22,6 +22,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/modes/cherrypicking" "github.com/jesseduffield/lazygit/pkg/gui/modes/diffing" "github.com/jesseduffield/lazygit/pkg/gui/modes/filtering" + "github.com/jesseduffield/lazygit/pkg/gui/presentation/authors" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/i18n" @@ -452,6 +453,8 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom oSCommand.SetOnRunCommand(onRunCommand) gui.OnRunCommand = onRunCommand + authors.SetCustomAuthors(gui.Config.GetUserConfig().Gui.AuthorColors) + return gui, nil } diff --git a/pkg/gui/presentation/authors/authors.go b/pkg/gui/presentation/authors/authors.go index 8040a8d4b..c48683a12 100644 --- a/pkg/gui/presentation/authors/authors.go +++ b/pkg/gui/presentation/authors/authors.go @@ -11,6 +11,8 @@ import ( "github.com/mattn/go-runewidth" ) +// if these being global variables causes trouble we can wrap them in a struct +// attached to the gui state. var authorInitialCache = make(map[string]string) var authorNameCache = make(map[string]string) var authorStyleCache = make(map[string]style.TextStyle) @@ -101,3 +103,10 @@ func getFirstRune(str string) rune { // should never land here return 0 } + +func SetCustomAuthors(customAuthorColors map[string]string) { + for authorName, colorSequence := range customAuthorColors { + style := style.New().SetFg(style.NewRGBColor(color.HEX(colorSequence, false))) + authorStyleCache[authorName] = style + } +} |