From 41c0b6386752e5798f8b0c571a7fbfa8b0269118 Mon Sep 17 00:00:00 2001 From: shadow cat Date: Mon, 17 Nov 2025 22:28:23 -0500 Subject: [PATCH] ime preedit --- iris | 2 +- src/client/mod.rs | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/iris b/iris index 7e257fd..4981bd7 160000 --- a/iris +++ b/iris @@ -1 +1 @@ -Subproject commit 7e257fd0420f17e4d80496be320e0dd279b19003 +Subproject commit 4981bd739a987e2140a9924b1ad2128800cd4501 diff --git a/src/client/mod.rs b/src/client/mod.rs index ffd2847..96930ba 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -39,6 +39,7 @@ pub struct Client { data: ClientData, handle: AppHandle, error: Option>, + ime: usize, } impl Client { @@ -58,6 +59,7 @@ impl Client { username: "".to_string(), clipboard: Clipboard::new().unwrap(), error: None, + ime: 0, }; ui::init(&mut s); s @@ -145,16 +147,22 @@ impl Client { } } } - WindowEvent::Ime(ime) => match ime { - Ime::Enabled | Ime::Disabled => (), - Ime::Preedit(_, _) => (), - Ime::Commit(content) => { - if let Some(sel) = &self.focus { - let mut text = self.ui.text(sel); - text.insert(&content); + WindowEvent::Ime(ime) => { + if let Some(sel) = &self.focus { + let mut text = self.ui.text(sel); + match ime { + Ime::Enabled | Ime::Disabled => (), + Ime::Preedit(content, _pos) => { + // TODO: highlight once that's real + text.replace(self.ime, &content); + self.ime = content.chars().count(); + } + Ime::Commit(content) => { + text.insert(&content); + } } } - }, + } _ => (), } if self.ui.needs_redraw() {