summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-19 23:50:26 +0300
committerGitHub <noreply@github.com>2025-06-19 23:50:26 +0300
commitbf39c17221d1df1815c9cd78fa33b144c9d5dfb6 (patch)
tree6feb76e083b948beeb92c2b17ccf4c791db5eff2 /internal
parent9f784dee3c132da890c22e1477fb2e41047a74e8 (diff)
parentd76f1e1e088b84c1ef3742f8f9cc855a8433ed44 (diff)
Merge pull request #4 from snonux/codex/add-basic-ui-with-charm.sh-for-tasks
Add Charm UI for listing tasks
Diffstat (limited to 'internal')
-rw-r--r--internal/ui/ui.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/internal/ui/ui.go b/internal/ui/ui.go
new file mode 100644
index 0000000..244c191
--- /dev/null
+++ b/internal/ui/ui.go
@@ -0,0 +1,47 @@
+package ui
+
+import (
+ "github.com/charmbracelet/bubbles/list"
+ tea "github.com/charmbracelet/bubbletea"
+)
+
+// Model wraps a Bubble Tea list.Model to display tasks.
+type Model struct {
+ list list.Model
+}
+
+// New creates a new UI model with the provided Bubble Tea list.
+func New(l list.Model) Model {
+ return Model{list: l}
+}
+
+// Init implements tea.Model.
+func (m Model) Init() tea.Cmd { return nil }
+
+// Update handles key and window events.
+func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
+ switch msg := msg.(type) {
+ case tea.KeyMsg:
+ switch msg.String() {
+ case "j":
+ msg = tea.KeyMsg{Type: tea.KeyDown}
+ case "k":
+ msg = tea.KeyMsg{Type: tea.KeyUp}
+ }
+ return m.updateList(msg)
+ case tea.WindowSizeMsg:
+ m.list.SetSize(msg.Width, msg.Height-2)
+ }
+ return m.updateList(msg)
+}
+
+func (m *Model) updateList(msg tea.Msg) (tea.Model, tea.Cmd) {
+ var cmd tea.Cmd
+ m.list, cmd = m.list.Update(msg)
+ return m, cmd
+}
+
+// View renders the list UI.
+func (m Model) View() string {
+ return m.list.View()
+}