v0.2.1 c0399be

kind.go RawHistoryFolder

1package types
2
3import (
4	"strings"
5
6	"github.com/bnema/puregotk/internal/gir/util"
7)
8
9type Kind int8
10
11const (
12	UnknownType Kind = iota
13	AliasType
14	CallbackType
15	ClassesType
16	InterfacesType
17	RecordsType
18	SliceType
19	OtherType
20)
21
22type KindMap map[string]KindPair
23
24func (km KindMap) key(ns string, name string) string {
25	return util.NormalizeNamespace(ns, name, false)
26}
27
28func (km KindMap) Add(ns string, name string, t Kind, v interface{}) {
29	k := km.key(ns, name)
30	km[k] = KindPair{
31		K:     t,
32		Value: v,
33	}
34}
35
36func (km KindMap) pair(ns string, name string) KindPair {
37	f := util.NormalizeNamespace(ns, name, false)
38	return km[f]
39}
40
41func (km KindMap) Kind(ns string, name string) Kind {
42	if strings.HasPrefix(name, "[") {
43		return SliceType
44	}
45	return km.pair(ns, name).K
46}
47
48func (km KindMap) MustInterface(ns string, name string) Interface {
49	p := km.pair(ns, name)
50	if p.K != InterfacesType {
51		panic("value is not an interface")
52	}
53	return p.Value.(Interface)
54}
55
56// GetCallback retrieves a callback definition by namespace and name.
57// Returns the Callback and true if found, otherwise nil and false.
58func (km KindMap) GetCallback(ns string, name string) (Callback, bool) {
59	p := km.pair(ns, name)
60	if p.K != CallbackType {
61		return Callback{}, false
62	}
63	cb, ok := p.Value.(Callback)
64	return cb, ok
65}
66
67type KindPair struct {
68	K     Kind
69	Value interface{}
70}

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 102

↑↓ moveenter openesc close