
From: Simon Glass <sjg@chromium.org> We don't want the pager appearing when entering commands, so add a way to bypass it. Reset the line count to zero before executing the command. Signed-off-by: Simon Glass <sjg@chromium.org> --- common/cli_readline.c | 13 +++++++++++-- common/pager.c | 15 +++++++++++++++ include/pager.h | 13 +++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/common/cli_readline.c b/common/cli_readline.c index 4e6797a1944..2326e4b4f37 100644 --- a/common/cli_readline.c +++ b/common/cli_readline.c @@ -13,6 +13,7 @@ #include <command.h> #include <hang.h> #include <malloc.h> +#include <pager.h> #include <time.h> #include <watchdog.h> #include <linux/errno.h> @@ -650,6 +651,9 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer, uint len = CONFIG_SYS_CBSIZE; int rc; static int initted; + bool old_bypass; + + old_bypass = pager_set_bypass(gd_pager(), true); /* * Say N to CMD_HISTORY_USE_CALLOC will skip runtime @@ -673,9 +677,14 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer, puts(prompt); rc = cread_line(prompt, p, &len, timeout); - return rc < 0 ? rc : len; + rc = rc < 0 ? rc : len; } else { - return cread_line_simple(prompt, p); + rc = cread_line_simple(prompt, p); } + + pager_set_bypass(gd_pager(), old_bypass); + pager_reset(gd_pager()); + + return rc; } diff --git a/common/pager.c b/common/pager.c index a7ad77bea3b..69b05dac5cc 100644 --- a/common/pager.c +++ b/common/pager.c @@ -141,6 +141,21 @@ bool pager_set_bypass(struct pager *pag, bool bypass) return was_bypassed; } +void pager_set_page_len(struct pager *pag, int page_len) +{ + if (page_len < 2) + return; + pag->page_len = page_len; + pag->line_count = 0; + if (!page_len) + pag->state = PAGERST_TEST_BYPASS; +} + +void pager_reset(struct pager *pag) +{ + pag->line_count = 0; +} + int pager_init(struct pager **pagp, int page_len, int buf_size) { struct pager *pag; diff --git a/include/pager.h b/include/pager.h index 9bd99b5c959..fde502f3edd 100644 --- a/include/pager.h +++ b/include/pager.h @@ -123,6 +123,15 @@ const char *pager_next(struct pager *pag, bool use_pager, int ch); */ bool pager_set_bypass(struct pager *pag, bool bypass); +/** + * pager_reset() - reset the line count in the pager + * + * Sets line_count to zero so that the pager starts afresh with its counting. + * + * @pag: Pager to update + */ +void pager_reset(struct pager *pag); + /** * pager_uninit() - Uninit the pager * @@ -149,6 +158,10 @@ static inline bool pager_set_bypass(struct pager *pag, bool bypass) return true; } +static void pager_reset(struct pager *pag) +{ +} + #endif /** -- 2.43.0