menu: Make use of CLI character processing
Avoid duplicating some of the escape-sequence processing here and use the
CLI function instead.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/common/cli_getch.c b/common/cli_getch.c
index 9eeea7f..87c23ed 100644
--- a/common/cli_getch.c
+++ b/common/cli_getch.c
@@ -140,10 +140,11 @@
* sequence
*/
if (!ichar) {
- if (cch->emit_upto) {
+ if (cch->emitting) {
if (cch->emit_upto < cch->esc_len)
return cch->esc_save[cch->emit_upto++];
cch->emit_upto = 0;
+ cch->emitting = false;
}
return 0;
} else if (ichar == -ETIMEDOUT) {
@@ -174,18 +175,21 @@
case ESC_SAVE:
/* save this character and return nothing */
cch->esc_save[cch->esc_len++] = ichar;
- return 0;
+ ichar = 0;
+ break;
case ESC_REJECT:
/*
* invalid escape sequence, start returning the
* characters in it
*/
cch->esc_save[cch->esc_len++] = ichar;
- return cch->esc_save[cch->emit_upto++];
+ ichar = cch->esc_save[cch->emit_upto++];
+ cch->emitting = true;
+ break;
case ESC_CONVERTED:
/* valid escape sequence, return the resulting char */
cch->esc_len = 0;
- return ichar;
+ break;
}
}