77222ff1b8
Run mode (r key on checklist cards): cursor navigates steps, space toggles done/undone, r resets all, esc saves changes to DB and exits. Persists step state — improvement over web which discards on exit. Fill mode (f key on template cards): tab/shift-tab navigates slots, type to fill values, enter resolves template and copies to clipboard with use count increment. Esc cancels without copying. Both modes are sub-states of detail view, keeping architecture simple.
66 lines
1.5 KiB
Go
66 lines
1.5 KiB
Go
package tui
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
|
)
|
|
|
|
func renderStatusBar(m model, width int) string {
|
|
left := countText(m)
|
|
right := contextHints(m)
|
|
|
|
leftRendered := statusStyle.Render(left)
|
|
rightRendered := helpStyle.Render(right)
|
|
|
|
gap := width - lipgloss.Width(leftRendered) - lipgloss.Width(rightRendered)
|
|
if gap < 0 {
|
|
gap = 0
|
|
}
|
|
|
|
pad := lipgloss.NewStyle().Width(gap).Render("")
|
|
return leftRendered + pad + rightRendered
|
|
}
|
|
|
|
func countText(m model) string {
|
|
var total int
|
|
if m.mode == modeCards {
|
|
total = len(m.cards.filtered)
|
|
} else {
|
|
total = len(m.list.displayEntities())
|
|
}
|
|
if m.filterTag != "" {
|
|
return fmt.Sprintf("%d entities #%s", total, m.filterTag)
|
|
}
|
|
return fmt.Sprintf("%d entities", total)
|
|
}
|
|
|
|
func contextHints(m model) string {
|
|
switch m.state {
|
|
case stateDetail:
|
|
switch m.detail.mode {
|
|
case detailRun:
|
|
return "space:toggle j/k:nav r:reset esc:save+exit"
|
|
case detailFill:
|
|
return "tab:next shift+tab:prev enter:copy esc:cancel"
|
|
default:
|
|
return "p:promote D:demote c:copy e:edit r:run f:fill !:pin esc:back"
|
|
}
|
|
case stateInput:
|
|
return "enter:submit esc:cancel"
|
|
case stateTagFilter:
|
|
return "j/k:nav enter:select esc:cancel"
|
|
case stateConfirm:
|
|
return "y:confirm n:cancel"
|
|
case statePromote:
|
|
return "j/k:nav enter:select esc:cancel"
|
|
case stateAbsorb:
|
|
return "j/k:nav enter:absorb esc:cancel"
|
|
default:
|
|
if m.mode == modeCards {
|
|
return "1:stream 2:cards s:sort tab:intent a:add ?:help q:quit"
|
|
}
|
|
return "1:stream 2:cards a:add/?search m:absorb d:del #:filter ?:help q:quit"
|
|
}
|
|
}
|