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.laneNeighbor(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) cascadeRectsInto(dst []Rect, ignoreFullWidth bool) []Rect {
40	g := w.gap()
41	width := w.cellWidth()
42	rects := slices.Grow(dst[:0], len(w.Columns))[:len(w.Columns)]
43	view := w.View + w.shiftPixels()
44	for i := range w.Columns {
45		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)}
46		if w.Columns[i].FullWidth && !ignoreFullWidth {
47			r.X = w.Usable.X + g
48			r.W = max(w.Usable.W-2*g, 0)
49		}
50		rects[i] = r
51	}
52	return rects
53}
54
55func (w *Workspace) cascadePoints() []float64 {
56	n, spacing := w.cascadeBands()
57	points := make([]float64, n)
58	for i := range points {
59		points[i] = float64(i * spacing)
60	}
61	return points
62}
63
64func (w *Workspace) cascadeFocus(view int) int {
65	if len(w.Columns) == 0 {
66		return 0
67	}
68	b := min(max(view/max(w.Usable.H, 1), 0), w.band(len(w.Columns)-1))
69	return w.cellInBand(b)
70}
71
72// laneOf is the lane of column i in the overview: its band, or the only
73// lane of a layout that does not wrap.
74func (w *Workspace) laneOf(i int) int {
75	if w.policy().wraps {
76		return w.band(i)
77	}
78	return 0
79}
80
81// laneBounds is the range of columns of a lane, first > last when the lane
82// does not exist. A layout that does not wrap has the whole row as lane 0.
83func (w *Workspace) laneBounds(lane int) (first, last int) {
84	k := len(w.Columns)
85	if w.policy().wraps {
86		k = max(w.MaxColumns, 1)
87	}
88	first = lane * k
89	if lane < 0 || first >= len(w.Columns) {
90		return 0, -1
91	}
92	return first, min(first+k, len(w.Columns)) - 1
93}
94
95// laneNeighbor is the closest column to the focus in the lane d lanes away,
96// the focus's offset in its lane kept; -1 past the first or last lane.
97func (w *Workspace) laneNeighbor(d int) int {
98	lane := w.laneOf(w.Focus)
99	first, _ := w.laneBounds(lane)
100	nfirst, nlast := w.laneBounds(lane + d)
101	if nfirst > nlast {
102		return -1
103	}
104	return min(nfirst+w.Focus-first, nlast)
105}

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 26

Tags 10

↑↓ moveenter openesc close