fix(keyboard): count preview line breaks in codepoints, mark caps-lock

The text preview was the last part of the keyboard still working in bytes
rather than codepoints. cpl is how many characters physically fit on a
line, so dividing byte offsets by it counted every 2-byte Cyrillic/Greek/
accented character as two: lines held half the text they had room for, and
a break could land inside a codepoint. Both display drivers are
permanently single-font, so translateUTF8ToBlocks() passes UTF-8 straight
through -- the truncated sequence reached print() and drew as garbage on
both sides of the break. Line boundaries now walk the buffer with the same
kbUtf8*() helpers insertion/backspace/T9 already use, and the per-line
buffers are sized for a full line of 2-byte characters.

Caps-lock also gets an underline on the shift key: it sets caps too, so
the highlight alone made a one-shot Shift and a held lock indistinguishable
despite capitalising one letter vs. every following one.

Drops UITask::applyFont() -- setSingleFont() is a no-op on both drivers
since they were pinned to misc-fixed, so it did nothing, and use_lemon_font
has had no Settings row for a while. The pref itself stays: it's part of
the on-disk layout. Retires the matching stale rationale on scriptHint().

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-07-27 23:24:42 +02:00
co-authored by Claude Opus 5
parent e558ea0b86
commit 07c80cd548
4 changed files with 47 additions and 28 deletions
@@ -1477,7 +1477,6 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
gpio_screen = new GpioScreen(this, node_prefs);
#endif
applyBrightness();
applyFont();
applyRotation();
applyFullRefreshInterval();
applyAllGpioModes(); // restore persisted pin modes to hardware before any UI/bot use
@@ -3339,13 +3338,6 @@ void UITask::applyBrightness() {
}
}
void UITask::applyFont() {
if (_display != NULL && _node_prefs != NULL) {
_display->setSingleFont(_node_prefs->use_lemon_font != 0);
_next_refresh = 0;
}
}
void UITask::applyRotation() {
if (_display != NULL && _node_prefs != NULL) {
_display->setDisplayRotation(_node_prefs->display_rotation);