summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyooooooga <eial5q265e5@gmail.com>2022-04-23 10:57:51 +0900
committerRyooooooga <eial5q265e5@gmail.com>2022-04-23 12:25:41 +0900
commit11d0e7e17df94407695e28831b4005de3a86f326 (patch)
tree2c29c937249bb22be1991c3a5e3e4db04120ca74
parentcb13fe7f46e2133912ea85d64e8c816aea0c0ca8 (diff)
feat(gui): show branch icons
-rw-r--r--pkg/gui/presentation/branches.go10
-rw-r--r--pkg/gui/presentation/icons/git_icons.go27
-rw-r--r--pkg/gui/presentation/remote_branches.go8
-rw-r--r--pkg/gui/presentation/tags.go8
4 files changed, 45 insertions, 8 deletions
diff --git a/pkg/gui/presentation/branches.go b/pkg/gui/presentation/branches.go
index b7d8b0270..7d68b04d5 100644
--- a/pkg/gui/presentation/branches.go
+++ b/pkg/gui/presentation/branches.go
@@ -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),
diff --git a/pkg/gui/presentation/icons/git_icons.go b/pkg/gui/presentation/icons/git_icons.go
index 89185a0e8..8acfead2b 100644
--- a/pkg/gui/presentation/icons/git_icons.go
+++ b/pkg/gui/presentation/icons/git_icons.go
@@ -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 {
diff --git a/pkg/gui/presentation/remote_branches.go b/pkg/gui/presentation/remote_branches.go
index c5c54dfcb..4052d3fed 100644
--- a/pkg/gui/presentation/remote_branches.go
+++ b/pkg/gui/presentation/remote_branches.go
@@ -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
}
diff --git a/pkg/gui/presentation/tags.go b/pkg/gui/presentation/tags.go
index 2157e29c9..2996db18d 100644
--- a/pkg/gui/presentation/tags.go
+++ b/pkg/gui/presentation/tags.go
@@ -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
}