diff options
| author | ewy <ewy0@protonmail.com> | 2026-04-29 01:30:12 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-04-29 01:30:12 +0200 |
| commit | 2b28ee919614d5ddaceda26ce488a0ca4c851cb3 (patch) | |
| tree | df9a9af3f6b37165c9522eefea8456aa1baea9d5 /menu | |
| parent | 19f68366eb4a2c01f801b29585fd0a36bdf47488 (diff) | |
simplify the contracts
Diffstat (limited to 'menu')
| -rw-r--r-- | menu/source.go | 6 | ||||
| -rw-r--r-- | menu/target.go | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/menu/source.go b/menu/source.go index 073c044..e08c8bd 100644 --- a/menu/source.go +++ b/menu/source.go @@ -38,16 +38,16 @@ func (m *Model) Source(src *model.HydratedSource) string { targets := make([]string, 0, len(src.Targets)) var sub []string for _, t := range src.HydratedTargets { - ts := t.Sub() + ts := t.Target().Sub() header := !slices.Equal(sub, ts) if header { sub = ts } - if header && strings.Join(ts, " ") != t.ShortestId() { + if header && strings.Join(ts, " ") != t.Target().ShortestId() { targets = append(targets, m.Category(strings.Join(ts, " "), "")) header = false } - targets = append(targets, m.Target(t, header)) + targets = append(targets, m.Target(src, t, header)) } targetContent := lipgloss.JoinVertical(lipgloss.Top, targets...) diff --git a/menu/target.go b/menu/target.go index 6d6fdec..e619cbc 100644 --- a/menu/target.go +++ b/menu/target.go @@ -48,7 +48,7 @@ var ( }) ) -func (m *Model) Target(t model.HydratedTarget, header bool) string { +func (m *Model) Target(src *model.HydratedSource, t model.HydratedTarget, header bool) string { _, selection := m.Result() selected := selection != nil && selection.Target() == t.Target() icon := "" @@ -67,12 +67,12 @@ func (m *Model) Target(t model.HydratedTarget, header bool) string { } var labelParts []string labelParts = append(labelParts, icon) - sub := t.Sub() - if sub != nil && sub[len(sub)-1] != t.ShortestId() { + sub := t.Target().Sub() + if sub != nil && sub[len(sub)-1] != t.Target().ShortestId() { labelParts = append(labelParts, TargetSubStyle.Render(sub...)) } - labelParts = append(labelParts, TargetLabelStyle.Render(t.Label())) - return lipgloss.JoinHorizontal(lipgloss.Left, selectionStyle.Render(labelParts...), selectionDescriptionStyle.Render(t.Description())) + labelParts = append(labelParts, TargetLabelStyle.Render(t.Target().Label())) + return lipgloss.JoinHorizontal(lipgloss.Left, selectionStyle.Render(labelParts...), selectionDescriptionStyle.Render(t.Description(src))) } func (m *Model) Category(input string, desc string) string { |
