Start SDL text input: the AKGL build's keyboard was dead
SDL3 has text input off by default and per-window, so without SDL_StartTextInput() it emits no SDL_EVENT_TEXT_INPUT at all and every keystroke reaches libakgl's ring with an empty text field. The editor had just been changed to prefer that composed text over the keycode, so it read every key as not-a-character: no echo in the window, and nothing on stdout either, because RUN could never be typed. One cause, both symptoms. The editor now falls back to the keycode when there is no composed text, so a host that forgets to start text input gets a worse keyboard rather than none. The suite missed this because every keyboard test pushes the text-input event into SDL's queue by hand -- which is what a real keyboard produces, but only once text input has been started. Synthesising the end of a chain cannot test the beginning of it. The new test asserts SDL_TextInputActive() directly, and both halves were checked by reverting each and watching it fail. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
19
TODO.md
19
TODO.md
@@ -568,6 +568,25 @@ which was the sharp end of the old limitation — it used to mean a program with
|
||||
had to be passed on the command line. Letters are no longer folded to upper case, because there
|
||||
is no longer any reason to.
|
||||
|
||||
**The host has to turn text input on**, and forgetting to is how this broke once. SDL3 has it
|
||||
off by default and per-window, so it is `akbasic_frontend_akgl_init()` that calls
|
||||
`SDL_StartTextInput()` — `akgl/controller.h` says as much. Without it SDL emits no
|
||||
`SDL_EVENT_TEXT_INPUT` at all, every keystroke reaches the ring with an empty `text`, and an
|
||||
editor that reads that as "not a character" is silently dead: nothing echoes in the window, and
|
||||
nothing reaches stdout either, because `RUN` can never be typed.
|
||||
|
||||
The editor therefore **falls back to the keycode** when a keystroke carries no composed text,
|
||||
folded to upper case. A worse keyboard is a great deal better than no keyboard, and it means a
|
||||
host that embeds these adaptors and forgets `SDL_StartTextInput()` gets a usable editor rather
|
||||
than a dead one. Both halves are asserted in `tests/akgl_frontend.c`, and both were checked by
|
||||
reverting each in turn and watching the test fail.
|
||||
|
||||
Worth knowing about the test suite that missed this: every other keyboard test pushes
|
||||
`SDL_EVENT_TEXT_INPUT` into SDL's queue by hand, which is what a real keyboard produces — *once
|
||||
text input has been started*. Synthesising the end of a chain cannot test the beginning of it.
|
||||
The new test asserts `SDL_TextInputActive()` directly for that reason, and the whole frontend
|
||||
suite has been run against a real X11 window as well as the dummy driver.
|
||||
|
||||
One limit remains, and it is a choice rather than a gap:
|
||||
|
||||
- **No cursor movement within a line.** Backspace and escape only. The arrow keys stay in the
|
||||
|
||||
Reference in New Issue
Block a user