v0.1.1 ac96fe0

lib.go RawHistoryFolder

1package server
2
3import (
4	"fmt"
5	"sync"
6	"unsafe"
7
8	"github.com/bnema/purego"
9)
10
11// libwayland-server entry points. Only non-varargs functions are bound.
12var (
13	wlDisplayCreate         func() uintptr
14	wlDisplayDestroy        func(display uintptr)
15	wlDisplayDestroyClients func(display uintptr)
16	wlDisplayAddSocketFD    func(display uintptr, fd int32) int32
17	wlDisplayGetEventLoop   func(display uintptr) uintptr
18	wlDisplayFlushClients   func(display uintptr)
19	wlEventLoopDispatch     func(loop uintptr, timeout int32) int32
20	wlEventLoopGetFD        func(loop uintptr) int32
21	wlEventLoopAddFD        func(loop uintptr, fd int32, mask uint32, fn, data uintptr) uintptr
22	wlEventSourceRemove     func(source uintptr) int32
23	wlGlobalCreate          func(display, iface uintptr, version int32, data uintptr, bind uintptr) uintptr
24	wlGlobalRemove          func(global uintptr)
25	wlResourceCreate        func(client, iface uintptr, version int32, id uint32) uintptr
26	wlResourceSetDispatcher func(resource, dispatcher, impl, data, destroy uintptr)
27	wlResourcePostEventArr  func(resource uintptr, opcode uint32, args unsafe.Pointer)
28	wlResourcePostError     func(resource uintptr, code uint32, msg uintptr)
29	wlResourceDestroy       func(resource uintptr)
30	wlResourceGetID         func(resource uintptr) uint32
31	wlResourceGetClient     func(resource uintptr) uintptr
32	wlResourceGetVersion    func(resource uintptr) int32
33	wlClientGetCredentials  func(client uintptr, pid, uid, gid unsafe.Pointer)
34)
35
36var (
37	loadOnce sync.Once
38	loadErr  error
39
40	// Shared C callbacks. purego callbacks are never freed, so there is one
41	// of each for the whole process.
42	cbDispatcher uintptr
43	cbDestroy    uintptr
44	cbBind       uintptr
45	cbWake       uintptr
46)
47
48func load() error {
49	loadOnce.Do(func() {
50		lib, err := purego.Dlopen("libwayland-server.so.0", purego.RTLD_NOW|purego.RTLD_GLOBAL)
51		if err != nil {
52			loadErr = fmt.Errorf("purego-libwayland: open libwayland-server.so.0: %w", err)
53			return
54		}
55		defer func() {
56			if r := recover(); r != nil {
57				loadErr = fmt.Errorf("purego-libwayland: %v", r)
58			}
59		}()
60		reg := func(fptr any, name string) { purego.RegisterLibFunc(fptr, lib, name) }
61		reg(&wlDisplayCreate, "wl_display_create")
62		reg(&wlDisplayDestroy, "wl_display_destroy")
63		reg(&wlDisplayDestroyClients, "wl_display_destroy_clients")
64		reg(&wlDisplayAddSocketFD, "wl_display_add_socket_fd")
65		reg(&wlDisplayGetEventLoop, "wl_display_get_event_loop")
66		reg(&wlDisplayFlushClients, "wl_display_flush_clients")
67		reg(&wlEventLoopDispatch, "wl_event_loop_dispatch")
68		reg(&wlEventLoopGetFD, "wl_event_loop_get_fd")
69		reg(&wlEventLoopAddFD, "wl_event_loop_add_fd")
70		reg(&wlEventSourceRemove, "wl_event_source_remove")
71		reg(&wlGlobalCreate, "wl_global_create")
72		reg(&wlGlobalRemove, "wl_global_remove")
73		reg(&wlResourceCreate, "wl_resource_create")
74		reg(&wlResourceSetDispatcher, "wl_resource_set_dispatcher")
75		reg(&wlResourcePostEventArr, "wl_resource_post_event_array")
76		reg(&wlResourcePostError, "wl_resource_post_error")
77		reg(&wlResourceDestroy, "wl_resource_destroy")
78		reg(&wlResourceGetID, "wl_resource_get_id")
79		reg(&wlResourceGetClient, "wl_resource_get_client")
80		reg(&wlResourceGetVersion, "wl_resource_get_version")
81		reg(&wlClientGetCredentials, "wl_client_get_credentials")
82
83		cbDispatcher = purego.NewCallback(dispatch)
84		cbDestroy = purego.NewCallback(destroyed)
85		cbBind = purego.NewCallback(bind)
86		cbWake = purego.NewCallback(wake)
87	})
88	return loadErr
89}

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 14

↑↓ moveenter openesc close