fix: KeyboardWidget preview buffer size and KEY_CONTEXT_MENU handling

- preview[] increased from 32 to 40 bytes to safely fit max label (15 chars)
  + 20 chars text + cursor + null without snprintf truncation
- KEY_CONTEXT_MENU (long-press ENTER) now treated as CANCEL in keyboard
  input handler, restoring BotScreen behavior lost in the refactor

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-13 18:28:04 +02:00
parent 07bd5f1167
commit 5fecafd4f9

View File

@@ -55,7 +55,7 @@ struct KeyboardWidget {
const char* disp_start = buf;
int disp_len = len;
if (disp_len > 20) { disp_start = buf + (disp_len - 20); disp_len = 20; }
char preview[32];
char preview[40];
snprintf(preview, sizeof(preview), "%s%.*s_", label, disp_len, disp_start);
display.setCursor(0, KB_TEXT_Y);
display.print(preview);
@@ -147,7 +147,7 @@ struct KeyboardWidget {
return NONE;
}
if (c == KEY_CANCEL) return CANCELLED;
if (c == KEY_CANCEL || c == KEY_CONTEXT_MENU) return CANCELLED;
if (c == KEY_UP) {
if (row > 0) {