main ece7682

types.go RawHistoryFolder

1package domain
2
3import "strings"
4
5// Anchor specifies a position in a 3x3 grid.
6type Anchor uint8
7
8const (
9	AnchorCenter Anchor = iota
10	AnchorTopLeft
11	AnchorTop
12	AnchorTopRight
13	AnchorLeft
14	AnchorRight
15	AnchorBottomLeft
16	AnchorBottom
17	AnchorBottomRight
18)
19
20// Valid reports whether a is a defined anchor.
21func (a Anchor) Valid() bool {
22	return a <= AnchorBottomRight
23}
24
25// String returns the canonical text representation of a.
26func (a Anchor) String() string {
27	switch a {
28	case AnchorCenter:
29		return "center"
30	case AnchorTopLeft:
31		return "top-left"
32	case AnchorTop:
33		return "top"
34	case AnchorTopRight:
35		return "top-right"
36	case AnchorLeft:
37		return "left"
38	case AnchorRight:
39		return "right"
40	case AnchorBottomLeft:
41		return "bottom-left"
42	case AnchorBottom:
43		return "bottom"
44	case AnchorBottomRight:
45		return "bottom-right"
46	default:
47		return "unknown"
48	}
49}
50
51// ParseAnchor parses a case-insensitive anchor name.
52func ParseAnchor(s string) (Anchor, bool) {
53	switch strings.ToLower(strings.TrimSpace(s)) {
54	case "center":
55		return AnchorCenter, true
56	case "top-left":
57		return AnchorTopLeft, true
58	case "top":
59		return AnchorTop, true
60	case "top-right":
61		return AnchorTopRight, true
62	case "left":
63		return AnchorLeft, true
64	case "right":
65		return AnchorRight, true
66	case "bottom-left":
67		return AnchorBottomLeft, true
68	case "bottom":
69		return AnchorBottom, true
70	case "bottom-right":
71		return AnchorBottomRight, true
72	default:
73		return AnchorCenter, false
74	}
75}
76
77// Size is a terminal dimension in columns and rows.
78type Size struct {
79	Cols, Rows int
80}
81
82// Valid reports whether sz has strictly positive columns and rows.
83func (sz Size) Valid() bool {
84	return sz.Cols > 0 && sz.Rows > 0
85}
86
87// Geometry combines a terminal's required cell dimensions with optional pixel
88// dimensions reported by the controlling terminal. Zero pixel dimensions mean
89// the terminal did not report them; they must not be inferred from cells.
90type Geometry struct {
91	Size
92	PixelWidth, PixelHeight int
93}
94
95// Valid reports whether the cell dimensions can describe a terminal screen.
96func (g Geometry) Valid() bool {
97	return g.Size.Valid()
98}
99
100// PixelsKnown reports whether both pixel dimensions are available.
101func (g Geometry) PixelsKnown() bool {
102	return g.PixelWidth > 0 && g.PixelHeight > 0
103}
104
105// NormalizePixels clears partial or negative pixel dimensions. Pixel geometry
106// is optional as a pair; retaining only one axis would give downstream PTYs and
107// terminal queries a geometry the controlling terminal never reported.
108func (g Geometry) NormalizePixels() Geometry {
109	if !g.PixelsKnown() {
110		g.PixelWidth = 0
111		g.PixelHeight = 0
112	}
113	return g
114}
115
116// Rect is an axis-aligned rectangle in cell coordinates.
117type Rect struct {
118	X, Y, Width, Height int
119}
120
121// SessionID uniquely identifies a session.
122type SessionID string
123
124// TabID identifies a tab by its session-local, user-facing ID.
125type TabID string
126
127// TabStableID identifies a tab independently of its mutable session position.
128type TabStableID string
129
130// PaneStableID identifies a pane independently of its layout-local PaneID.
131type PaneStableID string

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