1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

Switch to github.com/gookit/color for terminal colors

This commit is contained in:
mjarkk
2021-07-27 15:00:37 +02:00
parent a3b820fb5f
commit 79848087bc
100 changed files with 12406 additions and 1704 deletions

View File

@ -1,8 +1,8 @@
package presentation
import (
"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"
)
@ -10,35 +10,30 @@ import (
func GetFileLine(hasUnstagedChanges bool, hasStagedChanges bool, name string, diffName string, submoduleConfigs []*models.SubmoduleConfig, file *models.File) string {
// potentially inefficient to be instantiating these color
// objects with each render
red := color.New(color.FgRed)
green := color.New(color.FgGreen)
diffColor := color.New(theme.DiffTerminalColor)
partiallyModifiedColor := color.New(color.FgYellow)
partiallyModifiedColor := style.FgYellow
var restColor *color.Color
restColor := style.FgGreen
if name == diffName {
restColor = diffColor
restColor = theme.DiffTerminalColor
} else if file == nil && hasStagedChanges && hasUnstagedChanges {
restColor = partiallyModifiedColor
} else if hasUnstagedChanges {
restColor = red
} else {
restColor = green
restColor = style.FgRed
}
output := ""
if file != nil {
// this is just making things look nice when the background attribute is 'reverse'
firstChar := file.ShortStatus[0:1]
firstCharCl := green
firstCharCl := style.FgGreen
if firstChar == "?" {
firstCharCl = red
firstCharCl = style.FgRed
} else if firstChar == " " {
firstCharCl = restColor
}
secondChar := file.ShortStatus[1:2]
secondCharCl := red
secondCharCl := style.FgRed
if secondChar == " " {
secondCharCl = restColor
}
@ -51,7 +46,7 @@ func GetFileLine(hasUnstagedChanges bool, hasStagedChanges bool, name string, di
output += restColor.Sprint(utils.EscapeSpecialChars(name))
if file != nil && file.IsSubmodule(submoduleConfigs) {
output += utils.ColoredString(" (submodule)", theme.DefaultTextColor)
output += theme.DefaultTextColor.Sprint(" (submodule)")
}
return output