1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/gui/presentation/commit_files.go
2020-08-15 11:41:37 +10:00

42 lines
1.1 KiB
Go

package presentation
import (
"github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/patch"
"github.com/jesseduffield/lazygit/pkg/theme"
)
func GetCommitFileListDisplayStrings(commitFiles []*commands.CommitFile, diffName string) [][]string {
lines := make([][]string, len(commitFiles))
for i := range commitFiles {
diffed := commitFiles[i].Name == diffName
lines[i] = getCommitFileDisplayStrings(commitFiles[i], diffed)
}
return lines
}
// getCommitFileDisplayStrings returns the display string of branch
func getCommitFileDisplayStrings(f *commands.CommitFile, diffed bool) []string {
yellow := color.New(color.FgYellow)
green := color.New(color.FgGreen)
defaultColor := color.New(theme.DefaultTextColor)
diffTerminalColor := color.New(theme.DiffTerminalColor)
var colour *color.Color
switch f.Status {
case patch.UNSELECTED:
colour = defaultColor
case patch.WHOLE:
colour = green
case patch.PART:
colour = yellow
}
if diffed {
colour = diffTerminalColor
}
return []string{colour.Sprint(f.DisplayString)}
}