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(-)
@@ -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;
}
@@ -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;
@@ -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
/**