summaryrefslogtreecommitdiff
path: root/internal/hexaiaction/tui_delegate.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-06 13:19:01 +0300
committerPaul Buetow <paul@buetow.org>2025-09-06 13:19:01 +0300
commit04f290dbeeee8a6fcbc70fed253a968336bcb2ab (patch)
tree3ee23a4ac4bcc5b43b43697cfb0e905735fc6331 /internal/hexaiaction/tui_delegate.go
parent5e966f50111adf6e2cb2683fe588f6fe033fa931 (diff)
more tests
Diffstat (limited to 'internal/hexaiaction/tui_delegate.go')
-rw-r--r--internal/hexaiaction/tui_delegate.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/hexaiaction/tui_delegate.go b/internal/hexaiaction/tui_delegate.go
new file mode 100644
index 0000000..0e5a68c
--- /dev/null
+++ b/internal/hexaiaction/tui_delegate.go
@@ -0,0 +1,35 @@
+package hexaiaction
+
+import (
+ "fmt"
+ "io"
+
+ "github.com/charmbracelet/bubbles/list"
+ tea "github.com/charmbracelet/bubbletea"
+ "github.com/charmbracelet/lipgloss"
+)
+
+// oneLineDelegate renders a single compact line per item, no spacing.
+type oneLineDelegate struct{}
+
+var (
+ hotStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("205"))
+ cursorStyle = lipgloss.NewStyle().Bold(true)
+)
+
+func (oneLineDelegate) Height() int { return 1 }
+func (oneLineDelegate) Spacing() int { return 0 }
+func (oneLineDelegate) Update(tea.Msg, *list.Model) tea.Cmd { return nil }
+func (oneLineDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item) {
+ title := listItem.FilterValue()
+ hk := '?'
+ if it, ok := listItem.(item); ok {
+ hk = it.hotkey
+ }
+ hot := hotStyle.Render(fmt.Sprintf(" (%c)", hk))
+ cursor := " "
+ if index == m.Index() {
+ cursor = cursorStyle.Render("> ")
+ }
+ fmt.Fprintf(w, "%s%s%s", cursor, title, hot)
+}