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 /pkg/gui | |
parent | c96496c3a7b3c327a515b6953055ef2b1b815c6c (diff) |
support user-configurable author colours
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/gui.go | 3 | ||||
-rw-r--r-- | pkg/gui/presentation/authors/authors.go | 9 |
2 files changed, 12 insertions, 0 deletions
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 + } +} |