From 48d9f0f71987791db20b3caf0a68020eb6c83649 Mon Sep 17 00:00:00 2001 From: Lucas-blip-png <177052392+Lucas-blip-png@users.noreply.github.com> Date: Sat, 31 Oct 2026 03:40:09 -0400 Subject: [PATCH] Keep long menu descriptions whole in the description pane The pane copied each description into 512 bytes. The Russian button layout description is 840 bytes of UTF-8, so it stopped mid-sentence, and the English one (507 bytes) lost the note appended after it. The pane now holds UI_DESC_BYTES (2048), and probe_menu_text checks every English and Russian menu text leaves room for a note. --- runtime/ov_probe.c | 4 ++++ runtime/ui/option_rows.cpp | 2 +- runtime/ui_text.h | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/runtime/ov_probe.c b/runtime/ov_probe.c index c0ffa181..8a1eb20a 100644 --- a/runtime/ov_probe.c +++ b/runtime/ov_probe.c @@ -821,6 +821,10 @@ static void probe_menu_text(void) { for (int id = UI_MENU_FIRST; id <= UI_MENU_LAST_ID; id++) { CHECK(ui_text_defined("en", (UiTextId)id) && ui_text_defined("ru", (UiTextId)id), "menu text id %d lacks en or ru", id); CHECK(*ui_text_in("en", (UiTextId)id) && *ui_text_in("ru", (UiTextId)id), "menu text id %d is empty", id); + // the description pane keeps the whole text and a note after it (option_rows.cpp desc_set) + CHECK(strlen(ui_text_in("en", (UiTextId)id)) + 256 < UI_DESC_BYTES && + strlen(ui_text_in("ru", (UiTextId)id)) + 256 < UI_DESC_BYTES, "menu text id %d is too long for the " + "description pane", id); } CHECK(!ui_text_defined("en", UI_TEXT_COUNT) && !*ui_text_in("ru", UI_TEXT_COUNT), "an id past the catalog gives text"); // other languages fall back to English for the menu, and keep their own keyboard texts diff --git a/runtime/ui/option_rows.cpp b/runtime/ui/option_rows.cpp index f0f82b36..04199d01 100644 --- a/runtime/ui/option_rows.cpp +++ b/runtime/ui/option_rows.cpp @@ -36,7 +36,7 @@ static bool g_disable_next; // opt_disable_next: the next row is gr static UiTextId g_disable_note; // The description pane: this frame's hovered and selected rows, the page's first row, and the last one shown. -struct Desc { char text[512]; }; +struct Desc { char text[UI_DESC_BYTES]; }; static Desc g_hover, g_focus, g_first, g_shown; // disabled: the note of a row opt_disable_next greyed out, else NULL. diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 13a328b6..1043f7d5 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -163,6 +163,11 @@ typedef enum { UI_TEXT_COUNT } UiTextId; +// Bytes of the menu's description pane (ui/option_rows.cpp, struct Desc): a description plus the note appended to it +// ("after restart", "set by environment variable", a disabled row's note). UTF-8 Cyrillic takes two bytes a letter, so +// the longest Russian description is about 850 bytes; the probe checks every menu text leaves room for a note. +enum { UI_DESC_BYTES = 2048 }; + // UTF-8 text for id in the language of ov_language(); English when the catalog has no row for that language. const char *ui_text(UiTextId id); // The same for an explicit catalog language ("en", "ja", "fr", "de", "it", "es", "nl", "pt", "ru", "zh-Hans",