From 420a9938eab40c5b16e7bdaf81a8d56fb6d628f7 Mon Sep 17 00:00:00 2001 From: shadow cat Date: Mon, 17 Nov 2025 21:49:01 -0500 Subject: [PATCH] basic ime support --- iris | 2 +- src/client/app.rs | 1 + src/client/mod.rs | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/iris b/iris index c7b255b..7e257fd 160000 --- a/iris +++ b/iris @@ -1 +1 @@ -Subproject commit c7b255be4facfd20c0f261bc8e1380d1a2a38355 +Subproject commit 7e257fd0420f17e4d80496be320e0dd279b19003 diff --git a/src/client/app.rs b/src/client/app.rs index df984b8..788d96e 100644 --- a/src/client/app.rs +++ b/src/client/app.rs @@ -41,6 +41,7 @@ impl ApplicationHandler for App { let window = event_loop .create_window(Window::default_attributes()) .unwrap(); + window.set_ime_allowed(true); let client = Client::new(AppHandle { proxy: self.proxy.clone(), window: window.into(), diff --git a/src/client/mod.rs b/src/client/mod.rs index 48ccc87..ffd2847 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -3,7 +3,10 @@ use arboard::Clipboard; use input::Input; use iris::prelude::*; use render::Renderer; -use winit::{event::WindowEvent, event_loop::ActiveEventLoop}; +use winit::{ + event::{Ime, WindowEvent}, + event_loop::ActiveEventLoop, +}; use crate::{ client::ui::{Edited, Submit, main_view, msg_widget}, @@ -142,6 +145,16 @@ 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); + } + } + }, _ => (), } if self.ui.needs_redraw() {