v0.2.1 c0399be

gstring.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	"github.com/bnema/puregotk/v4/gobject/types"
12)
13
14// A `GString` is an object that handles the memory management of a C string.
15//
16// The emphasis of `GString` is on text, typically UTF-8. Crucially, the "str" member
17// of a `GString` is guaranteed to have a trailing nul character, and it is therefore
18// always safe to call functions such as `strchr()` or `strdup()` on it.
19//
20// However, a `GString` can also hold arbitrary binary data, because it has a "len" member,
21// which includes any possible embedded nul characters in the data. Conceptually then,
22// `GString` is like a `GByteArray` with the addition of many convenience methods for
23// text, and a guaranteed nul terminator.
24type String struct {
25	_ structs.HostLayout
26
27	Str uintptr
28
29	Len uint
30
31	AllocatedLen uint
32}
33
34var xStringGLibType func() types.GType
35
36func StringGLibType() types.GType {
37	return xStringGLibType()
38}
39
40func (x *String) GoPointer() uintptr {
41	return uintptr(unsafe.Pointer(x))
42}
43
44var xNewString func(uintptr) *String
45
46// Creates a new #GString, initialized with the given string.
47func NewString(InitVar *string) *String {
48
49	InitVarPtr := core.GStrdupNullable(InitVar)
50	defer core.GFreeNullable(InitVarPtr)
51
52	cret := xNewString(InitVarPtr)
53	return cret
54}
55
56var xNewStringLen func(string, int) *String
57
58// Creates a new #GString with @len bytes of the @init buffer.
59// Because a length is provided, @init need not be nul-terminated,
60// and can contain embedded nul bytes.
61//
62// Since this function does not stop at nul bytes, it is the caller's
63// responsibility to ensure that @init has at least @len addressable
64// bytes.
65func NewStringLen(InitVar string, LenVar int) *String {
66
67	cret := xNewStringLen(InitVar, LenVar)
68	return cret
69}
70
71var xNewStringTake func(uintptr) *String
72
73// Creates a new #GString, initialized with the given string.
74//
75// After this call, @init belongs to the #GString and may no longer be
76// modified by the caller. The memory of @init has to be dynamically
77// allocated and will eventually be freed with g_free().
78func NewStringTake(InitVar *string) *String {
79
80	cret := xNewStringTake(core.GStrdupNullable(InitVar))
81	return cret
82}
83
84var xStringSizedNew func(uint) *String
85
86// Creates a new #GString, with enough space for @dfl_size
87// bytes. This is useful if you are going to add a lot of
88// text to the string and don't want it to be reallocated
89// too often.
90func StringSizedNew(DflSizeVar uint) *String {
91
92	cret := xStringSizedNew(DflSizeVar)
93	return cret
94}
95
96var xStringAppend func(uintptr, string) *String
97
98// Adds a string onto the end of a #GString, expanding
99// it if necessary.
100func (x *String) Append(ValVar string) *String {
101
102	cret := xStringAppend(x.GoPointer(), ValVar)
103	return cret
104}
105
106var xStringAppendC func(uintptr, byte) *String
107
108// Adds a byte onto the end of a #GString, expanding
109// it if necessary.
110func (x *String) AppendC(CVar byte) *String {
111
112	cret := xStringAppendC(x.GoPointer(), CVar)
113	return cret
114}
115
116var xStringAppendLen func(uintptr, string, int) *String
117
118// Appends @len bytes of @val to @string.
119//
120// If @len is positive, @val may contain embedded nuls and need
121// not be nul-terminated. It is the caller's responsibility to
122// ensure that @val has at least @len addressable bytes.
123//
124// If @len is negative, @val must be nul-terminated and @len
125// is considered to request the entire string length. This
126// makes g_string_append_len() equivalent to g_string_append().
127func (x *String) AppendLen(ValVar string, LenVar int) *String {
128
129	cret := xStringAppendLen(x.GoPointer(), ValVar, LenVar)
130	return cret
131}
132
133var xStringAppendPrintf func(uintptr, string, ...interface{})
134
135// Appends a formatted string onto the end of a #GString.
136// This function is similar to g_string_printf() except
137// that the text is appended to the #GString.
138func (x *String) AppendPrintf(FormatVar string, varArgs ...interface{}) {
139
140	xStringAppendPrintf(x.GoPointer(), FormatVar, varArgs...)
141
142}
143
144var xStringAppendUnichar func(uintptr, uint32) *String
145
146// Converts a Unicode character into UTF-8, and appends it
147// to the string.
148func (x *String) AppendUnichar(WcVar uint32) *String {
149
150	cret := xStringAppendUnichar(x.GoPointer(), WcVar)
151	return cret
152}
153
154var xStringAppendUriEscaped func(uintptr, string, string, bool) *String
155
156// Appends @unescaped to @string, escaping any characters that
157// are reserved in URIs using URI-style escape sequences.
158func (x *String) AppendUriEscaped(UnescapedVar string, ReservedCharsAllowedVar string, AllowUtf8Var bool) *String {
159
160	cret := xStringAppendUriEscaped(x.GoPointer(), UnescapedVar, ReservedCharsAllowedVar, AllowUtf8Var)
161	return cret
162}
163
164var xStringAppendVprintf func(uintptr, string, []interface{})
165
166// Appends a formatted string onto the end of a #GString.
167// This function is similar to g_string_append_printf()
168// except that the arguments to the format string are passed
169// as a va_list.
170func (x *String) AppendVprintf(FormatVar string, ArgsVar []interface{}) {
171
172	xStringAppendVprintf(x.GoPointer(), FormatVar, ArgsVar)
173
174}
175
176var xStringAsciiDown func(uintptr) *String
177
178// Converts all uppercase ASCII letters to lowercase ASCII letters.
179func (x *String) AsciiDown() *String {
180
181	cret := xStringAsciiDown(x.GoPointer())
182	return cret
183}
184
185var xStringAsciiUp func(uintptr) *String
186
187// Converts all lowercase ASCII letters to uppercase ASCII letters.
188func (x *String) AsciiUp() *String {
189
190	cret := xStringAsciiUp(x.GoPointer())
191	return cret
192}
193
194var xStringAssign func(uintptr, string) *String
195
196// Copies the bytes from a string into a #GString,
197// destroying any previous contents. It is rather like
198// the standard strcpy() function, except that you do not
199// have to worry about having enough space to copy the string.
200func (x *String) Assign(RvalVar string) *String {
201
202	cret := xStringAssign(x.GoPointer(), RvalVar)
203	return cret
204}
205
206var xStringCopy func(uintptr) *String
207
208// Copies the [struct@GLib.String] instance and its contents.
209//
210// This will preserve the allocation length of the [struct@GLib.String] in the
211// copy.
212func (x *String) Copy() *String {
213
214	cret := xStringCopy(x.GoPointer())
215	return cret
216}
217
218var xStringDown func(uintptr) *String
219
220// Converts a #GString to lowercase.
221func (x *String) Down() *String {
222
223	cret := xStringDown(x.GoPointer())
224	return cret
225}
226
227var xStringEqual func(uintptr, *String) bool
228
229// Compares two strings for equality, returning %TRUE if they are equal.
230// For use with #GHashTable.
231func (x *String) Equal(V2Var *String) bool {
232
233	cret := xStringEqual(x.GoPointer(), V2Var)
234	return cret
235}
236
237var xStringErase func(uintptr, int, int) *String
238
239// Removes @len bytes from a #GString, starting at position @pos.
240// The rest of the #GString is shifted down to fill the gap.
241func (x *String) Erase(PosVar int, LenVar int) *String {
242
243	cret := xStringErase(x.GoPointer(), PosVar, LenVar)
244	return cret
245}
246
247var xStringFree func(uintptr, bool) string
248
249// Frees the memory allocated for the #GString.
250// If @free_segment is %TRUE it also frees the character data.  If
251// it's %FALSE, the caller gains ownership of the buffer and must
252// free it after use with g_free().
253//
254// Instead of passing %FALSE to this function, consider using
255// g_string_free_and_steal().
256func (x *String) Free(FreeSegmentVar bool) string {
257
258	cret := xStringFree(x.GoPointer(), FreeSegmentVar)
259	return cret
260}
261
262var xStringFreeAndSteal func(uintptr) string
263
264// Frees the memory allocated for the #GString.
265//
266// The caller gains ownership of the buffer and
267// must free it after use with g_free().
268func (x *String) FreeAndSteal() string {
269
270	cret := xStringFreeAndSteal(x.GoPointer())
271	return cret
272}
273
274var xStringFreeToBytes func(uintptr) *Bytes
275
276// Transfers ownership of the contents of @string to a newly allocated
277// #GBytes.  The #GString structure itself is deallocated, and it is
278// therefore invalid to use @string after invoking this function.
279//
280// Note that while #GString ensures that its buffer always has a
281// trailing nul character (not reflected in its "len"), the returned
282// #GBytes does not include this extra nul; i.e. it has length exactly
283// equal to the "len" member.
284func (x *String) FreeToBytes() *Bytes {
285
286	cret := xStringFreeToBytes(x.GoPointer())
287	return cret
288}
289
290var xStringHash func(uintptr) uint
291
292// Creates a hash code for @str; for use with #GHashTable.
293func (x *String) Hash() uint {
294
295	cret := xStringHash(x.GoPointer())
296	return cret
297}
298
299var xStringInsert func(uintptr, int, string) *String
300
301// Inserts a copy of a string into a #GString,
302// expanding it if necessary.
303func (x *String) Insert(PosVar int, ValVar string) *String {
304
305	cret := xStringInsert(x.GoPointer(), PosVar, ValVar)
306	return cret
307}
308
309var xStringInsertC func(uintptr, int, byte) *String
310
311// Inserts a byte into a #GString, expanding it if necessary.
312func (x *String) InsertC(PosVar int, CVar byte) *String {
313
314	cret := xStringInsertC(x.GoPointer(), PosVar, CVar)
315	return cret
316}
317
318var xStringInsertLen func(uintptr, int, string, int) *String
319
320// Inserts @len bytes of @val into @string at @pos.
321//
322// If @len is positive, @val may contain embedded nuls and need
323// not be nul-terminated. It is the caller's responsibility to
324// ensure that @val has at least @len addressable bytes.
325//
326// If @len is negative, @val must be nul-terminated and @len
327// is considered to request the entire string length.
328//
329// If @pos is -1, bytes are inserted at the end of the string.
330func (x *String) InsertLen(PosVar int, ValVar string, LenVar int) *String {
331
332	cret := xStringInsertLen(x.GoPointer(), PosVar, ValVar, LenVar)
333	return cret
334}
335
336var xStringInsertUnichar func(uintptr, int, uint32) *String
337
338// Converts a Unicode character into UTF-8, and insert it
339// into the string at the given position.
340func (x *String) InsertUnichar(PosVar int, WcVar uint32) *String {
341
342	cret := xStringInsertUnichar(x.GoPointer(), PosVar, WcVar)
343	return cret
344}
345
346var xStringOverwrite func(uintptr, uint, string) *String
347
348// Overwrites part of a string, lengthening it if necessary.
349func (x *String) Overwrite(PosVar uint, ValVar string) *String {
350
351	cret := xStringOverwrite(x.GoPointer(), PosVar, ValVar)
352	return cret
353}
354
355var xStringOverwriteLen func(uintptr, uint, string, int) *String
356
357// Overwrites part of a string, lengthening it if necessary.
358// This function will work with embedded nuls.
359func (x *String) OverwriteLen(PosVar uint, ValVar string, LenVar int) *String {
360
361	cret := xStringOverwriteLen(x.GoPointer(), PosVar, ValVar, LenVar)
362	return cret
363}
364
365var xStringPrepend func(uintptr, string) *String
366
367// Adds a string on to the start of a #GString,
368// expanding it if necessary.
369func (x *String) Prepend(ValVar string) *String {
370
371	cret := xStringPrepend(x.GoPointer(), ValVar)
372	return cret
373}
374
375var xStringPrependC func(uintptr, byte) *String
376
377// Adds a byte onto the start of a #GString,
378// expanding it if necessary.
379func (x *String) PrependC(CVar byte) *String {
380
381	cret := xStringPrependC(x.GoPointer(), CVar)
382	return cret
383}
384
385var xStringPrependLen func(uintptr, string, int) *String
386
387// Prepends @len bytes of @val to @string.
388//
389// If @len is positive, @val may contain embedded nuls and need
390// not be nul-terminated. It is the caller's responsibility to
391// ensure that @val has at least @len addressable bytes.
392//
393// If @len is negative, @val must be nul-terminated and @len
394// is considered to request the entire string length. This
395// makes g_string_prepend_len() equivalent to g_string_prepend().
396func (x *String) PrependLen(ValVar string, LenVar int) *String {
397
398	cret := xStringPrependLen(x.GoPointer(), ValVar, LenVar)
399	return cret
400}
401
402var xStringPrependUnichar func(uintptr, uint32) *String
403
404// Converts a Unicode character into UTF-8, and prepends it
405// to the string.
406func (x *String) PrependUnichar(WcVar uint32) *String {
407
408	cret := xStringPrependUnichar(x.GoPointer(), WcVar)
409	return cret
410}
411
412var xStringPrintf func(uintptr, string, ...interface{})
413
414// Writes a formatted string into a #GString.
415// This is similar to the standard sprintf() function,
416// except that the #GString buffer automatically expands
417// to contain the results. The previous contents of the
418// #GString are destroyed.
419func (x *String) Printf(FormatVar string, varArgs ...interface{}) {
420
421	xStringPrintf(x.GoPointer(), FormatVar, varArgs...)
422
423}
424
425var xStringReplace func(uintptr, string, string, uint) uint
426
427// Replaces the string @find with the string @replace in a #GString up to
428// @limit times. If the number of instances of @find in the #GString is
429// less than @limit, all instances are replaced. If @limit is `0`,
430// all instances of @find are replaced.
431//
432// If @find is the empty string, since versions 2.69.1 and 2.68.4 the
433// replacement will be inserted no more than once per possible position
434// (beginning of string, end of string and between characters). This did
435// not work correctly in earlier versions.
436func (x *String) Replace(FindVar string, ReplaceVar string, LimitVar uint) uint {
437
438	cret := xStringReplace(x.GoPointer(), FindVar, ReplaceVar, LimitVar)
439	return cret
440}
441
442var xStringSetSize func(uintptr, uint) *String
443
444// Sets the length of a #GString. If the length is less than
445// the current length, the string will be truncated. If the
446// length is greater than the current length, the contents
447// of the newly added area are undefined. (However, as
448// always, string->str[string->len] will be a nul byte.)
449func (x *String) SetSize(LenVar uint) *String {
450
451	cret := xStringSetSize(x.GoPointer(), LenVar)
452	return cret
453}
454
455var xStringTruncate func(uintptr, uint) *String
456
457// Cuts off the end of the GString, leaving the first @len bytes.
458func (x *String) Truncate(LenVar uint) *String {
459
460	cret := xStringTruncate(x.GoPointer(), LenVar)
461	return cret
462}
463
464var xStringUp func(uintptr) *String
465
466// Converts a #GString to uppercase.
467func (x *String) Up() *String {
468
469	cret := xStringUp(x.GoPointer())
470	return cret
471}
472
473var xStringVprintf func(uintptr, string, []interface{})
474
475// Writes a formatted string into a #GString.
476// This function is similar to g_string_printf() except that
477// the arguments to the format string are passed as a va_list.
478func (x *String) Vprintf(FormatVar string, ArgsVar []interface{}) {
479
480	xStringVprintf(x.GoPointer(), FormatVar, ArgsVar)
481
482}
483
484func init() {
485	core.SetPackageName("GLIB", "glib-2.0")
486	core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
487	var libs []uintptr
488	for _, libPath := range core.GetPaths("GLIB") {
489		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
490		if err != nil {
491			panic(err)
492		}
493		libs = append(libs, lib)
494	}
495
496	core.PuregoSafeRegister(&xStringGLibType, libs, "g_gstring_get_type")
497
498	core.PuregoSafeRegister(&xNewString, libs, "g_string_new")
499	core.PuregoSafeRegister(&xNewStringLen, libs, "g_string_new_len")
500	core.PuregoSafeRegister(&xNewStringTake, libs, "g_string_new_take")
501	core.PuregoSafeRegister(&xStringSizedNew, libs, "g_string_sized_new")
502
503	core.PuregoSafeRegister(&xStringAppend, libs, "g_string_append")
504	core.PuregoSafeRegister(&xStringAppendC, libs, "g_string_append_c")
505	core.PuregoSafeRegister(&xStringAppendLen, libs, "g_string_append_len")
506	core.PuregoSafeRegister(&xStringAppendPrintf, libs, "g_string_append_printf")
507	core.PuregoSafeRegister(&xStringAppendUnichar, libs, "g_string_append_unichar")
508	core.PuregoSafeRegister(&xStringAppendUriEscaped, libs, "g_string_append_uri_escaped")
509	core.PuregoSafeRegister(&xStringAppendVprintf, libs, "g_string_append_vprintf")
510	core.PuregoSafeRegister(&xStringAsciiDown, libs, "g_string_ascii_down")
511	core.PuregoSafeRegister(&xStringAsciiUp, libs, "g_string_ascii_up")
512	core.PuregoSafeRegister(&xStringAssign, libs, "g_string_assign")
513	core.PuregoSafeRegister(&xStringCopy, libs, "g_string_copy")
514	core.PuregoSafeRegister(&xStringDown, libs, "g_string_down")
515	core.PuregoSafeRegister(&xStringEqual, libs, "g_string_equal")
516	core.PuregoSafeRegister(&xStringErase, libs, "g_string_erase")
517	core.PuregoSafeRegister(&xStringFree, libs, "g_string_free")
518	core.PuregoSafeRegister(&xStringFreeAndSteal, libs, "g_string_free_and_steal")
519	core.PuregoSafeRegister(&xStringFreeToBytes, libs, "g_string_free_to_bytes")
520	core.PuregoSafeRegister(&xStringHash, libs, "g_string_hash")
521	core.PuregoSafeRegister(&xStringInsert, libs, "g_string_insert")
522	core.PuregoSafeRegister(&xStringInsertC, libs, "g_string_insert_c")
523	core.PuregoSafeRegister(&xStringInsertLen, libs, "g_string_insert_len")
524	core.PuregoSafeRegister(&xStringInsertUnichar, libs, "g_string_insert_unichar")
525	core.PuregoSafeRegister(&xStringOverwrite, libs, "g_string_overwrite")
526	core.PuregoSafeRegister(&xStringOverwriteLen, libs, "g_string_overwrite_len")
527	core.PuregoSafeRegister(&xStringPrepend, libs, "g_string_prepend")
528	core.PuregoSafeRegister(&xStringPrependC, libs, "g_string_prepend_c")
529	core.PuregoSafeRegister(&xStringPrependLen, libs, "g_string_prepend_len")
530	core.PuregoSafeRegister(&xStringPrependUnichar, libs, "g_string_prepend_unichar")
531	core.PuregoSafeRegister(&xStringPrintf, libs, "g_string_printf")
532	core.PuregoSafeRegister(&xStringReplace, libs, "g_string_replace")
533	core.PuregoSafeRegister(&xStringSetSize, libs, "g_string_set_size")
534	core.PuregoSafeRegister(&xStringTruncate, libs, "g_string_truncate")
535	core.PuregoSafeRegister(&xStringUp, libs, "g_string_up")
536	core.PuregoSafeRegister(&xStringVprintf, libs, "g_string_vprintf")
537
538}

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