mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-07 22:02:56 +03:00
Add shared function for loading map of custom colors
This commit is contained in:
committed by
Jesse Duffield
parent
4df7646654
commit
9adf4a1908
@@ -4,13 +4,13 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/gookit/color"
|
||||
"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"
|
||||
)
|
||||
|
||||
var branchPrefixColors = make(map[string]style.TextStyle)
|
||||
var branchPrefixColorCache = make(map[string]style.TextStyle)
|
||||
|
||||
func GetBranchListDisplayStrings(branches []*models.Branch, fullDescription bool, diffName string) [][]string {
|
||||
lines := make([][]string, len(branches))
|
||||
@@ -61,7 +61,7 @@ func getBranchDisplayStrings(b *models.Branch, fullDescription bool, diffed bool
|
||||
func GetBranchTextStyle(name string) style.TextStyle {
|
||||
branchType := strings.Split(name, "/")[0]
|
||||
|
||||
if value, ok := branchPrefixColors[branchType]; ok {
|
||||
if value, ok := branchPrefixColorCache[branchType]; ok {
|
||||
return value
|
||||
}
|
||||
|
||||
@@ -92,9 +92,6 @@ func BranchStatus(branch *models.Branch) string {
|
||||
return fmt.Sprintf("↑%s↓%s", branch.Pushables, branch.Pullables)
|
||||
}
|
||||
|
||||
func SetCustomBranchColors(customBranchColors map[string]string) {
|
||||
for branchPrefix, colorSequence := range customBranchColors {
|
||||
style := style.New().SetFg(style.NewRGBColor(color.HEX(colorSequence, false)))
|
||||
branchPrefixColors[branchPrefix] = style
|
||||
}
|
||||
func SetCustomBranches(customBranchColors map[string]string) {
|
||||
branchPrefixColorCache = utils.SetCustomColors(customBranchColors)
|
||||
}
|
||||
|
Reference in New Issue
Block a user