v0.1.11 353da72

help.go RawHistoryFolder

1package modes
2
3import (
4	"fmt"
5	"strings"
6
7	"github.com/mattn/go-runewidth"
8	"github.com/patriceckhart/zot/internal/tui"
9)
10
11// helpKeyRows is the list of keybindings shown by /help.
12var helpKeyRows = [][2]string{
13	{"enter", "submit the current input"},
14	{"alt+enter", "insert a newline"},
15	{"tab", "complete the highlighted slash command"},
16	{"esc", "cancel the current turn (while busy) - clear the input (while idle)"},
17	{"ctrl+c", "exit (while idle) - cancel the current turn (while busy)"},
18	{"ctrl+w", "delete previous word"},
19	{"alt+backspace", "delete previous word (same as ctrl+w)"},
20	{"ctrl+u / ctrl+k", "delete to start / end of line"},
21	{"ctrl+a / ctrl+e", "jump to start / end of line"},
22	{"alt+← / alt+→", "jump one word back / forward"},
23	{"ctrl+l", "redraw the screen"},
24	{"ctrl+o", "expand / collapse long tool results"},
25	{"pgup / pgdn", "scroll the chat one page up / down"},
26	{"up / down", "scroll by 3 lines (when input is empty) - prompt history (otherwise)"},
27}
28
29// renderHelpBlock builds the friendly /help view. Uses the shared
30// frameHeader/frameRule helpers so the rules match every other block
31// in the tui (tool results, code fences, dialogs) — full terminal width
32// in the muted colour.
33//
34// Slash commands and keybindings share the same label column width so
35// every description starts at the same x-position, regardless of which
36// section it lives in. The width is computed from the longest label
37// across BOTH lists, with a minimum of 14 cells so changes to either
38// list don't compress the column visually.
39func renderHelpBlock(th tui.Theme, width int) []string {
40	if width < 20 {
41		width = 20
42	}
43
44	// Label column width uses display cells, not byte length, so
45	// single-cell multibyte runes (← → - …) don't over-count and leave
46	// a raggedy right edge. `len("alt+← / alt+→")` is 17 bytes but
47	// only 13 cells; padding off byte length would either overshoot
48	// (setting labelWidth too high and wasting space on every row)
49	// or undershoot (never padding that row because len >= labelWidth
50	// already, leaving its description mis-aligned).
51	labelWidth := 14
52	for _, c := range slashCatalog {
53		if n := runewidth.StringWidth(c.Name); n > labelWidth {
54			labelWidth = n
55		}
56	}
57	for _, k := range helpKeyRows {
58		if n := runewidth.StringWidth(k[0]); n > labelWidth {
59			labelWidth = n
60		}
61	}
62
63	pad := func(s string) string {
64		w := runewidth.StringWidth(s)
65		if w >= labelWidth {
66			return s
67		}
68		return s + strings.Repeat(" ", labelWidth-w)
69	}
70
71	var out []string
72	out = append(out, frameHeader(th, "zot help", width))
73
74	// commands section
75	out = append(out, tui.Bold("slash commands:"))
76	for _, c := range slashCatalog {
77		out = append(out, fmt.Sprintf("  %s  %s",
78			th.FG256(th.Accent, pad(c.Name)),
79			th.FG256(th.Muted, c.Desc)))
80	}
81
82	// keys section
83	out = append(out, "", tui.Bold("keys:"))
84	for _, k := range helpKeyRows {
85		out = append(out, fmt.Sprintf("  %s  %s",
86			th.FG256(th.Accent, pad(k[0])),
87			th.FG256(th.Muted, k[1])))
88	}
89
90	out = append(out, frameRule(th, width), "")
91	return out
92}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close