v0.9.0 636c44c

script_cgo.go RawHistoryFolder

1//go:build webkit_cgo
2
3package webkit
4
5/*
6#cgo pkg-config: webkitgtk-6.0 gtk4
7#cgo CFLAGS: -I/usr/include/webkitgtk-6.0
8#include <stdlib.h>
9#include <webkit/webkit.h>
10*/
11import "C"
12
13import "unsafe"
14
15func (w *WebView) InjectScript(js string) error {
16	if w == nil || w.destroyed || w.native == nil || w.native.wv == nil {
17		return ErrNotImplemented
18	}
19	cjs := C.CString(js)
20	defer C.free(unsafe.Pointer(cjs))
21	// Fire-and-forget evaluation using the modern API
22	// length: -1 (NUL-terminated), world_name/source_uri: NULL, starting_line_number: 0
23	C.webkit_web_view_evaluate_javascript(
24		w.native.wv,
25		(*C.gchar)(cjs),
26		C.gssize(-1),
27		nil, // world_name
28		nil, // source_uri
29		nil, // cancellable
30		nil, // callback
31		nil, // user_data
32	)
33	return nil
34}
35
36// InjectScriptIntoWorld evaluates JavaScript in the specified script world.
37func (w *WebView) InjectScriptIntoWorld(js string, worldName string) error {
38	if w == nil || w.destroyed || w.native == nil || w.native.wv == nil {
39		return ErrNotImplemented
40	}
41	cjs := C.CString(js)
42	defer C.free(unsafe.Pointer(cjs))
43
44	var cworld *C.gchar
45	if worldName != "" {
46		cworld = (*C.gchar)(C.CString(worldName))
47		defer C.free(unsafe.Pointer(cworld))
48	}
49
50	// Evaluate JavaScript in the specified world
51	C.webkit_web_view_evaluate_javascript(
52		w.native.wv,
53		(*C.gchar)(cjs),
54		C.gssize(-1),
55		cworld, // world_name
56		nil,    // source_uri
57		nil,    // cancellable
58		nil,    // callback
59		nil,    // user_data
60	)
61	return nil
62}

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 8

Tags 42

↑↓ moveenter openesc close