feat/hints a471fa4

popup_test.go RawHistoryFolder

1package core
2
3import (
4	"testing"
5
6	"github.com/bnema/neferwl/internal/ports"
7)
8
9func TestPlacePopup(t *testing.T) {
10	menu := ports.Positioner{
11		Width: 40, Height: 30,
12		AnchorRect: Rect{X: 10, Y: 10, W: 20, H: 10},
13		Anchor:     ports.EdgeBottomRight, Gravity: ports.EdgeBottomRight,
14	}
15	bounds := Rect{X: 0, Y: 0, W: 100, H: 100}
16	for _, tc := range []struct {
17		name   string
18		mod    func(p *ports.Positioner)
19		bounds Rect
20		want   Rect
21	}{
22		{"fits", func(*ports.Positioner) {}, bounds, Rect{X: 30, Y: 20, W: 40, H: 30}},
23		{"no bounds", func(p *ports.Positioner) { p.OffsetX = 500 }, Rect{}, Rect{X: 530, Y: 20, W: 40, H: 30}},
24		{"centre", func(p *ports.Positioner) { p.Anchor, p.Gravity = 0, 0 }, bounds, Rect{X: 0, Y: 0, W: 40, H: 30}},
25		{"flip x", func(p *ports.Positioner) { p.OffsetX = 40; p.Adjust = ports.AdjustFlipX }, Rect{W: 90, H: 100}, Rect{X: 10, Y: 20, W: 40, H: 30}},
26		{"flip y", func(p *ports.Positioner) { p.AnchorRect.Y = 70; p.Adjust = ports.AdjustFlipY }, bounds, Rect{X: 30, Y: 40, W: 40, H: 30}},
27		{"slide", func(p *ports.Positioner) { p.AnchorRect.X = 80; p.Adjust = ports.AdjustSlideX }, bounds, Rect{X: 60, Y: 20, W: 40, H: 30}},
28		{"resize", func(p *ports.Positioner) { p.AnchorRect.X = 80; p.Adjust = ports.AdjustResizeX }, bounds, Rect{X: 100, Y: 20, W: 40, H: 30}},
29		{"resize y", func(p *ports.Positioner) { p.AnchorRect.Y = 70; p.Adjust = ports.AdjustResizeY }, bounds, Rect{X: 30, Y: 80, W: 40, H: 20}},
30		{"none", func(p *ports.Positioner) { p.AnchorRect.X = 80 }, bounds, Rect{X: 100, Y: 20, W: 40, H: 30}},
31	} {
32		p := menu
33		tc.mod(&p)
34		if got := place(p, tc.bounds); got != tc.want {
35			t.Errorf("%s: got %+v want %+v", tc.name, got, tc.want)
36		}
37	}
38}
39
40func TestFloatingWindows(t *testing.T) {
41	w := workspace()
42	w.AddWindow(1)
43	w.AddFloating(2, 20, 10)
44	if id, _ := w.Focused(); id != 2 {
45		t.Fatalf("focus %d, want the floating window", id)
46	}
47	l := w.Layout()
48	f := l[len(l)-1]
49	u := w.Usable
50	if f.ID != 2 || !f.Floating || !f.Focused || f.Rect.W != 20 || f.Rect.H != 10 ||
51		f.Rect.X != u.X+(u.W-20)/2 || f.Rect.Y != u.Y+(u.H-10)/2 {
52		t.Fatalf("float placement %+v in %+v", f, u)
53	}
54	w.ResizeFloating(2, 500, 500)
55	if r := w.Layout()[1].Rect; r.W != u.W || r.H != u.H {
56		t.Fatalf("clamped %+v", r)
57	}
58	// A dialog from a fullscreen window waits hidden: the fullscreen is
59	// exclusive and keeps the focus. It shows, focused, once it leaves.
60	w.SetFullscreen(1, true)
61	w.RemoveWindow(2)
62	w.AddFloating(2, 20, 10)
63	if l := w.Layout(); !l[1].Hidden || l[1].Focused || !l[0].Focused {
64		t.Fatalf("float over fullscreen %+v", l)
65	}
66	w.SetFullscreen(1, false)
67	if l := w.Layout(); l[1].Hidden || !l[1].Focused {
68		t.Fatalf("float after fullscreen %+v", l)
69	}
70	w.RemoveWindow(2)
71	if id, _ := w.Focused(); id != 1 || len(w.Floats) != 0 {
72		t.Fatalf("focus after close %d", id)
73	}
74}

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