diff options
| author | ewy <ewy0@protonmail.com> | 2026-04-29 00:47:34 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-04-29 00:47:34 +0200 |
| commit | 630d77e1962b43ee95e88a664f5e8b8993213060 (patch) | |
| tree | 8849c2a87443cd231786aed53b76dc7e4ea11aed /menu/git.go | |
| parent | 8efcf029576ad82908b4ae80b2c92022dfb857d2 (diff) | |
big stuff
* send empty screen after tui confirmation
* add scroll view / viewport
* auto enable scroll view on short terminals
* add motd tips
* add subdirs as categories
* add inline toggle hotkey (i)
Diffstat (limited to 'menu/git.go')
| -rw-r--r-- | menu/git.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/menu/git.go b/menu/git.go new file mode 100644 index 0000000..ed5a595 --- /dev/null +++ b/menu/git.go @@ -0,0 +1,54 @@ +package menu + +import ( + "github.com/charmbracelet/lipgloss" + "pik/menu/style" + "pik/model" + "strconv" +) + +var ( + GitColor = lipgloss.Color("4") + GitInfoStyle = style.New(func() lipgloss.Style { + return lipgloss.NewStyle().Background(GitColor).Border(lipgloss.OuterHalfBlockBorder(), false, false, false, true).BorderBackground(GitColor).Padding(0, 1) + }) + GitStatusStyle = style.New(func() lipgloss.Style { + return lipgloss.NewStyle().Bold(true).Background(GitColor).PaddingLeft(1) + }) + GitAddColor = lipgloss.Color("2") + GitAddStyle = style.New(func() lipgloss.Style { + return GitStatusStyle.Get().Foreground(GitAddColor) + }) + GitRemoveColor = lipgloss.Color("1") + GitRemoveStyle = style.New(func() lipgloss.Style { + return GitStatusStyle.Get().Foreground(GitRemoveColor) + }) + GitChangeColor = lipgloss.Color("5") + GitChangeStyle = style.New(func() lipgloss.Style { + return GitStatusStyle.Get().Foreground(GitChangeColor) + }) +) + +func Git(info *model.GitInfo) string { + var parts = []string{ + " ", + info.Branch, + } + + if info.Insertions > 0 { + parts = append(parts, GitAddStyle.Render("+"+strconv.Itoa(info.Insertions))) + } + if info.Deletions > 0 { + parts = append(parts, GitRemoveStyle.Render("-"+strconv.Itoa(info.Deletions))) + } + if info.Changes > 0 { + parts = append(parts, GitChangeStyle.Render("~"+strconv.Itoa(info.Changes))) + } + if info.Changes == 0 && info.Deletions == 0 && info.Insertions == 0 { + parts = append(parts, GitAddStyle.Render("clean")) + } + + return GitInfoStyle.Render(lipgloss.JoinHorizontal(lipgloss.Left, + parts..., + )) +} |
