v0.13.0 976176a

mouse_gestures.go RawHistoryFolder

1package webkit
2
3import (
4	"log"
5
6	"github.com/diamondburned/gotk4/pkg/gtk/v4"
7)
8
9// Mouse button constants for navigation
10// Standard button numbers (consistent across Wayland and GTK)
11const (
12	mouseButtonBack    = 8 // Side button (back)
13	mouseButtonForward = 9 // Side button (forward)
14)
15
16// AttachMouseGestures attaches mouse button gesture handling to the WebView
17// This enables hardware mouse button navigation (back/forward buttons)
18func (w *WebView) AttachMouseGestures() {
19	if w.view == nil {
20		log.Printf("[mouse-gestures] Cannot attach: WebView is nil")
21		return
22	}
23
24	// Create gesture controller for mouse clicks
25	gestureClick := gtk.NewGestureClick()
26
27	// Listen to all mouse buttons (0 = any button)
28	gestureClick.SetButton(0)
29
30	// Set to capture phase to intercept before WebView processes
31	gestureClick.SetPropagationPhase(gtk.PhaseCapture)
32
33	// Connect to pressed signal
34	gestureClick.ConnectPressed(func(nPress int, x, y float64) {
35		// Get which button was pressed
36		button := gestureClick.CurrentButton()
37
38		// Only handle single clicks (not double/triple clicks)
39		if nPress != 1 {
40			return
41		}
42
43		switch button {
44		case mouseButtonBack:
45			// Mouse back button - navigate backward
46			if w.view.CanGoBack() {
47				log.Printf("[mouse-gestures] Back button clicked - navigating backward")
48				w.view.GoBack()
49			} else {
50				log.Printf("[mouse-gestures] Back button clicked but cannot go back")
51			}
52
53		case mouseButtonForward:
54			// Mouse forward button - navigate forward
55			if w.view.CanGoForward() {
56				log.Printf("[mouse-gestures] Forward button clicked - navigating forward")
57				w.view.GoForward()
58			} else {
59				log.Printf("[mouse-gestures] Forward button clicked but cannot go forward")
60			}
61
62		default:
63			// Don't handle other buttons (let WebView handle normally)
64			return
65		}
66	})
67
68	// Attach controller to WebView
69	w.view.AddController(gestureClick)
70	log.Printf("[mouse-gestures] Mouse gesture controller attached to WebView ID %d", w.id)
71}

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