mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-15 22:26:40 +02:00
support user-configurable author colours
This commit is contained in:
parent
c96496c3a7
commit
c47c539e12
@ -50,6 +50,8 @@ gui:
|
|||||||
showRandomTip: true
|
showRandomTip: true
|
||||||
showCommandLog: true
|
showCommandLog: true
|
||||||
commandLogSize: 8
|
commandLogSize: 8
|
||||||
|
authorColors: # in case you're not happy with the randomly assigned colour
|
||||||
|
'John Smith': '#ff0000'
|
||||||
git:
|
git:
|
||||||
paging:
|
paging:
|
||||||
colorArg: always
|
colorArg: always
|
||||||
|
@ -24,6 +24,7 @@ type RefresherConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GuiConfig struct {
|
type GuiConfig struct {
|
||||||
|
AuthorColors map[string]string `yaml:"authorColors"`
|
||||||
ScrollHeight int `yaml:"scrollHeight"`
|
ScrollHeight int `yaml:"scrollHeight"`
|
||||||
ScrollPastBottom bool `yaml:"scrollPastBottom"`
|
ScrollPastBottom bool `yaml:"scrollPastBottom"`
|
||||||
MouseEvents bool `yaml:"mouseEvents"`
|
MouseEvents bool `yaml:"mouseEvents"`
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/gui/modes/cherrypicking"
|
"github.com/jesseduffield/lazygit/pkg/gui/modes/cherrypicking"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/modes/diffing"
|
"github.com/jesseduffield/lazygit/pkg/gui/modes/diffing"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/modes/filtering"
|
"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/style"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/i18n"
|
"github.com/jesseduffield/lazygit/pkg/i18n"
|
||||||
@ -452,6 +453,8 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom
|
|||||||
oSCommand.SetOnRunCommand(onRunCommand)
|
oSCommand.SetOnRunCommand(onRunCommand)
|
||||||
gui.OnRunCommand = onRunCommand
|
gui.OnRunCommand = onRunCommand
|
||||||
|
|
||||||
|
authors.SetCustomAuthors(gui.Config.GetUserConfig().Gui.AuthorColors)
|
||||||
|
|
||||||
return gui, nil
|
return gui, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ import (
|
|||||||
"github.com/mattn/go-runewidth"
|
"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 authorInitialCache = make(map[string]string)
|
||||||
var authorNameCache = make(map[string]string)
|
var authorNameCache = make(map[string]string)
|
||||||
var authorStyleCache = make(map[string]style.TextStyle)
|
var authorStyleCache = make(map[string]style.TextStyle)
|
||||||
@ -101,3 +103,10 @@ func getFirstRune(str string) rune {
|
|||||||
// should never land here
|
// should never land here
|
||||||
return 0
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user