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