presentation.go RawHistoryFolder

1package ui
2
3import "github.com/bnema/vev/internal/domain"
4
5const (
6	ResponsiveDrawerBreakpoint = 80
7	DrawerContextRows          = 3
8	DrawerBottomRows           = 1
9)
10
11// PresentationMode describes whether an overlay uses its preferred floating
12// geometry or becomes a narrow-terminal drawer.
13type PresentationMode uint8
14
15const (
16	PresentationFloating PresentationMode = iota
17	PresentationDrawer
18)
19
20// BorderEdges identifies the edges drawn around a presentation.
21type BorderEdges uint8
22
23const (
24	BorderTop BorderEdges = 1 << iota
25	BorderRight
26	BorderBottom
27	BorderLeft
28	BorderAll = BorderTop | BorderRight | BorderBottom | BorderLeft
29)
30
31// Presentation is the resolved outer and content geometry for an overlay.
32type Presentation struct {
33	Mode    PresentationMode
34	Bounds  domain.Rect
35	Inner   domain.Rect
36	Borders BorderEdges
37}
38
39// ResolvePresentation preserves preferred geometry on complete frames at or
40// above the responsive breakpoint. Narrow frames use a full-width bottom
41// drawer while reserving frame rows 0-2 and the bottom bar.
42func ResolvePresentation(base domain.Size, preferredBounds, preferredInner domain.Rect) Presentation {
43	if !base.Valid() {
44		return Presentation{}
45	}
46	if base.Cols >= ResponsiveDrawerBreakpoint {
47		return Presentation{
48			Mode:    PresentationFloating,
49			Bounds:  preferredBounds,
50			Inner:   preferredInner,
51			Borders: BorderAll,
52		}
53	}
54
55	available := max(0, base.Rows-DrawerContextRows-DrawerBottomRows)
56	height := min(max(preferredBounds.Height, 0), available)
57	bounds := domain.Rect{
58		X:      0,
59		Y:      base.Rows - DrawerBottomRows - height,
60		Width:  base.Cols,
61		Height: height,
62	}
63	inner := domain.Rect{
64		X:      0,
65		Y:      bounds.Y + min(1, height),
66		Width:  base.Cols,
67		Height: max(0, height-1),
68	}
69	return Presentation{
70		Mode:    PresentationDrawer,
71		Bounds:  bounds,
72		Inner:   inner,
73		Borders: BorderTop,
74	}
75}

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 12

Tags 11

↑↓ moveenter openesc close