GUI fields now trim leading and trailing whitespace:
This commit is contained in:
+26
-2
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user