detached 1a6c6c9

table.go RawHistoryFolder

1package linuxdmabuf
2
3import (
4	"encoding/binary"
5	"fmt"
6	"io"
7
8	"github.com/bnema/wlturbo/wl"
9	"golang.org/x/sys/unix"
10)
11
12// FormatEntry is one 16-byte format-table record. Padding is ignored.
13type FormatEntry struct {
14	Format   uint32
15	Modifier uint64
16}
17
18// ReadFormatTable consumes an owned format_table descriptor, even on error.
19// It reads a bounded snapshot with pread rather than mapping compositor-owned
20// memory, avoiding SIGBUS if the backing file is unexpectedly truncated.
21func ReadFormatTable(fd *wl.OwnedFD, size uint32) ([]FormatEntry, error) {
22	if fd == nil {
23		return nil, fmt.Errorf("missing format table descriptor")
24	}
25	n, err := fd.Take()
26	if err != nil {
27		return nil, err
28	}
29	defer unix.Close(n)
30	if size%16 != 0 || size > 16<<20 {
31		return nil, fmt.Errorf("invalid format table size %d", size)
32	}
33	b := make([]byte, size)
34	for off := 0; off < len(b); {
35		read, e := unix.Pread(n, b[off:], int64(off))
36		off += read
37		if e == unix.EINTR {
38			continue
39		}
40		if e != nil {
41			return nil, e
42		}
43		if read == 0 {
44			return nil, io.ErrUnexpectedEOF
45		}
46	}
47	entries := make([]FormatEntry, size/16)
48	for i := range entries {
49		off := i * 16
50		entries[i] = FormatEntry{binary.NativeEndian.Uint32(b[off:]), binary.NativeEndian.Uint64(b[off+8:])}
51	}
52	return entries, nil
53}
54
55// TrancheIndices decodes the uint16 indices into a format table.
56func TrancheIndices(data []byte, count int) ([]uint16, error) {
57	if len(data)%2 != 0 {
58		return nil, fmt.Errorf("odd tranche indices length")
59	}
60	indices := make([]uint16, len(data)/2)
61	for i := range indices {
62		indices[i] = binary.NativeEndian.Uint16(data[i*2:])
63		if int(indices[i]) >= count {
64			return nil, fmt.Errorf("format table index %d out of range", indices[i])
65		}
66	}
67	return indices, nil
68}

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 1

Tags 1

↑↓ moveenter openesc close