mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Switch to github.com/gookit/color for terminal colors
This commit is contained in:
@ -4,10 +4,9 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/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"
|
||||
)
|
||||
|
||||
func GetBranchListDisplayStrings(branches []*models.Branch, fullDescription bool, diffName string) [][]string {
|
||||
@ -32,48 +31,48 @@ func getBranchDisplayStrings(b *models.Branch, fullDescription bool, diffed bool
|
||||
if diffed {
|
||||
nameColorAttr = theme.DiffTerminalColor
|
||||
}
|
||||
coloredName := utils.ColoredString(displayName, nameColorAttr)
|
||||
coloredName := nameColorAttr.Sprint(displayName)
|
||||
if b.IsTrackingRemote() {
|
||||
coloredName = fmt.Sprintf("%s %s", coloredName, ColoredBranchStatus(b))
|
||||
}
|
||||
|
||||
recencyColor := color.FgCyan
|
||||
recencyColor := style.FgCyan
|
||||
if b.Recency == " *" {
|
||||
recencyColor = color.FgGreen
|
||||
recencyColor = style.FgGreen
|
||||
}
|
||||
|
||||
res := []string{recencyColor.Sprint(b.Recency), coloredName}
|
||||
if fullDescription {
|
||||
return []string{utils.ColoredString(b.Recency, recencyColor), coloredName, utils.ColoredString(b.UpstreamName, color.FgYellow)}
|
||||
return append(res, style.FgYellow.Sprint(b.UpstreamName))
|
||||
}
|
||||
|
||||
return []string{utils.ColoredString(b.Recency, recencyColor), coloredName}
|
||||
return res
|
||||
}
|
||||
|
||||
// GetBranchColor branch color
|
||||
func GetBranchColor(name string) color.Attribute {
|
||||
func GetBranchColor(name string) style.TextStyle {
|
||||
branchType := strings.Split(name, "/")[0]
|
||||
|
||||
switch branchType {
|
||||
case "feature":
|
||||
return color.FgGreen
|
||||
return style.FgGreen
|
||||
case "bugfix":
|
||||
return color.FgYellow
|
||||
return style.FgYellow
|
||||
case "hotfix":
|
||||
return color.FgRed
|
||||
return style.FgRed
|
||||
default:
|
||||
return theme.DefaultTextColor
|
||||
}
|
||||
}
|
||||
|
||||
func ColoredBranchStatus(branch *models.Branch) string {
|
||||
colour := color.FgYellow
|
||||
colour := style.FgYellow
|
||||
if branch.MatchesUpstream() {
|
||||
colour = color.FgGreen
|
||||
colour = style.FgGreen
|
||||
} else if !branch.IsTrackingRemote() {
|
||||
colour = color.FgRed
|
||||
colour = style.FgRed
|
||||
}
|
||||
|
||||
return utils.ColoredString(BranchStatus(branch), colour)
|
||||
return colour.Sprint(BranchStatus(branch))
|
||||
}
|
||||
|
||||
func BranchStatus(branch *models.Branch) string {
|
||||
|
Reference in New Issue
Block a user