v0.2.1 7e79979

view.go RawHistoryFolder

1package selection
2
3import "github.com/bnema/nefergui"
4
5// view draws the scene. Geometry goes through Node.Rect, so no CSS strings
6// are built per frame; classes come from the embedded stylesheet. Boxes with no
7// area are not emitted at all, so an idle surface is one dim box plus the
8// header and footer, and no empty chip is painted.
9func view(f *nefergui.Frame, m *model) {
10	m.syncMode() // a Tab on another overlay redraws this one
11	m.refreshFooter()
12	root := f.Root(nefergui.Class("root"))
13	st := root.Stack(nefergui.Class("scene"))
14	s := m.scene()
15	for i, r := range s.dim {
16		box(st, dimKeys[i], "dim", r)
17	}
18	for i, r := range s.grid {
19		box(st, gridKeys[i], "grid", r)
20	}
21	for i, r := range s.edges {
22		box(st, edgeKeys[i], "edge", r)
23	}
24	if n := tag(st, "label", s.label); n.ok {
25		n.node.Text(m.label.text)
26	}
27	if n := tag(st, "badge", s.badge); n.ok {
28		n.node.Text(badgeText(m.mode))
29	}
30	if n := tag(st, "header", s.header); n.ok {
31		n.node.Text(m.header)
32	}
33	if n := tag(st, "footer", s.footer); n.ok {
34		n.node.Text(m.footerText)
35	}
36}
37
38type tagged struct {
39	node nefergui.Node
40	ok   bool
41}
42
43func box(st nefergui.Node, key, class string, r frect) {
44	if r.w > 0 && r.h > 0 {
45		st.Box(nefergui.Key(key), nefergui.Class(class)).Rect(r.x, r.y, r.w, r.h)
46	}
47}
48
49func tag(st nefergui.Node, key string, r frect) tagged {
50	if r.w <= 0 || r.h <= 0 {
51		return tagged{}
52	}
53	return tagged{st.Box(nefergui.Key(key), nefergui.Class("tag")).Rect(r.x, r.y, r.w, r.h), true}
54}
55
56// Static keys avoid building identity strings per frame.
57var (
58	dimKeys  = [4]string{"dim0", "dim1", "dim2", "dim3"}
59	gridKeys = [6]string{"grid0", "grid1", "grid2", "grid3", "grid4", "grid5"}
60	edgeKeys = [4]string{"edge0", "edge1", "edge2", "edge3"}
61)

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 2

Tags 9

↑↓ moveenter openesc close