app: [macOS] implement IME support

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-02-09 16:10:12 +01:00
parent 98b02176db
commit b162ed56d7
3 changed files with 210 additions and 5 deletions
+5 -2
View File
@@ -149,6 +149,7 @@ func NewWindow(options ...Option) *Window {
dead: make(chan struct{}),
nocontext: cnf.CustomRenderer,
}
w.imeState.compose = key.Range{Start: -1, End: -1}
w.semantic.ids = make(map[router.SemanticID]router.SemanticNode)
w.callbacks.w = w
go w.run(options)
@@ -521,8 +522,10 @@ func (e *editorState) Replace(r key.Range, text string) {
}
e.Selection.Start = adjust(e.Selection.Start)
e.Selection.End = adjust(e.Selection.End)
e.compose.Start = adjust(e.compose.Start)
e.compose.End = adjust(e.compose.End)
if e.compose.Start != -1 {
e.compose.Start = adjust(e.compose.Start)
e.compose.End = adjust(e.compose.End)
}
s := e.Snippet
if r.End < s.Start || r.Start > s.End {
// Replacement does not overlap snippet.