v0.10.0 d5d679d

xkb_test.go RawHistoryFolder

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

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