app: fix Windows IME caret positioning

Some IME editors don't send explicit GCS_CURSORPOS messages, in
which case we should assume the cursor moves to the end of the
composition string.

Fixes: https://todo.sr.ht/~eliasnaur/gio/458
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-11-22 07:56:51 -06:00
parent 5c84cf7e90
commit dee53b3645
+3 -2
View File
@@ -407,11 +407,12 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
comp.Start = state.RunesIndex(state.UTF16Index(comp.Start) + start)
}
w.w.SetComposingRegion(comp)
pos := end
if lParam&windows.GCS_CURSORPOS != 0 {
rel := windows.ImmGetCompositionValue(imc, windows.GCS_CURSORPOS)
pos := state.RunesIndex(state.UTF16Index(rng.Start) + rel)
w.w.SetEditorSelection(key.Range{Start: pos, End: pos})
pos = state.RunesIndex(state.UTF16Index(rng.Start) + rel)
}
w.w.SetEditorSelection(key.Range{Start: pos, End: pos})
return windows.TRUE
case windows.WM_IME_ENDCOMPOSITION:
w.w.SetComposingRegion(key.Range{Start: -1, End: -1})