Skip to content

Add IME support for CJK and other composed input - #3

Open
kychiou wants to merge 1 commit into
ingur:mainfrom
kychiou:ime-support
Open

Add IME support for CJK and other composed input#3
kychiou wants to merge 1 commit into
ingur:mainfrom
kychiou:ime-support

Conversation

@kychiou

@kychiou kychiou commented Jul 23, 2026

Copy link
Copy Markdown

The embedded Terminal never enabled the OS IME for its window, so IME composition never engaged on any platform and only the raw ASCII fallback keystrokes (e.g. pinyin letters) reached the pty -- you could only type English. LineEdit/TextEdit avoid this by toggling window_set_ime_active on focus; the Terminal control never did.

  • Activate the OS IME while the terminal holds focus and deactivate on blur (sync_ime), mirroring LineEdit. Committed text then arrives as ordinary unicode key events, which encode_key already forwards, so no decoding changes are needed.
  • Track the cursor in control-local pixels and keep the IME candidate window positioned at it (refresh_ime_position).
  • Render the in-progress composition (preedit) inline over the grid at the cursor, underlined with a bar caret, from OS_IME_UPDATE via ime_get_text/ime_get_selection. The preedit is never sent to the pty; only the committed text is.

Uses only the portable DisplayServer IME API and is guarded by has_feature(FEATURE_IME), so backends without IME (e.g. Wayland today) no-op cleanly. No platform-specific code.

The embedded Terminal never enabled the OS IME for its window, so IME
composition never engaged on any platform and only the raw ASCII fallback
keystrokes (e.g. pinyin letters) reached the pty -- you could only type
English. LineEdit/TextEdit avoid this by toggling window_set_ime_active on
focus; the Terminal control never did.

- Activate the OS IME while the terminal holds focus and deactivate on
  blur (sync_ime), mirroring LineEdit. Committed text then arrives as
  ordinary unicode key events, which encode_key already forwards, so no
  decoding changes are needed.
- Track the cursor in control-local pixels and keep the IME candidate
  window positioned at it (refresh_ime_position).
- Render the in-progress composition (preedit) inline over the grid at
  the cursor, underlined with a bar caret, from OS_IME_UPDATE via
  ime_get_text/ime_get_selection. The preedit is never sent to the pty;
  only the committed text is.

Uses only the portable DisplayServer IME API and is guarded by
has_feature(FEATURE_IME), so backends without IME (e.g. Wayland today)
no-op cleanly. No platform-specific code.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ingur

ingur commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Thank you!, I'll review it over the next few days so we can add this functionality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants