[PR #4898] [MERGED] IME: show composition text under the caret and place the candidate window #5926

Closed
opened 2026-11-03 05:15:58 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4898
Author: @levzzz5154
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: parity/ime-preedit


📝 Commits (4)

  • a0b0a5b Show the input method's composition under the caret and place its candidate window there
  • 2d62140 Merge remote-tracking branch 'hr/main' into parity/ime-preedit
  • 9cc33bd Fix main's build: streaming candidates hold a SectionMask
  • 3839d80 Merge remote-tracking branch 'hr/main' into parity/ime-preedit

📊 Changes

8 files changed (+377 additions, -11 deletions)

View changed files

📝 crates/horizon-client-render/src/lib.rs (+1 -0)
📝 crates/horizon-client-render/src/multiline_edit.rs (+3 -0)
➕ crates/horizon-client-render/src/preedit.rs (+304 -0)
📝 crates/horizon-client-render/src/ui.rs (+3 -0)
📝 crates/horizon-client/src/game.rs (+11 -0)
📝 crates/horizon-client/src/game/ime.rs (+49 -0)
📝 crates/horizon-client/src/game/sign_edit.rs (+4 -9)
📝 crates/horizon-client/src/lib.rs (+2 -2)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally.

Part of #3518

Follow-up to #4347, which accepts committed IME text. This shows the text still being composed and puts the IME candidate window at the caret.

Rows:

  • PreeditEvent.fromSdlTextEditing: PreeditEvent::from_sdl_text_editing (code-point caret and selection, split into blocks); from_winit converts winit's byte range from Ime::Preedit to it (hidden cursor = caret at the end).
  • PreeditEvent.toFormattedText: to_formatted_text, the focused block underlined.
  • KeyboardHandler.textEditing: WindowEvent::Ime(Preedit) keeps the event (only while a text field has focus); a commit, Ime::Disabled or the field losing focus clears it, as textInput calls textEditing(null) first.
  • KeyboardHandler.submitPreeditEvent: Horizon draws its fields in many places, so instead of handing the event to the focused widget, the event is kept in preedit.rs and each focused field reports its caret (EditBox, the multi-line box used by dialogs, the sign editor, as vanilla's EditBox, MultiLineEditBox and AbstractSignEditScreen do).
  • IMEPreeditOverlay (same code path): the widget/preedit sprite, black underlined text, a blinking caret, kept inside the GUI and flipped above the field at the bottom edge, drawn after the rest of the GUI like extractDeferredElements.
  • TextInputManager.setTextInputArea: the caret (or the overlay when composing) goes to Window::set_ime_cursor_area in window pixels, only when it changes.

Not covered: fields drawn through append_field (no caller outside tests) and the book editor (vanilla's BookEditScreen has no preedit either).

Also fixes main's build: streaming.rs (two merged PRs disagreed on the candidate tuple type, SectionMask now derives Ord).

Vanilla: PreeditEvent, IMEPreeditOverlay, KeyboardHandler.textEditing, EditBox/MultiLineEditBox/AbstractSignEditScreen caret reporting, TextInputManager.setTextInputArea.

Tests: 6 unit tests in preedit.rs (code points, blocks, winit conversion, underline of the focused block); fmt and clippy -D warnings on horizon-client-render and horizon-client. Not tested with a real IME.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4898 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `parity/ime-preedit` --- ### 📝 Commits (4) - [`a0b0a5b`](https://github.com/horizon-rust/horizon/commit/a0b0a5ba502342bc6175ac2e0e4dc032702360a4) Show the input method's composition under the caret and place its candidate window there - [`2d62140`](https://github.com/horizon-rust/horizon/commit/2d621405c62477346e24b41dac993904dc861e8c) Merge remote-tracking branch 'hr/main' into parity/ime-preedit - [`9cc33bd`](https://github.com/horizon-rust/horizon/commit/9cc33bdda8b0b8e884fd7fa62912d2fa521aa136) Fix main's build: streaming candidates hold a SectionMask - [`3839d80`](https://github.com/horizon-rust/horizon/commit/3839d800765fa430c9d1d5a8deea629888130a62) Merge remote-tracking branch 'hr/main' into parity/ime-preedit ### 📊 Changes **8 files changed** (+377 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/lib.rs` (+1 -0) 📝 `crates/horizon-client-render/src/multiline_edit.rs` (+3 -0) ➕ `crates/horizon-client-render/src/preedit.rs` (+304 -0) 📝 `crates/horizon-client-render/src/ui.rs` (+3 -0) 📝 `crates/horizon-client/src/game.rs` (+11 -0) 📝 `crates/horizon-client/src/game/ime.rs` (+49 -0) 📝 `crates/horizon-client/src/game/sign_edit.rs` (+4 -9) 📝 `crates/horizon-client/src/lib.rs` (+2 -2) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #3518 Follow-up to #4347, which accepts committed IME text. This shows the text still being composed and puts the IME candidate window at the caret. Rows: - `PreeditEvent.fromSdlTextEditing`: `PreeditEvent::from_sdl_text_editing` (code-point caret and selection, split into blocks); `from_winit` converts winit's byte range from `Ime::Preedit` to it (hidden cursor = caret at the end). - `PreeditEvent.toFormattedText`: `to_formatted_text`, the focused block underlined. - `KeyboardHandler.textEditing`: `WindowEvent::Ime(Preedit)` keeps the event (only while a text field has focus); a commit, `Ime::Disabled` or the field losing focus clears it, as `textInput` calls `textEditing(null)` first. - `KeyboardHandler.submitPreeditEvent`: Horizon draws its fields in many places, so instead of handing the event to the focused widget, the event is kept in `preedit.rs` and each focused field reports its caret (`EditBox`, the multi-line box used by dialogs, the sign editor, as vanilla's EditBox, MultiLineEditBox and AbstractSignEditScreen do). - `IMEPreeditOverlay` (same code path): the `widget/preedit` sprite, black underlined text, a blinking caret, kept inside the GUI and flipped above the field at the bottom edge, drawn after the rest of the GUI like `extractDeferredElements`. - `TextInputManager.setTextInputArea`: the caret (or the overlay when composing) goes to `Window::set_ime_cursor_area` in window pixels, only when it changes. Not covered: fields drawn through `append_field` (no caller outside tests) and the book editor (vanilla's BookEditScreen has no preedit either). Also fixes main's build: `streaming.rs` (two merged PRs disagreed on the candidate tuple type, `SectionMask` now derives `Ord`). Vanilla: `PreeditEvent`, `IMEPreeditOverlay`, `KeyboardHandler.textEditing`, `EditBox`/`MultiLineEditBox`/`AbstractSignEditScreen` caret reporting, `TextInputManager.setTextInputArea`. Tests: 6 unit tests in `preedit.rs` (code points, blocks, winit conversion, underline of the focused block); fmt and clippy `-D warnings` on horizon-client-render and horizon-client. Not tested with a real IME. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:58 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5926
No description provided.