From c47c539e12df759b6a543dbd23e639f94fbd2e2d Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 30 Oct 2021 18:00:28 +1100 Subject: support user-configurable author colours --- pkg/gui/gui.go | 3 +++ pkg/gui/presentation/authors/authors.go | 9 +++++++++ 2 files changed, 12 insertions(+) (limited to 'pkg/gui') 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 + } +} -- cgit v1.2.3