v0.2.1 c0399be

gcompletion.go RawHistoryFolder

1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5	"structs"
6	"unsafe"
7
8	"github.com/ebitengine/purego"
9
10	"github.com/bnema/puregotk/pkg/core"
11)
12
13// Specifies the type of the function passed to g_completion_new(). It
14// should return the string corresponding to the given target item.
15// This is used when you use data structures as #GCompletion items.
16type CompletionFunc func(uintptr) string
17
18// Specifies the type of the function passed to
19// g_completion_set_compare(). This is used when you use strings as
20// #GCompletion items.
21type CompletionStrncmpFunc func(string, string, uint) int
22
23// `GCompletion` provides support for automatic completion of a string
24// using any group of target strings. It is typically used for file
25// name completion as is common in many UNIX shells.
26//
27// A `GCompletion` is created using [func@GLib.Completion.new]. Target items are
28// added and removed with [method@GLib.Completion.add_items],
29// [method@GLib.Completion.remove_items] and
30// [method@GLib.Completion.clear_items]. A completion attempt is requested with
31// [method@GLib.Completion.complete] or [method@GLib.Completion.complete_utf8].
32// When no longer needed, the `GCompletion` is freed with
33// [method@GLib.Completion.free].
34//
35// Items in the completion can be simple strings (e.g. filenames), or
36// pointers to arbitrary data structures. If data structures are used
37// you must provide a [type@GLib.CompletionFunc] in [func@GLib.Completion.new],
38// which retrieves the item’s string from the data structure. You can change
39// the way in which strings are compared by setting a different
40// [type@GLib.CompletionStrncmpFunc] in [method@GLib.Completion.set_compare].
41//
42// `GCompletion` has been marked as deprecated, since this API is rarely
43// used and not very actively maintained.
44type Completion struct {
45	_ structs.HostLayout
46
47	Items *List
48
49	Func CompletionFunc
50
51	Prefix uintptr
52
53	Cache *List
54
55	StrncmpFunc CompletionStrncmpFunc
56}
57
58func (x *Completion) GoPointer() uintptr {
59	return uintptr(unsafe.Pointer(x))
60}
61
62var xCompletionAddItems func(uintptr, *List)
63
64// Adds items to the #GCompletion.
65func (x *Completion) AddItems(ItemsVar *List) {
66
67	xCompletionAddItems(x.GoPointer(), ItemsVar)
68
69}
70
71var xCompletionClearItems func(uintptr)
72
73// Removes all items from the #GCompletion. The items are not freed, so if the
74// memory was dynamically allocated, it should be freed after calling this
75// function.
76func (x *Completion) ClearItems() {
77
78	xCompletionClearItems(x.GoPointer())
79
80}
81
82var xCompletionComplete func(uintptr, string, string) *List
83
84// Attempts to complete the string @prefix using the #GCompletion
85// target items.
86func (x *Completion) Complete(PrefixVar string, NewPrefixVar string) *List {
87
88	cret := xCompletionComplete(x.GoPointer(), PrefixVar, NewPrefixVar)
89	return cret
90}
91
92var xCompletionCompleteUtf8 func(uintptr, string, string) *List
93
94// Attempts to complete the string @prefix using the #GCompletion target items.
95// In contrast to g_completion_complete(), this function returns the largest common
96// prefix that is a valid UTF-8 string, omitting a possible common partial
97// character.
98//
99// You should use this function instead of g_completion_complete() if your
100// items are UTF-8 strings.
101func (x *Completion) CompleteUtf8(PrefixVar string, NewPrefixVar string) *List {
102
103	cret := xCompletionCompleteUtf8(x.GoPointer(), PrefixVar, NewPrefixVar)
104	return cret
105}
106
107var xCompletionFree func(uintptr)
108
109// Frees all memory used by the #GCompletion. The items are not freed, so if
110// the memory was dynamically allocated, it should be freed after calling this
111// function.
112func (x *Completion) Free() {
113
114	xCompletionFree(x.GoPointer())
115
116}
117
118var xCompletionRemoveItems func(uintptr, *List)
119
120// Removes items from a #GCompletion. The items are not freed, so if the memory
121// was dynamically allocated, free @items with g_list_free_full() after calling
122// this function.
123func (x *Completion) RemoveItems(ItemsVar *List) {
124
125	xCompletionRemoveItems(x.GoPointer(), ItemsVar)
126
127}
128
129var xCompletionSetCompare func(uintptr, uintptr)
130
131// Sets the function to use for string comparisons. The default string
132// comparison function is strncmp().
133func (x *Completion) SetCompare(StrncmpFuncVar *CompletionStrncmpFunc) {
134
135	var StrncmpFuncVarRef uintptr
136	if StrncmpFuncVar != nil {
137		StrncmpFuncVarPtr := uintptr(unsafe.Pointer(StrncmpFuncVar))
138		if cbRefPtr, ok := GetCallback(StrncmpFuncVarPtr); ok {
139			StrncmpFuncVarRef = cbRefPtr
140		} else {
141			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uint) int {
142				cbFn := *StrncmpFuncVar
143				return cbFn(core.GoString(arg0), core.GoString(arg1), arg2)
144			}
145			StrncmpFuncVarRef = purego.NewCallback(fcb)
146			SaveCallbackWithClosure(StrncmpFuncVarPtr, StrncmpFuncVarRef, StrncmpFuncVar)
147		}
148	}
149
150	xCompletionSetCompare(x.GoPointer(), StrncmpFuncVarRef)
151
152}
153
154func init() {
155	core.SetPackageName("GLIB", "glib-2.0")
156	core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
157	var libs []uintptr
158	for _, libPath := range core.GetPaths("GLIB") {
159		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
160		if err != nil {
161			panic(err)
162		}
163		libs = append(libs, lib)
164	}
165
166	core.PuregoSafeRegister(&xCompletionAddItems, libs, "g_completion_add_items")
167	core.PuregoSafeRegister(&xCompletionClearItems, libs, "g_completion_clear_items")
168	core.PuregoSafeRegister(&xCompletionComplete, libs, "g_completion_complete")
169	core.PuregoSafeRegister(&xCompletionCompleteUtf8, libs, "g_completion_complete_utf8")
170	core.PuregoSafeRegister(&xCompletionFree, libs, "g_completion_free")
171	core.PuregoSafeRegister(&xCompletionRemoveItems, libs, "g_completion_remove_items")
172	core.PuregoSafeRegister(&xCompletionSetCompare, libs, "g_completion_set_compare")
173
174}

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