mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
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:
+3
-2
@@ -407,11 +407,12 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
|
|||||||
comp.Start = state.RunesIndex(state.UTF16Index(comp.Start) + start)
|
comp.Start = state.RunesIndex(state.UTF16Index(comp.Start) + start)
|
||||||
}
|
}
|
||||||
w.w.SetComposingRegion(comp)
|
w.w.SetComposingRegion(comp)
|
||||||
|
pos := end
|
||||||
if lParam&windows.GCS_CURSORPOS != 0 {
|
if lParam&windows.GCS_CURSORPOS != 0 {
|
||||||
rel := windows.ImmGetCompositionValue(imc, windows.GCS_CURSORPOS)
|
rel := windows.ImmGetCompositionValue(imc, windows.GCS_CURSORPOS)
|
||||||
pos := state.RunesIndex(state.UTF16Index(rng.Start) + rel)
|
pos = state.RunesIndex(state.UTF16Index(rng.Start) + rel)
|
||||||
w.w.SetEditorSelection(key.Range{Start: pos, End: pos})
|
|
||||||
}
|
}
|
||||||
|
w.w.SetEditorSelection(key.Range{Start: pos, End: pos})
|
||||||
return windows.TRUE
|
return windows.TRUE
|
||||||
case windows.WM_IME_ENDCOMPOSITION:
|
case windows.WM_IME_ENDCOMPOSITION:
|
||||||
w.w.SetComposingRegion(key.Range{Start: -1, End: -1})
|
w.w.SetComposingRegion(key.Range{Start: -1, End: -1})
|
||||||
|
|||||||
Reference in New Issue
Block a user