v0.2.0 13c6a90

commands_test.go RawHistoryFolder

1package wayland
2
3import (
4	"context"
5	"reflect"
6	"testing"
7	"time"
8
9	"github.com/bnema/neferwl/internal/logging"
10	"github.com/bnema/neferwl/internal/ports"
11)
12
13func TestDrainCommandsCollapsesMotion(t *testing.T) {
14	cmds := make(chan ports.ClientCommand, 16)
15	cmds <- ports.PointerMotionTo{ID: 1, X: 2, DX: 0.25, UnaccelDX: 0.5}
16	cmds <- ports.PointerMotionTo{ID: 1, X: 3, DX: 0.25, DY: -0.5, UnaccelDX: 0.5, UnaccelDY: -1}
17	cmds <- ports.PointerButtonTo{ID: 1, Button: 272, Pressed: true}
18	cmds <- ports.PointerMotionTo{ID: 1, X: 4}
19	cmds <- ports.PointerFocus{ID: 2}
20	cmds <- ports.PointerMotionTo{ID: 2, X: 5}
21	cmds <- ports.PointerMotionTo{ID: 2, X: 6}
22	batch, open := drainCommands(ports.PointerMotionTo{ID: 1, X: 1, DX: 0.25, UnaccelDX: 0.5}, cmds)
23	want := []ports.ClientCommand{
24		// Slow motions add up: none of the sub-pixel deltas is lost.
25		ports.PointerMotionTo{ID: 1, X: 3, DX: 0.75, DY: -0.5, UnaccelDX: 1.5, UnaccelDY: -1},
26		ports.PointerButtonTo{ID: 1, Button: 272, Pressed: true},
27		ports.PointerMotionTo{ID: 1, X: 4},
28		ports.PointerFocus{ID: 2},
29		ports.PointerMotionTo{ID: 2, X: 6},
30	}
31	if !open || !reflect.DeepEqual(batch, want) {
32		t.Fatalf("open=%v batch=%#v", open, batch)
33	}
34	close(cmds)
35	if _, open := drainCommands(ports.PointerFocus{}, cmds); open {
36		t.Fatal("closed channel reported open")
37	}
38}
39
40// Each command used to cost one display.Do round trip (up to one 5 ms
41// event-loop dispatch), capping pointer motion at ~150/s. A 1 kHz mouse
42// must be absorbed without core blocking.
43func TestCommandThroughput(t *testing.T) {
44	cmds := make(chan ports.ClientCommand, 32)
45	s, err := New(Options{RuntimeDir: t.TempDir(), Outputs: testOutputs}, Channels{Commands: cmds}, logging.For(context.Background(), "wayland"))
46	if err != nil {
47		t.Fatal(err)
48	}
49	ctx, cancel := context.WithCancel(context.Background())
50	done := make(chan error, 1)
51	go func() { done <- s.Run(ctx) }()
52	defer func() { cancel(); <-done }()
53	start := time.Now()
54	for i := range 2000 {
55		cmds <- ports.PointerMotionTo{ID: 1, X: float64(i), Y: 1}
56	}
57	if d := time.Since(start); d > time.Second {
58		t.Fatalf("2000 motion commands took %v (%.0f/s); want well above 1000/s", d, 2000/d.Seconds())
59	}
60}

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