From patchwork Mon Jan 19 20:41:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1653 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=1768855420; bh=n6/diLelfIaMjMXWjSVX6GbI+RhiQiehI6WxxlBjXzU=; 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=gibl68UxrPQB/5gPaKdkbH0e4lXAT3bqEx021Lbq7WULx5S4TofhGHjithL4e8P3x 1/LSByBZ0SmIVZHrxTCCnRM1kfkviUBWAskoAIXMpFZLDAgljHzHfiJ0y916KWSoex joh2bvsbTZouAYDN8nlV0sFFIgBdB0ur2V5KY4/PA+0//aTj4EMrdNSnDVqeE2ureD 7IcYhvBz3gV/fVBcR/PidjrnXu0XqtX+fSyFWlvP9D9gItkDZ+GSvue+0vTgU99gPB KAumiOw2ovY/b6/tblGPMTBCLQ1t+zGNPt0306h+WEZjyQC1zqvXTMmw3mdco1kHdf UUAI6L0atb4LA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0DEC66951C for ; Mon, 19 Jan 2026 13:43:40 -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 iEJPwBiyCTmA for ; Mon, 19 Jan 2026 13:43:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855419; bh=n6/diLelfIaMjMXWjSVX6GbI+RhiQiehI6WxxlBjXzU=; 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=GCCSaluope9VVRuDuWzqa2rz2Fu+ICEXr8I/X5P/VVEd2HsYtaODrXVB210CQOsN7 TbTeh0rICG8AGmwf8xho8hfDF8dwjxtx0Bk17oOHtN8FzlkL2SJvWaPOYfwhifGNOn kVFQVA59gs/d9k5N9oc1pLGsmP2Ohji1DL94NUdtejO/UJLP/T8NR0RHeHo2T/XmG3 yL2uYlwLYCz67UcXYP+LfsghWCWeuin033DTNlTzp7PCRraGk6Qf6iGjLJ17S5Yj4Y NZMGlIp/8D4eQ7p5BWWDz4yPQX6DTMC3ro139v0jAal6T9rjDR/cwP/PlL6B/FKi1o ugImrr/09Vr3Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F0A3E69504 for ; Mon, 19 Jan 2026 13:43:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855416; bh=ZDCP08/wlWnLwVjwMK6BznjvZyaVZb9fV8Sq7iWgg7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BlvrnwzJUmTHqVEKAsqkdCNKgwJ9/oopWbJvT2QYBL4wur+VbGII7tfjybkt2wGYi lDgtpxsyl3TMeFWQviTqosZm3fzthjxHZ4tzydCxqHN5R+bbhL3W0MMPI9bammnC6r AacjBGtKpWnzZQO88i3NzwN7TFeB2+2RIk8uT4refWSnjlm/eDxPAoXh+Z2EFq+ga4 RdUMpX7x3vZsIJQBWATZuih1R+rCaLEiD2GXkqqVRkw19at5sv+HrvfykJk6/dRfrw uz6E7MCG+VyU50joyYrkJsdRgsdkMhIFwkuHaDctU4NQzipddIVjnXqdZp3BUMUctf 8f+eMyOyTTyeg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EFAA7693BA; Mon, 19 Jan 2026 13:43:36 -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 JCcDIEMraoiR; Mon, 19 Jan 2026 13:43:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855412; bh=7dcm9P8kAiSNyeDAF/m7VAWQ9CtpLT7WpjGKiYeIIj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IYLD6gGkVS7WfbqhNjAONyfXq2ZQX4Cls2N/DY7/bDktp3j7s8l3mYjBjVHTib8S4 hJHt5sPrqyQgSajRLndDizis8bbZ/UxANpWH53QyfbU0wIwzMcHKEXsfC+5M5uE0+g qyuiUaGkT6BLxojHkyYLoFToyOEAWDUakDmZ8HU5Ds0H39zyTbDV9vwHZTqaN/s0ML T2qLU6+v176r8PtY9AA8jSDmO41NYk2DulS2vUq5f4YMTU/UCADieMMoHqBbjrFvjh JTUy35m0pX9lKnobnO+gDnLihVfzr8di2I6B7mmw8qQbbJLCRXsQcfTvmyQJ0UH9Q/ HLBxmM5RvBixQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A12E9693E3; Mon, 19 Jan 2026 13:43:32 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 19 Jan 2026 13:41:16 -0700 Message-ID: <20260119204130.3972647-24-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260119204130.3972647-1-sjg@u-boot.org> References: <20260119204130.3972647-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: E4Y2XQH4SB5H3CSCK2Y23SEWUUGT4LMZ X-Message-ID-Hash: E4Y2XQH4SB5H3CSCK2Y23SEWUUGT4LMZ 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 23/27] expo: Add scene_txtin_open() for common text-input open code 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 Factor out the open code from scene_textline_open() into a shared helper scene_txtin_open() This sets up the text editor ready for use, including copying the backup text, setting cursor position, and initialising the CLI line state. Update scene_obj_open() to call scene_txtin_open() directly for both textline and textedit objects. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene.c | 5 ++--- boot/scene_internal.h | 10 +++++---- boot/scene_textline.c | 45 --------------------------------------- boot/scene_txtin.c | 49 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 52 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index b05291138ed..6b5c934a2e7 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -1670,11 +1670,10 @@ static int scene_obj_open(struct scene *scn, struct scene_obj *obj) case SCENEOBJT_MENU: case SCENEOBJT_TEXT: case SCENEOBJT_BOX: - case SCENEOBJT_TEXTEDIT: break; case SCENEOBJT_TEXTLINE: - ret = scene_textline_open(scn, - (struct scene_obj_textline *)obj); + case SCENEOBJT_TEXTEDIT: + ret = scene_txtin_open(scn, obj, scene_obj_txtin(obj)); if (ret) return log_msg_ret("op", ret); break; diff --git a/boot/scene_internal.h b/boot/scene_internal.h index 96bc4e06ad6..8899ba538ae 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -569,15 +569,17 @@ int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj, int scene_obj_calc_bbox(struct scene_obj *obj, struct vidconsole_bbox *bbox); /** - * scene_textline_open() - Open a textline object + * scene_txtin_open() - Open a text-input object * * Set up the text editor ready for use * - * @scn: Scene containing the textline - * @tline: textline object + * @scn: Scene containing the object + * @obj: Object to open + * @tin: Text-input info * Return: 0 if OK, -ve on error */ -int scene_textline_open(struct scene *scn, struct scene_obj_textline *tline); +int scene_txtin_open(struct scene *scn, struct scene_obj *obj, + struct scene_txtin *tin); /** * scene_textline_close() - Close a textline object diff --git a/boot/scene_textline.c b/boot/scene_textline.c index 46ab53e30c9..2199b3d0641 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -152,48 +152,3 @@ bool scene_textline_within(const struct scene *scn, return scene_within(scn, tline->tin.edit_id, x, y); } -/** - * scene_textline_putch() - Output a character to the vidconsole - * - * This is used as the putch callback for CLI line editing, so that characters - * are sent to the correct vidconsole. - * - * @cls: CLI line state - * @ch: Character to output - */ -static void scene_textline_putch(struct cli_line_state *cls, int ch) -{ - struct scene *scn = container_of(cls, struct scene, cls); - - vidconsole_put_char(scn->expo->cons, ch); -} - -int scene_textline_open(struct scene *scn, struct scene_obj_textline *tline) -{ - struct udevice *cons = scn->expo->cons; - struct scene_obj_txt *txt; - int ret; - - /* Copy the text into the scene buffer in case the edit is cancelled */ - memcpy(abuf_data(&scn->buf), abuf_data(&tline->tin.buf), - abuf_size(&scn->buf)); - - /* get the position of the editable */ - txt = scene_obj_find(scn, tline->tin.edit_id, SCENEOBJT_NONE); - if (!txt) - return log_msg_ret("cur", -ENOENT); - - vidconsole_set_cursor_pos(cons, txt->obj.bbox.x0, txt->obj.bbox.y0); - vidconsole_entry_start(cons); - cli_cread_init(&scn->cls, abuf_data(&tline->tin.buf), tline->tin.line_chars); - scn->cls.insert = true; - scn->cls.putch = scene_textline_putch; - ret = vidconsole_entry_save(cons, &scn->entry_save); - if (ret) - return log_msg_ret("sav", ret); - - /* make sure the cursor is visible */ - vidconsole_readline_start(true); - - return 0; -} diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index 2e7c496310d..a4c373c14fa 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -10,8 +10,10 @@ #include #include +#include #include #include +#include #include "scene_internal.h" int scene_txtin_init(struct scene_txtin *tin, uint size, uint line_chars) @@ -86,6 +88,53 @@ int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj, return 0; } +/** + * scene_txtin_putch() - Output a character to the vidconsole + * + * This is used as the putch callback for CLI line editing, so that characters + * are sent to the correct vidconsole. + * + * @cls: CLI line state + * @ch: Character to output + */ +static void scene_txtin_putch(struct cli_line_state *cls, int ch) +{ + struct scene *scn = container_of(cls, struct scene, cls); + + vidconsole_put_char(scn->expo->cons, ch); +} + +int scene_txtin_open(struct scene *scn, struct scene_obj *obj, + struct scene_txtin *tin) +{ + struct udevice *cons = scn->expo->cons; + struct scene_obj_txt *txt; + int ret; + + /* Copy the text into the scene buffer in case the edit is cancelled */ + memcpy(abuf_data(&scn->buf), abuf_data(&tin->buf), + abuf_size(&scn->buf)); + + /* get the position of the editable */ + txt = scene_obj_find(scn, tin->edit_id, SCENEOBJT_NONE); + if (!txt) + return log_msg_ret("cur", -ENOENT); + + vidconsole_set_cursor_pos(cons, txt->obj.bbox.x0, txt->obj.bbox.y0); + vidconsole_entry_start(cons); + cli_cread_init(&scn->cls, abuf_data(&tin->buf), tin->line_chars); + scn->cls.insert = true; + scn->cls.putch = scene_txtin_putch; + ret = vidconsole_entry_save(cons, &scn->entry_save); + if (ret) + return log_msg_ret("sav", ret); + + /* make sure the cursor is visible */ + vidconsole_readline_start(true); + + return 0; +} + void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin, struct vidconsole_bbox *bbox, struct vidconsole_bbox *edit_bbox)