detached 908d8c0

loader.go RawHistoryFolder

1package xkbcommon
2
3import (
4	"fmt"
5	"sync"
6
7	"github.com/bnema/purego"
8	"github.com/bnema/purego-xkbcommon/raw"
9)
10
11var loader struct {
12	sync.Once
13	f   raw.Funcs
14	err error
15}
16
17// resolveLibrary keeps path and required symbols injectable for diagnostic tests.
18// On success it leaves the library open for the lifetime of resolved function addresses.
19func resolveLibrary(path string, symbols []string) (map[string]uintptr, error) {
20	lib, err := purego.Dlopen(path, purego.RTLD_NOW|purego.RTLD_LOCAL)
21	if err != nil {
22		return nil, fmt.Errorf("xkbcommon: load %s: %w", path, err)
23	}
24	addresses := make(map[string]uintptr, len(symbols))
25	for _, name := range symbols {
26		address, e := purego.Dlsym(lib, name)
27		if e != nil || address == 0 {
28			_ = purego.Dlclose(lib)
29			return nil, fmt.Errorf("xkbcommon: incompatible %s: missing %s: %v", path, name, e)
30		}
31		addresses[name] = address
32	}
33	return addresses, nil
34}
35
36// Available resolves the SONAME and every required symbol, reporting the first
37// incompatible symbol rather than failing later in a keyboard event callback.
38func Available() error {
39	loader.Do(func() {
40		addresses, err := resolveLibrary("libxkbcommon.so.0", raw.Symbols)
41		if err != nil {
42			loader.err = err
43			return
44		}
45		raw.Register(&loader.f, addresses)
46		// Intentionally keep the library open: resolved function addresses and live
47		// native objects remain valid for the process lifetime.
48	})
49	return loader.err
50}

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 2

↑↓ moveenter openesc close