c2ea63dd16
Status bar with entity count and context-sensitive key hints. Help overlay via ? key. Tag filter via # with cursor-navigable tag list. Todo toggle (x), pin (!), promote (p), demote (D), copy (c), edit (e) via $EDITOR. Delete confirmation with 3s timeout. Date-grouped list with completed todo and pinned indicators. Esc clears active tag filter. Adds CompletedAt/ClearCompleted to EntityUpdate for todo toggling.
60 lines
1.3 KiB
Go
60 lines
1.3 KiB
Go
package tui
|
|
|
|
import "strings"
|
|
|
|
func renderHelp(width, height int) string {
|
|
sections := []struct {
|
|
title string
|
|
binds [][2]string
|
|
}{
|
|
{"Navigation", [][2]string{
|
|
{"j/k ↑/↓", "move cursor"},
|
|
{"g/G home/end", "top / bottom"},
|
|
{"pgup/pgdn", "page up / down"},
|
|
{"enter", "view detail"},
|
|
{"esc", "back / cancel"},
|
|
}},
|
|
{"Actions", [][2]string{
|
|
{"a", "add entity"},
|
|
{"d", "delete (with confirm)"},
|
|
{"x", "toggle todo completion"},
|
|
{"!", "toggle pin"},
|
|
{"#", "filter by tag"},
|
|
}},
|
|
{"Detail View", [][2]string{
|
|
{"p", "promote to card"},
|
|
{"D", "demote to fluid"},
|
|
{"c", "copy to clipboard"},
|
|
{"e", "edit in $EDITOR"},
|
|
{"!", "toggle pin"},
|
|
}},
|
|
{"Global", [][2]string{
|
|
{"?", "toggle help"},
|
|
{"q / ctrl+c", "quit"},
|
|
}},
|
|
}
|
|
|
|
var b strings.Builder
|
|
b.WriteString(detailHeaderStyle.Render("keybindings"))
|
|
b.WriteString("\n\n")
|
|
|
|
for _, s := range sections {
|
|
b.WriteString(titleStyle.Render(s.title))
|
|
b.WriteString("\n")
|
|
for _, bind := range s.binds {
|
|
key := helpKeyStyle.Render(bind[0])
|
|
desc := helpDescStyle.Render(bind[1])
|
|
b.WriteString(" " + key + " " + desc + "\n")
|
|
}
|
|
b.WriteString("\n")
|
|
}
|
|
|
|
b.WriteString(helpStyle.Render("press ? or esc to close"))
|
|
|
|
lines := strings.Split(b.String(), "\n")
|
|
if len(lines) > height {
|
|
lines = lines[:height]
|
|
}
|
|
return strings.Join(lines, "\n")
|
|
}
|