From patchwork Tue Jan 20 23:17:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1677 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=1768951133; bh=Eevv5fPKXytyFozgtuiia2qVLlAvAtsxpMcm7xXLQNg=; 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=ruNATsW2WbZ0+N/a7HjDnv1+lXBy8RBaCHGmoc6EhLprpyuYZsVLacKEtANmGB4j2 KHZRvtMkF9CFtUfwg5n7DiEsjA/cryBTF3VTo8/3MSQyiyx/I1WER4M6g7COfWdzsk RO4Hxl5U+j+C1cwXotaaxj4BwxT+8XLUTX+W/IQmEDHtHcphCtvBCVYhSnhpn/QCHj Bjc5CpQOhfPPVURk5GFGGghIRFonis/g0vtOHs8abXWyAQ2IxNXZzk8/2QTwUstMyV j9Qi+ROwUf2yL5GTXV7jAmZ/29WLXMNHWWExahWMejDYFcfVknecrWhT58OfYDa3sc H15WnYDNhc2qg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 132A969581 for ; Tue, 20 Jan 2026 16:18:53 -0700 (MST) 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 LqfPjKmvVdLH for ; Tue, 20 Jan 2026 16:18:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951133; bh=Eevv5fPKXytyFozgtuiia2qVLlAvAtsxpMcm7xXLQNg=; 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=ruNATsW2WbZ0+N/a7HjDnv1+lXBy8RBaCHGmoc6EhLprpyuYZsVLacKEtANmGB4j2 KHZRvtMkF9CFtUfwg5n7DiEsjA/cryBTF3VTo8/3MSQyiyx/I1WER4M6g7COfWdzsk RO4Hxl5U+j+C1cwXotaaxj4BwxT+8XLUTX+W/IQmEDHtHcphCtvBCVYhSnhpn/QCHj Bjc5CpQOhfPPVURk5GFGGghIRFonis/g0vtOHs8abXWyAQ2IxNXZzk8/2QTwUstMyV j9Qi+ROwUf2yL5GTXV7jAmZ/29WLXMNHWWExahWMejDYFcfVknecrWhT58OfYDa3sc H15WnYDNhc2qg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 014D369572 for ; Tue, 20 Jan 2026 16:18:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951131; bh=q9HbK0LjsYjz/plSV2tFfBLn0+09Ki8TxfJzlFfXE+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HMiV1u518r7n4oCgzY7L79o5lOttzvtQyKhNgTgGSFP5tFO5OUPKr+oSMGyDiRC75 iwC68pYh/eaGU8oj0jvyDZ8aagWFEL+3b97HgqCfn/oDEQLZFE42A4fczFqIgPKYdM E9mywiCa44wBso2mka2wS7+rPCb9E1ZUG2PJMFKbGZbKS3j7WyBVrcjdqBkDJe5xz/ f98GzbKqAwKA4T4cAZly/I5gcOTICwInnNFX+N0LOWKNPPHTdiKHb1rpvqdG3HQm8j pSnB0KkMF93yFqa0s/4K6REl1eaoGU7/USb4LtX8oEH0mzkGMsDsBicGVCcCLCMY2x Fc+heAv+9QyFg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 708C269441; Tue, 20 Jan 2026 16:18:51 -0700 (MST) 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 EY-ZyTUAn1L2; Tue, 20 Jan 2026 16:18:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951127; bh=/b/KV0zUH+C73bP35PDGbiy7V1Cnke8HNwAzUTHSmF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JxFg1lJSM04nlsDQLqn4fNtlF9XU5FFs6ZxZ8SmGnwYSzgh8ZWNy5wgRiKVP1OlVX e6EnJbaibPSMBL10+pSGghNokbo2cH55YWMRt9ZZoXVA9BuA1Fhj7q1xlU4acaSVQB wgBMNAulk1kpEgB7c+4NpQ0QrEyaoXzOKOrGEc/tDTF1IGsACxP5X3Xtu1C7DY7J9N zngpAlsye06lZeRNqpGyN0jexH7r/8igTTnV/j5m5NZbxs/HsDb9CL2yBL1WONkD8u XqBsbNPuEnfchAT7aHhkvr9qyYC746ImCljmNIIDf/k3bGAJiKXz1EmrErREO1tLg6 hJqYMWGY25pDA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 276D16913F; Tue, 20 Jan 2026 16:18:47 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:31 -0700 Message-ID: <20260120231814.2033069-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260120231814.2033069-1-sjg@u-boot.org> References: <20260120231814.2033069-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QPPLGSJLYFDNVUR22WQXIWRGURJHHLRT X-Message-ID-Hash: QPPLGSJLYFDNVUR22WQXIWRGURJHHLRT 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 , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/36] cli: Split initial-text output from cli_cread_init() 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 Move the initial-text output from cli_cread_init() into a new function cli_cread_add_initial(). This allows callers to set up additional state (like the putch callback) before the initial text is output. Update cread_line() and scene_txtin_open() to call the new function. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_txtin.c | 1 + common/cli_readline.c | 12 ++++++++---- include/cli.h | 10 ++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index 4f9230f931d..b5413dc145f 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -131,6 +131,7 @@ int scene_txtin_open(struct scene *scn, struct scene_obj *obj, cli_cread_init(&scn->cls, abuf_data(&tin->buf), tin->line_chars); scn->cls.insert = true; scn->cls.putch = scene_txtin_putch; + cli_cread_add_initial(&scn->cls); ret = vidconsole_entry_save(cons, &scn->entry_save); if (ret) return log_msg_ret("sav", ret); diff --git a/common/cli_readline.c b/common/cli_readline.c index 4eb34d7cf7c..0173072109b 100644 --- a/common/cli_readline.c +++ b/common/cli_readline.c @@ -470,16 +470,19 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) void cli_cread_init(struct cli_line_state *cls, char *buf, uint buf_size) { - int init_len = strlen(buf); - memset(cls, '\0', sizeof(struct cli_line_state)); cls->insert = true; cls->buf = buf; cls->len = buf_size; +} + +void cli_cread_add_initial(struct cli_line_state *cls) +{ + int init_len = strlen(cls->buf); if (init_len) - cread_add_str(cls, buf, init_len, 0, &cls->num, &cls->eol_num, - buf, buf_size); + cread_add_str(cls, cls->buf, init_len, 0, &cls->num, + &cls->eol_num, cls->buf, cls->len); } static int cread_line(const char *const prompt, char *buf, unsigned int *len, @@ -492,6 +495,7 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len, cli_ch_init(cch); cli_cread_init(cls, buf, *len); + cli_cread_add_initial(cls); cls->prompt = prompt; cls->history = true; cls->cmd_complete = true; diff --git a/include/cli.h b/include/cli.h index 88f96c03cb3..ec0f5d31046 100644 --- a/include/cli.h +++ b/include/cli.h @@ -279,6 +279,16 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar); */ void cli_cread_init(struct cli_line_state *cls, char *buf, uint buf_size); +/** + * cli_cread_add_initial() - Output initial buffer contents + * + * Called after cli_cread_init() to output the initial text in the buffer and + * set up the line state accordingly + * + * @cls: CLI line state + */ +void cli_cread_add_initial(struct cli_line_state *cls); + /** cread_print_hist_list() - Print the command-line history list */ void cread_print_hist_list(void);