v0.3.0 cf370a0

float_core_test.go RawHistoryFolder

1package core
2
3import (
4	"context"
5	"testing"
6
7	"github.com/bnema/neferwl/internal/ports"
8)
9
10func TestCoreCoveringFloatSceneAndHit(t *testing.T) {
11	cfg := ports.Config{}
12	cfg.Keyboard.CmdKey = "super"
13	cfg.Layout.MaxColumns = 2
14	cfg.Border.Width = 2
15	cfg.Floating.Dim = 0.3
16	scenes := make(chan []ports.Scene, 1)
17	commands := make(chan ports.ClientCommand, 128)
18	c, err := New(cfg, Channels{Scenes: scenes, Commands: commands})
19	if err != nil {
20		t.Fatal(err)
21	}
22	c.cur().info = ports.OutputInfo{Name: "OUT", Width: 100, Height: 80}
23	m := c.cur().mon
24	m.SetOutput(100, 80)
25	w := m.Current()
26	w.AddWindow(1)
27	w.AddFloating(2, 100, 80)
28	ctx := context.Background()
29	check := func(dim float64, ids ...WindowID) {
30		t.Helper()
31		if err := c.publish(ctx); err != nil {
32			t.Fatal(err)
33		}
34		s := (<-scenes)[0]
35		if s.Dim != dim {
36			t.Fatalf("dim %v, want %v", s.Dim, dim)
37		}
38		if len(s.Windows) != len(ids) {
39			t.Fatalf("scene %+v", s.Windows)
40		}
41		for i, id := range ids {
42			if s.Windows[i].ID != id {
43				t.Fatalf("scene %+v, want %v", s.Windows, ids)
44			}
45		}
46	}
47	check(0.3, 1, 2)
48	w.FocusID(1)
49	check(0, 2, 1)
50	if !w.Layout()[0].Below {
51		t.Fatal("float not below")
52	}
53	if id, _, _ := c.hit(50, 40); id != 1 {
54		t.Fatalf("hit %d, want tile", id)
55	}
56	w.AddFloating(3, 12, 10)
57	check(0.3, 2, 1, 3)
58	if id, _, _ := c.hit(50, 40); id != 3 {
59		t.Fatalf("hit %d, want dialog", id)
60	}
61	w.FocusID(2)
62	check(0.3, 1, 2, 3)
63	m.ToggleOverview()
64	if err := c.publish(ctx); err != nil {
65		t.Fatal(err)
66	}
67	if s := (<-scenes)[0]; s.Dim != 0.3 || !s.DimBehind {
68		t.Fatalf("overview dim %v behind %v", s.Dim, s.DimBehind)
69	}
70}
71
72// The overview darkens the wallpaper behind its previews, tiles only too.
73func TestCoreOverviewDimsBehind(t *testing.T) {
74	cfg := ports.Config{}
75	cfg.Keyboard.CmdKey = "super"
76	cfg.Layout.MaxColumns = 2
77	cfg.Floating.Dim = 0.3
78	scenes := make(chan []ports.Scene, 1)
79	c, err := New(cfg, Channels{Scenes: scenes, Commands: make(chan ports.ClientCommand, 128)})
80	if err != nil {
81		t.Fatal(err)
82	}
83	c.cur().info = ports.OutputInfo{Name: "OUT", Width: 100, Height: 80}
84	m := c.cur().mon
85	m.SetOutput(100, 80)
86	m.Current().AddWindow(1)
87	ctx := context.Background()
88	for _, tc := range []struct {
89		dim    float64
90		behind bool
91	}{{0, false}, {0.3, true}, {0, false}} {
92		if err := c.publish(ctx); err != nil {
93			t.Fatal(err)
94		}
95		if s := (<-scenes)[0]; s.Dim != tc.dim || s.DimBehind != tc.behind {
96			t.Fatalf("dim %v behind %v, want %v %v", s.Dim, s.DimBehind, tc.dim, tc.behind)
97		}
98		m.ToggleOverview()
99	}
100}

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