diff options
author | Artem Belyakov <artm.belyakov@gmail.com> | 2024-04-06 13:35:50 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-04-06 13:46:15 +0200 |
commit | f3dba743f04a7768a4d97ddcd9f9b6ce4acb9fed (patch) | |
tree | d750990bc7eba16dbf775d8072a2246bf9d0b0fa /pkg/gui/presentation | |
parent | 53f0c4aeffadabfc0bad783831843fdd128b51be (diff) |
Add `SpinnerConfig`
This new config section allows to customize frames and rate of
thespinner
Diffstat (limited to 'pkg/gui/presentation')
-rw-r--r-- | pkg/gui/presentation/branches.go | 21 | ||||
-rw-r--r-- | pkg/gui/presentation/remotes.go | 7 | ||||
-rw-r--r-- | pkg/gui/presentation/status.go | 13 | ||||
-rw-r--r-- | pkg/gui/presentation/tags.go | 14 |
4 files changed, 43 insertions, 12 deletions
diff --git a/pkg/gui/presentation/branches.go b/pkg/gui/presentation/branches.go index bb1f0bdc3..4f9a4aba4 100644 --- a/pkg/gui/presentation/branches.go +++ b/pkg/gui/presentation/branches.go @@ -50,7 +50,7 @@ func getBranchDisplayStrings( ) []string { checkedOutByWorkTree := git_commands.CheckedOutByOtherWorktree(b, worktrees) showCommitHash := fullDescription || userConfig.Gui.ShowBranchCommitHash - branchStatus := BranchStatus(b, itemOperation, tr, now) + branchStatus := BranchStatus(b, itemOperation, tr, now, userConfig) worktreeIcon := lo.Ternary(icons.IsIconEnabled(), icons.LINKED_WORKTREE_ICON, fmt.Sprintf("(%s)", tr.LcWorktree)) // Recency is always three characters, plus one for the space @@ -159,14 +159,25 @@ func branchStatusColor(branch *models.Branch, itemOperation types.ItemOperation) return colour } -func ColoredBranchStatus(branch *models.Branch, itemOperation types.ItemOperation, tr *i18n.TranslationSet) string { - return branchStatusColor(branch, itemOperation).Sprint(BranchStatus(branch, itemOperation, tr, time.Now())) +func ColoredBranchStatus( + branch *models.Branch, + itemOperation types.ItemOperation, + tr *i18n.TranslationSet, + userConfig *config.UserConfig, +) string { + return branchStatusColor(branch, itemOperation).Sprint(BranchStatus(branch, itemOperation, tr, time.Now(), userConfig)) } -func BranchStatus(branch *models.Branch, itemOperation types.ItemOperation, tr *i18n.TranslationSet, now time.Time) string { +func BranchStatus( + branch *models.Branch, + itemOperation types.ItemOperation, + tr *i18n.TranslationSet, + now time.Time, + userConfig *config.UserConfig, +) string { itemOperationStr := ItemOperationToString(itemOperation, tr) if itemOperationStr != "" { - return itemOperationStr + " " + utils.Loader(now) + return itemOperationStr + " " + utils.Loader(now, userConfig.Gui.Spinner) } if !branch.IsTrackingRemote() { diff --git a/pkg/gui/presentation/remotes.go b/pkg/gui/presentation/remotes.go index dc0f39ec0..61fc82e02 100644 --- a/pkg/gui/presentation/remotes.go +++ b/pkg/gui/presentation/remotes.go @@ -4,6 +4,7 @@ import ( "time" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/gui/presentation/icons" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" @@ -18,10 +19,11 @@ func GetRemoteListDisplayStrings( diffName string, getItemOperation func(item types.HasUrn) types.ItemOperation, tr *i18n.TranslationSet, + userConfig *config.UserConfig, ) [][]string { return lo.Map(remotes, func(remote *models.Remote, _ int) []string { diffed := remote.Name == diffName - return getRemoteDisplayStrings(remote, diffed, getItemOperation(remote), tr) + return getRemoteDisplayStrings(remote, diffed, getItemOperation(remote), tr, userConfig) }) } @@ -31,6 +33,7 @@ func getRemoteDisplayStrings( diffed bool, itemOperation types.ItemOperation, tr *i18n.TranslationSet, + userConfig *config.UserConfig, ) []string { branchCount := len(r.Branches) @@ -46,7 +49,7 @@ func getRemoteDisplayStrings( descriptionStr := style.FgBlue.Sprintf("%d branches", branchCount) itemOperationStr := ItemOperationToString(itemOperation, tr) if itemOperationStr != "" { - descriptionStr += " " + style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader(time.Now())) + descriptionStr += " " + style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader(time.Now(), userConfig.Gui.Spinner)) } res = append(res, textStyle.Sprint(r.Name), descriptionStr) return res diff --git a/pkg/gui/presentation/status.go b/pkg/gui/presentation/status.go index 7bf81948f..d3686510e 100644 --- a/pkg/gui/presentation/status.go +++ b/pkg/gui/presentation/status.go @@ -5,17 +5,26 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/types/enums" + "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/gui/presentation/icons" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/i18n" ) -func FormatStatus(repoName string, currentBranch *models.Branch, itemOperation types.ItemOperation, linkedWorktreeName string, workingTreeState enums.RebaseMode, tr *i18n.TranslationSet) string { +func FormatStatus( + repoName string, + currentBranch *models.Branch, + itemOperation types.ItemOperation, + linkedWorktreeName string, + workingTreeState enums.RebaseMode, + tr *i18n.TranslationSet, + userConfig *config.UserConfig, +) string { status := "" if currentBranch.IsRealBranch() { - status += ColoredBranchStatus(currentBranch, itemOperation, tr) + " " + status += ColoredBranchStatus(currentBranch, itemOperation, tr, userConfig) + " " } if workingTreeState != enums.REBASE_MODE_NONE { diff --git a/pkg/gui/presentation/tags.go b/pkg/gui/presentation/tags.go index 2d3a73755..441cd229a 100644 --- a/pkg/gui/presentation/tags.go +++ b/pkg/gui/presentation/tags.go @@ -4,6 +4,7 @@ import ( "time" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/gui/presentation/icons" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" @@ -18,15 +19,22 @@ func GetTagListDisplayStrings( getItemOperation func(item types.HasUrn) types.ItemOperation, diffName string, tr *i18n.TranslationSet, + userConfig *config.UserConfig, ) [][]string { return lo.Map(tags, func(tag *models.Tag, _ int) []string { diffed := tag.Name == diffName - return getTagDisplayStrings(tag, getItemOperation(tag), diffed, tr) + return getTagDisplayStrings(tag, getItemOperation(tag), diffed, tr, userConfig) }) } // getTagDisplayStrings returns the display string of branch -func getTagDisplayStrings(t *models.Tag, itemOperation types.ItemOperation, diffed bool, tr *i18n.TranslationSet) []string { +func getTagDisplayStrings( + t *models.Tag, + itemOperation types.ItemOperation, + diffed bool, + tr *i18n.TranslationSet, + userConfig *config.UserConfig, +) []string { textStyle := theme.DefaultTextColor if diffed { textStyle = theme.DiffTerminalColor @@ -39,7 +47,7 @@ func getTagDisplayStrings(t *models.Tag, itemOperation types.ItemOperation, diff descriptionStr := descriptionColor.Sprint(t.Description()) itemOperationStr := ItemOperationToString(itemOperation, tr) if itemOperationStr != "" { - descriptionStr = style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader(time.Now())) + " " + descriptionStr + descriptionStr = style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader(time.Now(), userConfig.Gui.Spinner)) + " " + descriptionStr } res = append(res, textStyle.Sprint(t.Name), descriptionStr) return res |