mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-25 12:24:47 +02:00
feat(gui): show branch icons
This commit is contained in:
parent
cb13fe7f46
commit
11d0e7e17d
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/jesseduffield/generics/slices"
|
||||
"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/i18n"
|
||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||
@ -42,9 +43,14 @@ func getBranchDisplayStrings(b *models.Branch, fullDescription bool, diffed bool
|
||||
recencyColor = style.FgGreen
|
||||
}
|
||||
|
||||
res := []string{recencyColor.Sprint(b.Recency), coloredName}
|
||||
res := make([]string, 0, 4)
|
||||
res = append(res, recencyColor.Sprint(b.Recency))
|
||||
if icons.IsIconEnabled() {
|
||||
res = append(res, nameTextStyle.Sprint(icons.IconForBranch(b)))
|
||||
}
|
||||
res = append(res, coloredName)
|
||||
if fullDescription {
|
||||
return append(
|
||||
res = append(
|
||||
res,
|
||||
fmt.Sprintf("%s %s",
|
||||
style.FgYellow.Sprint(b.UpstreamRemote),
|
||||
|
@ -1,10 +1,29 @@
|
||||
package icons
|
||||
|
||||
import "github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
)
|
||||
|
||||
const BRANCH_ICON = "\ufb2b" // שׂ
|
||||
const COMMIT_ICON = "\ufc16" // ﰖ
|
||||
const MERGE_COMMIT_ICON = "\ufb2c" // שּׁ
|
||||
const BRANCH_ICON = "\ufb2b" // שׂ
|
||||
const DETACHED_HEAD_ICON = "\ue729" //
|
||||
const TAG_ICON = "\uf02b" //
|
||||
const COMMIT_ICON = "\ufc16" // ﰖ
|
||||
const MERGE_COMMIT_ICON = "\ufb2c" // שּׁ
|
||||
|
||||
func IconForBranch(branch *models.Branch) string {
|
||||
if branch.DisplayName != "" {
|
||||
return DETACHED_HEAD_ICON
|
||||
}
|
||||
return BRANCH_ICON
|
||||
}
|
||||
|
||||
func IconForRemoteBranch(branch *models.RemoteBranch) string {
|
||||
return BRANCH_ICON
|
||||
}
|
||||
|
||||
func IconForTag(tag *models.Tag) string {
|
||||
return TAG_ICON
|
||||
}
|
||||
|
||||
func IconForCommit(commit *models.Commit) string {
|
||||
if len(commit.Parents) > 1 {
|
||||
|
@ -3,6 +3,7 @@ package presentation
|
||||
import (
|
||||
"github.com/jesseduffield/generics/slices"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||
)
|
||||
|
||||
@ -20,5 +21,10 @@ func getRemoteBranchDisplayStrings(b *models.RemoteBranch, diffed bool) []string
|
||||
textStyle = theme.DiffTerminalColor
|
||||
}
|
||||
|
||||
return []string{textStyle.Sprint(b.Name)}
|
||||
res := make([]string, 0, 2)
|
||||
if icons.IsIconEnabled() {
|
||||
res = append(res, textStyle.Sprint(icons.IconForRemoteBranch(b)))
|
||||
}
|
||||
res = append(res, textStyle.Sprint(b.Name))
|
||||
return res
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package presentation
|
||||
import (
|
||||
"github.com/jesseduffield/generics/slices"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||
)
|
||||
|
||||
@ -19,5 +20,10 @@ func getTagDisplayStrings(t *models.Tag, diffed bool) []string {
|
||||
if diffed {
|
||||
textStyle = theme.DiffTerminalColor
|
||||
}
|
||||
return []string{textStyle.Sprint(t.Name)}
|
||||
res := make([]string, 0, 2)
|
||||
if icons.IsIconEnabled() {
|
||||
res = append(res, textStyle.Sprint(icons.IconForTag(t)))
|
||||
}
|
||||
res = append(res, textStyle.Sprint(t.Name))
|
||||
return res
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user