aboutsummaryrefslogtreecommitdiff
path: root/common/cli_getch.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-01-06 08:52:26 -0600
committerTom Rini <trini@konsulko.com>2023-01-16 14:14:11 -0500
commit32bab0eae51b55898d1e2804e6614d9143840581 (patch)
tree67686cc8705aaf301695e8b66f50f613422b60b9 /common/cli_getch.c
parent86cc3c5215fc6e3c2cb77ee162c22ad91dbfaff5 (diff)
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>
Diffstat (limited to 'common/cli_getch.c')
-rw-r--r--common/cli_getch.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/common/cli_getch.c b/common/cli_getch.c
index 9eeea7fef2..87c23edcf4 100644
--- a/common/cli_getch.c
+++ b/common/cli_getch.c
@@ -140,10 +140,11 @@ int cli_ch_process(struct cli_ch_state *cch, int ichar)
* 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 @@ int cli_ch_process(struct cli_ch_state *cch, int ichar)
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;
}
}