1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-14 11:23:09 +02:00
lazygit/pkg/gui/presentation/worktrees.go

34 lines
871 B
Go
Raw Normal View History

package presentation
import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/theme"
)
2022-09-11 07:36:47 +02:00
func GetWorktreeDisplayString(isCurrent bool, isPathMissing bool, worktree *models.Worktree) []string {
textStyle := theme.DefaultTextColor
current := ""
currentColor := style.FgCyan
2022-09-11 07:36:47 +02:00
if isCurrent {
current = " *"
currentColor = style.FgGreen
}
2022-09-11 07:36:47 +02:00
icon := icons.IconForWorktree(worktree, false)
if isPathMissing {
textStyle = style.FgRed
2022-09-11 07:36:47 +02:00
icon = icons.IconForWorktree(worktree, true)
}
res := make([]string, 0, 3)
res = append(res, currentColor.Sprint(current))
if icons.IsIconEnabled() {
res = append(res, textStyle.Sprint(icon))
}
2022-09-11 07:36:47 +02:00
res = append(res, textStyle.Sprint(worktree.Name()))
return res
}