axis_test.go RawHistoryFolder

1package wayland
2
3import (
4	"testing"
5
6	"github.com/bnema/neferwl/internal/ports"
7)
8
9// High-resolution wheels send fractions of a detent: pre-v8 clients get a
10// discrete step once 120 builds up; a direction change drops the rest.
11func TestWheelSteps(t *testing.T) {
12	s := &Server{}
13	var values [2]float64
14	wheel := func(v, h int32) (steps [2]int32) {
15		steps, values = s.seat.wheelSteps(ports.PointerAxis{
16			Vertical:   ports.ScrollAxis{Set: v != 0, V120: v, Value: float64(v) / 8},
17			Horizontal: ports.ScrollAxis{Set: h != 0, V120: h},
18		})
19		return steps
20	}
21	for i, tc := range []struct {
22		v, h int32
23		want [2]int32
24	}{
25		{60, 0, [2]int32{}},
26		{60, 0, [2]int32{1, 0}},
27		{180, 0, [2]int32{1, 0}},
28		{60, 0, [2]int32{1, 0}},
29		{-60, 240, [2]int32{0, 2}},
30		{-60, 0, [2]int32{-1, 0}},
31		{30, -30, [2]int32{}},
32	} {
33		if got := wheel(tc.v, tc.h); got != tc.want {
34			t.Fatalf("step %d: got %v, want %v", i, got, tc.want)
35		}
36	}
37	// The held value sums the frames since the last step.
38	*s = Server{}
39	wheel(60, 0)
40	if s.seat.wheelHeld[0] != 7.5 {
41		t.Fatal("held", s.seat.wheelHeld[0])
42	}
43	if wheel(60, 0) != [2]int32{1, 0} || s.seat.wheelHeld[0] != 0 || values[0] != 15 {
44		t.Fatal("held after step", s.seat.wheelHeld[0])
45	}
46	// A direction change drops what was held the other way.
47	wheel(60, 0)
48	if wheel(-180, 0) != [2]int32{-1, 0} || values[0] != -22.5 {
49		t.Fatal("after reversal", values)
50	}
51	if steps, _ := s.seat.wheelSteps(ports.PointerAxis{Source: ports.AxisFinger, Vertical: ports.ScrollAxis{Set: true, V120: 240}}); steps != [2]int32{} {
52		t.Fatal("finger scroll made discrete steps")
53	}
54}

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 25

Tags 10

↑↓ moveenter openesc close