v0.2.1 c0399be

pangocairo.go RawHistoryFolder

1// Package pangocairo was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package pangocairo
3
4import (
5	"unsafe"
6
7	"github.com/ebitengine/purego"
8
9	"github.com/bnema/puregotk/pkg/core"
10	"github.com/bnema/puregotk/v4/cairo"
11	"github.com/bnema/puregotk/v4/glib"
12	"github.com/bnema/puregotk/v4/gobject"
13	"github.com/bnema/puregotk/v4/gobject/types"
14	"github.com/bnema/puregotk/v4/pango"
15)
16
17// Function type for rendering attributes of type %PANGO_ATTR_SHAPE
18// with Pango's Cairo renderer.
19type ShapeRendererFunc func(*cairo.Context, *pango.AttrShape, bool, uintptr)
20
21// `PangoCairoFont` is an interface exported by fonts for
22// use with Cairo.
23//
24// The actual type of the font will depend on the particular
25// font technology Cairo was compiled to use.
26type Font interface {
27	GoPointer() uintptr
28	SetGoPointer(uintptr)
29	GetScaledFont() *cairo.ScaledFont
30}
31
32var xFontGLibType func() types.GType
33
34func FontGLibType() types.GType {
35	return xFontGLibType()
36}
37
38type FontBase struct {
39	Ptr uintptr
40}
41
42func (x *FontBase) GoPointer() uintptr {
43	if x == nil {
44		return 0
45	}
46	return x.Ptr
47}
48
49func (x *FontBase) SetGoPointer(ptr uintptr) {
50	x.Ptr = ptr
51}
52
53// Gets the `cairo_scaled_font_t` used by @font.
54// The scaled font can be referenced and kept using
55// cairo_scaled_font_reference().
56func (x *FontBase) GetScaledFont() *cairo.ScaledFont {
57
58	cret := XPangoCairoFontGetScaledFont(x.GoPointer())
59	return cret
60}
61
62var XPangoCairoFontGetScaledFont func(uintptr) *cairo.ScaledFont
63
64// `PangoCairoFontMap` is an interface exported by font maps for
65// use with Cairo.
66//
67// The actual type of the font map will depend on the particular
68// font technology Cairo was compiled to use.
69type FontMap interface {
70	GoPointer() uintptr
71	SetGoPointer(uintptr)
72	CreateContext() *pango.Context
73	GetFontType() cairo.FontType
74	GetResolution() float64
75	SetDefault()
76	SetResolution(DpiVar float64)
77}
78
79var xFontMapGLibType func() types.GType
80
81func FontMapGLibType() types.GType {
82	return xFontMapGLibType()
83}
84
85type FontMapBase struct {
86	Ptr uintptr
87}
88
89func (x *FontMapBase) GoPointer() uintptr {
90	if x == nil {
91		return 0
92	}
93	return x.Ptr
94}
95
96func (x *FontMapBase) SetGoPointer(ptr uintptr) {
97	x.Ptr = ptr
98}
99
100// Create a `PangoContext` for the given fontmap.
101func (x *FontMapBase) CreateContext() *pango.Context {
102	var cls *pango.Context
103
104	cret := XPangoCairoFontMapCreateContext(x.GoPointer())
105
106	if cret == 0 {
107		return nil
108	}
109	cls = &pango.Context{}
110	cls.Ptr = cret
111	return cls
112}
113
114// Gets the type of Cairo font backend that @fontmap uses.
115func (x *FontMapBase) GetFontType() cairo.FontType {
116
117	cret := XPangoCairoFontMapGetFontType(x.GoPointer())
118	return cret
119}
120
121// Gets the resolution for the fontmap.
122//
123// See [method@PangoCairo.FontMap.set_resolution].
124func (x *FontMapBase) GetResolution() float64 {
125
126	cret := XPangoCairoFontMapGetResolution(x.GoPointer())
127	return cret
128}
129
130// Sets a default `PangoCairoFontMap` to use with Cairo.
131//
132// This can be used to change the Cairo font backend that the
133// default fontmap uses for example. The old default font map
134// is unreffed and the new font map referenced.
135//
136// Note that since Pango 1.32.6, the default fontmap is per-thread.
137// This function only changes the default fontmap for
138// the current thread. Default fontmaps of existing threads
139// are not changed. Default fontmaps of any new threads will
140// still be created using [func@PangoCairo.FontMap.new].
141//
142// A value of %NULL for @fontmap will cause the current default
143// font map to be released and a new default font map to be created
144// on demand, using [func@PangoCairo.FontMap.new].
145func (x *FontMapBase) SetDefault() {
146
147	XPangoCairoFontMapSetDefault(x.GoPointer())
148
149}
150
151// Sets the resolution for the fontmap.
152//
153// This is a scale factor between
154// points specified in a `PangoFontDescription` and Cairo units. The
155// default value is 96, meaning that a 10 point font will be 13
156// units high. (10 * 96. / 72. = 13.3).
157func (x *FontMapBase) SetResolution(DpiVar float64) {
158
159	XPangoCairoFontMapSetResolution(x.GoPointer(), DpiVar)
160
161}
162
163var XPangoCairoFontMapCreateContext func(uintptr) uintptr
164var XPangoCairoFontMapGetFontType func(uintptr) cairo.FontType
165var XPangoCairoFontMapGetResolution func(uintptr) float64
166var XPangoCairoFontMapSetDefault func(uintptr)
167var XPangoCairoFontMapSetResolution func(uintptr, float64)
168
169var xContextGetFontOptions func(uintptr) *cairo.FontOptions
170
171// Retrieves any font rendering options previously set with
172// [func@PangoCairo.context_set_font_options].
173//
174// This function does not report options that are derived from
175// the target surface by [func@update_context].
176func ContextGetFontOptions(ContextVar *pango.Context) *cairo.FontOptions {
177
178	cret := xContextGetFontOptions(ContextVar.GoPointer())
179	return cret
180}
181
182var xContextGetResolution func(uintptr) float64
183
184// Gets the resolution for the context.
185//
186// See [func@PangoCairo.context_set_resolution]
187func ContextGetResolution(ContextVar *pango.Context) float64 {
188
189	cret := xContextGetResolution(ContextVar.GoPointer())
190	return cret
191}
192
193var xContextGetShapeRenderer func(uintptr, uintptr) uintptr
194
195// Sets callback function for context to use for rendering attributes
196// of type %PANGO_ATTR_SHAPE.
197//
198// See `PangoCairoShapeRendererFunc` for details.
199//
200// Retrieves callback function and associated user data for rendering
201// attributes of type %PANGO_ATTR_SHAPE as set by
202// [func@PangoCairo.context_set_shape_renderer], if any.
203func ContextGetShapeRenderer(ContextVar *pango.Context, DataVar uintptr) uintptr {
204
205	cret := xContextGetShapeRenderer(ContextVar.GoPointer(), DataVar)
206	return cret
207}
208
209var xContextSetFontOptions func(uintptr, *cairo.FontOptions)
210
211// Sets the font options used when rendering text with this context.
212//
213// These options override any options that [func@update_context]
214// derives from the target surface.
215func ContextSetFontOptions(ContextVar *pango.Context, OptionsVar *cairo.FontOptions) {
216
217	xContextSetFontOptions(ContextVar.GoPointer(), OptionsVar)
218
219}
220
221var xContextSetResolution func(uintptr, float64)
222
223// Sets the resolution for the context.
224//
225// This is a scale factor between points specified in a `PangoFontDescription`
226// and Cairo units. The default value is 96, meaning that a 10 point font will
227// be 13 units high. (10 * 96. / 72. = 13.3).
228func ContextSetResolution(ContextVar *pango.Context, DpiVar float64) {
229
230	xContextSetResolution(ContextVar.GoPointer(), DpiVar)
231
232}
233
234var xContextSetShapeRenderer func(uintptr, uintptr, uintptr, uintptr)
235
236// Sets callback function for context to use for rendering attributes
237// of type %PANGO_ATTR_SHAPE.
238//
239// See `PangoCairoShapeRendererFunc` for details.
240func ContextSetShapeRenderer(ContextVar *pango.Context, FuncVar *ShapeRendererFunc, DataVar uintptr, DnotifyVar *glib.DestroyNotify) {
241
242	var FuncVarRef uintptr
243	if FuncVar != nil {
244		FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
245		if cbRefPtr, ok := glib.GetCallback(FuncVarPtr); ok {
246			FuncVarRef = cbRefPtr
247		} else {
248			fcb := func(arg0 *cairo.Context, arg1 *pango.AttrShape, arg2 bool, arg3 uintptr) {
249				cbFn := *FuncVar
250				cbFn(arg0, arg1, arg2, arg3)
251			}
252			FuncVarRef = purego.NewCallback(fcb)
253			glib.SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
254		}
255	}
256
257	var DnotifyVarRef uintptr
258	if DnotifyVar != nil {
259		DnotifyVarPtr := uintptr(unsafe.Pointer(DnotifyVar))
260		if cbRefPtr, ok := glib.GetCallback(DnotifyVarPtr); ok {
261			DnotifyVarRef = cbRefPtr
262		} else {
263			fcb := func(arg0 uintptr) {
264				cbFn := *DnotifyVar
265				cbFn(arg0)
266			}
267			DnotifyVarRef = purego.NewCallback(fcb)
268			glib.SaveCallbackWithClosure(DnotifyVarPtr, DnotifyVarRef, DnotifyVar)
269		}
270	}
271
272	xContextSetShapeRenderer(ContextVar.GoPointer(), FuncVarRef, DataVar, DnotifyVarRef)
273
274}
275
276var xCreateContext func(*cairo.Context) uintptr
277
278// Creates a context object set up to match the current transformation
279// and target surface of the Cairo context.
280//
281// This context can then be
282// used to create a layout using [ctor@Pango.Layout.new].
283//
284// This function is a convenience function that creates a context using
285// the default font map, then updates it to @cr. If you just need to
286// create a layout for use with @cr and do not need to access `PangoContext`
287// directly, you can use [func@create_layout] instead.
288func CreateContext(CrVar *cairo.Context) *pango.Context {
289	var cls *pango.Context
290
291	cret := xCreateContext(CrVar)
292
293	if cret == 0 {
294		return nil
295	}
296	cls = &pango.Context{}
297	cls.Ptr = cret
298	return cls
299}
300
301var xCreateLayout func(*cairo.Context) uintptr
302
303// Creates a layout object set up to match the current transformation
304// and target surface of the Cairo context.
305//
306// This layout can then be used for text measurement with functions
307// like [method@Pango.Layout.get_size] or drawing with functions like
308// [func@show_layout]. If you change the transformation or target
309// surface for @cr, you need to call [func@update_layout].
310//
311// This function is the most convenient way to use Cairo with Pango,
312// however it is slightly inefficient since it creates a separate
313// `PangoContext` object for each layout. This might matter in an
314// application that was laying out large amounts of text.
315func CreateLayout(CrVar *cairo.Context) *pango.Layout {
316	var cls *pango.Layout
317
318	cret := xCreateLayout(CrVar)
319
320	if cret == 0 {
321		return nil
322	}
323	cls = &pango.Layout{}
324	cls.Ptr = cret
325	return cls
326}
327
328var xErrorUnderlinePath func(*cairo.Context, float64, float64, float64, float64)
329
330// Add a squiggly line to the current path in the specified cairo context that
331// approximately covers the given rectangle in the style of an underline used
332// to indicate a spelling error.
333//
334// The width of the underline is rounded to an integer number of up/down
335// segments and the resulting rectangle is centered in the original rectangle.
336func ErrorUnderlinePath(CrVar *cairo.Context, XVar float64, YVar float64, WidthVar float64, HeightVar float64) {
337
338	xErrorUnderlinePath(CrVar, XVar, YVar, WidthVar, HeightVar)
339
340}
341
342var xFontMapGetDefault func() uintptr
343
344// Gets a default `PangoCairoFontMap` to use with Cairo.
345//
346// Note that the type of the returned object will depend on the
347// particular font backend Cairo was compiled to use; you generally
348// should only use the `PangoFontMap` and `PangoCairoFontMap`
349// interfaces on the returned object.
350//
351// The default Cairo fontmap can be changed by using
352// [method@PangoCairo.FontMap.set_default]. This can be used to
353// change the Cairo font backend that the default fontmap uses
354// for example.
355//
356// Note that since Pango 1.32.6, the default fontmap is per-thread.
357// Each thread gets its own default fontmap. In this way, PangoCairo
358// can be used safely from multiple threads.
359func FontMapGetDefault() *pango.FontMap {
360	var cls *pango.FontMap
361
362	cret := xFontMapGetDefault()
363
364	if cret == 0 {
365		return nil
366	}
367	gobject.IncreaseRef(cret)
368	cls = &pango.FontMap{}
369	cls.Ptr = cret
370	return cls
371}
372
373var xFontMapNew func() uintptr
374
375// Creates a new `PangoCairoFontMap` object.
376//
377// A fontmap is used to cache information about available fonts,
378// and holds certain global parameters such as the resolution.
379// In most cases, you can use `func@PangoCairo.font_map_get_default]
380// instead.
381//
382// Note that the type of the returned object will depend
383// on the particular font backend Cairo was compiled to use;
384// You generally should only use the `PangoFontMap` and
385// `PangoCairoFontMap` interfaces on the returned object.
386//
387// You can override the type of backend returned by using an
388// environment variable %PANGOCAIRO_BACKEND. Supported types,
389// based on your build, are fc (fontconfig), win32, and coretext.
390// If requested type is not available, NULL is returned. Ie.
391// this is only useful for testing, when at least two backends
392// are compiled in.
393func FontMapNew() *pango.FontMap {
394	var cls *pango.FontMap
395
396	cret := xFontMapNew()
397
398	if cret == 0 {
399		return nil
400	}
401	cls = &pango.FontMap{}
402	cls.Ptr = cret
403	return cls
404}
405
406var xFontMapNewForFontType func(cairo.FontType) uintptr
407
408// Creates a new `PangoCairoFontMap` object of the type suitable
409// to be used with cairo font backend of type @fonttype.
410//
411// In most cases one should simply use [func@PangoCairo.FontMap.new], or
412// in fact in most of those cases, just use [func@PangoCairo.FontMap.get_default].
413func FontMapNewForFontType(FonttypeVar cairo.FontType) *pango.FontMap {
414	var cls *pango.FontMap
415
416	cret := xFontMapNewForFontType(FonttypeVar)
417
418	if cret == 0 {
419		return nil
420	}
421	cls = &pango.FontMap{}
422	cls.Ptr = cret
423	return cls
424}
425
426var xGlyphStringPath func(*cairo.Context, uintptr, *pango.GlyphString)
427
428// Adds the glyphs in @glyphs to the current path in the specified
429// cairo context.
430//
431// The origin of the glyphs (the left edge of the baseline)
432// will be at the current point of the cairo context.
433func GlyphStringPath(CrVar *cairo.Context, FontVar *pango.Font, GlyphsVar *pango.GlyphString) {
434
435	xGlyphStringPath(CrVar, FontVar.GoPointer(), GlyphsVar)
436
437}
438
439var xLayoutLinePath func(*cairo.Context, *pango.LayoutLine)
440
441// Adds the text in `PangoLayoutLine` to the current path in the
442// specified cairo context.
443//
444// The origin of the glyphs (the left edge of the line) will be
445// at the current point of the cairo context.
446func LayoutLinePath(CrVar *cairo.Context, LineVar *pango.LayoutLine) {
447
448	xLayoutLinePath(CrVar, LineVar)
449
450}
451
452var xLayoutPath func(*cairo.Context, uintptr)
453
454// Adds the text in a `PangoLayout` to the current path in the
455// specified cairo context.
456//
457// The top-left corner of the `PangoLayout` will be at the
458// current point of the cairo context.
459func LayoutPath(CrVar *cairo.Context, LayoutVar *pango.Layout) {
460
461	xLayoutPath(CrVar, LayoutVar.GoPointer())
462
463}
464
465var xShowErrorUnderline func(*cairo.Context, float64, float64, float64, float64)
466
467// Draw a squiggly line in the specified cairo context that approximately
468// covers the given rectangle in the style of an underline used to indicate a
469// spelling error.
470//
471// The width of the underline is rounded to an integer
472// number of up/down segments and the resulting rectangle is centered in the
473// original rectangle.
474func ShowErrorUnderline(CrVar *cairo.Context, XVar float64, YVar float64, WidthVar float64, HeightVar float64) {
475
476	xShowErrorUnderline(CrVar, XVar, YVar, WidthVar, HeightVar)
477
478}
479
480var xShowGlyphItem func(*cairo.Context, string, *pango.GlyphItem)
481
482// Draws the glyphs in @glyph_item in the specified cairo context,
483//
484// embedding the text associated with the glyphs in the output if the
485// output format supports it (PDF for example), otherwise it acts
486// similar to [func@show_glyph_string].
487//
488// The origin of the glyphs (the left edge of the baseline) will
489// be drawn at the current point of the cairo context.
490//
491// Note that @text is the start of the text for layout, which is then
492// indexed by `glyph_item->item->offset`.
493func ShowGlyphItem(CrVar *cairo.Context, TextVar string, GlyphItemVar *pango.GlyphItem) {
494
495	xShowGlyphItem(CrVar, TextVar, GlyphItemVar)
496
497}
498
499var xShowGlyphString func(*cairo.Context, uintptr, *pango.GlyphString)
500
501// Draws the glyphs in @glyphs in the specified cairo context.
502//
503// The origin of the glyphs (the left edge of the baseline) will
504// be drawn at the current point of the cairo context.
505func ShowGlyphString(CrVar *cairo.Context, FontVar *pango.Font, GlyphsVar *pango.GlyphString) {
506
507	xShowGlyphString(CrVar, FontVar.GoPointer(), GlyphsVar)
508
509}
510
511var xShowLayout func(*cairo.Context, uintptr)
512
513// Draws a `PangoLayout` in the specified cairo context.
514//
515// The top-left corner of the `PangoLayout` will be drawn
516// at the current point of the cairo context.
517func ShowLayout(CrVar *cairo.Context, LayoutVar *pango.Layout) {
518
519	xShowLayout(CrVar, LayoutVar.GoPointer())
520
521}
522
523var xShowLayoutLine func(*cairo.Context, *pango.LayoutLine)
524
525// Draws a `PangoLayoutLine` in the specified cairo context.
526//
527// The origin of the glyphs (the left edge of the line) will
528// be drawn at the current point of the cairo context.
529func ShowLayoutLine(CrVar *cairo.Context, LineVar *pango.LayoutLine) {
530
531	xShowLayoutLine(CrVar, LineVar)
532
533}
534
535var xUpdateContext func(*cairo.Context, uintptr)
536
537// Updates a `PangoContext` previously created for use with Cairo to
538// match the current transformation and target surface of a Cairo
539// context.
540//
541// If any layouts have been created for the context, it's necessary
542// to call [method@Pango.Layout.context_changed] on those layouts.
543func UpdateContext(CrVar *cairo.Context, ContextVar *pango.Context) {
544
545	xUpdateContext(CrVar, ContextVar.GoPointer())
546
547}
548
549var xUpdateLayout func(*cairo.Context, uintptr)
550
551// Updates the private `PangoContext` of a `PangoLayout` created with
552// [func@create_layout] to match the current transformation and target
553// surface of a Cairo context.
554func UpdateLayout(CrVar *cairo.Context, LayoutVar *pango.Layout) {
555
556	xUpdateLayout(CrVar, LayoutVar.GoPointer())
557
558}
559
560func init() {
561	core.SetPackageName("PANGOCAIRO", "pangocairo")
562	core.SetSharedLibraries("PANGOCAIRO", []string{"libpangocairo-1.0.so.0"})
563	var libs []uintptr
564	for _, libPath := range core.GetPaths("PANGOCAIRO") {
565		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
566		if err != nil {
567			panic(err)
568		}
569		libs = append(libs, lib)
570	}
571
572	core.PuregoSafeRegister(&xContextGetFontOptions, libs, "pango_cairo_context_get_font_options")
573	core.PuregoSafeRegister(&xContextGetResolution, libs, "pango_cairo_context_get_resolution")
574	core.PuregoSafeRegister(&xContextGetShapeRenderer, libs, "pango_cairo_context_get_shape_renderer")
575	core.PuregoSafeRegister(&xContextSetFontOptions, libs, "pango_cairo_context_set_font_options")
576	core.PuregoSafeRegister(&xContextSetResolution, libs, "pango_cairo_context_set_resolution")
577	core.PuregoSafeRegister(&xContextSetShapeRenderer, libs, "pango_cairo_context_set_shape_renderer")
578	core.PuregoSafeRegister(&xCreateContext, libs, "pango_cairo_create_context")
579	core.PuregoSafeRegister(&xCreateLayout, libs, "pango_cairo_create_layout")
580	core.PuregoSafeRegister(&xErrorUnderlinePath, libs, "pango_cairo_error_underline_path")
581	core.PuregoSafeRegister(&xFontMapGetDefault, libs, "pango_cairo_font_map_get_default")
582	core.PuregoSafeRegister(&xFontMapNew, libs, "pango_cairo_font_map_new")
583	core.PuregoSafeRegister(&xFontMapNewForFontType, libs, "pango_cairo_font_map_new_for_font_type")
584	core.PuregoSafeRegister(&xGlyphStringPath, libs, "pango_cairo_glyph_string_path")
585	core.PuregoSafeRegister(&xLayoutLinePath, libs, "pango_cairo_layout_line_path")
586	core.PuregoSafeRegister(&xLayoutPath, libs, "pango_cairo_layout_path")
587	core.PuregoSafeRegister(&xShowErrorUnderline, libs, "pango_cairo_show_error_underline")
588	core.PuregoSafeRegister(&xShowGlyphItem, libs, "pango_cairo_show_glyph_item")
589	core.PuregoSafeRegister(&xShowGlyphString, libs, "pango_cairo_show_glyph_string")
590	core.PuregoSafeRegister(&xShowLayout, libs, "pango_cairo_show_layout")
591	core.PuregoSafeRegister(&xShowLayoutLine, libs, "pango_cairo_show_layout_line")
592	core.PuregoSafeRegister(&xUpdateContext, libs, "pango_cairo_update_context")
593	core.PuregoSafeRegister(&xUpdateLayout, libs, "pango_cairo_update_layout")
594
595	core.PuregoSafeRegister(&xFontGLibType, libs, "pango_cairo_font_get_type")
596
597	core.PuregoSafeRegister(&XPangoCairoFontGetScaledFont, libs, "pango_cairo_font_get_scaled_font")
598
599	core.PuregoSafeRegister(&xFontMapGLibType, libs, "pango_cairo_font_map_get_type")
600
601	core.PuregoSafeRegister(&XPangoCairoFontMapCreateContext, libs, "pango_cairo_font_map_create_context")
602	core.PuregoSafeRegister(&XPangoCairoFontMapGetFontType, libs, "pango_cairo_font_map_get_font_type")
603	core.PuregoSafeRegister(&XPangoCairoFontMapGetResolution, libs, "pango_cairo_font_map_get_resolution")
604	core.PuregoSafeRegister(&XPangoCairoFontMapSetDefault, libs, "pango_cairo_font_map_set_default")
605	core.PuregoSafeRegister(&XPangoCairoFontMapSetResolution, libs, "pango_cairo_font_map_set_resolution")
606
607}

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