From patchwork Thu Jan 22 04:11: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: 1773 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=1769055193; bh=VQtSTK3P9h4ibfJ5r317LEWqWCAcs5+XOc3J58nuI64=; 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=mvqQZ2mYf1DE+8O8QYwP2xJwcIxgZIcEqtOQph+1dbE6VKB8OOuDiOUEO39UVxSxW vHb9OaBfZG8/3rydEgYenZUhstdUNsQQQb5qvt/Qq516XtY4ZphiatSJSvP9Z10njU m1y8tN/0GNZp8328ggXCWvsNR0ydLzm/GngOjKDEWkqZUnceTjU0ucOxR9/+g4cewJ rw0yzV6WHMs3Mvnk4Ma2XLOR8AYCW7gYFxV3kqQhJeRs2T8WNgRY6pfgEtRoZyXjih AsWvTpM+UjyLteWcKGxcoGodl2mPgI6i7K4X0rhZdn3jHvpZCdQN0NNXfca0Lj99ro 4c34MAFoar/Kw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B26AC6962E for ; Wed, 21 Jan 2026 21:13: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 OTOKRhqQTrwm for ; Wed, 21 Jan 2026 21:13:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769055193; bh=VQtSTK3P9h4ibfJ5r317LEWqWCAcs5+XOc3J58nuI64=; 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=mvqQZ2mYf1DE+8O8QYwP2xJwcIxgZIcEqtOQph+1dbE6VKB8OOuDiOUEO39UVxSxW vHb9OaBfZG8/3rydEgYenZUhstdUNsQQQb5qvt/Qq516XtY4ZphiatSJSvP9Z10njU m1y8tN/0GNZp8328ggXCWvsNR0ydLzm/GngOjKDEWkqZUnceTjU0ucOxR9/+g4cewJ rw0yzV6WHMs3Mvnk4Ma2XLOR8AYCW7gYFxV3kqQhJeRs2T8WNgRY6pfgEtRoZyXjih AsWvTpM+UjyLteWcKGxcoGodl2mPgI6i7K4X0rhZdn3jHvpZCdQN0NNXfca0Lj99ro 4c34MAFoar/Kw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A010E6962A for ; Wed, 21 Jan 2026 21:13:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769055191; bh=BrfzBAQneVUfGc1AgZNbRIgN+Y02HcyOKhRBEavjQU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V/9b8HroyVKzYAmcb6i0Q7S4srJ6a0FGNBD53MRLqcrfcsLK8IU3fw8bwgkgV+L18 rOE+BFki3aJtJNe0Gql72ODu5xLf9uZ1O6ZFZcrE+6pTVH+0ksXfaQMoBB0LIp1SrF DDddgqeY7GyTQHi9Ki0QknJxNvhKFdNGt81CzxX5E/7w/5rOvri5LowzE5+EFsb7ZS 78d4bf6BOoy0JpV00oaZ4HkP47r8SZsf0t68wKIBYIlZbs2p1TQ85/KYFIpPbKqZrH HKSdH6yV8AW/hV1tySLj76gZbmbUj2jZmWnhNf9T9b7MOxGYYT31RkS6Evw6XHiS2Z RbeiuKRPb56BA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A740D6962C; Wed, 21 Jan 2026 21:13: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 CNhbi1fvweZV; Wed, 21 Jan 2026 21:13:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769055187; bh=5EQjkhtk383Id91rRQgd6bu9K/+3yiX7GNDgK05g6GM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nx0Gp95H9N7BbwYx1zt7mlT/xQaV8oJrJqoE+Zb9H4su6Ylg2kBiqkpYkSG2q8W+2 XwA3UWD7LZiFMzLicQzcVmhrMWCKQCY9cBX+M6BvoHowFn73PlkalJ0WRpWK82iMUc ut+CYjvwyKe0dBYYB7bNH3ZiyF1Wz/RAH9rCs8BSS3LC8dPh+KdMWb8sayRYIydAAa kepZNy96hchKHNertp+rb/BCnPxQL6Lhg3EyCBImj2axjQ+/r03+7kMCuXkFlNk712 dBhbjnPHgC2YshI+biCLBLFPsy5ySfif6hZpo//EbEMgCob8ibIrovS6OkzCnlY2Ms emJ3ugFALTFVA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2648E69616; Wed, 21 Jan 2026 21:13:07 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 21 Jan 2026 21:11:42 -0700 Message-ID: <20260122041155.174721-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260122041155.174721-1-sjg@u-boot.org> References: <20260122041155.174721-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: MOVLD27VLCPC3L3ZDMYKCVKVIB7MM4YL X-Message-ID-Hash: MOVLD27VLCPC3L3ZDMYKCVKVIB7MM4YL 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: support cursor positioning for multiline textedits 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 For multiline text input, using backspaces to position the cursor does not work correctly across wrapped line boundaries: the vidconsole cursor-position tracking goes wrong when backspacing at the start of a wrapped line. Fix this by using direct cursor-positioning via a call to vidconsole_set_cursor_pos() in scene_txtin_render_deps(), using the line-measurement info attached to the text object to calculate the correct position for the cursor. Single-line textline objects continue to use the backspace approach. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_txtin.c | 56 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index 338c7da63d3..72552222fe1 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -68,6 +68,46 @@ int scene_txtin_arrange(struct scene *scn, struct expo_arrange_info *arr, return x; } +/** + * set_cursor_pos() - Set cursor position for multiline text + * + * Finds the visual line containing the cursor and sets the cursor position + * to the correct pixel location within that line. + * + * @cons: Vidconsole device + * @ctx: Vidconsole context + * @txt: Text object containing line measurement info + * @buf: Text buffer + * @pos: Cursor position in buffer + */ +static void set_cursor_pos(struct udevice *cons, void *ctx, + struct scene_obj_txt *txt, const char *buf, uint pos) +{ + const struct vidconsole_mline *mline, *res; + struct vidconsole_bbox bbox; + struct alist lines; + uint i; + + alist_init_struct(&lines, struct vidconsole_mline); + for (i = 0; i < txt->gen.lines.count; i++) { + mline = alist_get(&txt->gen.lines, i, struct vidconsole_mline); + if (pos < mline->start || pos > mline->start + mline->len) + continue; + if (vidconsole_measure(cons, txt->gen.font_name, + txt->gen.font_size, buf + mline->start, + pos - mline->start, -1, &bbox, &lines)) + break; + /* measured text is within a single line, so only one result */ + res = alist_get(&lines, 0, struct vidconsole_mline); + if (!res) + break; + vidconsole_set_cursor_pos(cons, ctx, txt->obj.bbox.x0 + res->xpos, + txt->obj.bbox.y0 + mline->bbox.y0); + break; + } + alist_uninit(&lines); +} + int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj, struct scene_txtin *tin) { @@ -81,9 +121,19 @@ int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj, if (open) { scene_render_obj(scn, tin->edit_id, ctx); - /* move cursor back to the correct position */ - for (i = cls->num; i < cls->eol_num; i++) - vidconsole_put_char(cons, ctx, '\b'); + if (cls->multiline) { + /* for multiline, set cursor position directly */ + struct scene_obj_txt *txt; + + txt = scene_obj_find(scn, tin->edit_id, SCENEOBJT_NONE); + if (txt) + set_cursor_pos(cons, ctx, txt, cls->buf, + cls->num); + } else { + /* for single-line, use backspaces */ + for (i = cls->num; i < cls->eol_num; i++) + vidconsole_put_char(cons, ctx, '\b'); + } vidconsole_show_cursor(cons, ctx); }