[Concept,19/22] menu: Start bootmenu_key values at 0x100

Message ID 20251207201628.2882382-20-sjg@u-boot.org
State New
Headers
Series expo: Expand docs, dump and textlines in non-popup expos |

Commit Message

Simon Glass Dec. 7, 2025, 8:16 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

At present the backspace key (Ctrl-B) has the same value as BKEY_UP,
which means the keys are ambiguous. This causes problems when trying
to edit a textline. The same problem applies to other keys used in
cread_line_process_ch()

Start the bootmenu_key enum values at 0x100 to avoid this collision.
Keep BKEY_NONE as 0, since it is a sentinel value.

Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 include/menu.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
  

Patch

diff --git a/include/menu.h b/include/menu.h
index 6cede89b950..9914e680307 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -45,10 +45,16 @@  struct bootmenu_data {
 	struct bootmenu_entry *first;	/* first menu entry */
 };
 
-/** enum bootmenu_key - keys that can be returned by the bootmenu */
+/**
+ * enum bootmenu_key - keys that can be returned by the bootmenu
+ *
+ * These values start at 0x100 to avoid colliding with ASCII control characters
+ * (0x01-0x1f) which are used for editing operations in textlines. BKEY_NONE is
+ * kept at 0 as a sentinel value.
+ */
 enum bootmenu_key {
 	BKEY_NONE = 0,
-	BKEY_UP,
+	BKEY_UP = 0x100,
 	BKEY_DOWN,
 	BKEY_SELECT,
 	BKEY_QUIT,