Allow setting terminal cursor for screen readers and IME preview using ui_adaptor #59035
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Infrastructure "Allow setting terminal cursor for screen readers and IME preview using ui_adaptor"
Purpose of change
The ncurses cursor is used by screen readers and used as the position for IME preview, but it is transient -- any output will change its position, making the code prone to regression when new code is added. Contributes to #39638.
Describe the solution
Set the desired final cursor via
ui_adaptor
, which automatically sets the cursor to the desired position once all UIs finish drawing.Migrate existing UIs that set the cursor to the new system.
Finally, place cursor at the highlighted line in the player display (@) menu to demonstrate the flexibility of the system.
disable_cursor()
andset_cursor()
are used to place the cursor at the correct line without having the output code of the non-active UIs interfere with the cursor.Describe alternatives you've considered
A
on_out_of_scope
solution might work too, but some drawing code spans several functions, which will make a scope-based solution complicated.Testing
Tested all affected UIs on the ncurses build. The IME preview was shown at the desired cursor position, so screen readers should also work in these UIs.
Also tested all affected UIs on the tiles build, and the UIs worked as before. Tested #45951 and there was no regression.
Additional context
This should make it somewhat easier to add screen reader support to the remaining menus in #39638.