GUI fields now trim leading and trailing whitespace:

This commit is contained in:
Dmitry Sergeev
2026-09-02 00:23:03 +03:00
parent e7b032ce77
commit da5ff8ea4a
9 changed files with 200 additions and 15 deletions
+26 -2
View File
@@ -63,8 +63,11 @@ var (
sdlGetAudioPlaybackDevices func(count *int32) uintptr
sdlGetAudioDeviceName func(devid uint32) uintptr
sdlStartTextInput func(window uintptr)
sdlStopTextInput func(window uintptr)
sdlStartTextInput func(window uintptr)
sdlStopTextInput func(window uintptr)
sdlGetClipboardText func() uintptr
sdlSetClipboardText func(text *byte) bool
sdlFree func(memory uintptr)
)
var loaded = false
@@ -98,6 +101,9 @@ func Load() error {
// input
purego.RegisterLibFunc(&sdlStartTextInput, h, "SDL_StartTextInput")
purego.RegisterLibFunc(&sdlStopTextInput, h, "SDL_StopTextInput")
purego.RegisterLibFunc(&sdlGetClipboardText, h, "SDL_GetClipboardText")
purego.RegisterLibFunc(&sdlSetClipboardText, h, "SDL_SetClipboardText")
purego.RegisterLibFunc(&sdlFree, h, "SDL_free")
loaded = true
return nil
}
@@ -197,3 +203,21 @@ func GetAudioPlaybackDevices() []AudioDevice {
// Input wrappers
func StartTextInput(window uintptr) { sdlStartTextInput(window) }
func StopTextInput(window uintptr) { sdlStopTextInput(window) }
func GetClipboardText() string {
text := sdlGetClipboardText()
if text == 0 {
return ""
}
result := cstr(text)
sdlFree(text)
return result
}
func SetClipboardText(text string) bool {
bytes := make([]byte, len(text)+1)
copy(bytes, text)
result := sdlSetClipboardText(&bytes[0])
runtime.KeepAlive(bytes)
return result
}