v0.1.0 d9218d6

cursor.go RawHistoryFolder

1package headless
2
3import (
4	"image"
5	"sync"
6
7	"github.com/bnema/neferwl/internal/ports"
8)
9
10// Cursor is the software cursor drawn into screenshots; it plays the role of
11// the DRM cursor plane. Move is called from the input goroutine.
12type Cursor struct {
13	mu     sync.Mutex
14	x, y   float64
15	img    ports.CursorImage
16	hidden bool
17}
18
19func (c *Cursor) Move(x, y float64) {
20	c.mu.Lock()
21	c.x, c.y, c.hidden = x, y, false
22	c.mu.Unlock()
23}
24
25// Hide stops drawing the cursor until the next move.
26func (c *Cursor) Hide() {
27	c.mu.Lock()
28	c.hidden = true
29	c.mu.Unlock()
30}
31
32func (c *Cursor) set(img ports.CursorImage) {
33	c.mu.Lock()
34	c.img = img
35	c.mu.Unlock()
36}
37
38// draw blends the premultiplied cursor over dst with its hotspot at (x, y).
39func (c *Cursor) draw(dst *image.RGBA) {
40	c.mu.Lock()
41	defer c.mu.Unlock()
42	if c.hidden {
43		return
44	}
45	img := c.img
46	ox, oy := int(c.x)-img.HotX, int(c.y)-img.HotY
47	b := dst.Bounds()
48	for y := range img.H {
49		for x := range img.W {
50			dx, dy := ox+x, oy+y
51			if !image.Pt(dx, dy).In(b) {
52				continue
53			}
54			s := img.Pixels[(y*img.W+x)*4:]
55			a := int(s[3])
56			if a == 0 {
57				continue
58			}
59			d := dst.Pix[dst.PixOffset(dx, dy):]
60			// Source is premultiplied B,G,R,A; dst is straight R,G,B,A (opaque).
61			// min guards against themes that are not really premultiplied.
62			d[0] = byte(min(255, int(s[2])+int(d[0])*(255-a)/255))
63			d[1] = byte(min(255, int(s[1])+int(d[1])*(255-a)/255))
64			d[2] = byte(min(255, int(s[0])+int(d[2])*(255-a)/255))
65		}
66	}
67}

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