383 lines
12 KiB
Go
383 lines
12 KiB
Go
// Generated by `wit-bindgen` 0.57.1. DO NOT EDIT!
|
|
//
|
|
// This code was generated from the following packages:
|
|
// pumpkin:plugin@0.1.0
|
|
|
|
package pumpkin_plugin_text
|
|
|
|
import (
|
|
"github.com/Pumpkin-MC/pumpkin-api-go/pkg/pumpkin_plugin_common"
|
|
witRuntime "go.bytecodealliance.org/pkg/wit/runtime"
|
|
witTypes "go.bytecodealliance.org/pkg/wit/types"
|
|
"runtime"
|
|
"unsafe"
|
|
)
|
|
|
|
type NamedColor = pumpkin_plugin_common.NamedColor
|
|
type RgbColor = pumpkin_plugin_common.RgbColor
|
|
type ArgbColor = pumpkin_plugin_common.ArgbColor
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [resource-drop]text-component
|
|
func resourceDropTextComponent(handle int32)
|
|
|
|
type TextComponent struct {
|
|
handle *witRuntime.Handle
|
|
}
|
|
|
|
func (self *TextComponent) TakeHandle() int32 {
|
|
return self.handle.Take()
|
|
}
|
|
|
|
func (self *TextComponent) SetHandle(handle int32) {
|
|
self.handle.Set(handle)
|
|
}
|
|
|
|
func (self *TextComponent) Handle() int32 {
|
|
return self.handle.Use()
|
|
}
|
|
|
|
func (self *TextComponent) Drop() {
|
|
handle := self.handle.TakeOrNil()
|
|
if handle != 0 {
|
|
resourceDropTextComponent(handle)
|
|
}
|
|
}
|
|
|
|
func TextComponentFromOwnHandle(handleValue int32) *TextComponent {
|
|
handle := witRuntime.MakeHandle(handleValue)
|
|
value := &TextComponent{handle}
|
|
runtime.AddCleanup(value, func(_ int) {
|
|
handleValue := handle.TakeOrNil()
|
|
if handleValue != 0 {
|
|
resourceDropTextComponent(handleValue)
|
|
}
|
|
}, 0)
|
|
return value
|
|
}
|
|
|
|
func TextComponentFromBorrowHandle(handleValue int32) *TextComponent {
|
|
handle := witRuntime.MakeHandle(handleValue)
|
|
return &TextComponent{handle}
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [static]text-component.text
|
|
func wasm_import_static_text_component_text(arg0 uintptr, arg1 uint32) int32
|
|
|
|
func TextComponentText(plain string) *TextComponent {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
utf8 := unsafe.Pointer(unsafe.StringData(plain))
|
|
pinner.Pin(utf8)
|
|
result := wasm_import_static_text_component_text(uintptr(utf8), uint32(len(plain)))
|
|
return TextComponentFromOwnHandle(int32(uintptr(result)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [static]text-component.translate
|
|
func wasm_import_static_text_component_translate(arg0 uintptr, arg1 uint32, arg2 uintptr, arg3 uint32) int32
|
|
|
|
func TextComponentTranslate(key string, with []*TextComponent) *TextComponent {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
utf8 := unsafe.Pointer(unsafe.StringData(key))
|
|
pinner.Pin(utf8)
|
|
slice := with
|
|
length := uint32(len(slice))
|
|
result := witRuntime.Allocate(pinner, uintptr(length*4), 4)
|
|
for index, element := range slice {
|
|
base := unsafe.Add(result, index*4)
|
|
*(*int32)(unsafe.Add(unsafe.Pointer(base), 0)) = (element).TakeHandle()
|
|
|
|
}
|
|
|
|
result0 := wasm_import_static_text_component_translate(uintptr(utf8), uint32(len(key)), uintptr(result), length)
|
|
return TextComponentFromOwnHandle(int32(uintptr(result0)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.add-child
|
|
func wasm_import_method_text_component_add_child(arg0 int32, arg1 int32)
|
|
|
|
func (self *TextComponent) AddChild(child *TextComponent) {
|
|
|
|
wasm_import_method_text_component_add_child((self).Handle(), (child).TakeHandle())
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.add-text
|
|
func wasm_import_method_text_component_add_text(arg0 int32, arg1 uintptr, arg2 uint32)
|
|
|
|
func (self *TextComponent) AddText(text string) {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
utf8 := unsafe.Pointer(unsafe.StringData(text))
|
|
pinner.Pin(utf8)
|
|
wasm_import_method_text_component_add_text((self).Handle(), uintptr(utf8), uint32(len(text)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.get-text
|
|
func wasm_import_method_text_component_get_text(arg0 int32, arg1 uintptr)
|
|
|
|
func (self *TextComponent) GetText() string {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
returnArea := uintptr(witRuntime.Allocate(pinner, (2 * 4), 4))
|
|
wasm_import_method_text_component_get_text((self).Handle(), returnArea)
|
|
value := unsafe.String((*uint8)(unsafe.Pointer(uintptr(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 0))))), *(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 4)))
|
|
result := value
|
|
return result
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.encode
|
|
func wasm_import_method_text_component_encode(arg0 int32, arg1 uintptr)
|
|
|
|
func (self *TextComponent) Encode() []uint8 {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
returnArea := uintptr(witRuntime.Allocate(pinner, (2 * 4), 4))
|
|
wasm_import_method_text_component_encode((self).Handle(), returnArea)
|
|
value := unsafe.Slice((*uint8)(unsafe.Pointer(uintptr(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 0))))), *(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 4)))
|
|
result := value
|
|
return result
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.color-named
|
|
func wasm_import_method_text_component_color_named(arg0 int32, arg1 int32)
|
|
|
|
func (self *TextComponent) ColorNamed(color pumpkin_plugin_common.NamedColor) {
|
|
|
|
wasm_import_method_text_component_color_named((self).Handle(), int32(color))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.color-rgb
|
|
func wasm_import_method_text_component_color_rgb(arg0 int32, arg1 int32, arg2 int32, arg3 int32)
|
|
|
|
func (self *TextComponent) ColorRgb(color pumpkin_plugin_common.RgbColor) {
|
|
|
|
wasm_import_method_text_component_color_rgb((self).Handle(), int32((color).R), int32((color).G), int32((color).B))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.bold
|
|
func wasm_import_method_text_component_bold(arg0 int32, arg1 int32)
|
|
|
|
func (self *TextComponent) Bold(value bool) {
|
|
|
|
var result int32
|
|
if value {
|
|
result = 1
|
|
} else {
|
|
result = 0
|
|
}
|
|
wasm_import_method_text_component_bold((self).Handle(), result)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.italic
|
|
func wasm_import_method_text_component_italic(arg0 int32, arg1 int32)
|
|
|
|
func (self *TextComponent) Italic(value bool) {
|
|
|
|
var result int32
|
|
if value {
|
|
result = 1
|
|
} else {
|
|
result = 0
|
|
}
|
|
wasm_import_method_text_component_italic((self).Handle(), result)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.underlined
|
|
func wasm_import_method_text_component_underlined(arg0 int32, arg1 int32)
|
|
|
|
func (self *TextComponent) Underlined(value bool) {
|
|
|
|
var result int32
|
|
if value {
|
|
result = 1
|
|
} else {
|
|
result = 0
|
|
}
|
|
wasm_import_method_text_component_underlined((self).Handle(), result)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.strikethrough
|
|
func wasm_import_method_text_component_strikethrough(arg0 int32, arg1 int32)
|
|
|
|
func (self *TextComponent) Strikethrough(value bool) {
|
|
|
|
var result int32
|
|
if value {
|
|
result = 1
|
|
} else {
|
|
result = 0
|
|
}
|
|
wasm_import_method_text_component_strikethrough((self).Handle(), result)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.obfuscated
|
|
func wasm_import_method_text_component_obfuscated(arg0 int32, arg1 int32)
|
|
|
|
func (self *TextComponent) Obfuscated(value bool) {
|
|
|
|
var result int32
|
|
if value {
|
|
result = 1
|
|
} else {
|
|
result = 0
|
|
}
|
|
wasm_import_method_text_component_obfuscated((self).Handle(), result)
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.insertion
|
|
func wasm_import_method_text_component_insertion(arg0 int32, arg1 uintptr, arg2 uint32)
|
|
|
|
func (self *TextComponent) Insertion(text string) {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
utf8 := unsafe.Pointer(unsafe.StringData(text))
|
|
pinner.Pin(utf8)
|
|
wasm_import_method_text_component_insertion((self).Handle(), uintptr(utf8), uint32(len(text)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.font
|
|
func wasm_import_method_text_component_font(arg0 int32, arg1 uintptr, arg2 uint32)
|
|
|
|
func (self *TextComponent) Font(font string) {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
utf8 := unsafe.Pointer(unsafe.StringData(font))
|
|
pinner.Pin(utf8)
|
|
wasm_import_method_text_component_font((self).Handle(), uintptr(utf8), uint32(len(font)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.shadow-color
|
|
func wasm_import_method_text_component_shadow_color(arg0 int32, arg1 int32, arg2 int32, arg3 int32, arg4 int32)
|
|
|
|
func (self *TextComponent) ShadowColor(color pumpkin_plugin_common.ArgbColor) {
|
|
|
|
wasm_import_method_text_component_shadow_color((self).Handle(), int32((color).A), int32((color).R), int32((color).G), int32((color).B))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.click-open-url
|
|
func wasm_import_method_text_component_click_open_url(arg0 int32, arg1 uintptr, arg2 uint32)
|
|
|
|
func (self *TextComponent) ClickOpenUrl(url string) {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
utf8 := unsafe.Pointer(unsafe.StringData(url))
|
|
pinner.Pin(utf8)
|
|
wasm_import_method_text_component_click_open_url((self).Handle(), uintptr(utf8), uint32(len(url)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.click-run-command
|
|
func wasm_import_method_text_component_click_run_command(arg0 int32, arg1 uintptr, arg2 uint32)
|
|
|
|
func (self *TextComponent) ClickRunCommand(command string) {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
utf8 := unsafe.Pointer(unsafe.StringData(command))
|
|
pinner.Pin(utf8)
|
|
wasm_import_method_text_component_click_run_command((self).Handle(), uintptr(utf8), uint32(len(command)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.click-suggest-command
|
|
func wasm_import_method_text_component_click_suggest_command(arg0 int32, arg1 uintptr, arg2 uint32)
|
|
|
|
func (self *TextComponent) ClickSuggestCommand(command string) {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
utf8 := unsafe.Pointer(unsafe.StringData(command))
|
|
pinner.Pin(utf8)
|
|
wasm_import_method_text_component_click_suggest_command((self).Handle(), uintptr(utf8), uint32(len(command)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.click-copy-to-clipboard
|
|
func wasm_import_method_text_component_click_copy_to_clipboard(arg0 int32, arg1 uintptr, arg2 uint32)
|
|
|
|
func (self *TextComponent) ClickCopyToClipboard(text string) {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
utf8 := unsafe.Pointer(unsafe.StringData(text))
|
|
pinner.Pin(utf8)
|
|
wasm_import_method_text_component_click_copy_to_clipboard((self).Handle(), uintptr(utf8), uint32(len(text)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.hover-show-text
|
|
func wasm_import_method_text_component_hover_show_text(arg0 int32, arg1 int32)
|
|
|
|
func (self *TextComponent) HoverShowText(text *TextComponent) {
|
|
|
|
wasm_import_method_text_component_hover_show_text((self).Handle(), (text).TakeHandle())
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.hover-show-item
|
|
func wasm_import_method_text_component_hover_show_item(arg0 int32, arg1 uintptr, arg2 uint32)
|
|
|
|
func (self *TextComponent) HoverShowItem(item string) {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
utf8 := unsafe.Pointer(unsafe.StringData(item))
|
|
pinner.Pin(utf8)
|
|
wasm_import_method_text_component_hover_show_item((self).Handle(), uintptr(utf8), uint32(len(item)))
|
|
|
|
}
|
|
|
|
//go:wasmimport pumpkin:plugin/text@0.1.0 [method]text-component.hover-show-entity
|
|
func wasm_import_method_text_component_hover_show_entity(arg0 int32, arg1 uintptr, arg2 uint32, arg3 uintptr, arg4 uint32, arg5 int32, arg6 int32)
|
|
|
|
func (self *TextComponent) HoverShowEntity(entityType string, id string, name witTypes.Option[*TextComponent]) {
|
|
pinner := &runtime.Pinner{}
|
|
defer pinner.Unpin()
|
|
|
|
utf8 := unsafe.Pointer(unsafe.StringData(entityType))
|
|
pinner.Pin(utf8)
|
|
utf80 := unsafe.Pointer(unsafe.StringData(id))
|
|
pinner.Pin(utf80)
|
|
var option int32
|
|
var option1 int32
|
|
switch name.Tag() {
|
|
case witTypes.OptionNone:
|
|
|
|
option = int32(0)
|
|
option1 = 0
|
|
case witTypes.OptionSome:
|
|
payload := name.Some()
|
|
|
|
option = int32(1)
|
|
option1 = (payload).TakeHandle()
|
|
default:
|
|
panic("unreachable")
|
|
}
|
|
wasm_import_method_text_component_hover_show_entity((self).Handle(), uintptr(utf8), uint32(len(entityType)), uintptr(utf80), uint32(len(id)), option, option1)
|
|
|
|
}
|