detached f2d166b

state_geometry_test.go RawHistoryFolder

1package core
2
3import (
4	"testing"
5
6	"github.com/bnema/neferwl/internal/ports"
7)
8
9// Every workspace lists its tiled columns and windows with settled
10// rectangles; only the workspace on screen is visible.
11func TestStateWorkspaceGeometry(t *testing.T) {
12	cfg := ports.Config{}
13	cfg.Keyboard.CmdKey = "super"
14	cfg.Layout.Overflow = "fixed"
15	cfg.Layout.MaxColumns = 2
16	cfg.Layout.Gaps = 10
17	c, err := New(cfg, Channels{Commands: make(chan ports.ClientCommand, 16), Scenes: make(chan []ports.Scene, 1)}, Options{})
18	if err != nil {
19		t.Fatal(err)
20	}
21	c.addScreen(ports.OutputInfo{Name: "OUT-1", Width: 1000, Height: 800})
22	m := c.cur().mon
23	shown := m.Current()
24	shown.Columns = []Column{{Windows: []WindowID{1}}, {Windows: []WindowID{2, 3}}}
25	m.normalize() // the trailing empty workspace, as in a session
26	other := m.newWorkspace()
27	other.Columns = []Column{{Windows: []WindowID{4}}}
28	m.hidden = append(m.hidden, other)
29
30	got := c.state().Workspaces
31	if len(got) != 3 {
32		t.Fatalf("%d workspaces: %+v", len(got), got)
33	}
34	ws := got[0]
35	if ws.ID != shown.ID || ws.Number != 1 || ws.Output != "OUT-1" || !ws.Visible || ws.Overflow != "fixed" {
36		t.Fatalf("%+v", ws)
37	}
38	want := []ports.ColumnState{
39		{Rect: Rect{X: 10, Y: 10, W: 485, H: 780}, Windows: []ports.TileState{{ID: 1, Rect: Rect{X: 10, Y: 10, W: 485, H: 780}}}},
40		{Rect: Rect{X: 505, Y: 10, W: 485, H: 780}, Windows: []ports.TileState{{ID: 2, Rect: Rect{X: 505, Y: 10, W: 485, H: 385}}, {ID: 3, Rect: Rect{X: 505, Y: 405, W: 485, H: 385}}}},
41	}
42	if len(ws.Columns) != len(want) {
43		t.Fatalf("%+v", ws.Columns)
44	}
45	for i := range want {
46		if ws.Columns[i].Rect != want[i].Rect || len(ws.Columns[i].Windows) != len(want[i].Windows) {
47			t.Fatalf("column %d: %+v, want %+v", i, ws.Columns[i], want[i])
48		}
49		for j := range want[i].Windows {
50			if ws.Columns[i].Windows[j] != want[i].Windows[j] {
51				t.Errorf("column %d tile %d: %+v, want %+v", i, j, ws.Columns[i].Windows[j], want[i].Windows[j])
52			}
53		}
54	}
55	var found bool
56	for _, w := range got[1:] {
57		if w.ID == other.ID {
58			found = true
59			if w.Visible || w.Number != 0 || len(w.Columns) != 1 || w.Columns[0].Windows[0].ID != 4 {
60				t.Errorf("hidden workspace: %+v", w)
61			}
62		} else if w.Visible {
63			t.Errorf("workspace %d visible", w.ID)
64		}
65	}
66	if !found {
67		t.Error("second workspace missing")
68	}
69}
70
71// A change of geometry is a change of state; an unchanged one is not.
72func TestStateWorkspaceChange(t *testing.T) {
73	cfg := ports.Config{}
74	cfg.Keyboard.CmdKey = "super"
75	cfg.Layout.MaxColumns = 2
76	c, err := New(cfg, Channels{Commands: make(chan ports.ClientCommand, 16), Scenes: make(chan []ports.Scene, 1)}, Options{})
77	if err != nil {
78		t.Fatal(err)
79	}
80	c.addScreen(ports.OutputInfo{Name: "OUT-1", Width: 1000, Height: 800})
81	w := c.cur().mon.Current()
82	w.Columns = []Column{{Windows: []WindowID{1}}}
83	a := c.state()
84	if !sameState(a, c.state()) {
85		t.Fatal("same layout reported as changed")
86	}
87	w.Columns = []Column{{Windows: []WindowID{1}}, {Windows: []WindowID{2}}}
88	if sameState(a, c.state()) {
89		t.Fatal("new column not seen")
90	}
91}

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