v0.33.2 57f21d6

gesture_test.go RawHistoryFolder

1package input
2
3import (
4	"context"
5	"testing"
6
7	"github.com/bnema/puregotk/v4/gtk"
8	"github.com/stretchr/testify/assert"
9)
10
11type testGestureNavigator struct{}
12
13func (testGestureNavigator) GoBackDirect()    {}
14func (testGestureNavigator) GoForwardDirect() {}
15
16func TestGestureHandlerAttachClearsExistingAttachmentState(t *testing.T) {
17	h := NewGestureHandler(context.Background())
18	h.pressedCb = func(gtk.GestureClick, int, float64, float64) {}
19	h.destroyCb = func(gtk.Widget) {}
20	h.pressedHandlerID = 1
21	h.destroyHandlerID = 2
22	h.onAction = func(context.Context, Action) error { return nil }
23	h.navigator = testGestureNavigator{}
24
25	h.detachExistingAttachment()
26
27	assert.Nil(t, h.pressedCb)
28	assert.Nil(t, h.destroyCb)
29	assert.Zero(t, h.pressedHandlerID)
30	assert.Zero(t, h.destroyHandlerID)
31	assert.Nil(t, h.onAction)
32	assert.Nil(t, h.navigator)
33}
34
35func TestGestureHandlerDetachClearsRetainedCallbacksAndState(t *testing.T) {
36	h := NewGestureHandler(context.Background())
37	h.pressedCb = func(gtk.GestureClick, int, float64, float64) {}
38	h.destroyCb = func(gtk.Widget) {}
39	h.pressedHandlerID = 1
40	h.destroyHandlerID = 2
41	h.onAction = func(context.Context, Action) error { return nil }
42	h.navigator = testGestureNavigator{}
43
44	h.Detach()
45
46	assert.Nil(t, h.pressedCb)
47	assert.Nil(t, h.destroyCb)
48	assert.Zero(t, h.pressedHandlerID)
49	assert.Zero(t, h.destroyHandlerID)
50	assert.Nil(t, h.onAction)
51	assert.Nil(t, h.navigator)
52}
53
54func TestGestureHandlerDetachForDestroyClearsRetainedCallbacksAndState(t *testing.T) {
55	h := NewGestureHandler(context.Background())
56	h.pressedCb = func(gtk.GestureClick, int, float64, float64) {}
57	h.destroyCb = func(gtk.Widget) {}
58	h.pressedHandlerID = 1
59	h.destroyHandlerID = 2
60	h.onAction = func(context.Context, Action) error { return nil }
61	h.navigator = testGestureNavigator{}
62
63	h.DetachForDestroy()
64
65	assert.Nil(t, h.pressedCb)
66	assert.Nil(t, h.destroyCb)
67	assert.Zero(t, h.pressedHandlerID)
68	assert.Zero(t, h.destroyHandlerID)
69	assert.Nil(t, h.onAction)
70	assert.Nil(t, h.navigator)
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