From patchwork Fri Aug 22 14:21:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 114 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872559; bh=2woP0AgfnS1lA3/AKx4S+y09gC1103+EkDgv2im4JH8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=rsLl9fxZajeQ1eX9gOhq8v11UpWI5Sit+Kzy+wMHW7fpWFkewCl/YaIdlvAXcXrn6 gm4mtegvcF5q5jRDBLQLmhi8Yz47194Qv7hxDS5rtqW6GutiKsNz1mN+a+eH7cg/mM 6LQGR78ZOwEpAMaUrUcliRvP3Yx5iMtG5fuWhVKzjtr6qAwR9gqNkSeasmp5nngxWF 11Q6q3xJaYGBjXJfYbmRdWL6Y5hPXuYXPVf5gBiycYEVWC0M0cm6d89rTe9I8rfdCQ Z9l2IHzNFysmG0yx2LuReVqijAN/7Wi5fuxz4nHDIZHyJkIuzSU0NsFgPtQTiWQuEJ pFACZPhjyDqHA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 70B7F676EF for ; Fri, 22 Aug 2025 08:22:39 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id A7lDpO1PU6QS for ; Fri, 22 Aug 2025 08:22:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872555; bh=2woP0AgfnS1lA3/AKx4S+y09gC1103+EkDgv2im4JH8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=O+0GDs7MvN/joYPbAe5NCRNK6ng689eYiCGszHwxzOVirHmDE4dLO08jnIipuSeo8 aM5SIy7Vs9j4xa7Gina8C/Xm1yXMEppzk9cE8JOWbfdQBZbJF3n9Y4Jzytg6wLjTUY 820hN5npyo8A5tEAiVXKtVr3oD7SOCfCifxy5B7RA5ZjyBXy5g4jWWSvQ482RC+9WY KNAKK0gyDJ+haY5PpRC3/p6Cl/mxsWGPBrZvApKyfMFhh8lGueL5ElkAA0mttGpBVF tJkD9kmNHBU8QsvBrrTFIQWvtr/bJXhVCKAHmszlDllFMkgRG1xr6ISz7/8s3h0MEu +F2jpg9mKxBhg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BAE80676F1 for ; Fri, 22 Aug 2025 08:22:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872553; bh=PdWvNC39qec4gcm3EHTM5C1RWpurEYv9juclrKsMYiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FwbA4lWMS2NfOM2jJ49exhOtbRoIcUU3tuzvQQF16cvv1K3JS/82Tx9Twxa8OIvqJ yDHNJ6Pr4difI3vTXICLuIqOlN19uvoZ1ooykkhCQ/U/rgimPaqOUTIahpw2DWR+Bx 7IzvrnGuZFzdkexxXiFu/4hnUpkZSHZK1fzZvpdsktNMTvejRFrgCihV2oX1uaigwh 7gcNVjuqy6LXc94svLAOWL0cVb1/imdUUAe290t9VhpT9dKNKxDiPoxQ4LI/evkwL1 f0ayh8WohYfHO0LZX6Veeypnf8H47cpw/fpXS/cWYKOuidtc5cHXIkc1VaniwjxRhQ 7VOioD+WW/0GA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B00FD67722; Fri, 22 Aug 2025 08:22:33 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id bCTpPgYroYkL; Fri, 22 Aug 2025 08:22:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755872548; bh=mwjhIRD64D8iNxjM8Z2ulbKVLhG6w3q+1hd/GzeR5Zk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y6tKRFNxpL1PXHvPjfzXGRk5viwhEQhLajyb7GjIse0MCIS5R03M2W34GmnEUIHio tTrLawozAdR09FhJn6GPRlOORGlS1HX15/YiwPUjZOD1JJTzRAgC8KcKkGHYzLYlqP S0G06VtDrYFOMVDEacMHyfs9n1LBsSVtSAjTIL+cVXgI9ZH2HcPQeCX9qtHw2JTFqR VQgVjsyUm0OQ5DR31fBh3IXClJQPQbSuUatPGUUFLMTHLYhWWUN/I46+qc06On6WNJ pFAiplHiKw6x8Ul2JT2fszea037GREY2GShnC0G/G/TpWzcnqbqtrW75bKxOEp/MXj RJBHFEyKxBNDw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 045966770D; Fri, 22 Aug 2025 08:22:27 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 22 Aug 2025 08:21:40 -0600 Message-ID: <20250822142153.3404275-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250822142153.3404275-1-sjg@u-boot.org> References: <20250822142153.3404275-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BYIIPTEZTNJ72JRXEZ6OHWUEYDE5EAX6 X-Message-ID-Hash: BYIIPTEZTNJ72JRXEZ6OHWUEYDE5EAX6 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/16] console: Reset the pager when entering a new command List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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 --- 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 #include #include +#include #include #include #include @@ -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 /**