scene.go RawHistoryFolder

1package core
2
3import (
4	"context"
5	"slices"
6
7	"github.com/bnema/neferwl/internal/ports"
8)
9
10// sceneFor builds the scene of screen i and sends the configures it sizes.
11// drawable reports that it can show the focus pulse on the focused window.
12func (c *Core) sceneFor(ctx context.Context, i int, sc *screen, only *screen, capture *capView, pulse float64) (scene ports.Scene, drawable bool, err error) {
13	o := sc.mon.Output()
14	// view.frame is the viewport of the workspace on screen: the whole
15	// output unless it has a size override (never in the overview).
16	view := sc.mon.viewport()
17	var clip Rect
18	if view.frame != (Rect{W: o.W, H: o.H}) {
19		clip = view.frame
20	}
21	// layout is what is drawn; settled (same indexes) is where the
22	// windows are going, and alone sizes the configures.
23	layout, settled := sc.shown, sc.settledLayout
24	scene = ports.Scene{Security: c.security, Output: sc.name(), OutputWidth: o.W, OutputHeight: o.H, WorkspaceClip: clip, Scale: sc.scale, Transform: sc.transform, Off: sc.off, Background: c.cfg.Background.Color, Border: ports.Border{Width: c.cfg.Border.Width, Active: c.cfg.Border.Active, Inactive: c.cfg.Border.Inactive}, Windows: make([]ports.SceneWindow, 0, len(layout)+len(c.popupOrder)), Layers: shownLayers(sc)}
25	if !sc.mon.previewing() {
26		// Tiles stop at the panels; the overview lays out previews over
27		// the whole output.
28		u := view.usable
29		scene.TileInset = ports.Insets{Top: u.Y, Left: u.X, Right: o.W - u.X - u.W, Bottom: o.H - u.Y - u.H}
30	}
31	var real map[WindowID]Placement
32	if sc.mon.previewing() {
33		// Local to this screen's build: reused, cleared each time.
34		if c.overviewReal == nil {
35			c.overviewReal = make(map[WindowID]Placement)
36		}
37		clear(c.overviewReal)
38		real = c.overviewReal
39		for w := range sc.mon.all() {
40			c.realBuf = w.layoutInto(c.realBuf)
41			for _, p := range c.realBuf {
42				real[p.ID] = p
43			}
44		}
45	}
46	scene.Dim = floatDim(layout, view, c.cfg.Floating.Dim)
47	if sc.mon.previewing() {
48		// Darken the wallpaper around the previews.
49		scene.Dim = c.cfg.Floating.Dim
50		scene.DimBehind = scene.Dim > 0
51	}
52	if d := c.drag; d != nil && d.target.screen == sc && d.target.kind != dropNone {
53		scene.DropHints = slices.Clone(d.target.hints)
54	}
55	if sc.mon.ov.open {
56		// Frame the selection and separate numbered and named row groups.
57		_, scene.Separators = sc.mon.overviewRows()
58		scene.Separators = append(scene.Separators, overviewOutline(layout, max(c.cfg.Border.Width, 2))...)
59	} else if sc.mon.switcherShown() {
60		// The switcher's cards: only the selection is framed.
61		scene.Separators = overviewOutline(layout, max(c.cfg.Border.Width, 2))
62	} else {
63		// Only the focused output lights the focused window's lines.
64		scene.Separators = separators(layout, c.cfg.Border.Width, sc.mon.Current().gap(), view, i == c.focusScreen)
65	}
66	// A window alone on screen needs no pulse to show it has the focus.
67	alone := i == c.focusScreen && c.pulse.target != 0 && visibleCount(layout, view) == 1
68	for k, p := range layout {
69		ps := settled[k]
70		// Only the focused output has an activated window.
71		focused := p.Focused && i == c.focusScreen
72		sw := ports.SceneWindow{ID: p.ID, Rect: p.Rect, Focused: focused, Fullscreen: p.Fullscreen, Hidden: p.Hidden, Floating: p.Floating, Below: p.Below, Inset: p.Inset, Preview: p.Preview, Fade: p.Fade}
73		if p.Zoom > 0 && (p.Zoom < 1 || p.Preview > 0) {
74			// A scale motion: the content follows the drawn size. A
75			// card in flight drawn at its size still needs Zoom 1:
76			// without it the renderer would shrink it by Preview.
77			sw.Zoom = p.Zoom
78		}
79		// A peek's veil is the configured one plus its animated offset.
80		sw.Dim = max(0, min(p.Dim+c.peekDim(p), 1))
81		if p.Leaving {
82			// A window fading out after it closed or hid: drawn, but
83			// hidden to everything else, its configures included.
84			sw.Hidden = false
85			scene.Windows = append(scene.Windows, sw)
86			// A window the workspace still holds (a hidden stash
87			// window) keeps its last configure: prune would forget it,
88			// and its next one would start from nothing. A closed one
89			// was forgotten at its unmap and stays so.
90			if w, _ := sc.mon.find(p.ID); w != nil {
91				c.configures.keep(p.ID)
92			}
93			continue
94		}
95		if focused && p.ID == c.pulse.target && !alone && !p.Fullscreen && !p.Hidden && p.Preview == 0 && !sc.mon.previewing() && hasRoom(view, p) {
96			drawable = true
97			if p.ID == c.pulse.id {
98				sw.FocusEffect = pulse
99			}
100		}
101		scene.Windows = append(scene.Windows, sw)
102		t := configureTarget{output: sc.name(), view: view, focused: focused, captured: capture != nil && capture.window == p.ID}
103		if !p.Hidden && p.Preview == 0 {
104			// Only a sized configure needs the client size.
105			t.client, t.imposed = c.clientRect(ps), sc.mon.Current().imposedFloat(p.ID)
106		} else if t.captured && p.Hidden {
107			// A captured hidden window is sized like its capture.
108			t.client = capture.windowSz
109		} else if p.Preview > 0 && !p.Hidden {
110			if rp, ok := real[p.ID]; ok && !rp.Hidden {
111				t.realTiled = !rp.Floating
112				t.client = c.clientRect(rp)
113			}
114		}
115		cp, t := c.captureConfigure(sc, ps, t)
116		if v, send := c.configures.nextWithCapture(ps, t, cp); send {
117			if err := c.command(ctx, v); err != nil {
118				return ports.Scene{}, false, err
119			}
120			c.configures.mark(v)
121		}
122	}
123	scene.Windows = append(scene.Windows, c.scenePopups(sc)...)
124	scene.CaptureIndicators = c.captureIndicators(sc)
125	scene.Capture = c.captureSceneFor(sc, capture)
126	// A scene carrying a capture image always gets a fresh Seq, and so
127	// does one of an animating screen (the one being stepped, or any
128	// when none is): the outputs drop a scene they already show, and a
129	// spring that starts at the previous scene, or rounds to it in its
130	// tail, would get no flip and wait for the fallback timer. Any other
131	// keeps its output's Seq while it draws the same, so an idle output
132	// is not recomposed.
133	withCapture := scene.Capture != nil && (sc == capture.hiddenScr || sc == capture.windowScr)
134	animating := (sc.springing() || c.pulsing(sc)) && (only == nil || only == sc)
135	if !withCapture && !animating && sc.last.Seq != 0 && scene.SameAs(sc.last) {
136		scene.Seq = sc.last.Seq
137	} else {
138		c.seq++
139		scene.Seq = c.seq
140	}
141	if withCapture {
142		switch sc {
143		case capture.hiddenScr:
144			scene.CaptureScene = c.captureScene(scene.Seq)
145		case capture.windowScr:
146			scene.CaptureScene = c.captureWindowScene(capture, scene.Seq)
147		}
148	}
149	return scene, drawable, nil
150}

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