app: [Android] move UTF-16 to UTF-32 conversion routines to Go

They're easier to test and can be re-used for macOS/Windows.

While here, add a Go 1.18 build tag to app/ime_test.go; it relies
on Go 1.18 fuzzing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-02-09 20:27:36 +01:00
parent ef9e4071e7
commit 98b02176db
4 changed files with 117 additions and 59 deletions
+14
View File
@@ -1081,6 +1081,20 @@ func Java_org_gioui_GioView_imeReplace(env *C.JNIEnv, class C.jclass, handle C.j
w.callbacks.EditorReplace(r, text)
}
//export Java_org_gioui_GioView_imeToRunes
func Java_org_gioui_GioView_imeToRunes(env *C.JNIEnv, class C.jclass, handle C.jlong, chars C.jint) C.jint {
w := views[handle]
state := w.callbacks.EditorState()
return C.jint(state.RunesIndex(int(chars)))
}
//export Java_org_gioui_GioView_imeToUTF16
func Java_org_gioui_GioView_imeToUTF16(env *C.JNIEnv, class C.jclass, handle C.jlong, runes C.jint) C.jint {
w := views[handle]
state := w.callbacks.EditorState()
return C.jint(state.UTF16Index(int(runes)))
}
func (w *window) EditorStateChanged(old, new editorState) {
runInJVM(javaVM(), func(env *C.JNIEnv) {
if old.Snippet != new.Snippet {