[Concept,07/19] expo: Read all available input to keep up with key repeat

Message ID 20260130035849.3580212-8-simon.glass@canonical.com
State New
Headers
Series Enhanced command-line editing with undo/redo support |

Commit Message

Simon Glass Jan. 30, 2026, 3:58 a.m. UTC
  When the user holds down a key, the terminal sends characters faster
than expo can process them if it only reads one character per poll.
Change poll_keys() to drain the input buffer by reading all available
characters until a complete key is decoded or no more input is
available.

There are no tests for this feature.

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

 boot/expo.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Patch

diff --git a/boot/expo.c b/boot/expo.c
index 842bacae163..e44c7552f30 100644
--- a/boot/expo.c
+++ b/boot/expo.c
@@ -498,10 +498,12 @@  static int poll_keys(struct expo *exp)
 
 	ichar = cli_ch_process(&exp->cch, 0);
 	if (!ichar) {
-		/* Check once for available input */
-		if (tstc()) {
+		/* Read all available input to keep up with key repeat */
+		while (tstc()) {
 			ch = getchar();
 			ichar = cli_ch_process(&exp->cch, ch);
+			if (ichar)
+				break;
 		}
 
 		if (!ch && get_timer(exp->last_key_ms) >= 10)