From patchwork Sun Jan 18 20:42:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1605 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=1768769063; bh=T9tLmSbXKuNNwdjYOZk1L5F00v0sWYyd5yoVf2KEtLo=; 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=mLzKtf6Yh0baEkG72rqdt1daiwWLRpmGifkqxxl5jAH7fXbfwk76wCCiI7Q6m03wE 4QNTzSzGeQuG0zm1h7yUvqmrF/qtRtn1hJM3GpLmYz7hqmiQ4av/m9vtn5IPzzd2Yk WkTp81YcxccQiRRKgm3NMa22AoXSLRHaJeh1mzo91UHOl2VYgQqlHpTfNGsPLVI++R 5RW7fq8D+7hBw7FNXIsfCLmMF7iKhQPaZhkggAlauYIvk37zCPF/SeguEckirctKZl m7iNYXJQOtkq4cH913Z5Xb4dPWHKUFJwXZLLBKOJUbUNAEd9VAn1n5GFJDBmHzifmi vKOoAWf6Kk7OQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0CEB96949E for ; Sun, 18 Jan 2026 13:44:23 -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 KtO-1uftk5T5 for ; Sun, 18 Jan 2026 13:44:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769062; bh=T9tLmSbXKuNNwdjYOZk1L5F00v0sWYyd5yoVf2KEtLo=; 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=wfzdvEYYybjBPpE4r9vFyGty3lc/VNQEg6k0PjB+IvjRrx7k0VpssEiwka2p1JnKz YngB7d5RO2WepHSQrEocRsbhrHWWUzwwrqpBKv5EYPH3eqczMWsCkz4s1gq3MvNCBZ yXowGof/P5/bZJdQGuISnLLUkdTY0JKlmt3N46b9RBaI/9Ni4LE9SB4jsMP3yyIgh2 KpAIL8RC3w1v5Gfjo8P9ykAmWnhTXfX+ffv0NGKNqc7wpuminxZJIQCsNdKny4kYfk u0FAnM8mJ72yu24v1tTgalIwNfh8MWL2hBQ70t/PEyAtmWtHqFXAXkXHbc8T8uKDpS Idaqd8HwVmPLA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EE92069491 for ; Sun, 18 Jan 2026 13:44:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769060; bh=C9iuCcAhFzf+FHN/tebWFk2n5f640prXw+zYQf3BPO8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PniZPq0wCYRmnmvJL01YIxZG1z8M7heWVNpJUtBSvchRvzcgcq5QU3f/fsoDxhPPM gUyNCqnPlSV2dszJzRPE9Y2DZPSICBLwwyaIb31RdzVPpd+0mhgxB6x3sd/lqlzlzW eT3USqkp8fx2ptOZKfmbR2gQKAKeYZM4MBQ/m37TY2D+jyiI+N519M6cfahvEnXpfQ lCDyI4ygxANbarV1bUxgu3hZ96N09h9UEcK0VyCuA6Bxkf35NfjsvYU9CuifJwyzlO bBylaYeQDAELYk8B56Gy7bs4qJSV30g4oYGC5zxa2BpgoxWFJYXNCqY6QlnkOr/Ugn fzJEdm3dKql+Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DEDF269491; Sun, 18 Jan 2026 13:44:20 -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 3HOxIpY8950F; Sun, 18 Jan 2026 13:44:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769056; bh=vfxQOMQNG7loDvetaSqhOdED7vOXn7ejTCdwpkZnVv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A8osuPbLzLCHiIdCvwOeFdPETWtZ+2RXyaVl+BxMRVzjgOFlq+pSfWABdQQ0rMPBj D6DbppVWqY584YH1WdY8DooQ+bSlkgVcVTWEKkngd35G8u/5rByXY/RwSbbqr0yd5F VLbPGBf942x4kdjnuqqVkBQmE38r3sWXu8I1k5IIQ88b5ZoaHMWRJIQ8dN8kffz4EB m1uTklgTb9uR2478qOGEza4vK/TBp4n7bAn3YNqjYBaTmjHBJMbnuuSWiCSNrDk2o/ zR1ZXKoiU6vpp3iuAYsmUWri1iu3DonKRATWOdxJCxyUv5cg+qHzG+5ENAo6wKov3i VRfco3+2m7rBQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 912A86946A; Sun, 18 Jan 2026 13:44:16 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:53 -0700 Message-ID: <20260118204303.1982533-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260118204303.1982533-1-sjg@u-boot.org> References: <20260118204303.1982533-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZKI6TLLPYGRJINK6L2ERD6EGX76RMQEH X-Message-ID-Hash: ZKI6TLLPYGRJINK6L2ERD6EGX76RMQEH 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 14/16] expo: Add scene_txtin_init() for common text-input 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 Factor out common init code from scene_textline() and scene_texted() into a new scene_txtin_init() helper. This handles buffer allocation, clearing, and setting line_chars. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_internal.h | 10 ++++++++++ boot/scene_textedit.c | 10 +++------- boot/scene_textline.c | 9 +++------ boot/scene_txtin.c | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/boot/scene_internal.h b/boot/scene_internal.h index cc58a2264f6..b54bc1d426a 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -511,6 +511,16 @@ int scene_textline_calc_dims(struct scene_obj_textline *tline, void scene_menu_calc_bbox(struct scene_obj_menu *menu, struct vidconsole_bbox *bbox); +/** + * scene_txtin_init() - Initialise common text-input fields + * + * @tin: Text-input info to init + * @size: Size to use for buffer + * @line_chars: Number of characters in the text line + * Return: 0 if OK, -ENOMEM if out of memory + */ +int scene_txtin_init(struct scene_txtin *tin, uint size, uint line_chars); + /** * scene_txtin_calc_bbox() - Calculate bounding box for a text-input object * diff --git a/boot/scene_textedit.c b/boot/scene_textedit.c index 37138fc7542..9d0bfb2d552 100644 --- a/boot/scene_textedit.c +++ b/boot/scene_textedit.c @@ -22,7 +22,6 @@ int scene_texted(struct scene *scn, const char *name, uint id, uint line_chars, struct scene_obj_txtedit **teditp) { struct scene_obj_txtedit *ted; - char *buf; int ret; ret = scene_obj_add(scn, name, id, SCENEOBJT_TEXTEDIT, @@ -31,12 +30,9 @@ int scene_texted(struct scene *scn, const char *name, uint id, if (ret < 0) return log_msg_ret("obj", ret); - abuf_init(&ted->tin.buf); - if (!abuf_realloc(&ted->tin.buf, INITIAL_SIZE)) - return log_msg_ret("buf", -ENOMEM); - buf = abuf_data(&ted->tin.buf); - *buf = '\0'; - ted->tin.line_chars = line_chars; + ret = scene_txtin_init(&ted->tin, INITIAL_SIZE, line_chars); + if (ret) + return log_msg_ret("tin", ret); if (teditp) *teditp = ted; diff --git a/boot/scene_textline.c b/boot/scene_textline.c index 0f542dd590f..960f5e8861f 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -20,7 +20,6 @@ int scene_textline(struct scene *scn, const char *name, uint id, uint line_chars, struct scene_obj_textline **tlinep) { struct scene_obj_textline *tline; - char *buf; int ret; if (line_chars >= EXPO_MAX_CHARS) @@ -31,12 +30,10 @@ int scene_textline(struct scene *scn, const char *name, uint id, (struct scene_obj **)&tline); if (ret < 0) return log_msg_ret("obj", -ENOMEM); - if (!abuf_init_size(&tline->tin.buf, line_chars + 1)) - return log_msg_ret("buf", -ENOMEM); - buf = abuf_data(&tline->tin.buf); - *buf = '\0'; + ret = scene_txtin_init(&tline->tin, line_chars + 1, line_chars); + if (ret) + return log_msg_ret("tin", ret); tline->pos = line_chars; - tline->tin.line_chars = line_chars; if (tlinep) *tlinep = tline; diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index b2d8d0ad49e..cd27f9b7115 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -11,8 +11,22 @@ #include #include #include +#include #include "scene_internal.h" +int scene_txtin_init(struct scene_txtin *tin, uint size, uint line_chars) +{ + char *buf; + + if (!abuf_init_size(&tin->buf, size)) + return log_msg_ret("buf", -ENOMEM); + buf = abuf_data(&tin->buf); + *buf = '\0'; + tin->line_chars = line_chars; + + return 0; +} + void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin, struct vidconsole_bbox *bbox, struct vidconsole_bbox *edit_bbox)