diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-16 17:15:19 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-30 18:35:22 +1000 |
commit | 5868750abaa6de4d32909f99253765361f77ef30 (patch) | |
tree | 317db3c0b75e4c40044d80d4b70f3e99779de676 /pkg/gui/presentation | |
parent | ab3052f6423c8b94ac2ecd0eab394e17ea20d8b5 (diff) |
Move status panel presentation logic into presentation package
Diffstat (limited to 'pkg/gui/presentation')
-rw-r--r-- | pkg/gui/presentation/status.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/gui/presentation/status.go b/pkg/gui/presentation/status.go new file mode 100644 index 000000000..e0288406f --- /dev/null +++ b/pkg/gui/presentation/status.go @@ -0,0 +1,32 @@ +package presentation + +import ( + "fmt" + + "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/commands/types/enums" + "github.com/jesseduffield/lazygit/pkg/gui/style" + "github.com/jesseduffield/lazygit/pkg/i18n" + "github.com/jesseduffield/lazygit/pkg/utils" +) + +func FormatStatus(currentBranch *models.Branch, mainWorktreeName string, workingTreeState enums.RebaseMode, tr *i18n.TranslationSet) string { + status := "" + + if currentBranch.IsRealBranch() { + status += ColoredBranchStatus(currentBranch, tr) + " " + } + + if workingTreeState != enums.REBASE_MODE_NONE { + status += style.FgYellow.Sprintf("(%s) ", FormatWorkingTreeStateLower(tr, workingTreeState)) + } + + name := GetBranchTextStyle(currentBranch.Name).Sprint(currentBranch.Name) + repoName := utils.GetCurrentRepoName() + if repoName != mainWorktreeName { + repoName = fmt.Sprintf("%s(%s)", mainWorktreeName, style.FgCyan.Sprint(repoName)) + } + status += fmt.Sprintf("%s → %s ", repoName, name) + + return status +} |