diff options
author | Ryooooooga <eial5q265e5@gmail.com> | 2022-04-23 10:41:40 +0900 |
---|---|---|
committer | Ryooooooga <eial5q265e5@gmail.com> | 2022-04-23 12:25:41 +0900 |
commit | cb13fe7f46e2133912ea85d64e8c816aea0c0ca8 (patch) | |
tree | b68760d5c2fa5dabdbdc93394765e867d884a1c8 /pkg/gui | |
parent | b07aeda5a6d9b4990acf559ce0dc2639a7aca877 (diff) |
feat(gui): show commit icons
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/gui.go | 3 | ||||
-rw-r--r-- | pkg/gui/presentation/commits.go | 6 | ||||
-rw-r--r-- | pkg/gui/presentation/files.go | 10 | ||||
-rw-r--r-- | pkg/gui/presentation/icons/git_icons.go | 14 | ||||
-rw-r--r-- | pkg/gui/presentation/icons/icons.go | 11 |
5 files changed, 34 insertions, 10 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index f8fc02982..f2dd1c3f4 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -28,6 +28,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/presentation/authors" "github.com/jesseduffield/lazygit/pkg/gui/presentation/graph" + "github.com/jesseduffield/lazygit/pkg/gui/presentation/icons" "github.com/jesseduffield/lazygit/pkg/gui/services/custom_commands" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" @@ -479,7 +480,7 @@ func NewGui( gui.c = helperCommon authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors) - presentation.SetShowFileIcon(gui.UserConfig.Gui.ShowIcons) + icons.SetIconEnabled(gui.UserConfig.Gui.ShowIcons) presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors) return gui, nil diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index 7ec4e78af..59802dabf 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -9,6 +9,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/presentation/authors" "github.com/jesseduffield/lazygit/pkg/gui/presentation/graph" + "github.com/jesseduffield/lazygit/pkg/gui/presentation/icons" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/theme" "github.com/jesseduffield/lazygit/pkg/utils" @@ -275,7 +276,10 @@ func displayCommit( authorFunc = authors.LongAuthor } - cols := make([]string, 0, 5) + cols := make([]string, 0, 7) + if icons.IsIconEnabled() { + cols = append(cols, shaColor.Sprint(icons.IconForCommit(commit))) + } cols = append(cols, shaColor.Sprint(commit.ShortSha())) cols = append(cols, bisectString) if fullDescription { diff --git a/pkg/gui/presentation/files.go b/pkg/gui/presentation/files.go index 68cc81bfb..d3c86a33a 100644 --- a/pkg/gui/presentation/files.go +++ b/pkg/gui/presentation/files.go @@ -12,8 +12,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/utils" ) -var showFileIcon = false - const ( EXPANDED_ARROW = "▼" COLLAPSED_ARROW = "►" @@ -160,7 +158,7 @@ func getFileLine(hasUnstagedChanges bool, hasStagedChanges bool, name string, di isSubmodule := file != nil && file.IsSubmodule(submoduleConfigs) isDirectory := file == nil - if showFileIcon { + if icons.IsIconEnabled() { output += restColor.Sprintf("%s ", icons.IconForFile(name, isSubmodule, isDirectory)) } @@ -199,7 +197,7 @@ func getCommitFileLine(name string, diffName string, commitFile *models.CommitFi isSubmodule := false // TODO: submodule isDirectory := commitFile == nil - if showFileIcon { + if icons.IsIconEnabled() { output += colour.Sprintf("%s ", icons.IconForFile(name, isSubmodule, isDirectory)) } @@ -223,7 +221,3 @@ func getColorForChangeStatus(changeStatus string) style.TextStyle { return theme.DefaultTextColor } } - -func SetShowFileIcon(show bool) { - showFileIcon = show -} diff --git a/pkg/gui/presentation/icons/git_icons.go b/pkg/gui/presentation/icons/git_icons.go new file mode 100644 index 000000000..89185a0e8 --- /dev/null +++ b/pkg/gui/presentation/icons/git_icons.go @@ -0,0 +1,14 @@ +package icons + +import "github.com/jesseduffield/lazygit/pkg/commands/models" + +const BRANCH_ICON = "\ufb2b" // שׂ +const COMMIT_ICON = "\ufc16" // ﰖ +const MERGE_COMMIT_ICON = "\ufb2c" // שּׁ + +func IconForCommit(commit *models.Commit) string { + if len(commit.Parents) > 1 { + return MERGE_COMMIT_ICON + } + return COMMIT_ICON +} diff --git a/pkg/gui/presentation/icons/icons.go b/pkg/gui/presentation/icons/icons.go new file mode 100644 index 000000000..81b16108b --- /dev/null +++ b/pkg/gui/presentation/icons/icons.go @@ -0,0 +1,11 @@ +package icons + +var isIconEnabled = false + +func IsIconEnabled() bool { + return isIconEnabled +} + +func SetIconEnabled(showIcons bool) { + isIconEnabled = showIcons +} |