From patchwork Sun Jan 18 20:42:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1592 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=1768769002; bh=ZxovhrEjOYcsiFcN9i3mwPMKkhYo3N+wsipV0ab/WDM=; 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=USMsAos0dC4yw4z1BLUQ1H8v+lCMFjFKljhgRULIKfJHSBI5J9zNDJgS0sM76/UXs 4r0+fag5fFSli5eFyZAjfL9CDVbg1LJxWXAO/xzHk8dL1T9FfUBNIVcZdbwqfhN1i2 k0U6xoSaux2T2/AUa0R9vQZyXCi1XP66TkB5+aG/31l4EUDxti1ioin567PxQn750n ag7QEw3qo7zSE6m1KEIY8MgULoMz7aDp6VQ4UcoI0wOv3iL4SutsnguGxZxEJB7cgA 4RVGM+fGsvj520H73ILnr6biurMg2vy9O7zeYAnORO0xuWKUaWtPDPhNIY8/RfX2up h/pGauRPLH59Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D24786948C for ; Sun, 18 Jan 2026 13:43:22 -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 j6GE5aNPpaFn for ; Sun, 18 Jan 2026 13:43:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769002; bh=ZxovhrEjOYcsiFcN9i3mwPMKkhYo3N+wsipV0ab/WDM=; 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=USMsAos0dC4yw4z1BLUQ1H8v+lCMFjFKljhgRULIKfJHSBI5J9zNDJgS0sM76/UXs 4r0+fag5fFSli5eFyZAjfL9CDVbg1LJxWXAO/xzHk8dL1T9FfUBNIVcZdbwqfhN1i2 k0U6xoSaux2T2/AUa0R9vQZyXCi1XP66TkB5+aG/31l4EUDxti1ioin567PxQn750n ag7QEw3qo7zSE6m1KEIY8MgULoMz7aDp6VQ4UcoI0wOv3iL4SutsnguGxZxEJB7cgA 4RVGM+fGsvj520H73ILnr6biurMg2vy9O7zeYAnORO0xuWKUaWtPDPhNIY8/RfX2up h/pGauRPLH59Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C154669491 for ; Sun, 18 Jan 2026 13:43:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769000; bh=vk2w9v0Ix2+rtvTrQfgSQ86q+XmlXNEbQNRr3Xs5Er4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F9zm6dGWgR+xW/IAkM4t59zR6kiV5PXUZ+NAI+z0m2j6km/gx+Fz+ht5xXfVc6WoZ LhN8lW/t3en4vYvY5PCirN58kGODatq1gHzA5g6368W052Efv+jTf2IQcp1asO1elo 5QFmuoAwjZsTSGJkNyFQz4y57gnBMk4AM1eTvMp+pQalV1xc21zgYXzfB4KXCiCk/X 6Pfo3WfMmDXrnlGepbZBH0ECCIJzqDdkddmHO753HgC6HCrKRxVLHDQkYydTJ/jXJo Axh089apflIdyPHixqCtADIaF3pbb0SOrbJVQ7ojrPfERjAX3jsB8YM+mByKm/NjIh 8WENRf41yZy/w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C3EA16948C; Sun, 18 Jan 2026 13:43: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 0fhDHZgmQUlt; Sun, 18 Jan 2026 13:43:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768768996; bh=DhVKzZDAYL9AGDJ3BSojvsBM8yg2KV7Orh79IUVkM44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g1UbrURB8o37oSrMzWb6zvjlawG7vbz/3oAMrWHb/m24AXSqn2Yg/AFle317vYZ23 U2ZrWng/n4z4x9lNBYgZZl9Bnub+nM3OAigddabMHRGOXCvzNGc2NltlC0JjdP+/wq Ic4Gy/9D6Thk07LKvFgQl06cpliREXKIFrXKwJMaRC8+Y0XQ0VPjG9O4uBLiRBtdSO VnUiuP7XvQDGx2v7meb2WvauhwFG+hFAD0QABNoZZpNL/ufwMXelTHY003w08J2xqC 75z0bf2zNUL7ZHKodQx/5M6Z/kmdSEJ8iXXf5Spv4qGuft5brcW8Vo5uTkowaW5Cnb K6OGQJ4dDhYgA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7A50069394; Sun, 18 Jan 2026 13:43:16 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:40 -0700 Message-ID: <20260118204303.1982533-2-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: ZHOYGN5ZU5UWYKIEWXQZFRVFVVOYKCIW X-Message-ID-Hash: ZHOYGN5ZU5UWYKIEWXQZFRVFVVOYKCIW 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 01/16] test: acpi: Fix flaky dm_test_acpi_fpdt checksum test 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 The test modifies ebs_entry and ebs_exit to 123 and 456, then expects the checksum to become invalid. However, the original values come from timer_get_boot_us() which varies each run. If the byte sum of the timer values coincidentally equals the byte sum of 123 + 456, the checksum remains valid and the test fails. Use 0 for the modified values instead, since the test already verifies the original values are non-zero. This guarantees the checksum changes. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/dm/acpi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 1409c333eb1..588a518bc4f 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -1012,9 +1012,12 @@ static int dm_test_acpi_fpdt(struct unit_test_state *uts) ut_asserteq_ptr(rec, (struct acpi_fpdt_boot *)(fpdt + 1)); ut_asserteq(1234, rec->reset_end); - /* Update a timing field */ - rec->ebs_entry = 123; - rec->ebs_exit = 456; + /* + * Update timing fields - use 0 since we know the original values are + * non-zero + */ + rec->ebs_entry = 0; + rec->ebs_exit = 0; /* Checksum should now be invalid */ ut_assert(table_compute_checksum(fpdt, fpdt->header.length) != 0); @@ -1026,8 +1029,8 @@ static int dm_test_acpi_fpdt(struct unit_test_state *uts) ut_asserteq(0, table_compute_checksum(fpdt, fpdt->header.length)); /* Verify the updated values are still there */ - ut_asserteq(123, rec->ebs_entry); - ut_asserteq(456, rec->ebs_exit); + ut_asserteq(0, rec->ebs_entry); + ut_asserteq(0, rec->ebs_exit); unmap_sysmem(buf); From patchwork Sun Jan 18 20:42:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1593 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=1768769008; bh=8brEVj9grnTKeaxUQljUbh7It/+axzPKma1l8RWsT5Q=; 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=UOwRY++9lPcf5SAHW9LwcKmO00HsxBk/+SdpbZ/TJu3HmvrcSMnU2vWRxP+G4vB0w UOVKHSTTouEhBlhIGwqmgwFt72wh46KySnJcdkE9LyoAmDsY1BROuQR3mcM5XXST/r ZhHYVI/Kwoz+h0ULDrcCYoGnr2BeET3tA7J1hE5x5S79rV5CIMRlxLGtD3uscyOmSV /Z4jPM8qV9CtQI/mMrRt4DPgGUerFzcRDQiHxT8FM/EpEJ5LGva+BqsezXyH4gd9GE V5WV/2U5ID6zSuolr96r+j3K6AFTJt0JAGtXLPctY5OoCiymvQDw5ZUG2A5EvFEOeK fDJVN0L2b/yEQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 41E3369494 for ; Sun, 18 Jan 2026 13:43:28 -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 ebUofX6hfEN3 for ; Sun, 18 Jan 2026 13:43:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769008; bh=8brEVj9grnTKeaxUQljUbh7It/+axzPKma1l8RWsT5Q=; 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=UOwRY++9lPcf5SAHW9LwcKmO00HsxBk/+SdpbZ/TJu3HmvrcSMnU2vWRxP+G4vB0w UOVKHSTTouEhBlhIGwqmgwFt72wh46KySnJcdkE9LyoAmDsY1BROuQR3mcM5XXST/r ZhHYVI/Kwoz+h0ULDrcCYoGnr2BeET3tA7J1hE5x5S79rV5CIMRlxLGtD3uscyOmSV /Z4jPM8qV9CtQI/mMrRt4DPgGUerFzcRDQiHxT8FM/EpEJ5LGva+BqsezXyH4gd9GE V5WV/2U5ID6zSuolr96r+j3K6AFTJt0JAGtXLPctY5OoCiymvQDw5ZUG2A5EvFEOeK fDJVN0L2b/yEQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2DABC6948C for ; Sun, 18 Jan 2026 13:43:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769005; bh=8R3uUhNyon4WsqNwrjw0X6E/QVL/JpaoYz66x1u0Sp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZNpgPiPkbxHpDZalTnNudyEd/VHZPYiM6S2Dvsvcyw2qN+0XUyfxj/QfAEERElky2 6qUiTz/JnwiH1Tb1s/VtRG3zg9kWdOfsmTEee2q4NUkK54kXhhXsXdZ//kWP+5RrOL BarUwsKSQr4VxT6yx+7soZtaoixyf8Aj5SgkamZ55bldgy1d8DwrcQWFBbb32QbRwi km3STmpaNu73hsUTEVvmcp0wMcmd1qi1Jhe+bqqJRpjwoeS4upYD/Zkg09Sj2eaFuN T8K/66K4RjcL8nnVwDSTfFQt3xPXsg8kU3IVN2Jo9TrsknJroedepb1YEOiZ16NPgq hL5FlZOYuKRzw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6F1986946A; Sun, 18 Jan 2026 13:43:25 -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 pHtUbJpOKoDx; Sun, 18 Jan 2026 13:43:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769001; bh=tNaGiZ0QkvFO2VsBjt/n2Fu6H29VgzyOFsDnQnfugcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HhGqdfvaoNEHVf3w+qTbD7ZQPJoTT+2iHetULYUXoa7VNgyISjQS6E0xBmOIT2nDU vTJBFIZRuK+kSUtb58uW7S1Y3BztibzP7/ai9dxpqx+3N086ci0riP6ietCANDCDK6 6MGyBZWBsK8Kzx2TMUHNmpHrA+fPka4tjTST9e+wM6fNM/1ox/yZP8V9cYDmT1LWe3 A8iwfOqUAujtURipYBIYXxJmMCEDWru6f0HbsPanC0VKyKZS6aA5DOcAB+R42mvXIS AM1/2B2+zC3/B6scvUjvl7EMG4BNxvbWAJl/mYQ5gWhTk2l+5Op5dqppe87cOPBUb2 laZ/Cr3bAGcbA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 14E1969394; Sun, 18 Jan 2026 13:43:21 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:41 -0700 Message-ID: <20260118204303.1982533-3-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: OSX7HWUEEGECKNH725FPHR4SLAOZOSYT X-Message-ID-Hash: OSX7HWUEEGECKNH725FPHR4SLAOZOSYT 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 02/16] cli: Add putch callback to struct cli_line_state 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 Add a callback function pointer to struct cli_line_state that allows redirection of character output during line editing. This enables expo textlines to direct output to the correct vidconsole context. Add a new Kconfig option CLI_READLINE_CALLBACK which is selected by EXPO When enabled, the callback is checked before outputting characters. When disabled, the compiler optimises away the check. Update all character-output functions in cli_readline.c to use the new cls_putch() helper, which calls the callback if set or falls back to putc() Add a few comments while we are here. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/Kconfig | 1 + cmd/Kconfig | 8 +++++ common/cli_readline.c | 82 +++++++++++++++++++++++++++---------------- include/cli.h | 2 ++ 4 files changed, 63 insertions(+), 30 deletions(-) diff --git a/boot/Kconfig b/boot/Kconfig index cde4472ca57..7ff0dedb748 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -973,6 +973,7 @@ config EXPO bool "Support for expos - groups of scenes displaying a UI" depends on VIDEO default y if BOOTMETH_VBE + select CLI_READLINE_CALLBACK if CMDLINE_EDITING help An expo is a way of presenting and collecting information from the user. It consists of a collection of 'scenes' of which only one is diff --git a/cmd/Kconfig b/cmd/Kconfig index 072ff879cd8..8a873b1d927 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -54,6 +54,14 @@ config CMDLINE_EDITING Enable editing and History functions for interactive command line input operations +config CLI_READLINE_CALLBACK + bool "Support a callback for character output" + depends on CMDLINE_EDITING + help + Enable a callback for character output during line editing. This + allows redirection of output to a different destination, such as + a vidconsole. This is used by expo to support textline editing. + config CMDLINE_PS_SUPPORT bool "Enable support for changing the command prompt string at run-time" depends on HUSH_PARSER diff --git a/common/cli_readline.c b/common/cli_readline.c index 244a287b435..81b0688da38 100644 --- a/common/cli_readline.c +++ b/common/cli_readline.c @@ -71,9 +71,23 @@ static char *delete_char (char *buffer, char *p, int *colp, int *np, int plen) #define DEL7 ((char)127) #define CREAD_HIST_CHAR ('!') -#define getcmd_putch(ch) putc(ch) #define getcmd_getch() getchar() -#define getcmd_cbeep() getcmd_putch('\a') + +/** + * cls_putch() - Output a character, using callback if available + * + * @cls: CLI line state + * @ch: Character to output + */ +static void cls_putch(struct cli_line_state *cls, int ch) +{ + if (CONFIG_IS_ENABLED(CLI_READLINE_CALLBACK) && cls->putch) + cls->putch(cls, ch); + else + putc(ch); +} + +#define getcmd_cbeep(cls) cls_putch(cls, '\a') #ifdef CONFIG_XPL_BUILD #define HIST_MAX 3 @@ -95,12 +109,19 @@ static char *hist_list[HIST_MAX]; #define add_idx_minus_one() ((hist_add_idx == 0) ? hist_max : hist_add_idx-1) -static void getcmd_putchars(int count, int ch) +/** + * cls_putchars() - Output a character multiple times + * + * @cls: CLI line state + * @count: Number of times to output the character + * @ch: Character to output + */ +static void cls_putchars(struct cli_line_state *cls, int count, int ch) { int i; for (i = 0; i < count; i++) - getcmd_putch(ch); + cls_putch(cls, ch); } static int hist_init(void) @@ -206,7 +227,7 @@ void cread_print_hist_list(void) #define BEGINNING_OF_LINE() { \ while (cls->num) { \ - getcmd_putch(CTL_BACKSPACE); \ + cls_putch(cls, CTL_BACKSPACE); \ cls->num--; \ } \ } @@ -215,7 +236,7 @@ void cread_print_hist_list(void) if (cls->num < cls->eol_num) { \ printf("%*s", (int)(cls->eol_num - cls->num), ""); \ do { \ - getcmd_putch(CTL_BACKSPACE); \ + cls_putch(cls, CTL_BACKSPACE); \ } while (--cls->eol_num > cls->num); \ } \ } @@ -228,15 +249,15 @@ void cread_print_hist_list(void) } \ } -static void cread_add_char(char ichar, int insert, uint *num, - uint *eol_num, char *buf, uint len) +static void cread_add_char(struct cli_line_state *cls, char ichar, int insert, + uint *num, uint *eol_num, char *buf, uint len) { uint wlen; /* room ??? */ if (insert || *num == *eol_num) { if (*eol_num > len - 1) { - getcmd_cbeep(); + getcmd_cbeep(cls); return; } (*eol_num)++; @@ -251,7 +272,7 @@ static void cread_add_char(char ichar, int insert, uint *num, putnstr(buf + *num, wlen); (*num)++; while (--wlen) - getcmd_putch(CTL_BACKSPACE); + cls_putch(cls, CTL_BACKSPACE); } else { /* echo the character */ wlen = 1; @@ -261,11 +282,12 @@ static void cread_add_char(char ichar, int insert, uint *num, } } -static void cread_add_str(char *str, int strsize, int insert, - uint *num, uint *eol_num, char *buf, uint len) +static void cread_add_str(struct cli_line_state *cls, char *str, int strsize, + int insert, uint *num, uint *eol_num, char *buf, + uint len) { while (strsize--) { - cread_add_char(*str, insert, num, eol_num, buf, len); + cread_add_char(cls, *str, insert, num, eol_num, buf, len); str++; } } @@ -293,13 +315,13 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) return -EINTR; case CTL_CH('f'): if (cls->num < cls->eol_num) { - getcmd_putch(buf[cls->num]); + cls_putch(cls, buf[cls->num]); cls->num++; } break; case CTL_CH('b'): if (cls->num) { - getcmd_putch(CTL_BACKSPACE); + cls_putch(cls, CTL_BACKSPACE); cls->num--; } break; @@ -314,9 +336,9 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) putnstr(buf + cls->num, wlen); } - getcmd_putch(' '); + cls_putch(cls, ' '); do { - getcmd_putch(CTL_BACKSPACE); + cls_putch(cls, CTL_BACKSPACE); } while (wlen--); cls->eol_num--; } @@ -346,11 +368,11 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) memmove(&buf[base], &buf[cls->num], cls->eol_num - base + 1); cls->num = base; - getcmd_putchars(wlen, CTL_BACKSPACE); + cls_putchars(cls, wlen, CTL_BACKSPACE); puts(buf + base); - getcmd_putchars(wlen, ' '); - getcmd_putchars(wlen + cls->eol_num - cls->num, - CTL_BACKSPACE); + cls_putchars(cls, wlen, ' '); + cls_putchars(cls, wlen + cls->eol_num - cls->num, + CTL_BACKSPACE); } break; case CTL_CH('x'): @@ -367,11 +389,11 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) wlen = cls->eol_num - cls->num; cls->num--; memmove(&buf[cls->num], &buf[cls->num + 1], wlen); - getcmd_putch(CTL_BACKSPACE); + cls_putch(cls, CTL_BACKSPACE); putnstr(buf + cls->num, wlen); - getcmd_putch(' '); + cls_putch(cls, ' '); do { - getcmd_putch(CTL_BACKSPACE); + cls_putch(cls, CTL_BACKSPACE); } while (wlen--); cls->eol_num--; } @@ -387,7 +409,7 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) hline = hist_next(); if (!hline) { - getcmd_cbeep(); + getcmd_cbeep(cls); break; } @@ -411,7 +433,7 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) /* do not autocomplete when in the middle */ if (cls->num < cls->eol_num) { - getcmd_cbeep(); + getcmd_cbeep(cls); break; } @@ -427,8 +449,8 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) } fallthrough; default: - cread_add_char(ichar, cls->insert, &cls->num, &cls->eol_num, - buf, cls->len); + cread_add_char(cls, ichar, cls->insert, &cls->num, + &cls->eol_num, buf, cls->len); break; } @@ -451,8 +473,8 @@ void cli_cread_init(struct cli_line_state *cls, char *buf, uint buf_size) cls->len = buf_size; if (init_len) - cread_add_str(buf, init_len, 0, &cls->num, &cls->eol_num, buf, - buf_size); + cread_add_str(cls, buf, init_len, 0, &cls->num, &cls->eol_num, + buf, buf_size); } static int cread_line(const char *const prompt, char *buf, unsigned int *len, diff --git a/include/cli.h b/include/cli.h index e183d561369..88f96c03cb3 100644 --- a/include/cli.h +++ b/include/cli.h @@ -36,6 +36,7 @@ struct cli_ch_state { * be set) * @buf: Buffer containing line * @prompt: Prompt for the line + * @putch: Function to call to output a character (NULL to use putc()) */ struct cli_line_state { uint num; @@ -46,6 +47,7 @@ struct cli_line_state { bool cmd_complete; char *buf; const char *prompt; + void (*putch)(struct cli_line_state *cls, int ch); }; /** From patchwork Sun Jan 18 20:42:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1594 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=1768769011; bh=GPrYKAOcHzuZzLwe1ypejuje0mP1OOWbYcFbUCNalZM=; 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=eUfsd+Czte+KpLExr2Leaf7HDtQcJsSixwpoxjjTnc75EAFgc4F3DLwK+41ooUR15 9eweHuS4Lc2wYnfbJ02jbGHiqizk9xGrPHIUWzaXvT5XNt+nieZ0xQpK2kGApBCyr+ BefmmOGNi9dlzADrpKExJKuoqMgGuIK3baJIEzyYkCDKPDPhdPH980XHvV69Kjzfah 6pXDT4cwuUECcl1OwCyu+ZuLB5iVFhcPsVSs909mnpNqSpytYhCMsfDk0/NObwIS+c kSZ9nXMPHDs5vrJnPu/zFrg7L/pXD9KT64eX5fTBMSBgqVZFz4pKCCgEOG8e+fHsWw p+rEI2qaewBrA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A511B69494 for ; Sun, 18 Jan 2026 13:43:31 -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 9MEuBZXt7F9v for ; Sun, 18 Jan 2026 13:43:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769011; bh=GPrYKAOcHzuZzLwe1ypejuje0mP1OOWbYcFbUCNalZM=; 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=eUfsd+Czte+KpLExr2Leaf7HDtQcJsSixwpoxjjTnc75EAFgc4F3DLwK+41ooUR15 9eweHuS4Lc2wYnfbJ02jbGHiqizk9xGrPHIUWzaXvT5XNt+nieZ0xQpK2kGApBCyr+ BefmmOGNi9dlzADrpKExJKuoqMgGuIK3baJIEzyYkCDKPDPhdPH980XHvV69Kjzfah 6pXDT4cwuUECcl1OwCyu+ZuLB5iVFhcPsVSs909mnpNqSpytYhCMsfDk0/NObwIS+c kSZ9nXMPHDs5vrJnPu/zFrg7L/pXD9KT64eX5fTBMSBgqVZFz4pKCCgEOG8e+fHsWw p+rEI2qaewBrA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9525B6948C for ; Sun, 18 Jan 2026 13:43:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769010; bh=B36VLoSvw92uzsyUr32DyBGqWOoe/+fkUUoO0CqGSeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kPEuizCklMI8Qoy8EWIdWZ8VsOH9wUmc+egMDx1h+9NEAwGOxhZ2+L7WlAewF1kl4 Yh/cUepeWJOZ8Jdig5Z31KWc+Xq9LR+8yeOAYJb8ns5azTdc9RSFOYaipouKcEikjo W8No7rGjDTycZLycFZvOqi+wUy/69hcl2IXgIYpZEujLP573yHrtZjUEWTv0VmNpXb wbh/bRPYYBwRdecYj+aoPtxLY49bF6ZZ/70Lqjfajn41nf4au0lD0vTxh43hG4smIz 6VJWHcbpnmhmh2JBO//7ZT9ctynmB9GSmGY6LRQhAXZOQBqXWwGiODmMaZZ9zIt2bK U7azs6NHP5Wxg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9FF046948C; Sun, 18 Jan 2026 13:43:30 -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 JRSErmgAEyPn; Sun, 18 Jan 2026 13:43:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769006; bh=p2r0S4f0pzDBFwPTU/3+s83nCLu3gADvx4iidP9n240=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IRDo7oRRGn2HW8Zdy4HS5uyf+DC8g02C0qmTZsz3iKPPPnp5YpOzlKjjYvbfMaaAf 2EJoOVuJChBDuvn0iTQuLJIA26LD1jDNNWaSS8FIYmqID7ejePGlsidIzxTRNEr68Y n+Ur2EJZnE+q8+RBYqAt/vTN957AggT79Hz5QdFaXAVBt8MoCZSTqpVzSYbhAPVxKb Q8hWrUolFaEYX4GBn98YmH2tFqs5p9556t57ec0ppiG0WjqjGEkLDRL8pDR32StKF6 79NZw+cZ0GbwiisTrvSrINSLpSjc1eRQ7oo4nBPpqN0kg8U+pw73WzqdPcGxKFR6rE wrYdAry1Tb3RA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B04EB69394; Sun, 18 Jan 2026 13:43:25 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:42 -0700 Message-ID: <20260118204303.1982533-4-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: 44KH5FV546CF4Y6ODZ675KAG6ZTDB6NP X-Message-ID-Hash: 44KH5FV546CF4Y6ODZ675KAG6ZTDB6NP 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 03/16] cli: Convert ERASE_TO_EOL macro to a function 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 Convert the ERASE_TO_EOL macro to cread_erase_to_eol() function. This reduces code size by 71 bytes since the function is called from three places. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- common/cli_readline.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/common/cli_readline.c b/common/cli_readline.c index 81b0688da38..2e41aa5afef 100644 --- a/common/cli_readline.c +++ b/common/cli_readline.c @@ -232,13 +232,14 @@ void cread_print_hist_list(void) } \ } -#define ERASE_TO_EOL() { \ - if (cls->num < cls->eol_num) { \ - printf("%*s", (int)(cls->eol_num - cls->num), ""); \ - do { \ - cls_putch(cls, CTL_BACKSPACE); \ - } while (--cls->eol_num > cls->num); \ - } \ +static void cread_erase_to_eol(struct cli_line_state *cls) +{ + if (cls->num < cls->eol_num) { + printf("%*s", (int)(cls->eol_num - cls->num), ""); + do { + cls_putch(cls, CTL_BACKSPACE); + } while (--cls->eol_num > cls->num); + } } #define REFRESH_TO_EOL() { \ @@ -344,7 +345,7 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) } break; case CTL_CH('k'): - ERASE_TO_EOL(); + cread_erase_to_eol(cls); break; case CTL_CH('e'): REFRESH_TO_EOL(); @@ -378,7 +379,7 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) case CTL_CH('x'): case CTL_CH('u'): BEGINNING_OF_LINE(); - ERASE_TO_EOL(); + cread_erase_to_eol(cls); break; case DEL: case DEL7: @@ -418,7 +419,7 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) BEGINNING_OF_LINE(); /* erase to end of line */ - ERASE_TO_EOL(); + cread_erase_to_eol(cls); /* copy new line into place and display */ strcpy(buf, hline); From patchwork Sun Jan 18 20:42:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1595 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=1768769016; bh=WRpPHrFCecNWMk4E7gpPBO55Fx7oe9kT01Ou8mzFTkM=; 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=f4ULT2tIf8ZuBWgMzwKZC6LnKDBMH0oTqe14vAFiCFdqmLyqZYwI2+E5CVsOmUQn0 mJpTpu70J42gdP5g2dNN0xJaozhI40kJ7DUzPjkDEkH3WXvW9ZX5k5MyHqQ6GfXw6s Xhg9I+aqTxLT67U62awuGJwLNL2wUYnyA8SoWCWYAIPTTHJxBVPjJheVC+cTZEovgW DyicZunZ2XOWyQsLFgkpFSqB4aMEUUkRBhM2dLXQY90kPa00GUHzAqlla/ffatHvut ltCydaSwNeYUkcRZuJ1NP0qETsUh89CctmhyflYoYkCDXJZapNXsg832f0lCmPxOlb wUb7nko+y43Dw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 746C26948C for ; Sun, 18 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 10024) with ESMTP id aF1EgA6wuWqg for ; Sun, 18 Jan 2026 13:43:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769016; bh=WRpPHrFCecNWMk4E7gpPBO55Fx7oe9kT01Ou8mzFTkM=; 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=f4ULT2tIf8ZuBWgMzwKZC6LnKDBMH0oTqe14vAFiCFdqmLyqZYwI2+E5CVsOmUQn0 mJpTpu70J42gdP5g2dNN0xJaozhI40kJ7DUzPjkDEkH3WXvW9ZX5k5MyHqQ6GfXw6s Xhg9I+aqTxLT67U62awuGJwLNL2wUYnyA8SoWCWYAIPTTHJxBVPjJheVC+cTZEovgW DyicZunZ2XOWyQsLFgkpFSqB4aMEUUkRBhM2dLXQY90kPa00GUHzAqlla/ffatHvut ltCydaSwNeYUkcRZuJ1NP0qETsUh89CctmhyflYoYkCDXJZapNXsg832f0lCmPxOlb wUb7nko+y43Dw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 61F8A69491 for ; Sun, 18 Jan 2026 13:43:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769014; bh=jCUmWIUkxz3l4VG+xGJL5pUZssxMFt0jTGquj8wuQ9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J0YdYLKreUwUJwQnaqQHNluVZECZ068Fo+1ftIQH72blgXlxj3L45tOvyZfo3FeJd 0gRJyHKKjosqRUNbU8zKXYDZa/kipawd3CJRJATROC6X4UOg7lvjRHpGNYhcEPxV1r D7mozLKwAaJ84Qimi27u5WsTQl1l76FRiynEsRnHZnag6xFughW8LDpnX+YoVzq90j dZp5CIcZwaUoZHkopaX/xge1LNgpGnOdhnIoiBgGrMuAtphI/ZCVHb+WtoOuyXZ9p/ yj1hE35xfxvbKsK4Qwa+Sd7XG1qs22UfOhHPpR8fXEtNM2MMfalTd3Kcnz7xjH9ARo T5eirI77XJNCg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9612A6948C; Sun, 18 Jan 2026 13:43:34 -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 UjpZhpMSIYoC; Sun, 18 Jan 2026 13:43:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769010; bh=1hv9iGktruAalLkRjR9/B6mJsG7nnhPEaQrBqwVSOsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mIe13DodhFVQ2LeD/4HrSEIsN2plpEdAGWtED1mjS0PUr5ayIyoR49CfvTZnfKTTV 4MAO5XzYnzGIz9JZilZ6dsNI75MvEAhb/eZndeFUac4qT2OgSsVDcpUlWXuvgGbi2n yljngmBsqij9l5XY0g/Zey9Z88sTq4bXrY1RaL09igCuSTd84d/Mn8g9M8i9htGo+u 8R/oY9Jn4+MIFkT12Ksb5aliq0YUSrn5KK3izulbDXWVhGqXM8lvrWIq3FJ2vYrh4o ZUHM+q+6Vr9q7TUym4/SFGsIMPjsU5stFwipR6xSwvd9hVZ6Wwq2QG52VACJMdobSd 74mOVAvRUU89g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4CBE16946A; Sun, 18 Jan 2026 13:43:30 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:43 -0700 Message-ID: <20260118204303.1982533-5-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: GA52Q7UPHDMYVJUSOVAFKZB5OBWPKBWW X-Message-ID-Hash: GA52Q7UPHDMYVJUSOVAFKZB5OBWPKBWW 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/16] cli: Add cls_putnstr() for string output with callback 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 Add cls_putnstr() to output a string of specified length using the putch callback. Update all putnstr() calls to use cls_putnstr() so that string output is also redirected when a callback is set. Remove the now-unused putnstr macro. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- common/cli_readline.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/common/cli_readline.c b/common/cli_readline.c index 2e41aa5afef..4eb34d7cf7c 100644 --- a/common/cli_readline.c +++ b/common/cli_readline.c @@ -64,8 +64,6 @@ static char *delete_char (char *buffer, char *p, int *colp, int *np, int plen) * Author: Janghoon Lyu */ -#define putnstr(str, n) printf("%.*s", (int)n, str) - #define CTL_BACKSPACE ('\b') #define DEL ((char)255) #define DEL7 ((char)127) @@ -87,6 +85,12 @@ static void cls_putch(struct cli_line_state *cls, int ch) putc(ch); } +static void cls_putnstr(struct cli_line_state *cls, const char *str, size_t n) +{ + while (n-- > 0) + cls_putch(cls, *str++); +} + #define getcmd_cbeep(cls) cls_putch(cls, '\a') #ifdef CONFIG_XPL_BUILD @@ -245,7 +249,7 @@ static void cread_erase_to_eol(struct cli_line_state *cls) #define REFRESH_TO_EOL() { \ if (cls->num < cls->eol_num) { \ uint wlen = cls->eol_num - cls->num; \ - putnstr(buf + cls->num, wlen); \ + cls_putnstr(cls, buf + cls->num, wlen); \ cls->num = cls->eol_num; \ } \ } @@ -270,7 +274,7 @@ static void cread_add_char(struct cli_line_state *cls, char ichar, int insert, memmove(&buf[*num+1], &buf[*num], wlen-1); buf[*num] = ichar; - putnstr(buf + *num, wlen); + cls_putnstr(cls, buf + *num, wlen); (*num)++; while (--wlen) cls_putch(cls, CTL_BACKSPACE); @@ -278,7 +282,7 @@ static void cread_add_char(struct cli_line_state *cls, char ichar, int insert, /* echo the character */ wlen = 1; buf[*num] = ichar; - putnstr(buf + *num, wlen); + cls_putnstr(cls, buf + *num, wlen); (*num)++; } } @@ -334,7 +338,7 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) if (wlen) { memmove(&buf[cls->num], &buf[cls->num + 1], wlen); - putnstr(buf + cls->num, wlen); + cls_putnstr(cls, buf + cls->num, wlen); } cls_putch(cls, ' '); @@ -370,7 +374,7 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) cls->eol_num - base + 1); cls->num = base; cls_putchars(cls, wlen, CTL_BACKSPACE); - puts(buf + base); + cls_putnstr(cls, buf + base, cls->eol_num - base); cls_putchars(cls, wlen, ' '); cls_putchars(cls, wlen + cls->eol_num - cls->num, CTL_BACKSPACE); @@ -391,7 +395,7 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) cls->num--; memmove(&buf[cls->num], &buf[cls->num + 1], wlen); cls_putch(cls, CTL_BACKSPACE); - putnstr(buf + cls->num, wlen); + cls_putnstr(cls, buf + cls->num, wlen); cls_putch(cls, ' '); do { cls_putch(cls, CTL_BACKSPACE); From patchwork Sun Jan 18 20:42:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1596 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=1768769019; bh=mdO1icx33cmC1lqqY6gDUIgJVPANY+7eht9OCRPkpMQ=; 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=nl70YtGi9wEKbHXRiG/LKjjAnKGRCiXfA6SOQPiM4e5skoG6EymrJC8YPF8jo84ff atF9waiNUktjI8cAdC7OlH6S3SUn6i6jX9ETCIFxy9k0WRYD4afhb9KGjnjwjJE104 TbemSNXmxXQHPR7Vu/gynzG4OUtGPYS3VFdIRAkapuwKalNoITvfAASMSekCfnY++s CusEX0EFgOYwZGdoQ6PFJtH7XWIWUh5t7b/ppFCjVmF4g6rZTeZW3CQjG2840xlsLZ TLdFOBFXUeeVRgsvLtq2GqV2RE+Fg8G09ZNUvArfQJRtLKWXmVPQ01TUN9rFKCaMGV Xbqb5aMtYFZSw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E9E856949B for ; Sun, 18 Jan 2026 13:43:39 -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 05YNFRhDtuBD for ; Sun, 18 Jan 2026 13:43:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769019; bh=mdO1icx33cmC1lqqY6gDUIgJVPANY+7eht9OCRPkpMQ=; 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=nl70YtGi9wEKbHXRiG/LKjjAnKGRCiXfA6SOQPiM4e5skoG6EymrJC8YPF8jo84ff atF9waiNUktjI8cAdC7OlH6S3SUn6i6jX9ETCIFxy9k0WRYD4afhb9KGjnjwjJE104 TbemSNXmxXQHPR7Vu/gynzG4OUtGPYS3VFdIRAkapuwKalNoITvfAASMSekCfnY++s CusEX0EFgOYwZGdoQ6PFJtH7XWIWUh5t7b/ppFCjVmF4g6rZTeZW3CQjG2840xlsLZ TLdFOBFXUeeVRgsvLtq2GqV2RE+Fg8G09ZNUvArfQJRtLKWXmVPQ01TUN9rFKCaMGV Xbqb5aMtYFZSw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D8C3A69494 for ; Sun, 18 Jan 2026 13:43:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769019; bh=c0glyGhW2spS9/5G/6IwjLlnNbQnKNPu8p2El58CRr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TN11MEUoSSqrIetCHYWcJtRpqhq+ctcLtgbdwFZSDroMLxAxVncPcFTos8c+akVvb PF14dhA9bRT5djTOWVyB2i32n97jlwKSagVG6U11zM/5o5hLBmk5mBuVgkdROOhP8w TkPVWt+cMLiOo8UlsUOlU+aBEM8BdkSLRnd8D6o3xnPBsECR0erbtfBz/eUigO9npW rFfDm1HlMTo2oz6UmsqaVnxLTiGiTtudbxWmzMNeG+ftflRErcLPG81nlffhu7jg7X tkcA2li1pClCGftfZbkAdIe2H0D79zRDjTfbW4amt+x/7rsUC+vE3FQI5rIdDByOYn Pz6BjjQhzKt/Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2CBFE6948C; Sun, 18 Jan 2026 13:43:39 -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 1DxilYQpxuO9; Sun, 18 Jan 2026 13:43:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769015; bh=p5uyj91zpKlZyn6jIRmZp9yQxarnGlKvLx8a22YZtwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b3AcFBaKA+Q4SOrDlGbiYpRzGsejsGJxuoVCUBSve3YY4IsRObkHNDESqyfpZZZx+ +5e2XH43R+5pCOh3IwdcKoyjBclgZQ40flXNbLthk9JDdfVaEYZcEd8ay+jFSFWu/U 1gykRixWHR5CHvsoOf8K9sb0hU8mpJ0wHf9+4HacKAGVtPSYWizY7APVkwM96bAiUM Acb3LRuivF8t/MRLx3KV7qp+HADZpvoMxvvc8FbuLWyZiUlwtAOes1gNNAswSyAiK1 gJm/95P8fGziK/sCN4wNJ5EE7WMgdTbKK7xG0cqJsUknX9hbtFkOQj5OadDc+jIICS Ubd+TUiNZNyJw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D64426946A; Sun, 18 Jan 2026 13:43:34 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:44 -0700 Message-ID: <20260118204303.1982533-6-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: VVUL4CZGED5CWHE7LDEFJQRRAIVIHPDJ X-Message-ID-Hash: VVUL4CZGED5CWHE7LDEFJQRRAIVIHPDJ 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 05/16] expo: Wire up putch callback for textline editing 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 Add a scene_textline_putch() callback that outputs characters to the vidconsole using vidconsole_put_char(). Set this callback in scene_textline_open() so that CLI line editing output goes to the correct vidconsole rather than the default console. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_textline.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/boot/scene_textline.c b/boot/scene_textline.c index 20e2d7f33c4..082b39f2497 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -213,6 +213,22 @@ int scene_textline_render_deps(struct scene *scn, return 0; } +/** + * 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; @@ -232,6 +248,7 @@ int scene_textline_open(struct scene *scn, struct scene_obj_textline *tline) vidconsole_entry_start(cons); cli_cread_init(&scn->cls, abuf_data(&tline->buf), tline->max_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); From patchwork Sun Jan 18 20:42:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1597 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=1768769025; bh=tJ608chImMK+Ye8I6i/VNBMKCBb3vgJAiU/BlWBqSHc=; 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=tvOdnLM1YfHWoasmXZxXxew8DJXH3ZcB/cjB8z0CfZesXeG9Xa+Dwgzy34LFHuyp6 W9A4H82N+UsA0IwM0LJznXJ8g5qyTL+MHImbhhFgjPpgaZYgnZqU9GfpGrL+wEiOao b9reRLM3ceR0NRPEg2jQbty/aMpdCOEsej0J95LU6cJekjXFm+tVcRL96a9xtA9wDg 7ksqnAA+DFs1HVZAA4OLQTIa76lRp4NL28EeCUnx5FKEmYsIlMmKKl0jqw5yYGGbqn Cj3BXZbgfg6JYsZr2eQ+ttL1ivv8IR/AXbPwfBzE0kSQ1dlQZpL5+H4hv2vNnJzxzs dvB3R/M531EUQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6A2376949B for ; Sun, 18 Jan 2026 13:43:45 -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 TNwyXYu8is-W for ; Sun, 18 Jan 2026 13:43:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769025; bh=tJ608chImMK+Ye8I6i/VNBMKCBb3vgJAiU/BlWBqSHc=; 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=tvOdnLM1YfHWoasmXZxXxew8DJXH3ZcB/cjB8z0CfZesXeG9Xa+Dwgzy34LFHuyp6 W9A4H82N+UsA0IwM0LJznXJ8g5qyTL+MHImbhhFgjPpgaZYgnZqU9GfpGrL+wEiOao b9reRLM3ceR0NRPEg2jQbty/aMpdCOEsej0J95LU6cJekjXFm+tVcRL96a9xtA9wDg 7ksqnAA+DFs1HVZAA4OLQTIa76lRp4NL28EeCUnx5FKEmYsIlMmKKl0jqw5yYGGbqn Cj3BXZbgfg6JYsZr2eQ+ttL1ivv8IR/AXbPwfBzE0kSQ1dlQZpL5+H4hv2vNnJzxzs dvB3R/M531EUQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 590EB69491 for ; Sun, 18 Jan 2026 13:43:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769023; bh=XGTGxNTMY5bSlkktRSolmnavZuOD2ghUyOZnKvMF3r4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMfl573VqoSLnlDp47Z9eH9cLNFSoP17q2gNsWFmiIV2K+hFIMNXAPwcMGJmqncv/ 6LXF8ERRdsn+eAe9bKgO7XxRMiNP1NWPfH1y4jtFB2NW9kyfzC+muTYDk0ugtGU7Ci s7CcTjNwtwU4dcn7Xgw6V63/AKXaJiHzs7px3LNaw6MM0uqRqM3uQcwY3u3jlblqrB Bpx84oeIvjA2Y7qG9DMgvd39aXZQq6TeVb8Xd973cH17v6quvHIYGfVEfJXYt2rZkl tyv7WdbdaU8cBP2T9xCkrG6Z7nb9Jg8cefbMS4J60AkoAMPlDk++fqKjxid6spreEB LCVW49E4ViQmg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C74A86948C; Sun, 18 Jan 2026 13:43:43 -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 qP4__gOq9tHz; Sun, 18 Jan 2026 13:43:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769019; bh=QxvFJ4OXqWnSAWvLeMfUjRHU90hQ5wL4F5jKWd/ta5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EhjfoTVJtKcdHcGcV34wshwQtgCSX5DzIJRMvpFGSYhojF1Yqd4VcB2pPN4FAYHE5 6JDQnb8LR2Rer1fA14yzT6sYN71mpkA7Hqq5KWcVJf2mGiSA+7p1LVR38AYwvW73H7 JP0xHPVXC1uWD3g99bCKBwow/HwDDTTnMu8amEeMvqU48Gf9JbxqDt+zEcfyT8Yu/4 +GhWUdjkpb+C9x1CrIfF4zLugYQBzqmQ/CiDo148oJicwrIraY5zurferYOtogkMCb PymxgW8s2e7kLCPic72r+NjL7cgGlkKcGJYCp4RGysRFjABkAWGT30tfuIHi8phLfc 1qYoGp7KyKqfw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 725026946A; Sun, 18 Jan 2026 13:43:39 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:45 -0700 Message-ID: <20260118204303.1982533-7-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: SBZ2MVCG63F3ZVMBGKFBZ7UC3FLREDLM X-Message-ID-Hash: SBZ2MVCG63F3ZVMBGKFBZ7UC3FLREDLM 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 06/16] test: expo: Add a separate test for textedit 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 Add a dedicated test for textedit rendering. Move the textedit creation out of create_test_expo() into its own test function, allowing each test to configure the textedit as needed. Update the checksums in expo_render_image() and expo_render_textline() since the textedit is no longer rendered there. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/expo.c | 77 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/test/boot/expo.c b/test/boot/expo.c index 03ad3e2167d..62b0b1a7c1b 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -490,7 +490,6 @@ static int create_test_expo(struct unit_test_state *uts, struct expo **expp, struct scene_obj_menu *menu; struct abuf buf, logo_copy; struct scene *scn; - struct abuf orig, *text; struct udevice *dev; struct expo *exp; int id, size; @@ -595,14 +594,6 @@ static int create_test_expo(struct unit_test_state *uts, struct expo **expp, ut_assert(id > 0); ut_assertok(scene_obj_set_bbox(scn, OBJ_BOX, 500, 200, 1000, 350)); - id = scene_texted(scn, "editor", OBJ_TEXTED, STR_TEXTED, NULL); - ut_assert(id > 0); - ut_assertok(scene_obj_set_bbox(scn, OBJ_TEXTED, 100, 200, 400, 650)); - ut_assertok(expo_edit_str(exp, STR_TEXTED, &orig, &text)); - - abuf_printf(text, "This\nis the initial contents of the text editor " - "but it is quite likely that more will be added later"); - /* * Add an extra text object that overlaps with OBJ_TEXT to test reverse * search order. OBJ_TEXT is at (400, 100), so let's add one nearby @@ -732,17 +723,17 @@ static int expo_render_image(struct unit_test_state *uts) /* render it */ expo_set_scene_id(exp, SCENE1); ut_assertok(expo_render(exp)); - ut_asserteq(19065, video_compress_fb(uts, dev, false)); + ut_asserteq(15711, video_compress_fb(uts, dev, false)); ut_asserteq(0, scn->highlight_id); ut_assertok(scene_arrange(scn)); ut_asserteq(0, scn->highlight_id); ut_assertok(expo_render(exp)); - ut_asserteq(20707, video_compress_fb(uts, dev, false)); + ut_asserteq(17342, video_compress_fb(uts, dev, false)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(20707, video_compress_fb(uts, dev, false)); + ut_asserteq(17342, video_compress_fb(uts, dev, false)); scene_set_highlight_id(scn, OBJ_MENU); ut_asserteq(OBJ_MENU, scn->highlight_id); @@ -754,7 +745,7 @@ static int expo_render_image(struct unit_test_state *uts) ut_assert(!(obj->flags & SCENEOF_HIDE)); ut_assertok(expo_render(exp)); - ut_asserteq(20707, video_compress_fb(uts, dev, false)); + ut_asserteq(17342, video_compress_fb(uts, dev, false)); /* move down */ ut_assertok(expo_send_key(exp, BKEY_DOWN)); @@ -767,12 +758,9 @@ static int expo_render_image(struct unit_test_state *uts) ut_asserteq(ITEM2, scene_menu_get_cur_item(scn, OBJ_MENU)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(19953, video_compress_fb(uts, dev, false)); + ut_asserteq(16637, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); - /* hide the text editor since the following tests don't need it */ - scene_obj_set_hide(scn, OBJ_TEXTED, true); - /* do some alignment checks */ ut_assertok(scene_obj_set_halign(scn, OBJ_TEXT3, SCENEOA_CENTRE)); ut_assertok(expo_render(exp)); @@ -1430,13 +1418,13 @@ static int expo_render_textline(struct unit_test_state *uts) expo_set_scene_id(exp, SCENE1); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(21007, video_compress_fb(uts, dev, false)); + ut_asserteq(17714, video_compress_fb(uts, dev, false)); /* highlight the textline and re-render */ scene_set_highlight_id(scn, OBJ_TEXTLINE); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(22693, video_compress_fb(uts, dev, false)); + ut_asserteq(19382, video_compress_fb(uts, dev, false)); /* open the textline and re-render */ ut_assertok(scene_set_open(scn, OBJ_TEXTLINE, true)); @@ -1444,13 +1432,13 @@ static int expo_render_textline(struct unit_test_state *uts) ut_assertok(expo_render(exp)); /* the cursor should be at the end */ - ut_asserteq(22695, video_compress_fb(uts, dev, false)); + ut_asserteq(19347, video_compress_fb(uts, dev, false)); /* send a keypress to add a character */ ut_assertok(expo_send_key(exp, 'a')); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(22818, video_compress_fb(uts, dev, false)); + ut_asserteq(19524, video_compress_fb(uts, dev, false)); /* move cursor left 3 times */ ut_assertok(expo_send_key(exp, CTL_CH('b'))); @@ -1461,7 +1449,7 @@ static int expo_render_textline(struct unit_test_state *uts) ut_asserteq_str("sample hopwinda", abuf_data(&tline->buf)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(22884, video_compress_fb(uts, dev, false)); + ut_asserteq(19552, video_compress_fb(uts, dev, false)); ut_assertok(expo_send_key(exp, CTL_CH('b'))); ut_assertok(expo_send_key(exp, CTL_CH('b'))); @@ -1473,7 +1461,7 @@ static int expo_render_textline(struct unit_test_state *uts) ut_asserteq_str("sample hopwinda", abuf_data(&tline->buf)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(22915, video_compress_fb(uts, dev, false)); + ut_asserteq(19570, video_compress_fb(uts, dev, false)); /* delete a character at the cursor */ ut_assertok(expo_send_key(exp, CTL_CH('d'))); @@ -1484,7 +1472,7 @@ static int expo_render_textline(struct unit_test_state *uts) ut_asserteq_str("sample hopwnda", abuf_data(&tline->buf)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(22856, video_compress_fb(uts, dev, false)); + ut_asserteq(19505, video_compress_fb(uts, dev, false)); /* close the textline with Enter (BKEY_SELECT) */ ut_assertok(expo_send_key(exp, BKEY_SELECT)); @@ -1498,7 +1486,7 @@ static int expo_render_textline(struct unit_test_state *uts) ut_asserteq_str("sample hopwnda", abuf_data(&tline->buf)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(22839, video_compress_fb(uts, dev, false)); + ut_asserteq(19543, video_compress_fb(uts, dev, false)); abuf_uninit(&buf); abuf_uninit(&logo_copy); @@ -1508,3 +1496,42 @@ static int expo_render_textline(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(expo_render_textline, UTF_DM | UTF_SCAN_FDT | UTF_NO_SILENT); + +/* Check rendering a textedit */ +static int expo_render_textedit(struct unit_test_state *uts) +{ + struct scene_obj_txtedit *ted; + struct scene_obj_menu *menu; + struct abuf buf, logo_copy; + struct abuf orig, *text; + struct scene *scn; + struct udevice *dev; + struct expo *exp; + int id; + + ut_assertok(create_test_expo(uts, &exp, &scn, &menu, &buf, &logo_copy)); + dev = exp->display; + + id = scene_texted(scn, "texted", OBJ_TEXTED, STR_TEXTED, &ted); + ut_asserteq(OBJ_TEXTED, id); + ut_assertok(scene_obj_set_bbox(scn, OBJ_TEXTED, 100, 200, 400, 300)); + ut_assertok(scene_txted_set_font(scn, OBJ_TEXTED, + "nimbus_sans_l_regular", 20)); + ut_assertok(expo_edit_str(exp, STR_TEXTED, &orig, &text)); + + abuf_printf(text, "This\nis the initial contents of the text editor " + "but it is quite likely that more will be added later"); + + expo_set_scene_id(exp, SCENE1); + ut_assertok(scene_arrange(scn)); + ut_assertok(expo_render(exp)); + ut_asserteq(19601, video_compress_fb(uts, dev, false)); + + abuf_uninit(&buf); + abuf_uninit(&logo_copy); + + expo_destroy(exp); + + return 0; +} +BOOTSTD_TEST(expo_render_textedit, UTF_DM | UTF_SCAN_FDT | UTF_NO_SILENT); From patchwork Sun Jan 18 20:42:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1598 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=1768769030; bh=i1CyS2trt3Sbs4PRRv/TVZjold4C8EaCG0auUPaRUFA=; 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=NwcFPxYxtM5pQlg1oa61f3ynLRF3y2JgsJ3ma0ki+rdt6OB5RIrjEr3DdXFQDIKCW rh5QAOxNaZBH6ixVjC9SbQDTsVX0/lqhg0eP9lELyv7/6GFLT4OwBrpHow3+dqm6Oj k4p2i4VJ2QcFYeBVjXt01wqSexe7Keg+FqFqIQ7zoVx01Sm4gPCi3Sdy91B12M0gNA iWmRxI4qeMe81Sb65IhZRfxQ7OV5MZywRInMkqj4MqAeVQKIfcR/RxOqZYi/floPPY v1aqJEbBlv/PJAm5R2DBaIXuoBZ89guFLfLNMy2XBSjMmoufvQGzFRsV/k6fT5VWfc 7jDIGWqR0MEmA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1F3576949D for ; Sun, 18 Jan 2026 13:43:50 -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 T8RUqGgZRjiw for ; Sun, 18 Jan 2026 13:43:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769030; bh=i1CyS2trt3Sbs4PRRv/TVZjold4C8EaCG0auUPaRUFA=; 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=NwcFPxYxtM5pQlg1oa61f3ynLRF3y2JgsJ3ma0ki+rdt6OB5RIrjEr3DdXFQDIKCW rh5QAOxNaZBH6ixVjC9SbQDTsVX0/lqhg0eP9lELyv7/6GFLT4OwBrpHow3+dqm6Oj k4p2i4VJ2QcFYeBVjXt01wqSexe7Keg+FqFqIQ7zoVx01Sm4gPCi3Sdy91B12M0gNA iWmRxI4qeMe81Sb65IhZRfxQ7OV5MZywRInMkqj4MqAeVQKIfcR/RxOqZYi/floPPY v1aqJEbBlv/PJAm5R2DBaIXuoBZ89guFLfLNMy2XBSjMmoufvQGzFRsV/k6fT5VWfc 7jDIGWqR0MEmA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0D7FE69491 for ; Sun, 18 Jan 2026 13:43:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769028; bh=MU3RR9AnKciY8xpKImRa0wGt7cWW71IX5meAolLO7QU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F/eYoG8bG/xUgIRi0XtcYjpoNI/o1E4Po9pY5HInFhQybuFoagMMAPKAdmfkwblJc x2NjoDK4ZBA9sq1zP7wAoH+9STbpwGBN/Td1o+UWZKsCPil5q4Z99kV7AEuThu6GbC YZY4tqzi8Drp5j53K/Phg7x+u1BugA3Wvi48khXoKVmOFYWJZ3dNqloiCYaqlG0Al/ pJNk2MK5JUijsDuLeNDOJ6e5HSbwU1zxGLwQa4s3yvXNhNLncWUnPy2A3eVEpnczV1 7+NZGLEzQk4E15weJ/aRzNBXqCqxHX3v4h7pzD1+wEgEFNnqk0ylTWRHdwhdwiXgfY 4Y9/SZaRLD38A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 72C436948C; Sun, 18 Jan 2026 13:43:48 -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 YvaDbHjxNVOg; Sun, 18 Jan 2026 13:43:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769024; bh=z8pl4oHAyifz1mLfg3FzHgVvoXlkr42f06y/Mj2BUV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WXymu/rh2iHeqFtuSEfh6QABqjKKPUtZLCET8ttOjy8eCdkmV7NlGbbkcX5VbtnI1 CVf4yKitvlQrxk8J4Vdo3C+jYuXMDN4vOYwp59o3tCgsYo2W5vMaBSamMd82f9Hs0v Gq++r/XbTO6aFbcfdLYpLrLIk19n04wwBVPApvkW+RcUYLYEy1Imd3u3u8yLJlxEmr w0GXKFo9KX8Qg2eYOUVlksxxZytw8cvUq62F9DrjGP3BEKNbEmPSHQu91EsibisoJD go6qt4GcsjGRWHBtyMx1hMci4P5TY2VEsmu/TvPNy4e8n5+15uGehT8411LzJw0w03 N9ekjOE9lI6tQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1896E6946A; Sun, 18 Jan 2026 13:43:44 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:46 -0700 Message-ID: <20260118204303.1982533-8-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: JSO75JTOIP6TZ6OKNSFBIAR4S4CKEVYV X-Message-ID-Hash: JSO75JTOIP6TZ6OKNSFBIAR4S4CKEVYV 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 07/16] expo: Refactor textedit to use label_id and edit_id 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 Update scene_obj_txtedit to follow the same pattern as textline, with separate label_id and edit_id fields pointing to text objects rather than embedding a scene_txt_generic directly. This allows the label and edit text to be rendered as regular scene objects and enables consistent handling between textline and textedit. Changes include: - Remove gen field from scene_obj_txtedit, add label_id and edit_id - Update scene_texted() to not take a str_id parameter - Update scene_txted_set_font() to set font on the edit text object - Add scene_txted_render_deps() for rendering dependencies - Update expo_dump to show label_id and edit_id - Update test to create label and edit text objects separately Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/expo_dump.c | 6 ++---- boot/scene.c | 18 ++++++------------ boot/scene_textedit.c | 9 ++------- include/expo.h | 11 ++++++----- test/boot/expo.c | 26 +++++++++++++++++--------- 5 files changed, 33 insertions(+), 37 deletions(-) diff --git a/boot/expo_dump.c b/boot/expo_dump.c index eb0c7bce6fc..5f9ea22c50a 100644 --- a/boot/expo_dump.c +++ b/boot/expo_dump.c @@ -116,10 +116,8 @@ static void dump_textline(struct dump_ctx *ctx, static void dump_textedit(struct dump_ctx *ctx, struct scene_obj_txtedit *tedit) { - outf(ctx, "Textedit: str_id %x font_name '%s' font_size %x\n", - tedit->gen.str_id, - tedit->gen.font_name ? tedit->gen.font_name : "(default)", - tedit->gen.font_size); + outf(ctx, "Textedit: label_id %x edit_id %x\n", + tedit->label_id, tedit->edit_id); } static void obj_dump_(struct dump_ctx *ctx, struct scene_obj *obj) diff --git a/boot/scene.c b/boot/scene.c index 5c19bff6011..d515754c702 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -468,6 +468,7 @@ int scene_obj_get_hw(struct scene *scn, uint id, int *widthp) case SCENEOBJT_MENU: case SCENEOBJT_TEXTLINE: case SCENEOBJT_BOX: + case SCENEOBJT_TEXTEDIT: break; case SCENEOBJT_IMAGE: { struct scene_obj_img *img = (struct scene_obj_img *)obj; @@ -479,18 +480,14 @@ int scene_obj_get_hw(struct scene *scn, uint id, int *widthp) *widthp = width; return height; } - case SCENEOBJT_TEXT: - case SCENEOBJT_TEXTEDIT: { + case SCENEOBJT_TEXT: { struct scene_txt_generic *gen; struct expo *exp = scn->expo; struct vidconsole_bbox bbox; int len, ret, limit; const char *str; - if (obj->type == SCENEOBJT_TEXT) - gen = &((struct scene_obj_txt *)obj)->gen; - else - gen = &((struct scene_obj_txtedit *)obj)->gen; + gen = &((struct scene_obj_txt *)obj)->gen; str = expo_get_str(exp, gen->str_id); if (!str) @@ -753,14 +750,11 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode) obj->bbox.y1, box->width, vid_priv->colour_fg, box->fill); break; } - case SCENEOBJT_TEXTEDIT: { - struct scene_obj_txtedit *ted = (struct scene_obj_txtedit *)obj; - - ret = scene_txt_render(exp, dev, cons, obj, &ted->gen, x, y, - theme->menu_inset); + case SCENEOBJT_TEXTEDIT: + if (obj->flags & SCENEOF_OPEN) + scene_render_background(obj, true, false); break; } - } return 0; } diff --git a/boot/scene_textedit.c b/boot/scene_textedit.c index 8242eb39806..3c1edf38592 100644 --- a/boot/scene_textedit.c +++ b/boot/scene_textedit.c @@ -18,7 +18,7 @@ enum { INITIAL_SIZE = SZ_4K, }; -int scene_texted(struct scene *scn, const char *name, uint id, uint str_id, +int scene_texted(struct scene *scn, const char *name, uint id, struct scene_obj_txtedit **teditp) { struct scene_obj_txtedit *ted; @@ -37,9 +37,6 @@ int scene_texted(struct scene *scn, const char *name, uint id, uint str_id, buf = abuf_data(&ted->buf); *buf = '\0'; - ret = scene_txt_generic_init(scn->expo, &ted->gen, name, str_id, buf); - if (ret) - return log_msg_ret("teg", ret); if (teditp) *teditp = ted; @@ -54,8 +51,6 @@ int scene_txted_set_font(struct scene *scn, uint id, const char *font_name, ted = scene_obj_find(scn, id, SCENEOBJT_TEXTEDIT); if (!ted) return log_msg_ret("find", -ENOENT); - ted->gen.font_name = font_name; - ted->gen.font_size = font_size; - return 0; + return scene_txt_set_font(scn, ted->edit_id, font_name, font_size); } diff --git a/include/expo.h b/include/expo.h index f9f85b38b9c..9d6300024fc 100644 --- a/include/expo.h +++ b/include/expo.h @@ -539,17 +539,19 @@ struct scene_obj_box { }; /** - * struct scene_obj_txtedit - information about a box in a scene + * struct scene_obj_txtedit - information about a textedit in a scene * * A text editor which allows users to edit a small text file * * @obj: Basic object information - * @gen: Generic information common to all objects which show text + * @label_id: ID of the label text object (not string ID), or 0 if none + * @edit_id: ID of the editable text object (not string ID) * @buf: Text buffer containing current text */ struct scene_obj_txtedit { struct scene_obj obj; - struct scene_txt_generic gen; + uint label_id; + uint edit_id; struct abuf buf; }; @@ -890,11 +892,10 @@ int scene_box_set_fill(struct scene *scn, uint id, bool fill); * @scn: Scene to update * @name: Name to use (this is allocated by this call) * @id: ID to use for the new object (0 to allocate one) - * @strid: ID of the string to edit * @teditp: If non-NULL, returns the new object * Returns: ID number for the object (typically @id), or -ve on error */ -int scene_texted(struct scene *scn, const char *name, uint id, uint strid, +int scene_texted(struct scene *scn, const char *name, uint id, struct scene_obj_txtedit **teditp); /** diff --git a/test/boot/expo.c b/test/boot/expo.c index 62b0b1a7c1b..7d76431208a 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -1503,7 +1503,6 @@ static int expo_render_textedit(struct unit_test_state *uts) struct scene_obj_txtedit *ted; struct scene_obj_menu *menu; struct abuf buf, logo_copy; - struct abuf orig, *text; struct scene *scn; struct udevice *dev; struct expo *exp; @@ -1512,20 +1511,29 @@ static int expo_render_textedit(struct unit_test_state *uts) ut_assertok(create_test_expo(uts, &exp, &scn, &menu, &buf, &logo_copy)); dev = exp->display; - id = scene_texted(scn, "texted", OBJ_TEXTED, STR_TEXTED, &ted); - ut_asserteq(OBJ_TEXTED, id); + id = scene_texted(scn, "texted", OBJ_TEXTED, &ted); + ut_assert(id > 0); ut_assertok(scene_obj_set_bbox(scn, OBJ_TEXTED, 100, 200, 400, 300)); - ut_assertok(scene_txted_set_font(scn, OBJ_TEXTED, - "nimbus_sans_l_regular", 20)); - ut_assertok(expo_edit_str(exp, STR_TEXTED, &orig, &text)); - abuf_printf(text, "This\nis the initial contents of the text editor " - "but it is quite likely that more will be added later"); + /* create the label text object */ + id = scene_txt_str(scn, "ted-label", 0, 0, "Editor:", NULL); + ut_assert(id > 0); + ted->label_id = id; + + /* create the edit text object pointing to the textedit buffer */ + abuf_printf(&ted->buf, "This\nis the initial contents of the text " + "editor but it is quite likely that more will be added later"); + id = scene_txt_str(scn, "ted-edit", STR_TEXTED, 0, abuf_data(&ted->buf), + NULL); + ut_assert(id > 0); + ted->edit_id = id; + ut_assertok(scene_txt_set_font(scn, ted->edit_id, + "nimbus_sans_l_regular", 20)); expo_set_scene_id(exp, SCENE1); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(19601, video_compress_fb(uts, dev, false)); + ut_asserteq(19651, video_compress_fb(uts, dev, false)); abuf_uninit(&buf); abuf_uninit(&logo_copy); From patchwork Sun Jan 18 20:42:47 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1599 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=1768769034; bh=7idLoK5kiQPALttf5o0DXDFqprJoybPmmYj6VhGED94=; 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=kOs6seGPRhsaZUf/JhepRyLydx/+xMOXDpgzbstr9b8F8PHLOlGIEL0BE9mRMt4Bd oKPb6Sh87vfH22mHxSRhr0Um2lgEkfi5gTFjV7rMaFpX9F5xBdxiYhSjXNpQFO4RPb Uw/PzaXB/I8fL/mQvhEq3fa7qxJUxck2vMclW+ahmzTcK2nqfaxv5NfOoiu8gasdK0 pS9iRr/sWGnUL16mRJ898k+weF0sKS2uKvkOFZKrl9ExhOYs1BvgChibSdKZIdAmR6 EJNFyvWNQmFC9Ux40J52Z1vGVmJd4rjeZ7YpMwpgEPVB3recnzVHfLtzAQCl4X504k ktfrFL2vZ0GRA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8C0706948C for ; Sun, 18 Jan 2026 13:43:54 -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 gFZWalqTKFPk for ; Sun, 18 Jan 2026 13:43:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769034; bh=7idLoK5kiQPALttf5o0DXDFqprJoybPmmYj6VhGED94=; 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=kOs6seGPRhsaZUf/JhepRyLydx/+xMOXDpgzbstr9b8F8PHLOlGIEL0BE9mRMt4Bd oKPb6Sh87vfH22mHxSRhr0Um2lgEkfi5gTFjV7rMaFpX9F5xBdxiYhSjXNpQFO4RPb Uw/PzaXB/I8fL/mQvhEq3fa7qxJUxck2vMclW+ahmzTcK2nqfaxv5NfOoiu8gasdK0 pS9iRr/sWGnUL16mRJ898k+weF0sKS2uKvkOFZKrl9ExhOYs1BvgChibSdKZIdAmR6 EJNFyvWNQmFC9Ux40J52Z1vGVmJd4rjeZ7YpMwpgEPVB3recnzVHfLtzAQCl4X504k ktfrFL2vZ0GRA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7AAE369491 for ; Sun, 18 Jan 2026 13:43:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769033; bh=UfjXGehX2WnbCrXtFv/Z3Fa9yu05dTWqYa8C8vzfSXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hmQiErL6E0fymMwiAMjqkYpehlf+gKIrXD4NwEKnxxUnHPhMN+BuNvIs/9HGePoNw 1cKm/0fN03dgCeWa0wED4KjDufCnCthHo4QjLflpdtZCmxr+TytFQsHmB19X+Z6zdv BCi1JQC39F87ERMIFi42qRbvbn0/CxZjhSdIb4hIdTO5ICnluANlq1Jz1PAsd2XQPt 6KCH6lVIOpQm05m7cxS5+UEQLbvSOe00RfsmKWAqr/4mKk8qy9kj/ZSRSozvoCsXeq pcuAhMOHZlZ0gFT4UUUKJXcqsNBvl2p/XSpDsvhk0Y7rnJyU8deVitkIVlkgnjmzYT WEo+8x5Gywo0w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 10C686948C; Sun, 18 Jan 2026 13:43: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 10026) with ESMTP id NXwzGS9BfzwN; Sun, 18 Jan 2026 13:43:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769029; bh=vjrFlSXRpZCYnq8Kwg3Q0N1OXP7LsppULbdIKJQgb1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KyCpaRU1L+qQQ5kJGVZCjF11AA28/NSVU9z5LmCKFhYHVHcPEVR/sCAzjjkrsyl0c YNkSQeQpMpuOwtKfkPlFhbg3hGhj00WrwjMsc1Sk5XGvZMiilduV67BjQzURWrQ24a 8hYkeNK6Q2Q8aN7/94FIinIAWMqjR6Fghfk0GlzYHS2ftuUhXXerj9o+CEzwK4+Y3A dSqeZsKc6ugP4i49e+yAkJgizLfz/KZ+ig6sQcMcchXvNOEbgwiHA3W4ZA/SlRbIc2 +e6Il+VR7EJyggtxh91kEbrVP7YcqRpEc53yHpRM1T3Nl/xUQ3LlKv+V11L2p/bO+N BQXs2vsRe6JEg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B058C6946A; Sun, 18 Jan 2026 13:43:48 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:47 -0700 Message-ID: <20260118204303.1982533-9-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: RYCOBNCE5MGGWIQL6LLVK5L3UAYRMNOI X-Message-ID-Hash: RYCOBNCE5MGGWIQL6LLVK5L3UAYRMNOI 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 08/16] expo: Rename textline max_chars to line_chars 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 Rename the max_chars field to line_chars to better describe its purpose. This field represents the nominal number of characters in a line, which for textline is also a hard limit. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/cedit.c | 4 ++-- boot/expo_build.c | 6 +++--- boot/expo_dump.c | 2 +- boot/scene_textline.c | 16 ++++++++-------- doc/usage/cmd/cedit.rst | 2 +- include/expo.h | 10 +++++----- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/boot/cedit.c b/boot/cedit.c index d58ae0ba51c..5a334787453 100644 --- a/boot/cedit.c +++ b/boot/cedit.c @@ -538,7 +538,7 @@ static int h_read_settings(struct scene_obj *obj, void *vpriv) tline = (struct scene_obj_textline *)obj; val = ofnode_read_prop(node, obj->name, &len); - if (len >= tline->max_chars) + if (len >= tline->line_chars) return log_msg_ret("str", -ENOSPC); strcpy(abuf_data(&tline->buf), val); break; @@ -708,7 +708,7 @@ static int h_read_settings_env(struct scene_obj *obj, void *vpriv) tline = (struct scene_obj_textline *)obj; value = env_get(var); - if (value && strlen(value) >= tline->max_chars) + if (value && strlen(value) >= tline->line_chars) return log_msg_ret("str", -ENOSPC); if (!value) value = ""; diff --git a/boot/expo_build.c b/boot/expo_build.c index 60a9cd71b7e..76611b4f6d7 100644 --- a/boot/expo_build.c +++ b/boot/expo_build.c @@ -328,17 +328,17 @@ static int textline_build(struct build_info *info, ofnode node, uint edit_id; const char *name; char buf[80]; - u32 max_chars; + u32 line_chars; int ret; name = ofnode_get_name(node); info->err_prop = "max-chars"; - ret = ofnode_read_u32(node, "max-chars", &max_chars); + ret = ofnode_read_u32(node, "max-chars", &line_chars); if (ret) return log_msg_ret("max", -ENOENT); - ret = scene_textline(scn, name, id, max_chars, &ted); + ret = scene_textline(scn, name, id, line_chars, &ted); if (ret < 0) return log_msg_ret("ted", ret); diff --git a/boot/expo_dump.c b/boot/expo_dump.c index 5f9ea22c50a..2cd74e137d4 100644 --- a/boot/expo_dump.c +++ b/boot/expo_dump.c @@ -109,7 +109,7 @@ static void dump_textline(struct dump_ctx *ctx, outf(ctx, "Textline: label_id %x edit_id %x\n", tline->label_id, tline->edit_id); ctx->indent += 2; - outf(ctx, "max_chars %x pos %x\n", tline->max_chars, tline->pos); + outf(ctx, "line_chars %x pos %x\n", tline->line_chars, tline->pos); ctx->indent -= 2; } diff --git a/boot/scene_textline.c b/boot/scene_textline.c index 082b39f2497..2270e1496e9 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -16,14 +16,14 @@ #include #include "scene_internal.h" -int scene_textline(struct scene *scn, const char *name, uint id, uint max_chars, - struct scene_obj_textline **tlinep) +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 (max_chars >= EXPO_MAX_CHARS) + if (line_chars >= EXPO_MAX_CHARS) return log_msg_ret("chr", -E2BIG); ret = scene_obj_add(scn, name, id, SCENEOBJT_TEXTLINE, @@ -31,12 +31,12 @@ int scene_textline(struct scene *scn, const char *name, uint id, uint max_chars, (struct scene_obj **)&tline); if (ret < 0) return log_msg_ret("obj", -ENOMEM); - if (!abuf_init_size(&tline->buf, max_chars + 1)) + if (!abuf_init_size(&tline->buf, line_chars + 1)) return log_msg_ret("buf", -ENOMEM); buf = abuf_data(&tline->buf); *buf = '\0'; - tline->pos = max_chars; - tline->max_chars = max_chars; + tline->pos = line_chars; + tline->line_chars = line_chars; if (tlinep) *tlinep = tline; @@ -73,7 +73,7 @@ int scene_textline_calc_dims(struct scene_obj_textline *tline, return log_msg_ret("dim", -ENOENT); ret = vidconsole_nominal(cons, txt->gen.font_name, txt->gen.font_size, - tline->max_chars, &bbox); + tline->line_chars, &bbox); if (ret) return log_msg_ret("nom", ret); @@ -246,7 +246,7 @@ int scene_textline_open(struct scene *scn, struct scene_obj_textline *tline) 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->buf), tline->max_chars); + cli_cread_init(&scn->cls, abuf_data(&tline->buf), tline->line_chars); scn->cls.insert = true; scn->cls.putch = scene_textline_putch; ret = vidconsole_entry_save(cons, &scn->entry_save); diff --git a/doc/usage/cmd/cedit.rst b/doc/usage/cmd/cedit.rst index 0eb8f09dc2c..5d2071bdd1a 100644 --- a/doc/usage/cmd/cedit.rst +++ b/doc/usage/cmd/cedit.rst @@ -362,7 +362,7 @@ This shows dumping the cedit:: bbox: (0,0)-(0,0) dims: 0x0 Textline: label_id 39 edit_id 18 - max_chars 20 pos 20 + line_chars 14 pos 14 Object 39 (title): type text flags bbox: (0,0)-(0,0) diff --git a/include/expo.h b/include/expo.h index 9d6300024fc..39245228574 100644 --- a/include/expo.h +++ b/include/expo.h @@ -510,7 +510,7 @@ struct scene_menitem { * @obj: Basic object information * @label_id: ID of the label text object (not string ID), or 0 if none * @edit_id: ID of the editable text object (not string ID) - * @max_chars: Maximum number of characters allowed + * @line_chars: Nominal number of characters in a line (also a hard limit) * @buf: Text buffer containing current text * @pos: Cursor position */ @@ -518,7 +518,7 @@ struct scene_obj_textline { struct scene_obj obj; uint label_id; uint edit_id; - uint max_chars; + uint line_chars; struct abuf buf; uint pos; }; @@ -855,12 +855,12 @@ int scene_menu(struct scene *scn, const char *name, uint id, * @scn: Scene to update * @name: Name to use (this is allocated by this call) * @id: ID to use for the new object (0 to allocate one) - * @max_chars: Maximum length of the textline in characters + * @line_chars: Number of characters in a line (also a hard limit) * @tlinep: If non-NULL, returns the new object * Returns: ID number for the object (typically @id), or -ve on error */ -int scene_textline(struct scene *scn, const char *name, uint id, uint max_chars, - struct scene_obj_textline **tlinep); +int scene_textline(struct scene *scn, const char *name, uint id, + uint line_chars, struct scene_obj_textline **tlinep); /** * scene_box() - create a box From patchwork Sun Jan 18 20:42:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1600 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=1768769040; bh=ZVoEfcPZJDug1eCXb3//GnnmtrB22REm4aiFTKY7Uew=; 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=XB1MmLyE65uzMj0v+y0LxnB7o2+0aiesMvSmFJG6kRXxqTaT2VQ9iYHZBxK8csBTN 7o5x2KKPQLdzNRsyRKGUQkn23GvChZmnNpddUtnpXzXSQbdjDoIk+8nkZAhiADVKEc FI3+mDeHyZoSmq5OtbvX2p+9gpUeisypdnCYRJq1NEQkjtkm0glE1nO8UBx43b+sKZ wKGHvnbEUusKZnTWTqX9Pb5cgMjq/SpotKO+NXyQZQfJ4tPXYICBkskuEwrZrrr0Zu PpSEAmaUF2mNQz+KRTqfKpPo85hXDKqP29iUjYufLHy5eNAvKVNn8QC+m6a5Yv8oXF Wh+3R8XltpT5w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1BD746949B for ; Sun, 18 Jan 2026 13:44:00 -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 K0NkXn3xAEhE for ; Sun, 18 Jan 2026 13:44:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769040; bh=ZVoEfcPZJDug1eCXb3//GnnmtrB22REm4aiFTKY7Uew=; 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=XB1MmLyE65uzMj0v+y0LxnB7o2+0aiesMvSmFJG6kRXxqTaT2VQ9iYHZBxK8csBTN 7o5x2KKPQLdzNRsyRKGUQkn23GvChZmnNpddUtnpXzXSQbdjDoIk+8nkZAhiADVKEc FI3+mDeHyZoSmq5OtbvX2p+9gpUeisypdnCYRJq1NEQkjtkm0glE1nO8UBx43b+sKZ wKGHvnbEUusKZnTWTqX9Pb5cgMjq/SpotKO+NXyQZQfJ4tPXYICBkskuEwrZrrr0Zu PpSEAmaUF2mNQz+KRTqfKpPo85hXDKqP29iUjYufLHy5eNAvKVNn8QC+m6a5Yv8oXF Wh+3R8XltpT5w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 06CA869491 for ; Sun, 18 Jan 2026 13:44:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769037; bh=2QkqNhxT8QvqcbeLjKQ5YDpoOy8iiZ16gvDx+NWXAsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PBkdiayiGDC4vyIsXMi9s6GsKRMeTLJkjYLYosVkYrn+wW9SIe8Jt2Y4WOaeOFMb5 hBTnhpWq30RVe/qrJlf7mbJ1GxR7r309ucbI7aEkgWRwTDKouGClt/lKWPLge2unkb 3ldEJY341raE9nZ61W/qY/nXzzUvaQGEXQsHdI+FqFoCJ6Tl9+Y4sqRvL2zWg0AYm2 KPTK9p/p+tmP3dBCsnrjAAecD1ZdebCuAqTkTPozjzY8vkNK2GeC6T2WwbDTiK5q6Z bJrIlL6wSRIQ9c+bOBv4ykjqiuAbh/ZX8AHNYL6RzZ6iXlWTMPLa15KkAT1WxW0jhH oy1QgeQ/xdQKg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A7DA16948C; Sun, 18 Jan 2026 13:43:57 -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 arfj5fr67Rgl; Sun, 18 Jan 2026 13:43:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769033; bh=LAN19vRYnoNBju39TQPpaiUQ/ULqEHvKps9PlZeD4V0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ikLnBEUZUXUP3h24VWKy3Mi9/CLaeLOsFNKv3A+Y6yg/r7crKp1JSZZY0TRf6HOnB WyfB9rpiPdACl+7NNLVUy9ZVFKkex0ZjMfR/rynEbMxxdgjnJHQtnQM5JcgvJsp1Oy 7QJ9xmTOkTeo7xUre9GMdZyy43xvoDDCPpOyRdxasBZy3wiedVlSJ+G/obNGzkTqS1 mHYjTv9grRtNo30zUm3jPTxGCQsN4qybjcDPR9vXOY+brfWDqzwVly+R2ZXEZIW2Gt CEJrCYvXVQfP4IP4xVI/t5ZyxWE2R9+vRIBUqjFN/KGYQ9FxZiW47Z0s6SapO9ZHfi 83BAqODtLhdPQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5899A6946A; Sun, 18 Jan 2026 13:43:53 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:48 -0700 Message-ID: <20260118204303.1982533-10-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: 3BOVX7AFOQ3OXHAWQO3PI3TYEMKP4BAW X-Message-ID-Hash: 3BOVX7AFOQ3OXHAWQO3PI3TYEMKP4BAW 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 09/16] expo: Add line_chars to scene_obj_txtedit 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 Add a line_chars field to scene_obj_txtedit to specify the nominal number of characters in a line. This is consistent with the line_chars field in scene_obj_textline. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_textedit.c | 3 ++- include/expo.h | 5 ++++- test/boot/expo.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/boot/scene_textedit.c b/boot/scene_textedit.c index 3c1edf38592..a55285f00cd 100644 --- a/boot/scene_textedit.c +++ b/boot/scene_textedit.c @@ -19,7 +19,7 @@ enum { }; int scene_texted(struct scene *scn, const char *name, uint id, - struct scene_obj_txtedit **teditp) + uint line_chars, struct scene_obj_txtedit **teditp) { struct scene_obj_txtedit *ted; char *buf; @@ -36,6 +36,7 @@ int scene_texted(struct scene *scn, const char *name, uint id, return log_msg_ret("buf", -ENOMEM); buf = abuf_data(&ted->buf); *buf = '\0'; + ted->line_chars = line_chars; if (teditp) *teditp = ted; diff --git a/include/expo.h b/include/expo.h index 39245228574..2d57e67d51c 100644 --- a/include/expo.h +++ b/include/expo.h @@ -546,12 +546,14 @@ struct scene_obj_box { * @obj: Basic object information * @label_id: ID of the label text object (not string ID), or 0 if none * @edit_id: ID of the editable text object (not string ID) + * @line_chars: Nominal number of characters in a line * @buf: Text buffer containing current text */ struct scene_obj_txtedit { struct scene_obj obj; uint label_id; uint edit_id; + uint line_chars; struct abuf buf; }; @@ -892,11 +894,12 @@ int scene_box_set_fill(struct scene *scn, uint id, bool fill); * @scn: Scene to update * @name: Name to use (this is allocated by this call) * @id: ID to use for the new object (0 to allocate one) + * @line_chars: Nominal number of characters in a line * @teditp: If non-NULL, returns the new object * Returns: ID number for the object (typically @id), or -ve on error */ int scene_texted(struct scene *scn, const char *name, uint id, - struct scene_obj_txtedit **teditp); + uint line_chars, struct scene_obj_txtedit **teditp); /** * scene_txt_set_font() - Set the font for an object diff --git a/test/boot/expo.c b/test/boot/expo.c index 7d76431208a..dc9ebe702b8 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -1511,7 +1511,7 @@ static int expo_render_textedit(struct unit_test_state *uts) ut_assertok(create_test_expo(uts, &exp, &scn, &menu, &buf, &logo_copy)); dev = exp->display; - id = scene_texted(scn, "texted", OBJ_TEXTED, &ted); + id = scene_texted(scn, "texted", OBJ_TEXTED, 40, &ted); ut_assert(id > 0); ut_assertok(scene_obj_set_bbox(scn, OBJ_TEXTED, 100, 200, 400, 300)); From patchwork Sun Jan 18 20:42:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1601 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=1768769043; bh=85i5VGul2I+TtFe08tFAF/0Bvi0+LD3A1r4rsXHqacs=; 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=R8l6K5xLXWXEP6yeupZjlc0Gv4qA9zIABZAMqd/46sK/4J8JzJoE/wayYaiwxG8D+ /Fvj44OYFahXrj1RK1/wZEltM76Ulj3EnDvZAkpBXmNjGeFhbNDgKQ0vmPUumVxNC0 C++vyKXX6IpvcMWXjnnWJUq4ekY6SCZQb4z/EV76mUDN6eYu5QvXLDKHKU2J3fr8g/ diLkoUpx/Yc8AHUWRJh07z35LFpU/MPI5MEbzsQGVQZ5u8MGTUdETBBjpAjROv6FFL BhUG5wOz1/+MLDIgB43PSdczlcl7oKRwFaPKh8ZoBIV+leJMy4Wf+ttlFss7NSEJBe cDKT3GiorwvdQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9237F6949E for ; Sun, 18 Jan 2026 13:44:03 -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 DxdQs6egz4yV for ; Sun, 18 Jan 2026 13:44:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769043; bh=85i5VGul2I+TtFe08tFAF/0Bvi0+LD3A1r4rsXHqacs=; 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=R8l6K5xLXWXEP6yeupZjlc0Gv4qA9zIABZAMqd/46sK/4J8JzJoE/wayYaiwxG8D+ /Fvj44OYFahXrj1RK1/wZEltM76Ulj3EnDvZAkpBXmNjGeFhbNDgKQ0vmPUumVxNC0 C++vyKXX6IpvcMWXjnnWJUq4ekY6SCZQb4z/EV76mUDN6eYu5QvXLDKHKU2J3fr8g/ diLkoUpx/Yc8AHUWRJh07z35LFpU/MPI5MEbzsQGVQZ5u8MGTUdETBBjpAjROv6FFL BhUG5wOz1/+MLDIgB43PSdczlcl7oKRwFaPKh8ZoBIV+leJMy4Wf+ttlFss7NSEJBe cDKT3GiorwvdQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7BE0B69494 for ; Sun, 18 Jan 2026 13:44:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769042; bh=s0KSOZKAwlDZbe5Aqhl0v4RdFt9hh7ydGZDWs3C8ftI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WFx2KIqeUZYFe2VNx2FNfb3U7JlHVFeC6eOu4/TMYlx7pP95F37ZMt3XK62k+R1rn bd3W2nledHe91padBiEllbQ4M7878IZln079xpP4ejJqyxnREpjUO7WaPq7QBWtPTl a8SHa8lQQgTTvzjvQKOKX2M1ceu+5P1zx0KgXilEt2qI6vOAoyH5A1sTbUETsbQjwn whooNGqhFoVzZ1waNHdNbg+fK+v+4L4GGdXcqfwqYrz0DOunMC6Tqfwbjs/1vkJPwe Lnmo7EqNSgppTgliHl3KVFLS3pdf49b2cs1ACKr8/K3R85Uw3QPQF3+6TRt+d+Zr9q GGSz+vI4p4fgw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7A6A06948C; Sun, 18 Jan 2026 13:44:02 -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 VtR6GRUouaoP; Sun, 18 Jan 2026 13:44:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769038; bh=NH5XBrVNr+8bf2v4bJfzzGXofwEZ7Melf+klX3lPtU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K6xaOHp4e1FduPMwrZJqPoHEEDwNZA/fCwu38VAka5Vzmm5gSdGs3sKXmYKs+QKz5 cKDt8XuPtDeEWDWHnX6eVjbv9k8LmIhiK6mgB0WMZHsRQ8K96mvK++YmiZ5gE2L8pE eYks7in9aUhx9tJQTU00yf7i+5PBl5owvjqG9bt+T8Oi8vvQoLrVNOfXTZC4AtLF0u YUUfTj/zJq7T8NetuUKvte9nRqYGL1x142pKlEDmlASODk3Ao9cAeYz+WvVGoFakAo k7SJO80k9gYnohrk5zJBMHyGeOqcmckZmSwuLIfyTSK5A0xVvJZ180hJoVfq0mnX+h Wi8fTZD2GU8lA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EACEF6946A; Sun, 18 Jan 2026 13:43:57 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:49 -0700 Message-ID: <20260118204303.1982533-11-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: YMG5MTRBCWMUTI4RQDTCC5YNIU5SPUST X-Message-ID-Hash: YMG5MTRBCWMUTI4RQDTCC5YNIU5SPUST 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 10/16] expo: Add arrangement support for textedit 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 Add scene_txted_arrange() to position the label and edit text objects within a textedit, following the same pattern as textline: - Position the label at the textedit's position - Position edit text after the label (with margin) - Set the SCENEOF_POINT flag when highlighted but not open - Calculate the overall dimensions of the textedit Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene.c | 10 +++++++++- boot/scene_internal.h | 14 ++++++++++++++ boot/scene_textedit.c | 37 +++++++++++++++++++++++++++++++++++++ test/boot/expo.c | 2 +- 4 files changed, 61 insertions(+), 2 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index d515754c702..882a250e17d 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -868,7 +868,6 @@ int scene_arrange(struct scene *scn) case SCENEOBJT_IMAGE: case SCENEOBJT_TEXT: case SCENEOBJT_BOX: - case SCENEOBJT_TEXTEDIT: break; case SCENEOBJT_MENU: { struct scene_obj_menu *menu; @@ -888,6 +887,15 @@ int scene_arrange(struct scene *scn) return log_msg_ret("arr", ret); break; } + case SCENEOBJT_TEXTEDIT: { + struct scene_obj_txtedit *ted; + + ted = (struct scene_obj_txtedit *)obj, + ret = scene_txted_arrange(scn, &arr, ted); + if (ret) + return log_msg_ret("arr", ret); + break; + } } } ret = scene_sync_bbox(scn); diff --git a/boot/scene_internal.h b/boot/scene_internal.h index 5cc81f031a0..1e5bd3d2a28 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -162,6 +162,20 @@ int scene_menu_arrange(struct scene *scn, struct expo_arrange_info *arr, int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr, struct scene_obj_textline *tline); +/** + * scene_txted_arrange() - Set the position of things in a textedit + * + * This updates any items associated with a textedit to make sure they are + * positioned correctly relative to the textedit. + * + * @scn: Scene to update + * @arr: Arrangement information + * @ted: textedit to process + * Returns: 0 if OK, -ve on error + */ +int scene_txted_arrange(struct scene *scn, struct expo_arrange_info *arr, + struct scene_obj_txtedit *ted); + /** * scene_apply_theme() - Apply a theme to a scene * diff --git a/boot/scene_textedit.c b/boot/scene_textedit.c index a55285f00cd..8714a4b5705 100644 --- a/boot/scene_textedit.c +++ b/boot/scene_textedit.c @@ -55,3 +55,40 @@ int scene_txted_set_font(struct scene *scn, uint id, const char *font_name, return scene_txt_set_font(scn, ted->edit_id, font_name, font_size); } + +int scene_txted_arrange(struct scene *scn, struct expo_arrange_info *arr, + struct scene_obj_txtedit *ted) +{ + const bool open = ted->obj.flags & SCENEOF_OPEN; + const struct expo_theme *theme = &scn->expo->theme; + bool point; + int x, y; + int ret; + + x = ted->obj.req_bbox.x0; + y = ted->obj.req_bbox.y0; + if (ted->label_id) { + ret = scene_obj_set_pos(scn, ted->label_id, x, y); + if (ret < 0) + return log_msg_ret("tit", ret); + + x += arr->label_width + theme->textline_label_margin_x; + } + + /* constrain the edit text to fit within the textedit bbox */ + ret = scene_obj_set_bbox(scn, ted->edit_id, x, y, + ted->obj.req_bbox.x1, ted->obj.req_bbox.y1); + if (ret < 0) + return log_msg_ret("edi", ret); + + point = scn->highlight_id == ted->obj.id; + point &= !open; + scene_obj_flag_clrset(scn, ted->edit_id, SCENEOF_POINT, + point ? SCENEOF_POINT : 0); + + ted->obj.dims.x = x - ted->obj.req_bbox.x0; + ted->obj.dims.y = y - ted->obj.req_bbox.y0; + scene_obj_set_size(scn, ted->obj.id, ted->obj.dims.x, ted->obj.dims.y); + + return 0; +} diff --git a/test/boot/expo.c b/test/boot/expo.c index dc9ebe702b8..b6ee4892d7a 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -1533,7 +1533,7 @@ static int expo_render_textedit(struct unit_test_state *uts) expo_set_scene_id(exp, SCENE1); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(19651, video_compress_fb(uts, dev, false)); + ut_asserteq(19493, video_compress_fb(uts, dev, false)); abuf_uninit(&buf); abuf_uninit(&logo_copy); From patchwork Sun Jan 18 20:42:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1602 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=1768769048; bh=nIS6WkoDUa79VfCsFVMN4BBP8x354ecsrlnLONHzvlI=; 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=v4cu4iqaJarcDJxkK8q9t+D6FxHyn6p7lRRe762ZpoFGPByyZSf0zJicVOfH7Zptn 5zUXtDfZiDZtTal1O1F4s7G6wx/ew0RM1rqIIJFfDty7mqMe7cCYV3Sn2+FYNBroL2 Gxn/nUJNKHevPHiEJpssqM417ci6bYZ6rC1Cs5QbzQbsOlC8QvG7KXG2qv4ymNyPlM YtEWkjx0JUVt2ezS0wDimIQcf+8dQbXYBzvlXgKCuPQV7CSJJpBUz4NwUTtRpVI0G6 Ac6omZD+5ruGE/wOsjRpxOmU7cN2oJD9tqkk3Guzb4Ug1qRYbi42QI6A7xRUjH2s15 NoS3mZBzmRl8Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8E1C36949D for ; Sun, 18 Jan 2026 13:44:08 -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 nFu6j5shsTzD for ; Sun, 18 Jan 2026 13:44:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769048; bh=nIS6WkoDUa79VfCsFVMN4BBP8x354ecsrlnLONHzvlI=; 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=v4cu4iqaJarcDJxkK8q9t+D6FxHyn6p7lRRe762ZpoFGPByyZSf0zJicVOfH7Zptn 5zUXtDfZiDZtTal1O1F4s7G6wx/ew0RM1rqIIJFfDty7mqMe7cCYV3Sn2+FYNBroL2 Gxn/nUJNKHevPHiEJpssqM417ci6bYZ6rC1Cs5QbzQbsOlC8QvG7KXG2qv4ymNyPlM YtEWkjx0JUVt2ezS0wDimIQcf+8dQbXYBzvlXgKCuPQV7CSJJpBUz4NwUTtRpVI0G6 Ac6omZD+5ruGE/wOsjRpxOmU7cN2oJD9tqkk3Guzb4Ug1qRYbi42QI6A7xRUjH2s15 NoS3mZBzmRl8Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7CABD69491 for ; Sun, 18 Jan 2026 13:44:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769047; bh=aQJhpn+BnIwGTn/eXRpyYXKeWWrO10oa16i4NSFNyB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jzy3hfE/HzIhEcQlrkio6sn5P1U04trO3inF4oNfLTqIZVqkxezytf8Zx3qZgCI/i qkEvrL9qt6dKQv8avvo2GXc/zex8ZTSWc4mRMh3z3lIJ7q3p3WjAGQTzSTzNusj6BX ATAOJ1oMN3c0pGyXwh0HV0ijJzGDODI1tOz9DU2gDllS/WA6eMscF474iWpXe+mDdt NnNxD0Xehx/WR+A8nUbQtj9ipEuDP0G14IXNAt2OZJJ/pp35rgEcurlyG0W/fQGjKj 7AokUpmnOHWZovu/d4I7jexxgDOWX7cm2tfnCBc2y5vY+N6OhT2MRurcJw87K7CbUi 9cBMjAQPJxS0Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 21C736948C; Sun, 18 Jan 2026 13:44:07 -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 BnyHhlxqrXTw; Sun, 18 Jan 2026 13:44:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769042; bh=HE+2gzBzO88BwLsxJif4q4cwzMXK350skhgSqiCKvNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Txm7eqvtttD6O1vWJqBGvPLQzdgTEdfq3Zk7pWj6va+vlbyQcjr+yoisGyLAYo1Kc 7++xbbtkVgjY8VpBPKEavmDkATfXphq5YgK9qAAoybsPgdgWopp/qzm8SHdyYYaPv/ HEE11p1TEONvznFGHL5g4eyEgB1Az1YBTH/Yox0oG+/+Z8aBFOIY0K26pYJ7WIBhqo KJT396sonoFC5d7wPm22oCVLbT2JKenygp3FCj1Z8kGV0yCyYv+ynNsCzg8tl+5B9g /JCDyP8yYRZFL2/mmZsr20MriLWpxYeDHA6rKIrHplUqmPs8pG/33yGE5Bgj9lCqAh v9BjLXk+i2OtQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8BFC86946A; Sun, 18 Jan 2026 13:44:02 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:50 -0700 Message-ID: <20260118204303.1982533-12-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: 6ZRZMQRGAFYCL2MTMSMB2MXZJZI2MEG6 X-Message-ID-Hash: 6ZRZMQRGAFYCL2MTMSMB2MXZJZI2MEG6 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 11/16] expo: Introduce scene_txtin for common text-input fields 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 Create a new struct scene_txtin to hold the common fields shared by textline and textedit objects: label_id, edit_id, line_chars, and buf Both scene_obj_textline and scene_obj_txtedit now contain a 'tin' member of this type, reducing code duplication and making the common interface clearer. Update all references throughout the codebase to use the tin. prefix when accessing these fields. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/bootctl/multi_ui.c | 4 ++-- boot/bootflow_menu.c | 6 +++--- boot/cedit.c | 12 ++++++------ boot/expo_build.c | 6 +++--- boot/expo_dump.c | 6 +++--- boot/scene.c | 2 +- boot/scene_textedit.c | 18 +++++++++--------- boot/scene_textline.c | 38 ++++++++++++++++++------------------- include/expo.h | 35 ++++++++++++++++++---------------- test/boot/bootctl/bootctl.c | 12 ++++++------ test/boot/cedit.c | 8 ++++---- test/boot/expo.c | 32 +++++++++++++++---------------- 12 files changed, 91 insertions(+), 88 deletions(-) diff --git a/boot/bootctl/multi_ui.c b/boot/bootctl/multi_ui.c index 5145e4357cb..c5b50b515d0 100644 --- a/boot/bootctl/multi_ui.c +++ b/boot/bootctl/multi_ui.c @@ -596,7 +596,7 @@ static int multiboot_ui_show_pass(struct udevice *dev, int seq, bool show) SCENEOBJT_TEXTLINE); if (!tline) return log_msg_ret("tln", -ENOENT); - buf = abuf_data(&tline->buf); + buf = abuf_data(&tline->tin.buf); *buf = '\0'; /* Set highlight and open the textline for editing */ @@ -625,7 +625,7 @@ static int multiboot_ui_get_pass(struct udevice *dev, int seq, if (!tline) return log_msg_ret("tln", -ENOENT); - *passp = abuf_data(&tline->buf); + *passp = abuf_data(&tline->tin.buf); return 0; } diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c index 909694f6e7b..fdc36348859 100644 --- a/boot/bootflow_menu.c +++ b/boot/bootflow_menu.c @@ -315,14 +315,14 @@ int bootflow_menu_add(struct expo *exp, struct bootflow *bflow, int seq, "Passphrase:", NULL); if (ret < 0) return log_msg_ret("itl", -EINVAL); - tline->label_id = ret; + tline->tin.label_id = ret; snprintf(name, sizeof(name), "item%d.pass.edit", seq); ret = scene_txt_str(scn, name, ITEM_PASS_EDIT + seq, 0, - abuf_data(&tline->buf), &txt); + abuf_data(&tline->tin.buf), &txt); if (ret < 0) return log_msg_ret("ite", -EINVAL); - tline->edit_id = ret; + tline->tin.edit_id = ret; txt->obj.flags |= SCENEOF_PASSWORD; /* Create message text (hidden by default) for success/error feedback */ diff --git a/boot/cedit.c b/boot/cedit.c index 5a334787453..f047849e19d 100644 --- a/boot/cedit.c +++ b/boot/cedit.c @@ -433,7 +433,7 @@ static int h_write_settings(struct scene_obj *obj, void *vpriv) const struct scene_obj_textline *tline; tline = (struct scene_obj_textline *)obj; - ret = write_dt_string(buf, obj->name, abuf_data(&tline->buf)); + ret = write_dt_string(buf, obj->name, abuf_data(&tline->tin.buf)); if (ret) return log_msg_ret("wr2", ret); break; @@ -538,9 +538,9 @@ static int h_read_settings(struct scene_obj *obj, void *vpriv) tline = (struct scene_obj_textline *)obj; val = ofnode_read_prop(node, obj->name, &len); - if (len >= tline->line_chars) + if (len >= tline->tin.line_chars) return log_msg_ret("str", -ENOSPC); - strcpy(abuf_data(&tline->buf), val); + strcpy(abuf_data(&tline->tin.buf), val); break; } case SCENEOBJT_MENU: { @@ -638,7 +638,7 @@ static int h_write_settings_env(struct scene_obj *obj, void *vpriv) const struct scene_obj_textline *tline; tline = (struct scene_obj_textline *)obj; - str = abuf_data(&tline->buf); + str = abuf_data(&tline->tin.buf); ret = env_set(var, str); if (ret) return log_msg_ret("set", ret); @@ -708,13 +708,13 @@ static int h_read_settings_env(struct scene_obj *obj, void *vpriv) tline = (struct scene_obj_textline *)obj; value = env_get(var); - if (value && strlen(value) >= tline->line_chars) + if (value && strlen(value) >= tline->tin.line_chars) return log_msg_ret("str", -ENOSPC); if (!value) value = ""; if (priv->verbose) printf("%s=%s\n", var, value); - strcpy(abuf_data(&tline->buf), value); + strcpy(abuf_data(&tline->tin.buf), value); break; } } diff --git a/boot/expo_build.c b/boot/expo_build.c index 76611b4f6d7..0da3ceceb5d 100644 --- a/boot/expo_build.c +++ b/boot/expo_build.c @@ -347,7 +347,7 @@ static int textline_build(struct build_info *info, ofnode node, ret = add_txt_str(info, node, scn, "title", buf, 0); if (ret < 0) return log_msg_ret("tit", ret); - ted->label_id = ret; + ted->tin.label_id = ret; /* Setup the editor */ info->err_prop = "edit-id"; @@ -356,11 +356,11 @@ static int textline_build(struct build_info *info, ofnode node, return log_msg_ret("id", -ENOENT); snprintf(buf, sizeof(buf), "%s.edit", name); - ret = scene_txt_str(scn, buf, edit_id, 0, abuf_data(&ted->buf), + ret = scene_txt_str(scn, buf, edit_id, 0, abuf_data(&ted->tin.buf), NULL); if (ret < 0) return log_msg_ret("add", ret); - ted->edit_id = ret; + ted->tin.edit_id = ret; return 0; } diff --git a/boot/expo_dump.c b/boot/expo_dump.c index 2cd74e137d4..b2ea60db50c 100644 --- a/boot/expo_dump.c +++ b/boot/expo_dump.c @@ -107,9 +107,9 @@ static void dump_textline(struct dump_ctx *ctx, struct scene_obj_textline *tline) { outf(ctx, "Textline: label_id %x edit_id %x\n", - tline->label_id, tline->edit_id); + tline->tin.label_id, tline->tin.edit_id); ctx->indent += 2; - outf(ctx, "line_chars %x pos %x\n", tline->line_chars, tline->pos); + outf(ctx, "line_chars %x pos %x\n", tline->tin.line_chars, tline->pos); ctx->indent -= 2; } @@ -117,7 +117,7 @@ static void dump_textedit(struct dump_ctx *ctx, struct scene_obj_txtedit *tedit) { outf(ctx, "Textedit: label_id %x edit_id %x\n", - tedit->label_id, tedit->edit_id); + tedit->tin.label_id, tedit->tin.edit_id); } static void obj_dump_(struct dump_ctx *ctx, struct scene_obj *obj) diff --git a/boot/scene.c b/boot/scene.c index 882a250e17d..9c02c9b36be 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -786,7 +786,7 @@ int scene_calc_arrange(struct scene *scn, struct expo_arrange_info *arr) struct scene_obj_textline *tline; tline = (struct scene_obj_textline *)obj, - label_id = tline->label_id; + label_id = tline->tin.label_id; break; } } diff --git a/boot/scene_textedit.c b/boot/scene_textedit.c index 8714a4b5705..de985c6f6e1 100644 --- a/boot/scene_textedit.c +++ b/boot/scene_textedit.c @@ -31,12 +31,12 @@ int scene_texted(struct scene *scn, const char *name, uint id, if (ret < 0) return log_msg_ret("obj", ret); - abuf_init(&ted->buf); - if (!abuf_realloc(&ted->buf, INITIAL_SIZE)) + abuf_init(&ted->tin.buf); + if (!abuf_realloc(&ted->tin.buf, INITIAL_SIZE)) return log_msg_ret("buf", -ENOMEM); - buf = abuf_data(&ted->buf); + buf = abuf_data(&ted->tin.buf); *buf = '\0'; - ted->line_chars = line_chars; + ted->tin.line_chars = line_chars; if (teditp) *teditp = ted; @@ -53,7 +53,7 @@ int scene_txted_set_font(struct scene *scn, uint id, const char *font_name, if (!ted) return log_msg_ret("find", -ENOENT); - return scene_txt_set_font(scn, ted->edit_id, font_name, font_size); + return scene_txt_set_font(scn, ted->tin.edit_id, font_name, font_size); } int scene_txted_arrange(struct scene *scn, struct expo_arrange_info *arr, @@ -67,8 +67,8 @@ int scene_txted_arrange(struct scene *scn, struct expo_arrange_info *arr, x = ted->obj.req_bbox.x0; y = ted->obj.req_bbox.y0; - if (ted->label_id) { - ret = scene_obj_set_pos(scn, ted->label_id, x, y); + if (ted->tin.label_id) { + ret = scene_obj_set_pos(scn, ted->tin.label_id, x, y); if (ret < 0) return log_msg_ret("tit", ret); @@ -76,14 +76,14 @@ int scene_txted_arrange(struct scene *scn, struct expo_arrange_info *arr, } /* constrain the edit text to fit within the textedit bbox */ - ret = scene_obj_set_bbox(scn, ted->edit_id, x, y, + ret = scene_obj_set_bbox(scn, ted->tin.edit_id, x, y, ted->obj.req_bbox.x1, ted->obj.req_bbox.y1); if (ret < 0) return log_msg_ret("edi", ret); point = scn->highlight_id == ted->obj.id; point &= !open; - scene_obj_flag_clrset(scn, ted->edit_id, SCENEOF_POINT, + scene_obj_flag_clrset(scn, ted->tin.edit_id, SCENEOF_POINT, point ? SCENEOF_POINT : 0); ted->obj.dims.x = x - ted->obj.req_bbox.x0; diff --git a/boot/scene_textline.c b/boot/scene_textline.c index 2270e1496e9..c0492896888 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -31,12 +31,12 @@ 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->buf, line_chars + 1)) + if (!abuf_init_size(&tline->tin.buf, line_chars + 1)) return log_msg_ret("buf", -ENOMEM); - buf = abuf_data(&tline->buf); + buf = abuf_data(&tline->tin.buf); *buf = '\0'; tline->pos = line_chars; - tline->line_chars = line_chars; + tline->tin.line_chars = line_chars; if (tlinep) *tlinep = tline; @@ -52,11 +52,11 @@ void scene_textline_calc_bbox(struct scene_obj_textline *tline, int inset = theme->menu_inset; bbox->valid = false; - scene_bbox_union(tline->obj.scene, tline->label_id, inset, bbox); - scene_bbox_union(tline->obj.scene, tline->edit_id, inset, bbox); + scene_bbox_union(tline->obj.scene, tline->tin.label_id, inset, bbox); + scene_bbox_union(tline->obj.scene, tline->tin.edit_id, inset, bbox); edit_bbox->valid = false; - scene_bbox_union(tline->obj.scene, tline->edit_id, inset, + scene_bbox_union(tline->obj.scene, tline->tin.edit_id, inset, edit_bbox); } @@ -68,12 +68,12 @@ int scene_textline_calc_dims(struct scene_obj_textline *tline, struct scene_obj_txt *txt; int ret; - txt = scene_obj_find(scn, tline->edit_id, SCENEOBJT_NONE); + txt = scene_obj_find(scn, tline->tin.edit_id, SCENEOBJT_NONE); if (!txt) return log_msg_ret("dim", -ENOENT); ret = vidconsole_nominal(cons, txt->gen.font_name, txt->gen.font_size, - tline->line_chars, &bbox); + tline->tin.line_chars, &bbox); if (ret) return log_msg_ret("nom", ret); @@ -98,19 +98,19 @@ int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr, x = tline->obj.req_bbox.x0; y = tline->obj.req_bbox.y0; - if (tline->label_id) { + if (tline->tin.label_id) { struct scene_obj *edit; - ret = scene_obj_set_pos(scn, tline->label_id, x, y); + ret = scene_obj_set_pos(scn, tline->tin.label_id, x, y); if (ret < 0) return log_msg_ret("tit", ret); x += arr->label_width + theme->textline_label_margin_x; - ret = scene_obj_set_pos(scn, tline->edit_id, x, y); + ret = scene_obj_set_pos(scn, tline->tin.edit_id, x, y); if (ret < 0) return log_msg_ret("til", ret); - edit = scene_obj_find(scn, tline->edit_id, SCENEOBJT_NONE); + edit = scene_obj_find(scn, tline->tin.edit_id, SCENEOBJT_NONE); if (!edit) return log_msg_ret("tie", -ENOENT); x += edit->dims.x; @@ -119,7 +119,7 @@ int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr, point = scn->highlight_id == tline->obj.id; point &= !open; - scene_obj_flag_clrset(scn, tline->edit_id, SCENEOF_POINT, + scene_obj_flag_clrset(scn, tline->tin.edit_id, SCENEOF_POINT, point ? SCENEOF_POINT : 0); tline->obj.dims.x = x - tline->obj.req_bbox.x0; @@ -143,7 +143,7 @@ int scene_textline_send_key(struct scene *scn, struct scene_obj_textline *tline, event->select.id = tline->obj.id; /* Copy the backup text from the scene buffer */ - memcpy(abuf_data(&tline->buf), abuf_data(&scn->buf), + memcpy(abuf_data(&tline->tin.buf), abuf_data(&scn->buf), abuf_size(&scn->buf)); /* cursor is not needed now */ @@ -181,7 +181,7 @@ int scene_textline_send_key(struct scene *scn, struct scene_obj_textline *tline, bool scene_textline_within(const struct scene *scn, struct scene_obj_textline *tline, int x, int y) { - return scene_within(scn, tline->edit_id, x, y); + return scene_within(scn, tline->tin.edit_id, x, y); } int scene_textline_render_deps(struct scene *scn, @@ -198,7 +198,7 @@ int scene_textline_render_deps(struct scene *scn, ret = vidconsole_entry_restore(cons, &scn->entry_save); if (ret) return log_msg_ret("sav", ret); - scene_render_obj(scn, tline->edit_id); + scene_render_obj(scn, tline->tin.edit_id); /* move cursor back to the correct position */ for (i = scn->cls.num; i < scn->cls.eol_num; i++) @@ -236,17 +236,17 @@ int scene_textline_open(struct scene *scn, struct scene_obj_textline *tline) int ret; /* Copy the text into the scene buffer in case the edit is cancelled */ - memcpy(abuf_data(&scn->buf), abuf_data(&tline->buf), + 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->edit_id, SCENEOBJT_NONE); + 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->buf), tline->line_chars); + 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); diff --git a/include/expo.h b/include/expo.h index 2d57e67d51c..e3451d8dd23 100644 --- a/include/expo.h +++ b/include/expo.h @@ -503,23 +503,32 @@ struct scene_menitem { }; /** - * struct scene_obj_textline - information about a textline in a scene - * - * A textline has a prompt and a line of editable text + * struct scene_txtin - generic info for text-input objects * - * @obj: Basic object information * @label_id: ID of the label text object (not string ID), or 0 if none * @edit_id: ID of the editable text object (not string ID) - * @line_chars: Nominal number of characters in a line (also a hard limit) + * @line_chars: Nominal number of characters in a line * @buf: Text buffer containing current text - * @pos: Cursor position */ -struct scene_obj_textline { - struct scene_obj obj; +struct scene_txtin { uint label_id; uint edit_id; uint line_chars; struct abuf buf; +}; + +/** + * struct scene_obj_textline - information about a textline in a scene + * + * A textline has a prompt and a line of editable text + * + * @obj: Basic object information + * @tin: Text-input info + * @pos: Cursor position + */ +struct scene_obj_textline { + struct scene_obj obj; + struct scene_txtin tin; uint pos; }; @@ -544,17 +553,11 @@ struct scene_obj_box { * A text editor which allows users to edit a small text file * * @obj: Basic object information - * @label_id: ID of the label text object (not string ID), or 0 if none - * @edit_id: ID of the editable text object (not string ID) - * @line_chars: Nominal number of characters in a line - * @buf: Text buffer containing current text + * @tin: Text-input info */ struct scene_obj_txtedit { struct scene_obj obj; - uint label_id; - uint edit_id; - uint line_chars; - struct abuf buf; + struct scene_txtin tin; }; /** diff --git a/test/boot/bootctl/bootctl.c b/test/boot/bootctl/bootctl.c index f251cd18507..ababe6f7b21 100644 --- a/test/boot/bootctl/bootctl.c +++ b/test/boot/bootctl/bootctl.c @@ -384,23 +384,23 @@ static int check_passphrase(struct unit_test_state *uts, /* Type 't', 'e', 's', 't' - each poll processes one character */ ut_asserteq(4, console_in_puts("test")); ut_assertok(bc_ui_poll(ui_dev, &seq_out, &selected)); - ut_asserteq_str("t", abuf_data(&tline->buf)); + ut_asserteq_str("t", abuf_data(&tline->tin.buf)); ut_assertok(bc_ui_poll(ui_dev, &seq_out, &selected)); - ut_asserteq_str("te", abuf_data(&tline->buf)); + ut_asserteq_str("te", abuf_data(&tline->tin.buf)); ut_assertok(bc_ui_poll(ui_dev, &seq_out, &selected)); - ut_asserteq_str("tes", abuf_data(&tline->buf)); + ut_asserteq_str("tes", abuf_data(&tline->tin.buf)); ut_assertok(bc_ui_poll(ui_dev, &seq_out, &selected)); - ut_asserteq_str("test", abuf_data(&tline->buf)); + ut_asserteq_str("test", abuf_data(&tline->tin.buf)); /* Send backspace to remove one character */ ut_asserteq(1, console_in_puts("\b")); ut_assertok(bc_ui_poll(ui_dev, &seq_out, &selected)); - ut_asserteq_str("tes", abuf_data(&tline->buf)); + ut_asserteq_str("tes", abuf_data(&tline->tin.buf)); /* Re-add the 't' and verify */ ut_asserteq(1, console_in_puts("t")); ut_assertok(bc_ui_poll(ui_dev, &seq_out, &selected)); - ut_asserteq_str("test", abuf_data(&tline->buf)); + ut_asserteq_str("test", abuf_data(&tline->tin.buf)); /* Send return key to submit - should close textline and select */ ut_asserteq(1, console_in_puts("\n")); diff --git a/test/boot/cedit.c b/test/boot/cedit.c index b8c46f2d50c..b8574c65e64 100644 --- a/test/boot/cedit.c +++ b/test/boot/cedit.c @@ -89,7 +89,7 @@ static int cedit_fdt(struct unit_test_state *uts) /* get a textline to fiddle with too */ tline = scene_obj_find(scn, ID_MACHINE_NAME, SCENEOBJT_TEXTLINE); ut_assertnonnull(tline); - str = abuf_data(&tline->buf); + str = abuf_data(&tline->tin.buf); strcpy(str, "my-machine"); ut_assertok(run_command("cedit write_fdt hostfs - settings.dtb", 0)); @@ -158,7 +158,7 @@ static int cedit_env(struct unit_test_state *uts) /* get a textline to fiddle with too */ tline = scene_obj_find(scn, ID_MACHINE_NAME, SCENEOBJT_TEXTLINE); ut_assertnonnull(tline); - str = abuf_data(&tline->buf); + str = abuf_data(&tline->tin.buf); strcpy(str, "my-machine"); ut_assertok(run_command("cedit write_env -v", 0)); @@ -398,7 +398,7 @@ static int cedit_render_textline(struct unit_test_state *uts) /* set up an initial value for the textline */ tline = scene_obj_find(scn, ID_MACHINE_NAME, SCENEOBJT_TEXTLINE); ut_assertnonnull(tline); - str = abuf_data(&tline->buf); + str = abuf_data(&tline->tin.buf); strcpy(str, "my-machine"); ut_asserteq(20, tline->pos); @@ -655,7 +655,7 @@ static int cedit_mouse(struct unit_test_state *uts) speed->obj.flags); /* click on the textline */ - ut_assertok(click_check(uts, scn, mach->edit_id, + ut_assertok(click_check(uts, scn, mach->tin.edit_id, EXPOACT_REPOINT_OPEN, &act)); ut_asserteq(ID_MACHINE_NAME, act.select.id); ut_asserteq(ID_CPU_SPEED, act.select.prev_id); diff --git a/test/boot/expo.c b/test/boot/expo.c index b6ee4892d7a..95b029568d0 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -1013,7 +1013,7 @@ static int expo_within_funcs(struct unit_test_state *uts) /* test scene_textline_within() */ tline = scene_obj_find(scn, ID_MACHINE_NAME, SCENEOBJT_NONE); ut_assertnonnull(tline); - obj = scene_obj_find(scn, tline->edit_id, SCENEOBJT_NONE); + obj = scene_obj_find(scn, tline->tin.edit_id, SCENEOBJT_NONE); ut_assertnonnull(obj); /* positive test: point within textline bounds */ @@ -1400,19 +1400,19 @@ static int expo_render_textline(struct unit_test_state *uts) id = scene_textline(scn, "textline", OBJ_TEXTLINE, 20, &tline); ut_assert(id > 0); ut_assertok(scene_obj_set_pos(scn, OBJ_TEXTLINE, 500, 500)); - strcpy(abuf_data(&tline->buf), "sample hopwind"); + strcpy(abuf_data(&tline->tin.buf), "sample hopwind"); /* create the label text object */ id = scene_txt_str(scn, "tline-label", 0, 0, "Label:", NULL); ut_assert(id > 0); - tline->label_id = id; + tline->tin.label_id = id; /* create the edit text object pointing to the textline buffer */ - id = scene_txt_str(scn, "tline-edit", 0, 0, abuf_data(&tline->buf), + id = scene_txt_str(scn, "tline-edit", 0, 0, abuf_data(&tline->tin.buf), NULL); ut_assert(id > 0); - tline->edit_id = id; - ut_assertok(scene_txt_set_font(scn, tline->edit_id, + tline->tin.edit_id = id; + ut_assertok(scene_txt_set_font(scn, tline->tin.edit_id, "nimbus_sans_l_regular", 40)); expo_set_scene_id(exp, SCENE1); @@ -1446,7 +1446,7 @@ static int expo_render_textline(struct unit_test_state *uts) /* check cursor moved back one position, before 'a' */ ut_asserteq(14, scn->cls.num); ut_asserteq(15, scn->cls.eol_num); - ut_asserteq_str("sample hopwinda", abuf_data(&tline->buf)); + ut_asserteq_str("sample hopwinda", abuf_data(&tline->tin.buf)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); ut_asserteq(19552, video_compress_fb(uts, dev, false)); @@ -1458,7 +1458,7 @@ static int expo_render_textline(struct unit_test_state *uts) /* check cursor moved back three more positions, before 'i' */ ut_asserteq(11, scn->cls.num); ut_asserteq(15, scn->cls.eol_num); - ut_asserteq_str("sample hopwinda", abuf_data(&tline->buf)); + ut_asserteq_str("sample hopwinda", abuf_data(&tline->tin.buf)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); ut_asserteq(19570, video_compress_fb(uts, dev, false)); @@ -1469,7 +1469,7 @@ static int expo_render_textline(struct unit_test_state *uts) /* check character deleted at cursor position */ ut_asserteq(11, scn->cls.num); ut_asserteq(14, scn->cls.eol_num); - ut_asserteq_str("sample hopwnda", abuf_data(&tline->buf)); + ut_asserteq_str("sample hopwnda", abuf_data(&tline->tin.buf)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); ut_asserteq(19505, video_compress_fb(uts, dev, false)); @@ -1483,7 +1483,7 @@ static int expo_render_textline(struct unit_test_state *uts) /* check the textline is closed and text was saved */ ut_asserteq(0, tline->obj.flags & SCENEOF_OPEN); - ut_asserteq_str("sample hopwnda", abuf_data(&tline->buf)); + ut_asserteq_str("sample hopwnda", abuf_data(&tline->tin.buf)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); ut_asserteq(19543, video_compress_fb(uts, dev, false)); @@ -1518,16 +1518,16 @@ static int expo_render_textedit(struct unit_test_state *uts) /* create the label text object */ id = scene_txt_str(scn, "ted-label", 0, 0, "Editor:", NULL); ut_assert(id > 0); - ted->label_id = id; + ted->tin.label_id = id; /* create the edit text object pointing to the textedit buffer */ - abuf_printf(&ted->buf, "This\nis the initial contents of the text " + abuf_printf(&ted->tin.buf, "This\nis the initial contents of the text " "editor but it is quite likely that more will be added later"); - id = scene_txt_str(scn, "ted-edit", STR_TEXTED, 0, abuf_data(&ted->buf), - NULL); + id = scene_txt_str(scn, "ted-edit", STR_TEXTED, 0, + abuf_data(&ted->tin.buf), NULL); ut_assert(id > 0); - ted->edit_id = id; - ut_assertok(scene_txt_set_font(scn, ted->edit_id, + ted->tin.edit_id = id; + ut_assertok(scene_txt_set_font(scn, ted->tin.edit_id, "nimbus_sans_l_regular", 20)); expo_set_scene_id(exp, SCENE1); From patchwork Sun Jan 18 20:42:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1603 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=1768769053; bh=mR5W+VrruBESXjoTi5ghP3KVpJOgFDVlVelcckcdAAU=; 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=Wwmoh67E/1rBr4/P+xQzLZtNWV6zCmTNSlxgP029QyiW0XEZtS8GiXS9ZtdWj6fmP 1lcleosbrYUGns5r23nWRWDUyzYFBnSlW2bRqu3TjGt9HQba85rgp7eluvU/3wf+AA 1IKJRhaYMNmm1mDhnyvwSrGJQXzB13QVWU4F6wW84v1BeNSZ7Uryhxy480IIafEIun bzzgIi+etCp8OGt9VFQW6uj5RLo4IDOX/h3YHGThRhG5tFk2EPLT7c6uEqLFqHgoyT JdNgz//rock6bR4F4qUL8F2pnSIMW+9aTZ5xkNKxfySbvPGuCcXSbwyg+r58N+h9qY izxH00PmjjjcQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 03D7A6949D for ; Sun, 18 Jan 2026 13:44:13 -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 aIEECBj-cgHL for ; Sun, 18 Jan 2026 13:44:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769052; bh=mR5W+VrruBESXjoTi5ghP3KVpJOgFDVlVelcckcdAAU=; 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=vgTsQuLCo/jh20BDepwhsDOq2NdXhA1MALpzNjwzPsYiczclqlk0W3PyLHO8Lgrkt AMuOdCBARZ/B5LFOiDX5gbQ1iFkEPYgZpcKH1RR3qfmDSVlcPEHh+cSVfM3Z9aWcrl erGx5ho0kW58kFc5LTyF//v02VyBsIkKxroxQ1jWKlyfUGv6yXLU4g874AgsMNMrJU gbAyRx9cc7kaqOQUN+lCDpDjf746yoIZwkI22epoERcTQtS2i5nFijm6ohNCKv3I4P AnB5FgxkS3BPbCi2rBNhIrdMrPVrVhF9jfzFp7Q0aV1z6U7ClNPVYtf1hs0LmlFopx b045tzah2LszA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E6D8469491 for ; Sun, 18 Jan 2026 13:44:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769051; bh=ce+U43F6BASqS/xG+9n8Vfg/f3mZKJ2cPCpLZSVkIjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KLILVpTtqDPN4bXgHVbqR2ZJj+ESu73AUIr9YvUwFfkfae//8BUl74piWob2qkT2v LnEDoJ5dqjy23oSYFI8x8Yr+zg9LgYZs+uTWPE+NiT0V0ErlWrZ1ZBoM3SvQdvozl5 N0+BiywbJJdkDAO65YM3/LmKaR15QFWWhA+dgNiQMq2j7nVQ7Ar3smn0HSit1p4Dab RSkLwxIk5rGNezLFI6XgeMWpOEYPnLhzbFlP5dLi+AbZI7sWK24nQUM6RY6KF8XmzL Q4ifmt8cDIC0dF/jayTba1VBg2N9IRbQ8xSPRqb2gk6HxGB9cyvd5JcJPzag67nW2d W12W8yswRFjbg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B4BF86948C; Sun, 18 Jan 2026 13:44:11 -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 xPEgRN8dfTCw; Sun, 18 Jan 2026 13:44:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769047; bh=lJC2kHbc+Tv6XB1juV/te+J3ns8xD/Yz5nv1x0cKeaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=btbHCIn9blbPv+I95JAxSPQzQjtxkCpZbLkfmHqcbFx+0L24fVBvNjgb7/T97yoT0 k2foTL7JkShYneEKWhn1iM7uqGqnDAqDis93qFjSIgcVyOBNRV806raGPq0Xaquioj 1vqfp2/kB6pEBJb8DDM0ifI75hxIg2D0sUn+VUtBtlcZmQrAe+4808xa4WzN4TThcs udCzc407vV8K+sTtsSsbAHw2c59LC1VAln9D5PkT1KDvpIMOINxIqH9/O32JpAB2Hw GqoGz7WToJCCVKDMef9I53pZe11l/h2SzHGzcxGZP2jtnWfqE2x39pEwqBx4e+hghL kRjnYB+HBv2SQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 656A26946A; Sun, 18 Jan 2026 13:44:07 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:51 -0700 Message-ID: <20260118204303.1982533-13-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: 5TTH3LK4XYV6VWT6WL4CFG3HYI3H5BFR X-Message-ID-Hash: 5TTH3LK4XYV6VWT6WL4CFG3HYI3H5BFR 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 12/16] expo: Factor out common calc_bbox code into scene_txtin.c 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 Create a new file scene_txtin.c containing common code for text-input scene objects (textline, textedit). Move the calc_bbox logic into scene_txtin_calc_bbox() which is called directly from scene_obj_calc_bbox() Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/Makefile | 2 +- boot/scene.c | 13 ++++++++++--- boot/scene_internal.h | 15 ++++++++------- boot/scene_textedit.c | 24 ++++++++++++++++++++++++ boot/scene_textline.c | 16 ---------------- boot/scene_txtin.c | 30 ++++++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 27 deletions(-) create mode 100644 boot/scene_txtin.c diff --git a/boot/Makefile b/boot/Makefile index 39069014310..b9129a174c7 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -61,7 +61,7 @@ obj-$(CONFIG_$(PHASE_)LOAD_FIT) += common_fit.o obj-$(CONFIG_$(PHASE_)EXPO) += expo.o scene.o expo_build.o obj-$(CONFIG_$(PHASE_)EXPO_DUMP) += expo_dump.o -obj-$(CONFIG_$(PHASE_)EXPO) += scene_menu.o scene_textline.o scene_textedit.o +obj-$(CONFIG_$(PHASE_)EXPO) += scene_menu.o scene_textline.o scene_textedit.o scene_txtin.o obj-$(CONFIG_$(PHASE_)EXPO_TEST) += expo_test.o ifdef CONFIG_COREBOOT_SYSINFO obj-$(CONFIG_$(PHASE_)EXPO) += expo_build_cb.o diff --git a/boot/scene.c b/boot/scene.c index 9c02c9b36be..220fbf26b44 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -1440,7 +1440,6 @@ int scene_obj_calc_bbox(struct scene_obj *obj, struct vidconsole_bbox bbox[]) case SCENEOBJT_IMAGE: case SCENEOBJT_TEXT: case SCENEOBJT_BOX: - case SCENEOBJT_TEXTEDIT: return -ENOSYS; case SCENEOBJT_MENU: { struct scene_obj_menu *menu = (struct scene_obj_menu *)obj; @@ -1452,8 +1451,16 @@ int scene_obj_calc_bbox(struct scene_obj *obj, struct vidconsole_bbox bbox[]) struct scene_obj_textline *tline; tline = (struct scene_obj_textline *)obj; - scene_textline_calc_bbox(tline, &bbox[SCENEBB_all], - &bbox[SCENEBB_label]); + scene_txtin_calc_bbox(obj, &tline->tin, &bbox[SCENEBB_all], + &bbox[SCENEBB_label]); + break; + } + case SCENEOBJT_TEXTEDIT: { + struct scene_obj_txtedit *ted; + + ted = (struct scene_obj_txtedit *)obj; + scene_txtin_calc_bbox(obj, &ted->tin, &bbox[SCENEBB_all], + &bbox[SCENEBB_label]); break; } } diff --git a/boot/scene_internal.h b/boot/scene_internal.h index 1e5bd3d2a28..a3eb720c385 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -20,6 +20,7 @@ struct scene_obj_dims; struct scene_obj_menu; struct scene_obj_textline; struct scene_obj_txtedit; +struct scene_txtin; struct scene_txt_generic; struct udevice; struct vidconsole_bbox; @@ -497,16 +498,16 @@ void scene_menu_calc_bbox(struct scene_obj_menu *menu, struct vidconsole_bbox *bbox); /** - * scene_textline_calc_bbox() - Calculate bounding box for the textline + * scene_txtin_calc_bbox() - Calculate bounding box for a text-input object * - * @textline: Menu to process - * @bbox: Returns bounding box of textline including prompt + * @obj: Object to process + * @tin: Text-input object info + * @bbox: Returns bounding box of object including label * @edit_bbox: Returns bounding box of editable part - * Return: 0 if OK, -ve on error */ -void scene_textline_calc_bbox(struct scene_obj_textline *menu, - struct vidconsole_bbox *bbox, - struct vidconsole_bbox *label_bbox); +void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin, + struct vidconsole_bbox *bbox, + struct vidconsole_bbox *edit_bbox); /** * scene_obj_calc_bbox() - Calculate bounding boxes for an object diff --git a/boot/scene_textedit.c b/boot/scene_textedit.c index de985c6f6e1..37138fc7542 100644 --- a/boot/scene_textedit.c +++ b/boot/scene_textedit.c @@ -56,6 +56,30 @@ int scene_txted_set_font(struct scene *scn, uint id, const char *font_name, return scene_txt_set_font(scn, ted->tin.edit_id, font_name, font_size); } +int scene_txted_calc_dims(struct scene_obj_txtedit *ted, struct udevice *cons) +{ + struct scene *scn = ted->obj.scene; + struct scene_obj_txt *txt; + int ret; + + txt = scene_obj_find(scn, ted->tin.edit_id, SCENEOBJT_NONE); + if (!txt) + return log_msg_ret("txt", -ENOENT); + + /* + * Set the edit text's bbox to match the textedit's bbox. This ensures + * SCENEOF_SIZE_VALID is set so vidconsole_measure() applies the width + * limit for word-wrapping/clipping. + */ + ret = scene_obj_set_bbox(scn, ted->tin.edit_id, + ted->obj.req_bbox.x0, ted->obj.req_bbox.y0, + ted->obj.req_bbox.x1, ted->obj.req_bbox.y1); + if (ret < 0) + return log_msg_ret("sbb", ret); + + return 0; +} + int scene_txted_arrange(struct scene *scn, struct expo_arrange_info *arr, struct scene_obj_txtedit *ted) { diff --git a/boot/scene_textline.c b/boot/scene_textline.c index c0492896888..0f542dd590f 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -44,22 +44,6 @@ int scene_textline(struct scene *scn, const char *name, uint id, return tline->obj.id; } -void scene_textline_calc_bbox(struct scene_obj_textline *tline, - struct vidconsole_bbox *bbox, - struct vidconsole_bbox *edit_bbox) -{ - const struct expo_theme *theme = &tline->obj.scene->expo->theme; - int inset = theme->menu_inset; - - bbox->valid = false; - scene_bbox_union(tline->obj.scene, tline->tin.label_id, inset, bbox); - scene_bbox_union(tline->obj.scene, tline->tin.edit_id, inset, bbox); - - edit_bbox->valid = false; - scene_bbox_union(tline->obj.scene, tline->tin.edit_id, inset, - edit_bbox); -} - int scene_textline_calc_dims(struct scene_obj_textline *tline, struct udevice *cons) { diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c new file mode 100644 index 00000000000..b2d8d0ad49e --- /dev/null +++ b/boot/scene_txtin.c @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Common code for text-input scene objects (textline, textedit) + * + * Copyright 2026 Canonical Ltd + * Written by Simon Glass + */ + +#define LOG_CATEGORY LOGC_EXPO + +#include +#include +#include +#include "scene_internal.h" + +void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin, + struct vidconsole_bbox *bbox, + struct vidconsole_bbox *edit_bbox) +{ + struct scene *scn = obj->scene; + const struct expo_theme *theme = &scn->expo->theme; + int inset = theme->menu_inset; + + bbox->valid = false; + scene_bbox_union(scn, tin->label_id, inset, bbox); + scene_bbox_union(scn, tin->edit_id, inset, bbox); + + edit_bbox->valid = false; + scene_bbox_union(scn, tin->edit_id, inset, edit_bbox); +} From patchwork Sun Jan 18 20:42:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1604 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=1768769058; bh=D9Ft2spy6wXaAjIvCNK64+1MUkzx8/WFpGBxxld4lRU=; 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=OE2vDvjSBhMxuR8bblqAOs0YHUXyQ68PkiefSRPZtW+164Aq0amcUjQUwoXW8IEPQ iBtkVar0NTAcviFxOtG7OlLjPR5luuMdDXET8PU+6694qRKnNY3QnQaBAiqHQQUQsj e/cEdSbm9kRqszuq+EG50manl9+JMEIxOxT8H44KtTAvu8faB8zMf97rFtCoIzkrV+ uAK8nvnBmgkUVd6OBD5NUYBwoXIAgN33/qgIT35ImbV0BFxx+UO3ieR/YjtiHj3vhG OR+dLwM6Hl+AXe8CSxQFEOjZ5Ddyx+y9j5L6aqi63waoiwq/K5dFtmymi0aiXHERAU KHjzCZkHJXlsA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 780366949D for ; Sun, 18 Jan 2026 13:44:18 -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 vghoURcr3lzz for ; Sun, 18 Jan 2026 13:44:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769058; bh=D9Ft2spy6wXaAjIvCNK64+1MUkzx8/WFpGBxxld4lRU=; 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=OE2vDvjSBhMxuR8bblqAOs0YHUXyQ68PkiefSRPZtW+164Aq0amcUjQUwoXW8IEPQ iBtkVar0NTAcviFxOtG7OlLjPR5luuMdDXET8PU+6694qRKnNY3QnQaBAiqHQQUQsj e/cEdSbm9kRqszuq+EG50manl9+JMEIxOxT8H44KtTAvu8faB8zMf97rFtCoIzkrV+ uAK8nvnBmgkUVd6OBD5NUYBwoXIAgN33/qgIT35ImbV0BFxx+UO3ieR/YjtiHj3vhG OR+dLwM6Hl+AXe8CSxQFEOjZ5Ddyx+y9j5L6aqi63waoiwq/K5dFtmymi0aiXHERAU KHjzCZkHJXlsA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 60BBC69491 for ; Sun, 18 Jan 2026 13:44:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769056; bh=ag7LzEncJZkCj3KI4Ypt5wIORErsqjGb6QTYm7qFINI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iu6WT4oNkaE9JL9K4D3xXt6yyA30pwU79ztnffVyjadfAH5pUOgsqC4QQqBjKQpUr CDS9Cr+89GiLhdmjN0eVePdRYQRfVLQ8jHIst74kekFYQm89cxlOTWYMpw3BHCPNSe 6PYRPhLm95og5h5WPVmLezAf/0lt5TV5Ptu6QLkFvBQPh4p+blFpxkt2LaYq9xhwau /Dda1oX1u1/umhJUkhFNog6sRWivjbxJuYf8/8lCG8TEjzSmGDySeliAHY0PQDJfly t72ROjOARddyydR0lOs3bUecKOSdP0ge8wwxenDM2l+NIeVtM/zgDc/rQLaI/SkW0s tjfRRYWLBYRLg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4C3E96948C; Sun, 18 Jan 2026 13:44:16 -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 7f3I64Spum_X; Sun, 18 Jan 2026 13:44:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769052; bh=cd+C/eHgeeolqTOdNKje/h6cLqWLYmYXAUMA9TDcZFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CyqFEIdJFvo1G55wQ4b0LcHO1yQAe94MiCxNt7Dlu9VzJl9TDoW7VbhQjB0aIMyb2 AHIBFWprIi3zgjSjhfaiszxWuruQdzW7SXa3ZRa3CRqsvDCunrnEoTIJRXtxIG5Sox YN3nafW4SVWI/SeFYLzOxK3PpldzPEP+IgrchAYt8DhZw3LrEfYm5vybXRpoQK8Zbz 6ZCsBY9Bi37X97oVK7hBFc4KXdOOTHgseS5tYTWH+jnSdEuBJsVBXunI/FZYOsMuXb HhPZulxZyo271Wxvs5A94LAKHf5O0XA6L4PyhneeOz91VNtq1EA5jQtY6VZNpQI4Z0 yPQj66xNj8fQg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 05F346946A; Sun, 18 Jan 2026 13:44:11 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:52 -0700 Message-ID: <20260118204303.1982533-14-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: EOXVU5VSRR5Q7RYN2EWQ6VKPNW764K4W X-Message-ID-Hash: EOXVU5VSRR5Q7RYN2EWQ6VKPNW764K4W 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 13/16] expo: Add scene_obj_txtin() helper for text-input objects 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 Add a static inline helper to get the scene_txtin pointer from a scene object. This simplifies code that handles both textline and textedit objects, since both have scene_txtin at the same offset. Use this in scene_obj_calc_bbox() to combine the TEXTLINE and TEXTEDIT cases. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene.c | 19 ++++--------------- boot/scene_internal.h | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 220fbf26b44..5691cbce847 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -1447,23 +1447,12 @@ int scene_obj_calc_bbox(struct scene_obj *obj, struct vidconsole_bbox bbox[]) scene_menu_calc_bbox(menu, bbox); break; } - case SCENEOBJT_TEXTLINE: { - struct scene_obj_textline *tline; - - tline = (struct scene_obj_textline *)obj; - scene_txtin_calc_bbox(obj, &tline->tin, &bbox[SCENEBB_all], - &bbox[SCENEBB_label]); - break; - } - case SCENEOBJT_TEXTEDIT: { - struct scene_obj_txtedit *ted; - - ted = (struct scene_obj_txtedit *)obj; - scene_txtin_calc_bbox(obj, &ted->tin, &bbox[SCENEBB_all], - &bbox[SCENEBB_label]); + case SCENEOBJT_TEXTLINE: + case SCENEOBJT_TEXTEDIT: + scene_txtin_calc_bbox(obj, scene_obj_txtin(obj), + &bbox[SCENEBB_all], &bbox[SCENEBB_label]); break; } - } return 0; } diff --git a/boot/scene_internal.h b/boot/scene_internal.h index a3eb720c385..cc58a2264f6 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -29,6 +29,20 @@ enum scene_obj_t; typedef int (*expo_scene_obj_iterator)(struct scene_obj *obj, void *priv); +/** + * scene_obj_txtin() - Get text-input info from a scene object + * + * This works for both textline and textedit objects since they have + * struct scene_txtin at the same offset (immediately after struct scene_obj). + * + * @obj: Object to get text-input info from + * Return: pointer to the text-input info + */ +static inline struct scene_txtin *scene_obj_txtin(struct scene_obj *obj) +{ + return (struct scene_txtin *)(obj + 1); +} + /** * enum scene_bbox_t - Parts of an object which can have a bounding box * 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) From patchwork Sun Jan 18 20:42:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1606 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=1768769066; bh=Tny2UdvtKruB5zqLd+9yYn2QC9H/1UC+sjmm3eSvdPI=; 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=MH+wpiwqU/B9Rys0rNVY/d99gCWuUabk9MWaXFBulXvDsg6nUDvKLTVMS+6N3EgeI 2zFNchvrHdQr6DxGJexn3o3vf3RhYII4JuEEaoWTTAuxTGsHtGx9lp3eSLiRpu8/qX mRKm5j3WAxt51wi8lID2u2Z3GoasaQAbNcpNxuJN70Au3y5JqnN70cXuraoU07/wwV biY57kXOZ9Physc+6Rfgte5+9mjI1G/p8sj2GuNNqH6DndLgobNuTEbkvl/x0D3AuJ Bef6eRaiTP9vnuKOekQRszBPJgSDAIcxTsFw3O0Lstm0GmgjjIMQz6PQAwOiC8VE7n o1J3SoS3fualA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C77D3694A8 for ; Sun, 18 Jan 2026 13:44:26 -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 ALfyQ9oLLP33 for ; Sun, 18 Jan 2026 13:44:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769066; bh=Tny2UdvtKruB5zqLd+9yYn2QC9H/1UC+sjmm3eSvdPI=; 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=MH+wpiwqU/B9Rys0rNVY/d99gCWuUabk9MWaXFBulXvDsg6nUDvKLTVMS+6N3EgeI 2zFNchvrHdQr6DxGJexn3o3vf3RhYII4JuEEaoWTTAuxTGsHtGx9lp3eSLiRpu8/qX mRKm5j3WAxt51wi8lID2u2Z3GoasaQAbNcpNxuJN70Au3y5JqnN70cXuraoU07/wwV biY57kXOZ9Physc+6Rfgte5+9mjI1G/p8sj2GuNNqH6DndLgobNuTEbkvl/x0D3AuJ Bef6eRaiTP9vnuKOekQRszBPJgSDAIcxTsFw3O0Lstm0GmgjjIMQz6PQAwOiC8VE7n o1J3SoS3fualA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AE60D69491 for ; Sun, 18 Jan 2026 13:44:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769065; bh=07fASjXWbHNb0UObRwGw5pnWLDRZZbWXa516xpPJE7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B/WwETjvOYKbdcs0oP4vI5XnhcnzOtbw7HlnU14p7GjWMz4aF3kFrpp8nmlY0NKBj hO0XfeLjKAPALJl3BK6KnFKAl/96ENoGkRGkVQ47XgdoyL1nj5CoFnk9fKjAwOFP9Y VIGNNeVBgw8hnmvs3nGBARF0KBmzcdcCEfGytWledug0J3EhubUMGpTg8TAZC8gpJH tWK21CFpGqMZg6Bp8eSrdb9A12XPoo6a+WL9wu2znrZqIdGSGx1Uesus/JG01Gy8wY PfS7yhFoaCvVrHhFxIt+HaufHuywoskUKRIqJye1IhrztTWH4Aj1a2julL9NlNVuxR T4+ycI7AsqcBg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7C0BA69491; Sun, 18 Jan 2026 13:44:25 -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 WrTD0BzEbgPo; Sun, 18 Jan 2026 13:44:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769061; bh=5UUe56Zc6DP1gQwg9gFODwiWFHhfqiKp/gjzOtxzkTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QoD/98LebfluGsl9Zo1yl5BzTVVFfJYQyFWex5Q7MLOKxdm3zDBLIiO3QRGXe3qn1 2AqNjVKaLoTAqTBamBK3qhUQRoZteLizLLPJX0XW3ScMnhp6IlWaMifChpdEBLP/gN v0NNVIIJkLOyFKqBZElfW4xexY1AfqxXyE/z1TfoEkjJTAg+W38eYBIx4RgiwlOPnI FijT0UC0lWAZ45YXkL5D713LSNtCKOpnFSAAGdKYrVJuUtrOgzwYnl3FHtCjnvvtCc T59k2Huz7WX3eHeqwSUJluKp5+jPgU/3VpYhF66s6oP1oT6W4R4GpYbiBgiUeKgTCt tlUNSXWgF2+Jg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 30ABC6946A; Sun, 18 Jan 2026 13:44:21 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:54 -0700 Message-ID: <20260118204303.1982533-16-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: J3SLWGWXPMXLQSP53ZBLJHNK2M2VJGVP X-Message-ID-Hash: J3SLWGWXPMXLQSP53ZBLJHNK2M2VJGVP 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 15/16] expo: Add scene_txtin_arrange() for common arrangement 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 common arrangement code from scene_textline_arrange() and scene_txted_arrange() into scene_txtin_arrange() This handles label positioning and setting the SCENEOF_POINT flag. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_internal.h | 14 ++++++++++++++ boot/scene_textedit.c | 26 ++++++-------------------- boot/scene_textline.c | 39 +++++++++++++-------------------------- boot/scene_txtin.c | 26 ++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 46 deletions(-) diff --git a/boot/scene_internal.h b/boot/scene_internal.h index b54bc1d426a..8c2196a7b11 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -521,6 +521,20 @@ void scene_menu_calc_bbox(struct scene_obj_menu *menu, */ int scene_txtin_init(struct scene_txtin *tin, uint size, uint line_chars); +/** + * scene_txtin_arrange() - Arrange common parts of a text-input object + * + * Sets the label position and SCENEOF_POINT flag + * + * @scn: Scene containing the object + * @arr: Arrangement info + * @obj: Object to arrange + * @tin: Text-input info + * Return: x position for edit object (positive), or -ve on error + */ +int scene_txtin_arrange(struct scene *scn, struct expo_arrange_info *arr, + struct scene_obj *obj, struct scene_txtin *tin); + /** * 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 9d0bfb2d552..160b9457a50 100644 --- a/boot/scene_textedit.c +++ b/boot/scene_textedit.c @@ -79,35 +79,21 @@ int scene_txted_calc_dims(struct scene_obj_txtedit *ted, struct udevice *cons) int scene_txted_arrange(struct scene *scn, struct expo_arrange_info *arr, struct scene_obj_txtedit *ted) { - const bool open = ted->obj.flags & SCENEOF_OPEN; - const struct expo_theme *theme = &scn->expo->theme; - bool point; - int x, y; + int x; int ret; - x = ted->obj.req_bbox.x0; - y = ted->obj.req_bbox.y0; - if (ted->tin.label_id) { - ret = scene_obj_set_pos(scn, ted->tin.label_id, x, y); - if (ret < 0) - return log_msg_ret("tit", ret); - - x += arr->label_width + theme->textline_label_margin_x; - } + x = scene_txtin_arrange(scn, arr, &ted->obj, &ted->tin); + if (x < 0) + return log_msg_ret("arr", x); /* constrain the edit text to fit within the textedit bbox */ - ret = scene_obj_set_bbox(scn, ted->tin.edit_id, x, y, + ret = scene_obj_set_bbox(scn, ted->tin.edit_id, x, ted->obj.req_bbox.y0, ted->obj.req_bbox.x1, ted->obj.req_bbox.y1); if (ret < 0) return log_msg_ret("edi", ret); - point = scn->highlight_id == ted->obj.id; - point &= !open; - scene_obj_flag_clrset(scn, ted->tin.edit_id, SCENEOF_POINT, - point ? SCENEOF_POINT : 0); - ted->obj.dims.x = x - ted->obj.req_bbox.x0; - ted->obj.dims.y = y - ted->obj.req_bbox.y0; + ted->obj.dims.y = 0; scene_obj_set_size(scn, ted->obj.id, ted->obj.dims.x, ted->obj.dims.y); return 0; diff --git a/boot/scene_textline.c b/boot/scene_textline.c index 960f5e8861f..f940be3ed28 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -71,37 +71,24 @@ int scene_textline_calc_dims(struct scene_obj_textline *tline, int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr, struct scene_obj_textline *tline) { - const bool open = tline->obj.flags & SCENEOF_OPEN; - const struct expo_theme *theme = &scn->expo->theme; - bool point; + struct scene_obj *edit; int x, y; int ret; - x = tline->obj.req_bbox.x0; + x = scene_txtin_arrange(scn, arr, &tline->obj, &tline->tin); + if (x < 0) + return log_msg_ret("arr", x); + y = tline->obj.req_bbox.y0; - if (tline->tin.label_id) { - struct scene_obj *edit; - - ret = scene_obj_set_pos(scn, tline->tin.label_id, x, y); - if (ret < 0) - return log_msg_ret("tit", ret); - - x += arr->label_width + theme->textline_label_margin_x; - ret = scene_obj_set_pos(scn, tline->tin.edit_id, x, y); - if (ret < 0) - return log_msg_ret("til", ret); - - edit = scene_obj_find(scn, tline->tin.edit_id, SCENEOBJT_NONE); - if (!edit) - return log_msg_ret("tie", -ENOENT); - x += edit->dims.x; - y += edit->dims.y; - } + ret = scene_obj_set_pos(scn, tline->tin.edit_id, x, y); + if (ret < 0) + return log_msg_ret("pos", ret); - point = scn->highlight_id == tline->obj.id; - point &= !open; - scene_obj_flag_clrset(scn, tline->tin.edit_id, SCENEOF_POINT, - point ? SCENEOF_POINT : 0); + edit = scene_obj_find(scn, tline->tin.edit_id, SCENEOBJT_NONE); + if (!edit) + return log_msg_ret("fnd", -ENOENT); + x += edit->dims.x; + y += edit->dims.y; tline->obj.dims.x = x - tline->obj.req_bbox.x0; tline->obj.dims.y = y - tline->obj.req_bbox.y0; diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index cd27f9b7115..dbd2555f71d 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -27,6 +27,32 @@ int scene_txtin_init(struct scene_txtin *tin, uint size, uint line_chars) return 0; } +int scene_txtin_arrange(struct scene *scn, struct expo_arrange_info *arr, + struct scene_obj *obj, struct scene_txtin *tin) +{ + const bool open = obj->flags & SCENEOF_OPEN; + const struct expo_theme *theme = &scn->expo->theme; + bool point; + int x; + int ret; + + x = obj->req_bbox.x0; + if (tin->label_id) { + ret = scene_obj_set_pos(scn, tin->label_id, x, obj->req_bbox.y0); + if (ret < 0) + return log_msg_ret("lab", ret); + + x += arr->label_width + theme->textline_label_margin_x; + } + + point = scn->highlight_id == obj->id; + point &= !open; + scene_obj_flag_clrset(scn, tin->edit_id, SCENEOF_POINT, + point ? SCENEOF_POINT : 0); + + return x; +} + void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin, struct vidconsole_bbox *bbox, struct vidconsole_bbox *edit_bbox) From patchwork Sun Jan 18 20:42:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1607 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=1768769072; bh=0RtA6oyvWoNfVE3TFkkMMe+lLQfQiK0Erua7VyBmC/4=; 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=b9XstD/CeKXD37TXtCKclBVH0EJscCdaM495EgAYiFntbqR+fT2qd/DzK/wsskDCb 2YzITGCZ1IpwzQSPxFmgut7/Fq0qn0vUTGqFpOv1xqk3EmR135osTWuFdVJmoGCgEO /mddB2hTfHG3SgT9DTy92zFM8oqle2WFMissApVx4nB/Uw4t3vfNm6o+8ITLhq1x1e 8LKev/GI+FGED2kyZuko1kW/O+LnpwyXkViYPCHuUEnYuAkGAXBXG+qzEGEUVlD9xb SFr7SxinLKYVRAwKoEsMmV/Iouwu7EKlLHJb8QUgAfnRLe7OAKyzu7gyDv0FwFU1RO 7jSMtF2Od5sAw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 310396949E for ; Sun, 18 Jan 2026 13:44:32 -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 xW6MNR31TSE3 for ; Sun, 18 Jan 2026 13:44:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769072; bh=0RtA6oyvWoNfVE3TFkkMMe+lLQfQiK0Erua7VyBmC/4=; 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=b9XstD/CeKXD37TXtCKclBVH0EJscCdaM495EgAYiFntbqR+fT2qd/DzK/wsskDCb 2YzITGCZ1IpwzQSPxFmgut7/Fq0qn0vUTGqFpOv1xqk3EmR135osTWuFdVJmoGCgEO /mddB2hTfHG3SgT9DTy92zFM8oqle2WFMissApVx4nB/Uw4t3vfNm6o+8ITLhq1x1e 8LKev/GI+FGED2kyZuko1kW/O+LnpwyXkViYPCHuUEnYuAkGAXBXG+qzEGEUVlD9xb SFr7SxinLKYVRAwKoEsMmV/Iouwu7EKlLHJb8QUgAfnRLe7OAKyzu7gyDv0FwFU1RO 7jSMtF2Od5sAw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1FA9569491 for ; Sun, 18 Jan 2026 13:44:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769070; bh=MR+CnSrbbOUrvY94yPnRTHUvCDUuuNRLl2jJaDdbn2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q++wMM35QqZAjOJasq5j0kY+Hn34h9Y/fq0p2q+Ew+gF7MzvcrTWGWvl5I/0A0GqF KHa9pdkdOIwD4AIKBbopGk0m48RHijp8DHpMLXSHYrIUGld3gnJ0Br5kgePyBrmRJL x388+e89BnepkRC68ws8Z9PpRk1W+lAMQ32fOmoZBXidGSdvMM6vRHDP600XWyB3rl Dz717XyD+5gcJzxaJNeUvlWfa3zMGzNXa8D0yjKgb66GExgOruQgmX+LLdfpsuuqYz r3SGDLu936SIuCnco0Pd422zXB1WgsMMVE6p6bSU2igLxj+KP9fv787a2i/aXrK5vA VQliTQhb7Uoiw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 196B06948C; Sun, 18 Jan 2026 13:44:30 -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 MetWsW36SpfI; Sun, 18 Jan 2026 13:44:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769066; bh=yvOT3KruU+UiknjPjOw/fB0LSCK/lB8f7ZWUpoLNG/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nmqT18DxDhB7lJnXewrGuOOxi/+a7VfujuxkUbEOx1CoRhqnhH1gyshtD1D1NY+b3 Bo/RzZ636TpGonDLJgp/L0jLrYqnJMooNtdBLGwCL9xP9s6DrxycxLKPlBfAzAq5DQ x/ngeuc5P1ox6G+orQk46mHTni142EZ6SsVLWEnpyqata8XcIhGq3CA9sIOQMtOCBD xQSY/sM2zHpsyz2fQCcQtr1+okO1s5+XKLO0wcfNxJIN9Iws8YJZpMnH56r6hB8Pfr yaR3WJomkc9RMqgKPt1As7ybhFV+8PraMh4jr1qq+6sEKQF/QccIGJAu81UomSCz7k RlG+m9Odl9E3w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id BE7036946A; Sun, 18 Jan 2026 13:44:25 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:55 -0700 Message-ID: <20260118204303.1982533-17-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: OKNQCRTLVFGGXJHKX5XAJNF23FPVROQP X-Message-ID-Hash: OKNQCRTLVFGGXJHKX5XAJNF23FPVROQP 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 16/16] expo: Enable textedit dimension calculation for word-wrap 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 Add textedit support to scene_calc_dims() by calling scene_txted_calc_dims(), thus enabling proper dimension-calculation for textedit objects. This is needed for word-wrapping. Update expo_render_textedit() with the new expected value, now that word-wrapping is working. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene.c | 24 ++++++++++++++++-------- boot/scene_internal.h | 39 +++++++++++++++++++++++++-------------- test/boot/expo.c | 2 +- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 5691cbce847..3565bfd77de 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -773,7 +773,6 @@ int scene_calc_arrange(struct scene *scn, struct expo_arrange_info *arr) case SCENEOBJT_IMAGE: case SCENEOBJT_TEXT: case SCENEOBJT_BOX: - case SCENEOBJT_TEXTEDIT: break; case SCENEOBJT_MENU: { struct scene_obj_menu *menu; @@ -782,14 +781,11 @@ int scene_calc_arrange(struct scene *scn, struct expo_arrange_info *arr) label_id = menu->title_id; break; } - case SCENEOBJT_TEXTLINE: { - struct scene_obj_textline *tline; - - tline = (struct scene_obj_textline *)obj, - label_id = tline->tin.label_id; + case SCENEOBJT_TEXTLINE: + case SCENEOBJT_TEXTEDIT: + label_id = scene_obj_txtin(obj)->label_id; break; } - } if (label_id) { int ret; @@ -1517,7 +1513,6 @@ int scene_calc_dims(struct scene *scn) case SCENEOBJT_NONE: case SCENEOBJT_TEXT: case SCENEOBJT_BOX: - case SCENEOBJT_TEXTEDIT: case SCENEOBJT_IMAGE: { int width; @@ -1533,6 +1528,19 @@ int scene_calc_dims(struct scene *scn) } case SCENEOBJT_MENU: break; + case SCENEOBJT_TEXTEDIT: { + struct scene_obj_txtedit *ted; + + ted = (struct scene_obj_txtedit *)obj; + if (!scn->expo->cons || do_menus) + continue; + + ret = scene_txted_calc_dims(ted, scn->expo->cons); + if (ret) + return log_msg_ret("ted", ret); + + break; + } case SCENEOBJT_TEXTLINE: { struct scene_obj_textline *tline; diff --git a/boot/scene_internal.h b/boot/scene_internal.h index 8c2196a7b11..db11f9c0f60 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -29,20 +29,6 @@ enum scene_obj_t; typedef int (*expo_scene_obj_iterator)(struct scene_obj *obj, void *priv); -/** - * scene_obj_txtin() - Get text-input info from a scene object - * - * This works for both textline and textedit objects since they have - * struct scene_txtin at the same offset (immediately after struct scene_obj). - * - * @obj: Object to get text-input info from - * Return: pointer to the text-input info - */ -static inline struct scene_txtin *scene_obj_txtin(struct scene_obj *obj) -{ - return (struct scene_txtin *)(obj + 1); -} - /** * enum scene_bbox_t - Parts of an object which can have a bounding box * @@ -64,6 +50,20 @@ enum scene_bbox_t { SCENEBB_count, }; +/** + * scene_obj_txtin() - Get text-input info from a scene object + * + * This works for both textline and textedit objects since they have + * struct scene_txtin at the same offset (immediately after struct scene_obj). + * + * @obj: Object to get text-input info from + * Return: pointer to the text-input info + */ +static inline struct scene_txtin *scene_obj_txtin(struct scene_obj *obj) +{ + return (struct scene_txtin *)(obj + 1); +} + /** * expo_lookup_scene_id() - Look up a scene ID * @@ -501,6 +501,17 @@ int scene_dims_union(struct scene *scn, uint id, struct scene_obj_dims *dims); int scene_textline_calc_dims(struct scene_obj_textline *tline, struct udevice *cons); +/** + * scene_txted_calc_dims() - Calculate the dimensions of a textedit + * + * Updates the width and height of the textedit based on its contents + * + * @ted: Textedit to update + * @cons: UCLASS_VIDEO_CONSOLE device (cannot be NULL) + * Returns 0 if OK, -ve on error + */ +int scene_txted_calc_dims(struct scene_obj_txtedit *ted, struct udevice *cons); + /** * scene_menu_calc_bbox() - Calculate bounding boxes for the menu * diff --git a/test/boot/expo.c b/test/boot/expo.c index 95b029568d0..97b9bf82bb7 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -1533,7 +1533,7 @@ static int expo_render_textedit(struct unit_test_state *uts) expo_set_scene_id(exp, SCENE1); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); - ut_asserteq(19493, video_compress_fb(uts, dev, false)); + ut_asserteq(19860, video_compress_fb(uts, dev, false)); abuf_uninit(&buf); abuf_uninit(&logo_copy);