v0.2.54 5c27086

layout.go RawHistoryFolder

1package tui
2
3import "strings"
4
5const (
6	InputStylePlain = "plain"
7	InputStyleLines = "lines"
8
9	StatusPositionAboveInput = "above_input"
10	StatusPositionBelowInput = "below_input"
11
12	WorkingPositionAboveInput = "above_input"
13	WorkingPositionBelowInput = "below_input"
14)
15
16func NormalizeInputStyle(v string) string {
17	switch strings.ToLower(strings.TrimSpace(v)) {
18	case InputStyleLines, "line", "boxed", "box":
19		return InputStyleLines
20	default:
21		return InputStylePlain
22	}
23}
24
25func NormalizeStatusPosition(v string) string {
26	switch strings.ToLower(strings.TrimSpace(v)) {
27	case StatusPositionBelowInput, "below", "bottom":
28		return StatusPositionBelowInput
29	default:
30		return StatusPositionAboveInput
31	}
32}
33
34func NormalizeWorkingPosition(v string) string {
35	switch strings.ToLower(strings.TrimSpace(v)) {
36	case WorkingPositionBelowInput, "below", "bottom":
37		return WorkingPositionBelowInput
38	default:
39		return WorkingPositionAboveInput
40	}
41}
42
43func InputLines(th Theme, lines []string, width int) []string {
44	if width < 1 {
45		width = 1
46	}
47	rule := th.FG256(th.Muted, strings.Repeat("─", width))
48	out := make([]string, 0, len(lines)+2)
49	out = append(out, rule)
50	out = append(out, lines...)
51	out = append(out, rule)
52	return out
53}
54
55func CursorColor256(index int) string {
56	r, g, b := xterm256RGB(index)
57	return "\x1b]12;rgb:" + hexByte(r) + "/" + hexByte(g) + "/" + hexByte(b) + "\x07"
58}
59
60func ResetCursorColor() string { return "\x1b]112\x07" }
61
62func CursorShapeBlock() string { return "\x1b[1 q" }
63
64func ResetCursorShape() string { return "\x1b[0 q" }
65
66func xterm256RGB(index int) (int, int, int) {
67	if index < 0 {
68		index = 0
69	}
70	if index > 255 {
71		index = 255
72	}
73	ansi := [16][3]int{
74		{0, 0, 0}, {128, 0, 0}, {0, 128, 0}, {128, 128, 0},
75		{0, 0, 128}, {128, 0, 128}, {0, 128, 128}, {192, 192, 192},
76		{128, 128, 128}, {255, 0, 0}, {0, 255, 0}, {255, 255, 0},
77		{0, 0, 255}, {255, 0, 255}, {0, 255, 255}, {255, 255, 255},
78	}
79	if index < 16 {
80		c := ansi[index]
81		return c[0], c[1], c[2]
82	}
83	if index < 232 {
84		idx := index - 16
85		levels := [6]int{0, 95, 135, 175, 215, 255}
86		return levels[idx/36], levels[(idx/6)%6], levels[idx%6]
87	}
88	gray := 8 + (index-232)*10
89	return gray, gray, gray
90}
91
92func hexByte(v int) string {
93	const digits = "0123456789abcdef"
94	if v < 0 {
95		v = 0
96	}
97	if v > 255 {
98		v = 255
99	}
100	return string([]byte{digits[v>>4], digits[v&0xf]})
101}

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 1

Tags 476

↑↓ moveenter openesc close