constraint_frame_test.go RawHistoryFolder

1package core
2
3import (
4	"context"
5	"testing"
6
7	"github.com/bnema/neferwl/internal/ports"
8)
9
10// partlyShown has window 2 straddling the left edge of a 100x100 viewport:
11// its client is x 75..125 of the monitor (1075..1125 globally) and only
12// 100..125 shows.
13func partlyShown(t *testing.T) *Core {
14	t.Helper()
15	var cfg ports.Config
16	cfg.Keyboard.CmdKey = "super"
17	cfg.Layout.MaxColumns = 2
18	c, err := New(cfg, Channels{Scenes: make(chan []ports.Scene, 1), Layouts: make(chan ports.Layout, 1), Constraints: make(chan ports.PointerConstraint, 1), State: make(chan ports.State, 1), Workspaces: make(chan ports.Workspaces, 1), Commands: make(chan ports.ClientCommand, 16)}, Options{})
19	if err != nil {
20		t.Fatal(err)
21	}
22	c.addScreen(ports.OutputInfo{Name: "A", Width: 300, Height: 200})
23	s := c.screens[0]
24	s.x = 1000
25	s.mon.SetNamed([]NamedWorkspace{{Name: "s", Size: [2]int{100, 100}}})
26	s.mon.ToggleNamed("s")
27	for id := WindowID(1); id <= 3; id++ {
28		s.mon.AddWindow(id)
29	}
30	s.mon.Current().View += 25
31	return c
32}
33
34// A constraint region is window-local: it starts at the whole client's
35// origin, not at the visible part's, and is then cut to the viewport.
36func TestConstraintRegionUsesFullClientOrigin(t *testing.T) {
37	c := partlyShown(t)
38	full, vis, ok := c.shownClient(2)
39	if !ok || full != (Rect{X: 1075, Y: 50, W: 50, H: 100}) || vis != (Rect{X: 1100, Y: 50, W: 25, H: 100}) {
40		t.Fatalf("full %+v visible %+v %v", full, vis, ok)
41	}
42	c.constrained = ports.PointerConstrained{ID: 2, PointerConstraint: ports.PointerConstraint{Mode: ports.ConstraintConfine, Rect: Rect{X: 30, Y: 10, W: 20, H: 20}}}
43	c.resolveConstraint()
44	// Local x 30..50 is global 1105..1125, all inside the visible part.
45	if want := (Rect{X: 1105, Y: 60, W: 20, H: 20}); c.constraint.Rect != want {
46		t.Fatalf("region %+v want %+v", c.constraint.Rect, want)
47	}
48	// A region straddling the viewport edge is cut to it: local 10..40 is 1085..1115.
49	c.constrained.PointerConstraint.Rect = Rect{X: 10, Y: 0, W: 30, H: 100}
50	c.resolveConstraint()
51	if want := (Rect{X: 1100, Y: 50, W: 15, H: 100}); c.constraint.Rect != want {
52		t.Fatalf("straddling region %+v want %+v", c.constraint.Rect, want)
53	}
54}
55
56// A warp target is computed from the whole client origin and refused when it
57// falls outside the viewport.
58func TestWarpUsesFullClientOriginAndFrame(t *testing.T) {
59	c := partlyShown(t)
60	c.pointer = 2
61	ctx := context.Background()
62	// Local 10 is global 1085: the hidden part of the window.
63	if err := c.warpPointer(ctx, ports.PointerWarp{ID: 2, X: 10, Y: 5}); err != nil {
64		t.Fatal(err)
65	}
66	if c.cursorX != 0 || c.cursorY != 0 {
67		t.Fatalf("warped into the hidden part: %v,%v", c.cursorX, c.cursorY)
68	}
69	// Local 30 is global 1105: shown.
70	if err := c.warpPointer(ctx, ports.PointerWarp{ID: 2, X: 30, Y: 5}); err != nil {
71		t.Fatal(err)
72	}
73	if c.cursorX != 1105 || c.cursorY != 55 {
74		t.Fatalf("cursor %v,%v want 1105,55", c.cursorX, c.cursorY)
75	}
76}

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