From 12b7af908c8ddb840c87597c9d2bb5ec7eb94751 Mon Sep 17 00:00:00 2001 From: Konstantin8105 Date: Fri, 25 Nov 2022 11:53:20 +0300 Subject: [PATCH] add TextBoxMulti --- raygui3_5/raygui.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/raygui3_5/raygui.go b/raygui3_5/raygui.go index 5138ed9..1a6ed39 100644 --- a/raygui3_5/raygui.go +++ b/raygui3_5/raygui.go @@ -1135,11 +1135,33 @@ func TextInputBox(bounds rl.Rectangle, title, message, buttons string, text *str return int32(C.TextInputBox(cbounds, ctitle, cmessage, cbuttons, &ctext, textMaxSize, &csecretViewActive)) } +// Text Box control with multiple lines +func TextBoxMulti(bounds rl.Rectangle, text *string, textSize int32, editMode bool) bool { + var cbounds C.struct_Rectangle + cbounds.x = C.float(bounds.X) + cbounds.y = C.float(bounds.Y) + cbounds.width = C.float(bounds.Width) + cbounds.height = C.float(bounds.Height) + + bs := []byte(*text) + if 0 < len(bs) && bs[len(bs)-1] != byte(0) { // minimalize allocation + bs = append(bs, byte(0)) // for next input symbols + } + ctext := (*C.char)(unsafe.Pointer(&bs[0])) + defer func() { + *text = strings.TrimSpace(string(bs)) + // no need : C.free(unsafe.Pointer(ctext)) + }() + + ctextSize := (C.int)(textSize) + ceditMode := (C.bool)(editMode) + + return bool(C.GuiTextBoxMulti(cbounds, &ctext, ctextSize, ceditMode)) +} + // List View with extended parameters // Warning (*ast.FunctionDecl): {prefix: n:GuiListViewEx,t1:int (Rectangle, const char **, int, int *, int *, int),t2:}. C4GO/tests/raylib/raygui.h:551 :cannot transpileFunctionDecl. cannot bindingFunctionDecl func `GuiListViewEx`. cannot parse C type: `const char **` -// Warning (*ast.FunctionDecl): {prefix: n:GuiTextBoxMulti,t1:_Bool (Rectangle, char *, int, _Bool),t2:}. C4GO/tests/raylib/raygui.h:541 :cannot transpileFunctionDecl. cannot bindingFunctionDecl func `GuiTextBoxMulti`. cannot parse C type: `_Bool` - // Check Box control, returns true when active // Warning (*ast.FunctionDecl): {prefix: n:GuiCheckBox,t1:_Bool (Rectangle, const char *, _Bool),t2:}. C4GO/tests/raylib/raygui.h:535 :cannot transpileFunctionDecl. cannot bindingFunctionDecl func `GuiCheckBox`. cannot parse C type: `_Bool`