PARSEC-5572 - Support additional character sets on macOS#170
PARSEC-5572 - Support additional character sets on macOS#170mtrang1263 wants to merge 4 commits intostablefrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the macOS text event path to allow non-ASCII input by only filtering ASCII control characters (instead of restricting to “visible ASCII”).
Changes:
- Replaces the “visible ASCII” gate with an early-return guard that only rejects ASCII control characters.
- Allows multi-byte UTF-8 text to flow through to
MTY_EVENT_TEXT.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/unix/apple/macosx/app.m
Outdated
| .type = MTY_EVENT_TEXT, | ||
| .window = ctx->window, | ||
| }; | ||
| if (!text || !text[0] || (strlen(text) == 1 && (text[0] < 0x20 || text[0] == 0x7F))) |
There was a problem hiding this comment.
strlen(text) == 1 scans the full string when you only need to know whether it’s a single byte/char. Prefer a constant-time check like text[1] == '\\0' to avoid unnecessary work in a hot text-input path (and to avoid reliance on potentially long/unterminated buffers).
| if (!text || !text[0] || (strlen(text) == 1 && (text[0] < 0x20 || text[0] == 0x7F))) | |
| if (!text || !text[0] || (text[1] == '\0' && (text[0] < 0x20 || text[0] == 0x7F))) |
src/unix/apple/macosx/app.m
Outdated
| if (!text || !text[0] || (strlen(text) == 1 && (text[0] < 0x20 || text[0] == 0x7F))) | ||
| // Ignore ASCII control characters | ||
| return; | ||
|
|
There was a problem hiding this comment.
The guard condition is fairly dense and mixes three concerns (null/empty, single-byte check, control-character check). Consider splitting into a couple of straightforward if statements (or a small helper predicate) and adding braces for clarity to reduce the chance of future mistakes when this logic is modified.
| if (!text || !text[0] || (strlen(text) == 1 && (text[0] < 0x20 || text[0] == 0x7F))) | |
| // Ignore ASCII control characters | |
| return; | |
| if (!text || !text[0]) { | |
| return; | |
| } | |
| if (strlen(text) == 1) { | |
| unsigned char c = (unsigned char) text[0]; | |
| // Ignore ASCII control characters | |
| if (c < 0x20 || c == 0x7F) { | |
| return; | |
| } | |
| } |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // Keyboard | ||
|
|
||
| static bool is_function_key(NSEvent *event) { |
There was a problem hiding this comment.
Adding this function so we can still ignore function keys that were previously ignored by the strict ASCII value check.
|
Moving back to coding to see if we can get the dead key support for additional accents. |
|
Spent the day exploring dead keys. The complexity is a bit high for an edge case that's resolved by the webview. Marking as ready for review. Since no changes since I've last run it, we should be good for code review and then QA. |
Update our text event handler to allow user to supply other unicode characters that are beyond the ascii character set.
QA Notes
Summary of changes
Update our handling of IMGUI text input to support additional characters. The method that sends the keypress events to the host is not affected (
window_keyboard_event)Platforms Affected
Test cases performed
Test cases untested