summaryrefslogtreecommitdiff
path: root/menu
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-04-17 00:00:40 +0200
committerewy <ewy0@protonmail.com>2026-04-17 00:00:40 +0200
commit022072ce8bac114ea0a7b94132ed3b8630de2f90 (patch)
tree199fb99ab9e242b6eb195c2b1180e58caa4303d6 /menu
parentfbdc2b9d849913ccf8dd7a9001012ce2d28cbd2f (diff)
* fix bug which prevented multiple sources from showing up in the tui at the same time
* add padding to bottom of sources * add git status panel to bottom of tui
Diffstat (limited to 'menu')
-rw-r--r--menu/menu.go6
-rw-r--r--menu/model.go2
-rw-r--r--menu/source.go47
3 files changed, 48 insertions, 7 deletions
diff --git a/menu/menu.go b/menu/menu.go
index 7f71e2d..97b4078 100644
--- a/menu/menu.go
+++ b/menu/menu.go
@@ -10,7 +10,7 @@ import (
var WrongModelTypeError = errors.New("wrong model type")
var NoSourcesIndexedError = errors.New("no sources indexed")
-func Show(st *model.State, hydrators []model.Hydrator) (*model.HydratedSource, model.HydratedTarget, error) {
+func Show(st *model.State, hydrators []model.Modder) (*model.HydratedSource, model.HydratedTarget, error) {
if len(st.Sources) == 0 {
return nil, nil, NoSourcesIndexedError
}
@@ -29,7 +29,7 @@ func Show(st *model.State, hydrators []model.Hydrator) (*model.HydratedSource, m
return src, t, nil
}
-func Hydrate(st *model.State, hydrators []model.Hydrator) *model.HydratedState {
+func Hydrate(st *model.State, hydrators []model.Modder) *model.HydratedState {
hyd := &model.HydratedState{
State: st,
HydratedSources: make([]*model.HydratedSource, len(st.Sources)),
@@ -38,7 +38,7 @@ func Hydrate(st *model.State, hydrators []model.Hydrator) *model.HydratedState {
hydSrc := s.Hydrate(hydrators)
for _, h := range hydrators {
- err := h.Hydrate(s, hydSrc)
+ err := h.Mod(s, hydSrc)
if err != nil {
spool.Warn("%v\n", err)
continue
diff --git a/menu/model.go b/menu/model.go
index 6dc4e1c..4eb2577 100644
--- a/menu/model.go
+++ b/menu/model.go
@@ -57,7 +57,7 @@ func (m *Model) Validate() {
}
}
-func NewModel(st *model.State, hydrators []model.Hydrator) *Model {
+func NewModel(st *model.State, hydrators []model.Modder) *Model {
m := &Model{
HydratedState: Hydrate(st, hydrators),
Index: 0,
diff --git a/menu/source.go b/menu/source.go
index 39b3280..efe4e0a 100644
--- a/menu/source.go
+++ b/menu/source.go
@@ -4,11 +4,12 @@ import (
"github.com/charmbracelet/lipgloss"
"pik/menu/style"
"pik/model"
+ "strconv"
)
var (
SourceStyle = style.New(func() lipgloss.Style {
- st := lipgloss.NewStyle()
+ st := lipgloss.NewStyle().PaddingBottom(1)
return st
})
SourceHeaderBackground = lipgloss.Color("5")
@@ -47,11 +48,18 @@ func (m *Model) Source(src *model.HydratedSource) string {
icon := SourceIconStyle.Render(Icon(src.Icon))
- return SourceStyle.Render(lipgloss.JoinVertical(lipgloss.Top,
+ parts := []string{
SourceHeaderStyle.Render(lipgloss.JoinHorizontal(lipgloss.Left, SourceLabelStyle.Render(lipgloss.JoinHorizontal(lipgloss.Left, icon, src.Label()), SourcePathStyle.Render(src.ShortPath())))),
SourceTargetsStyle.Render(targetContent),
- ))
+ }
+
+ if src.Git != nil {
+ parts = append(parts, Git(src.Git))
+ }
+ return SourceStyle.Render(lipgloss.JoinVertical(lipgloss.Top,
+ parts...,
+ ))
}
var (
@@ -68,3 +76,36 @@ func (m *Model) State(st *model.HydratedState) string {
return StateStyle.Render(lipgloss.JoinVertical(lipgloss.Top, sources...))
}
+
+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 {
+
+ return GitInfoStyle.Render(lipgloss.JoinHorizontal(lipgloss.Left,
+ " ",
+ info.Branch,
+ GitAddStyle.Render("+"+strconv.Itoa(info.Insertions)),
+ GitRemoveStyle.Render("-"+strconv.Itoa(info.Deletions)),
+ GitChangeStyle.Render("~"+strconv.Itoa(info.Changes)),
+ ))
+}