v0.11.2 619aabb

help.go RawHistoryFolder

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

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