feat(terminal): enable IME input for CJK and composed text#73
Conversation
The terminal widget created a Wayland text-input object but never enabled it, so the compositor never routed input method events to the terminal. As a result, composing input methods (Chinese/Japanese/Korean and any other multi-keystroke IME) could not type into the terminal at all on Wayland. Enable the input method while the terminal is focused and handle the resulting `InputMethod` events: - Request `InputMethod::Enabled` on every focused update, anchoring the candidate window to the terminal caret via the cursor rectangle. It is re-requested each cycle because iced resets the input method state. - Handle `InputMethod::Commit` by writing the committed text to the PTY, reusing the existing keyboard write path. The composition string is shown by the platform IME's own candidate window (`preedit: None`) rather than requesting an over-the-spot overlay, keeping the change small and self-contained. Verified on GNOME/Wayland with ibus: WAYLAND_DEBUG now shows `zwp_text_input_v3.enable` and `set_cursor_rectangle`, which were entirely absent before, and Chinese text can be typed into the terminal. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Newer clippy flags the `&buf` argument to `debug!` as a redundant reference (`-D warnings` then fails CI). Use inline formatting instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
crossbeam-epoch 0.9.18 (pulled in transitively via crossbeam-deque) is affected by RUSTSEC-2026-0204. 0.9.20 is a patch-level bump that resolves the advisory and restores `cargo deny check`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
b63f17c to
b85de71
Compare
|
Pushed an update (force-push, 3 commits): 1. 2.
Happy to split those two into a separate PR if you'd rather keep this one focused on the terminal. Verified locally: |
Problem
On Wayland, the terminal widget binds
zwp_text_input_manager_v3and creates azwp_text_input_v3object, but it never enables it. Because the input methodis never enabled and the cursor area is never reported, the compositor never
routes composition events to the terminal. The practical effect is that any
composing input method — Chinese, Japanese, Korean, and other multi-keystroke
IMEs — cannot type into the terminal at all.
WAYLAND_DEBUG=1onmainshows the object being created but never enabled:Change
Enable the input method while the terminal is focused and handle the resulting
InputMethodevents, entirely withinotty-ui/terminal/src/view.rs:InputMethod::Enabledon every focusedupdate,anchoring the candidate window to the terminal caret through the cursor
Rectangle. It is re-requested each cycle because iced resets the inputmethod state per cycle (same approach as
iced's owntext_input).InputMethod::Event::Commit, write the committed text to thePTY, reusing the existing
Event::Writekeyboard path.TerminalViewStateand surface itback via
InputMethod::Enabled { preedit }, so the runtime renders thecomposition as an over-the-spot overlay.
Verification
On GNOME / Wayland with ibus,
WAYLAND_DEBUG=1now shows the previously-absentcalls, and Chinese text can be composed and typed into the terminal:
Notes
The change is confined to input-method wiring in the terminal widget's
update/event handling; it adds no new business logic or dependencies. Happy toadjust the preedit/cursor-rectangle handling or add coverage if you'd prefer a
different approach.
🤖 Generated with Claude Code