v0.2.0 4859eb8

screen_helpers_test.go RawHistoryFolder

1package vt
2
3import (
4	"reflect"
5	"testing"
6
7	renderer "github.com/bnema/vev-vt/core"
8)
9
10func damageKinds(d []renderer.Damage) []renderer.DamageKind {
11	ks := make([]renderer.DamageKind, len(d))
12	for i, dd := range d {
13		ks[i] = dd.Kind
14	}
15	return ks
16}
17
18func hasDamageKind(d []renderer.Damage, kind renderer.DamageKind) bool {
19	for _, dd := range d {
20		if dd.Kind == kind {
21			return true
22		}
23	}
24	return false
25}
26
27func cellAt(s *Screen, x, y int) renderer.Cell {
28	return s.Frame.At(x, y)
29}
30
31func assertFramesEqual(t *testing.T, got, want renderer.Frame) {
32	t.Helper()
33	if !reflect.DeepEqual(got, want) {
34		t.Fatal("frame changed unexpectedly")
35	}
36}
37
38func assertCell(t *testing.T, s *Screen, x, y int, expected rune) {
39	t.Helper()
40	c := cellAt(s, x, y)
41	if c.Rune != expected {
42		t.Errorf("cell(%d,%d) rune = %q, want %q", x, y, c.Rune, expected)
43	}
44	if c.Continuation {
45		t.Errorf("cell(%d,%d) unexpectedly marked as continuation", x, y)
46	}
47}
48
49// assertContinuation asserts the cell at (x,y) is the right half of a
50// wide-character pair (Continuation set, Rune 0).
51func assertContinuation(t *testing.T, s *Screen, x, y int) {
52	t.Helper()
53	c := cellAt(s, x, y)
54	if !c.Continuation {
55		t.Errorf("cell(%d,%d) expected continuation, got rune=%q continuation=%v", x, y, c.Rune, c.Continuation)
56	}
57	if c.Rune != 0 {
58		t.Errorf("cell(%d,%d) continuation rune = %q, want 0", x, y, c.Rune)
59	}
60}
61
62// assertBlank asserts the cell at (x,y) is a blank default cell.
63func assertBlank(t *testing.T, s *Screen, x, y int) {
64	t.Helper()
65	c := cellAt(s, x, y)
66	if c.Rune != ' ' || c.Continuation {
67		t.Errorf("cell(%d,%d) = {rune:%q cont:%v}, want blank space", x, y, c.Rune, c.Continuation)
68	}
69}
70
71func assertNoOrphanWideCells(t *testing.T, s *Screen) {
72	t.Helper()
73	for y := range s.Frame.Height {
74		for x := range s.Frame.Width {
75			c := cellAt(s, x, y)
76			if c.Continuation {
77				if x == 0 || cellAt(s, x-1, y).Continuation || renderer.RuneWidth(cellAt(s, x-1, y).Rune) != 2 {
78					t.Fatalf("orphan continuation at (%d,%d)", x, y)
79				}
80				continue
81			}
82			if renderer.RuneWidth(c.Rune) == 2 && (x+1 >= s.Frame.Width || !cellAt(s, x+1, y).Continuation) {
83				t.Fatalf("orphan wide head at (%d,%d) rune %q", x, y, c.Rune)
84			}
85		}
86	}
87}
88
89func lineText(s *Screen, y int) string {
90	out := make([]rune, s.Frame.Width)
91	for x := range s.Frame.Width {
92		out[x] = s.Frame.At(x, y).Rune
93	}
94	return string(out)
95}
96
97func rowString(row []renderer.Cell) string {
98	out := make([]rune, len(row))
99	for i, cell := range row {
100		out[i] = cell.Rune
101	}
102	return string(out)
103}

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 2

Tags 13

↑↓ moveenter openesc close