From 630d77e1962b43ee95e88a664f5e8b8993213060 Mon Sep 17 00:00:00 2001 From: ewy Date: Wed, 29 Apr 2026 00:47:34 +0200 Subject: 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) --- menu/git.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 menu/git.go (limited to 'menu/git.go') 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..., + )) +} -- cgit v1.3.1