v0.2.0 13c6a90

xkb_test.go RawHistoryFolder

1package xkb
2
3import (
4	"strings"
5	"testing"
6
7	"github.com/bnema/neferwl/internal/ports"
8)
9
10func newTest(t *testing.T, layout string) *Keymap {
11	t.Helper()
12	k, err := New(RMLVO{Layout: layout})
13	if err != nil {
14		if strings.Contains(err.Error(), "libxkbcommon.so.0") {
15			t.Skipf("xkbcommon unavailable: %v", err)
16		}
17		t.Fatal(err)
18	}
19	t.Cleanup(k.Close)
20	return k
21}
22
23func TestKeymap(t *testing.T) {
24	k := newTest(t, "us")
25	if !strings.Contains(k.String(), "xkb_keymap") {
26		t.Fatal("missing keymap text")
27	}
28	if ev := k.Key(30, true, 123); ev.Keysym != "a" || ev.Keycode != 30 || !ev.Pressed || ev.TimeMsec != 123 {
29		t.Fatalf("A: %+v", ev)
30	}
31	k.Key(30, false, 0)
32	k.Key(42, true, 0)
33	if ev := k.Key(30, true, 0); ev.Keysym != "A" || ev.Mods&ports.ModShift == 0 || ev.State.Depressed == 0 {
34		t.Fatalf("shift A: %+v", ev)
35	}
36	k.Key(42, false, 0)
37	if ev := k.Key(30, false, 0); ev.Mods&ports.ModShift != 0 {
38		t.Fatalf("shift release: %+v", ev)
39	}
40	for _, tt := range []struct {
41		name      string
42		code      uint32
43		shift, ok bool
44	}{{"a", 30, false, true}, {"A", 30, true, true}, {"Return", 28, false, true}, {"nope", 0, false, false}} {
45		code, shift, ok := k.KeycodeFor(tt.name)
46		if code != tt.code || shift != tt.shift || ok != tt.ok {
47			t.Errorf("%s: %d %v %v", tt.name, code, shift, ok)
48		}
49	}
50	fr := newTest(t, "fr")
51	if code, _, ok := fr.KeycodeFor("a"); !ok || code != 16 {
52		t.Errorf("fr a: %d %v", code, ok)
53	}
54}
55
56func TestKeyLevels(t *testing.T) {
57	// With Shift held, Base still reports the unshifted keysym.
58	k := newTest(t, "us")
59	k.Key(42, true, 0)
60	if ev := k.Key(2, true, 0); ev.Keysym != "exclam" || ev.Base != "1" {
61		t.Fatalf("shift 1: %+v", ev)
62	}
63	if ev := k.Key(2, false, 0); ev.Base != "" {
64		t.Fatalf("release carries levels: %+v", ev)
65	}
66}

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 23

Tags 10

↑↓ moveenter openesc close