ime preedit

This commit is contained in:
2025-11-17 22:28:23 -05:00
parent b18ea96100
commit 41c0b63867
2 changed files with 17 additions and 9 deletions

2
iris

Submodule iris updated: 7e257fd042...4981bd739a

View File

@@ -39,6 +39,7 @@ pub struct Client {
data: ClientData, data: ClientData,
handle: AppHandle, handle: AppHandle,
error: Option<WidgetId<WidgetPtr>>, error: Option<WidgetId<WidgetPtr>>,
ime: usize,
} }
impl Client { impl Client {
@@ -58,6 +59,7 @@ impl Client {
username: "<unknown>".to_string(), username: "<unknown>".to_string(),
clipboard: Clipboard::new().unwrap(), clipboard: Clipboard::new().unwrap(),
error: None, error: None,
ime: 0,
}; };
ui::init(&mut s); ui::init(&mut s);
s s
@@ -145,16 +147,22 @@ impl Client {
} }
} }
} }
WindowEvent::Ime(ime) => match ime { WindowEvent::Ime(ime) => {
Ime::Enabled | Ime::Disabled => (),
Ime::Preedit(_, _) => (),
Ime::Commit(content) => {
if let Some(sel) = &self.focus { if let Some(sel) = &self.focus {
let mut text = self.ui.text(sel); 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); text.insert(&content);
} }
} }
}, }
}
_ => (), _ => (),
} }
if self.ui.needs_redraw() { if self.ui.needs_redraw() {