console: Add bypass keypress to disable paging

Add support for pressing 'Q' to put the pager into bypass mode,disabling
further paging for the current session.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-08-22 16:28:10 -06:00
parent e617ccfc40
commit c7ba355d1f
4 changed files with 70 additions and 10 deletions

View File

@@ -579,3 +579,42 @@ static int pager_test_console(struct unit_test_state *uts)
return 0;
}
COMMON_TEST(pager_test_console, UTF_CONSOLE);
/* Test bypass keypress ('Q') functionality */
static int pager_test_bypass_keypress(struct unit_test_state *uts)
{
struct pager *pag;
const char *out;
int ret;
ret = pager_init(&pag, 3, SZ_1K);
ut_assertok(ret);
/* Post text that will trigger paging */
out = pager_post(pag, true, "line1\nline2\nline3\nline4\n");
ut_assertnonnull(out);
ut_asserteq_str("line1\nline2", out);
/* Should be waiting for user input */
out = pager_next(pag, true, 0);
ut_asserteq_str(PAGER_PROMPT, out);
/* Press 'Q' to bypass */
out = pager_next(pag, true, 'Q');
ut_asserteq_str(PAGER_BLANK, out);
/* Verify pager is now in bypass mode */
ut_asserteq(PAGERST_BYPASS, pag->state);
/* Next call should return the remaining text without paging */
out = pager_next(pag, true, 0);
ut_asserteq_str("line3\nline4\n", out);
/* No more text should be available */
out = pager_next(pag, true, 0);
ut_asserteq_ptr(NULL, out);
pager_uninit(pag);
return 0;
}
COMMON_TEST(pager_test_bypass_keypress, 0);