cascade.go RawHistoryFolder

1package core
2
3import "slices"
4
5func (w *Workspace) band(i int) int         { return i / max(w.MaxColumns, 1) }
6func (w *Workspace) sameBand(a, b int) bool { return !w.policy().wraps || w.band(a) == w.band(b) }
7func (w *Workspace) cellX(i int) int {
8	return w.gap() + (i%max(w.MaxColumns, 1))*(w.cellWidth()+w.gap())
9}
10func (w *Workspace) cascadeBands() (n, spacing int) {
11	if len(w.Columns) == 0 || w.Usable.H <= 0 {
12		return 1, 0
13	}
14	return w.band(len(w.Columns)-1) + 1, w.Usable.H
15}
16func (w *Workspace) cellWidth() int {
17	k := max(w.MaxColumns, 1)
18	return max((w.Usable.W-w.gap()*(k+1))/k, 0)
19}
20func (w *Workspace) cellInBand(b int) int {
21	k := max(w.MaxColumns, 1)
22	return min(b*k+w.Focus%k, len(w.Columns)-1)
23}
24func (w *Workspace) focusBand(dir int) bool {
25	i := w.bandNeighbor(dir)
26	if i < 0 {
27		return false
28	}
29	w.unmaximize()
30	w.Focus = i
31	w.Columns[i].Focus = 0
32	if dir < 0 {
33		w.Columns[i].Focus = len(w.Columns[i].Windows) - 1
34	}
35	w.raiseColumns()
36	w.scroll()
37	return true
38}
39func (w *Workspace) bandNeighbor(dir int) int {
40	k := max(w.MaxColumns, 1)
41	b := w.band(w.Focus) + dir
42	if b < 0 || b*k >= len(w.Columns) {
43		return -1
44	}
45	return w.cellInBand(b)
46}
47
48func (w *Workspace) cascadeRectsInto(dst []Rect, ignoreFullWidth bool) []Rect {
49	g := w.gap()
50	width := w.cellWidth()
51	rects := slices.Grow(dst[:0], len(w.Columns))[:len(w.Columns)]
52	view := w.View + w.shiftPixels()
53	for i := range w.Columns {
54		r := Rect{X: w.Usable.X + w.cellX(i), Y: w.Usable.Y + g + w.band(i)*w.Usable.H - view, W: width, H: max(w.Usable.H-2*g, 0)}
55		if w.Columns[i].FullWidth && !ignoreFullWidth {
56			r.X = w.Usable.X + g
57			r.W = max(w.Usable.W-2*g, 0)
58		}
59		rects[i] = r
60	}
61	return rects
62}
63
64func (w *Workspace) cascadePoints() []float64 {
65	n, spacing := w.cascadeBands()
66	points := make([]float64, n)
67	for i := range points {
68		points[i] = float64(i * spacing)
69	}
70	return points
71}
72
73func (w *Workspace) cascadeFocus(view int) int {
74	if len(w.Columns) == 0 {
75		return 0
76	}
77	b := min(max(view/max(w.Usable.H, 1), 0), w.band(len(w.Columns)-1))
78	return w.cellInBand(b)
79}

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 23

Tags 10

↑↓ moveenter openesc close