summaryrefslogtreecommitdiffstats
path: root/pkg/gui/presentation
diff options
context:
space:
mode:
authorMatt Cles <matthew@cles.dev>2022-01-31 21:23:55 -0800
committerJesse Duffield <jessedduffield@gmail.com>2022-02-01 18:55:45 +1100
commit9adf4a190864fd0c6a3b00ef46f23e93b0e6a5f5 (patch)
tree8fac4c192259f733d8861ae868b9f40ffca39f50 /pkg/gui/presentation
parent4df76466542441bceb6ebbb21a0730c5ea97e620 (diff)
Add shared function for loading map of custom colors
Diffstat (limited to 'pkg/gui/presentation')
-rw-r--r--pkg/gui/presentation/authors/authors.go5
-rw-r--r--pkg/gui/presentation/branches.go13
2 files changed, 6 insertions, 12 deletions
diff --git a/pkg/gui/presentation/authors/authors.go b/pkg/gui/presentation/authors/authors.go
index 7924ba369..d4eb8e465 100644
--- a/pkg/gui/presentation/authors/authors.go
+++ b/pkg/gui/presentation/authors/authors.go
@@ -114,8 +114,5 @@ func getFirstRune(str string) rune {
}
func SetCustomAuthors(customAuthorColors map[string]string) {
- for authorName, colorSequence := range customAuthorColors {
- style := style.New().SetFg(style.NewRGBColor(color.HEX(colorSequence, false)))
- authorStyleCache[authorName] = style
- }
+ authorStyleCache = utils.SetCustomColors(customAuthorColors)
}
diff --git a/pkg/gui/presentation/branches.go b/pkg/gui/presentation/branches.go
index 50a4ef094..e31c823ce 100644
--- a/pkg/gui/presentation/branches.go
+++ b/pkg/gui/presentation/branches.go
@@ -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)
}