Skip to content

windows: combine UTF-16 surrogate pairs for non-BMP input - #41

Closed
NeonMedusa wants to merge 1 commit into
adxdits:masterfrom
NeonMedusa:textinput-wide-render
Closed

NeonMedusa wants to merge 1 commit into
adxdits:masterfrom
NeonMedusa:textinput-wide-render

Conversation

@NeonMedusa

Copy link
Copy Markdown
Contributor

Fixes #40.

Non-BMP characters (emoji) arrived as two KEY_EVENTs and both surrogate halves were rejected by the unicode_char < 0xD800 guard, so the input was silently dropped. Now the leading surrogate is buffered and combined with the trailing one, matching conhost's _leadingSurrogate behavior.

Two details worth noting:

  • The pairing is done before the virtual-key-code switch, so modifiers are still attached to the resulting .char event.
  • combineSurrogates and resolveSurrogate are plain functions with unit tests, so the state machine is covered on non-Windows CI too (72 -> 74 tests).

Verified on Windows Terminal / ConPTY: emoji picker (Win+.) and pasting emoji now produce a .char event; BMP input is unaffected. zig build test and zig build examples pass, plus a -target x86_64-linux-gnu compile check.

CJK and emoji occupy two terminal columns, but render advanced one column
per code point. The next glyph was then written into the trailing cell of
a wide character, and the buffer cleared the pair - wide characters never
appeared in the field (the value itself was correct, only the rendering
was wrong).

Cursor column, scroll window and glyph placement now all count display
columns via codepointWidth, matching the buffer's cell model. Covered by
tests for wide-character layout, cursor-on-wide-char, column-based
scrolling and placeholder clamping.
@NeonMedusa NeonMedusa closed this Sep 20, 2026
@NeonMedusa
NeonMedusa deleted the textinput-wide-render branch September 20, 2026 19:43
@NeonMedusa
NeonMedusa restored the textinput-wide-render branch September 20, 2026 19:56
@NeonMedusa NeonMedusa reopened this Sep 20, 2026
@NeonMedusa

Copy link
Copy Markdown
Contributor Author

Closing this in favour of #42, which covers the same input fix together with the related widget layout fixes I found while testing.

Sorry for the noise - nothing was wrong with this PR, it's just consolidated into one wide-character change now.

@NeonMedusa NeonMedusa closed this Sep 20, 2026
@NeonMedusa
NeonMedusa deleted the textinput-wide-render branch October 3, 2026 03:13
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.

Non-BMP characters (emoji, some symbols) typed or pasted on Windows produce no event. BMP input works fine.

1 participant