mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-28 16:02:01 +03:00
Add SpinnerConfig
This new config section allows to customize frames and rate of thespinner
This commit is contained in:
committed by
Stefan Haller
parent
53f0c4aeff
commit
f3dba743f0
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user