v0.2.41 1a24a20

input_test.go RawHistoryFolder

1package tui
2
3import "testing"
4
5func TestReaderParsesCSIUShiftEnter(t *testing.T) {
6	k := readKey(t, "\x1b[13;2u")
7	if k.Kind != KeyEnter || !k.Shift || k.Alt {
8		t.Fatalf("Read kind=%v shift=%v alt=%v, want shift+enter", k.Kind, k.Shift, k.Alt)
9	}
10}
11
12func TestReaderParsesModifyOtherKeysShiftEnter(t *testing.T) {
13	k := readKey(t, "\x1b[27;2;13~")
14	if k.Kind != KeyEnter || !k.Shift || k.Alt {
15		t.Fatalf("Read kind=%v shift=%v alt=%v, want shift+enter", k.Kind, k.Shift, k.Alt)
16	}
17}
18
19func TestReaderParsesCSIUCtrlC(t *testing.T) {
20	k := readKey(t, "\x1b[99;5u")
21	if k.Kind != KeyCtrlC || !k.Ctrl {
22		t.Fatalf("Read kind=%v ctrl=%v, want ctrl+c", k.Kind, k.Ctrl)
23	}
24}
25
26func TestReaderParsesModifyOtherKeysCtrlC(t *testing.T) {
27	k := readKey(t, "\x1b[27;5;99~")
28	if k.Kind != KeyCtrlC || !k.Ctrl {
29		t.Fatalf("Read kind=%v ctrl=%v, want ctrl+c", k.Kind, k.Ctrl)
30	}
31}
32
33func TestReaderParsesCSIUEsc(t *testing.T) {
34	k := readKey(t, "\x1b[27u")
35	if k.Kind != KeyEsc {
36		t.Fatalf("Read kind=%v, want esc", k.Kind)
37	}
38}
39
40func TestReaderParsesCSIUTabAndBackspace(t *testing.T) {
41	if k := readKey(t, "\x1b[9u"); k.Kind != KeyTab {
42		t.Fatalf("Read kind=%v, want tab", k.Kind)
43	}
44	if k := readKey(t, "\x1b[9;2u"); k.Kind != KeyShiftTab {
45		t.Fatalf("Read kind=%v, want shift-tab", k.Kind)
46	}
47	if k := readKey(t, "\x1b[127u"); k.Kind != KeyBackspace {
48		t.Fatalf("Read kind=%v, want backspace", k.Kind)
49	}
50}
51
52func TestReaderParsesSGRMouseWheel(t *testing.T) {
53	cases := []struct {
54		seq  string
55		want KeyKind
56	}{
57		{"\x1b[<64;10;20M", KeyMouseWheelUp},
58		{"\x1b[<65;10;20M", KeyMouseWheelDown},
59	}
60	for _, tc := range cases {
61		k := readKey(t, tc.seq)
62		if k.Kind != tc.want {
63			t.Fatalf("Read(%q) kind=%v, want %v", tc.seq, k.Kind, tc.want)
64		}
65	}
66}
67
68func readKey(t *testing.T, seq string) Key {
69	t.Helper()
70	idx := 0
71	r := NewReader(func() (byte, error) {
72		b := seq[idx]
73		idx++
74		return b, nil
75	})
76	k, err := r.Read()
77	if err != nil {
78		t.Fatalf("Read(%q): %v", seq, err)
79	}
80	return k
81}

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