zot/internal/agent/modes/help.go
patriceckhart 1f28b62a47 style: replace middle-dot separators with ascii hyphens
Swept the TUI strings and README for the stray U+00B7 MIDDLE DOT
(\u00b7) separators left over from earlier UI iterations. They read
fine on terminals that render the glyph as a small bullet, but
on some fonts (especially the telegram desktop client, a few
linux terminal fonts) it renders as an off-center dot that
looks like a smudge or a broken pipe. Plain ' - ' is universally
readable and matches every other separator already in the
status bar and dialogs.

Touched:
  README.md                    paragraph separators
  modes/btw_dialog.go          header joiner
  modes/help.go                table row separators
  modes/interactive.go         status bar tags, telegram mirror
  modes/jump_dialog.go         row separators
  modes/login_dialog.go        header joiners, status line
  modes/model_dialog.go        model + source joiner
  modes/slash_suggest.go       commands list
  tui/view.go                  assorted tui separators

No functional change. go test ./... still passes.
2026-04-21 17:39:08 +02:00

92 lines
3 KiB
Go

package modes
import (
"fmt"
"strings"
"github.com/mattn/go-runewidth"
"github.com/patriceckhart/zot/internal/tui"
)
// helpKeyRows is the list of keybindings shown by /help.
var helpKeyRows = [][2]string{
{"enter", "submit the current input"},
{"alt+enter", "insert a newline"},
{"tab", "complete the highlighted slash command"},
{"esc", "cancel the current turn (while busy) - clear the input (while idle)"},
{"ctrl+c", "exit (while idle) - cancel the current turn (while busy)"},
{"ctrl+w", "delete previous word"},
{"alt+backspace", "delete previous word (same as ctrl+w)"},
{"ctrl+u / ctrl+k", "delete to start / end of line"},
{"ctrl+a / ctrl+e", "jump to start / end of line"},
{"alt+← / alt+→", "jump one word back / forward"},
{"ctrl+l", "redraw the screen"},
{"ctrl+o", "expand / collapse long tool results"},
{"pgup / pgdn", "scroll the chat one page up / down"},
{"up / down", "scroll by 3 lines (when input is empty) - prompt history (otherwise)"},
}
// renderHelpBlock builds the friendly /help view. Uses the shared
// frameHeader/frameRule helpers so the rules match every other block
// in the tui (tool results, code fences, dialogs) — full terminal width
// in the muted colour.
//
// Slash commands and keybindings share the same label column width so
// every description starts at the same x-position, regardless of which
// section it lives in. The width is computed from the longest label
// across BOTH lists, with a minimum of 14 cells so changes to either
// list don't compress the column visually.
func renderHelpBlock(th tui.Theme, width int) []string {
if width < 20 {
width = 20
}
// Label column width uses display cells, not byte length, so
// single-cell multibyte runes (← → - …) don't over-count and leave
// a raggedy right edge. `len("alt+← / alt+→")` is 17 bytes but
// only 13 cells; padding off byte length would either overshoot
// (setting labelWidth too high and wasting space on every row)
// or undershoot (never padding that row because len >= labelWidth
// already, leaving its description mis-aligned).
labelWidth := 14
for _, c := range slashCatalog {
if n := runewidth.StringWidth(c.Name); n > labelWidth {
labelWidth = n
}
}
for _, k := range helpKeyRows {
if n := runewidth.StringWidth(k[0]); n > labelWidth {
labelWidth = n
}
}
pad := func(s string) string {
w := runewidth.StringWidth(s)
if w >= labelWidth {
return s
}
return s + strings.Repeat(" ", labelWidth-w)
}
var out []string
out = append(out, frameHeader(th, "zot help", width))
// commands section
out = append(out, tui.Bold("slash commands:"))
for _, c := range slashCatalog {
out = append(out, fmt.Sprintf(" %s %s",
th.FG256(th.Accent, pad(c.Name)),
th.FG256(th.Muted, c.Desc)))
}
// keys section
out = append(out, "", tui.Bold("keys:"))
for _, k := range helpKeyRows {
out = append(out, fmt.Sprintf(" %s %s",
th.FG256(th.Accent, pad(k[0])),
th.FG256(th.Muted, k[1])))
}
out = append(out, frameRule(th, width), "")
return out
}