From patchwork Tue Jan 20 23:17:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1680 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=1768951147; bh=mEt4sGvy+AtVzN/lng26f5hqoAxgKPreI8/lxLoj1WM=; 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=DDN085TM9IzJacQQILxlVAnm/r+u5UglbIHWtJVUnNaNDuESUu4ctZdBYj+EwqKa9 tmzqwx1wWQtn7cy0eboVPJHSQDRFpdZuCKjonsPj2r/sQbyLHkLuE4PUp7qZp+KKkO F5BC/uFgJTMANEmzXmYu8UDA9N6bp6Ht0cIflQlkF6hhCnUXzNtXFjeid7M+gyXZ72 kvC3sjw3g07DZqaSJuZCFKPZVb9TfkCSTnb3S5HBbj0kSx2b0GlG7fU5vx/Pq1AOcR Z720J4eNicSLN7oFMhS8ZpUiKMQlLtigEw/ykuH3/rDVC2qc92BX5qWBFCYzaDQmWG HhdxBzvZXi9zg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 15D7D69588 for ; Tue, 20 Jan 2026 16:19: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 10024) with ESMTP id abPlrAvNtpEO for ; Tue, 20 Jan 2026 16:19:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951147; bh=mEt4sGvy+AtVzN/lng26f5hqoAxgKPreI8/lxLoj1WM=; 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=DDN085TM9IzJacQQILxlVAnm/r+u5UglbIHWtJVUnNaNDuESUu4ctZdBYj+EwqKa9 tmzqwx1wWQtn7cy0eboVPJHSQDRFpdZuCKjonsPj2r/sQbyLHkLuE4PUp7qZp+KKkO F5BC/uFgJTMANEmzXmYu8UDA9N6bp6Ht0cIflQlkF6hhCnUXzNtXFjeid7M+gyXZ72 kvC3sjw3g07DZqaSJuZCFKPZVb9TfkCSTnb3S5HBbj0kSx2b0GlG7fU5vx/Pq1AOcR Z720J4eNicSLN7oFMhS8ZpUiKMQlLtigEw/ykuH3/rDVC2qc92BX5qWBFCYzaDQmWG HhdxBzvZXi9zg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 04ADB6957E for ; Tue, 20 Jan 2026 16:19:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951145; bh=Fm4xLSZNT8JQEkjs/pyu6Z3rrRpINtJmk34VyvqtckQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gDo63qh4CS7zpdWlVrOc8bjy+2RSAeRJfFJpcPkfM86Q/NIkIZDI5mTjEw6z50Fch QfS7fxpHhbWO0TDj8I4GDHnQQN64MWimCUU6Wt0MGUBIP406a4D4QjQR8covkT8Q9r jn7TNljIHFOLRk5VOj1YxLc+cjq2eBHEuta5PMpQzFyIOHJ8iviG7NYB07kFepyRyE ULbIle1ClkzU0Qgm3q2olatI+fe4U2fzrwjwA1OV4yNJAGXmyyyvqVeGByU0lQI2sZ dwnJB+Epgrrn1ByOh2EG/74rkwT2xPa2QbVFfL2tBSQgLj65jyl/kWvdb3Mxw3c6OJ 0vqyVT/VvYyPw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 621DC69572; Tue, 20 Jan 2026 16:19:05 -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 ZMV0kehX6_53; Tue, 20 Jan 2026 16:19:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951141; bh=ck2P98deKa9hcQfmAlEpJyd3xMfOMC2XH/KkNzSuTw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c48N0bxk/WqyD5gDrG0WR7OnDzBBA1AKfpdSLeKOUdR/fTCD+Phhq7bdsmlxjxlQG BWVUQYZ+1a0SQS2zvMkwjDnS1KrKbsB4BYpOuqzSnoet73cwH77plotBN3x6C9i9D5 VzR2eLU5kDLzbJkElPFdfl8/6fE9znCTbukDOHBnSq2h3/R12akHZ/xKjO8ibJjWj1 LJiRHq0NlgaqogmIjX26y620xbNk26fnWwcjh1WWRIHWaywBfb4jEpRRkGaVB70yNQ bMmO1FxhPoC1WGHBKMBZfm3JHlMeq09KuaJcGD379jBxvFqfUF7MsneKWFgU8pnoMI /oi0m1cFnGiIg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E5E9A6913F; Tue, 20 Jan 2026 16:19:00 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:34 -0700 Message-ID: <20260120231814.2033069-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260120231814.2033069-1-sjg@u-boot.org> References: <20260120231814.2033069-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: AHRCLKOF3HLGYR6CKOUUTHMDILVMO3YB X-Message-ID-Hash: AHRCLKOF3HLGYR6CKOUUTHMDILVMO3YB 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/36] expo: Move and generalise scene_textline_send_key() List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Move scene_textline_send_key() from scene_textline.c to scene_txtin.c and rename it to scene_txtin_send_key(). Change the signature to take a scene_obj and scene_txtin instead of scene_obj_textline, allowing it to be used for both textline and textedit objects. The scene is now obtained from obj->scene rather than being passed as a separate parameter. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene.c | 22 +++++++------------ boot/scene_internal.h | 10 ++++----- boot/scene_textline.c | 47 ----------------------------------------- boot/scene_txtin.c | 49 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 66 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 16814d53b65..2627335c0e8 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -1176,27 +1176,21 @@ int scene_send_key(struct scene *scn, int key, struct expo_action *event) return log_msg_ret("key", ret); break; } - case SCENEOBJT_TEXTLINE: { - struct scene_obj_textline *tline; - - tline = (struct scene_obj_textline *)cur, - ret = scene_textline_send_key(scn, tline, key, event); + case SCENEOBJT_TEXTLINE: + case SCENEOBJT_TEXTEDIT: + ret = scene_txtin_send_key(cur, scene_obj_txtin(cur), + key, event); if (ret) return log_msg_ret("key", ret); break; } - case SCENEOBJT_TEXTEDIT: - /* TODO(sjg@chromium.org): Implement this */ - break; - } return 0; } - if (cur && cur->type == SCENEOBJT_TEXTLINE) { - struct scene_obj_textline *tline; - - tline = (struct scene_obj_textline *)cur; - ret = scene_textline_send_key(scn, tline, key, event); + if (cur && (cur->type == SCENEOBJT_TEXTLINE || + cur->type == SCENEOBJT_TEXTEDIT)) { + ret = scene_txtin_send_key(cur, scene_obj_txtin(cur), + key, event); if (ret) return log_msg_ret("key", ret); return 0; diff --git a/boot/scene_internal.h b/boot/scene_internal.h index e732650b99f..733f0c0f6ca 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -227,16 +227,16 @@ int scene_menu_send_click(struct scene *scn, struct scene_obj_menu *menu, int x, int y, struct expo_action *event); /** - * scene_textline_send_key() - Send a key to a textline for processing + * scene_txtin_send_key() - Send a key to a text-input object for processing * - * @scn: Scene to use - * @tline: textline to use + * @obj: Object to use + * @tin: Text-input info * @key: Key code to send (KEY_...) * @event: Place to put any event which is generated by the key * Returns: 0 if OK (always) */ -int scene_textline_send_key(struct scene *scn, struct scene_obj_textline *tline, - int key, struct expo_action *event); +int scene_txtin_send_key(struct scene_obj *obj, struct scene_txtin *tin, + int key, struct expo_action *event); /** * scene_menu_destroy() - Destroy a menu in a scene diff --git a/boot/scene_textline.c b/boot/scene_textline.c index 9b5c40462fd..304a6d914cd 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -98,53 +98,6 @@ int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr, return 0; } -int scene_textline_send_key(struct scene *scn, struct scene_obj_textline *tline, - int key, struct expo_action *event) -{ - const bool open = tline->obj.flags & SCENEOF_OPEN; - - log_debug("key=%d\n", key); - switch (key) { - case BKEY_QUIT: - if (open) { - event->type = EXPOACT_CLOSE; - event->select.id = tline->obj.id; - - /* Copy the backup text from the scene buffer */ - memcpy(abuf_data(&tline->tin.buf), abuf_data(&scn->buf), - abuf_size(&scn->buf)); - - scene_txtin_close(scn); - } else { - event->type = EXPOACT_QUIT; - log_debug("menu quit\n"); - } - break; - case BKEY_SELECT: - if (!open) - break; - event->type = EXPOACT_CLOSE; - event->select.id = tline->obj.id; - key = '\n'; - fallthrough; - default: { - struct udevice *cons = scn->expo->cons; - int ret; - - ret = vidconsole_entry_restore(cons, &scn->entry_save); - if (ret) - return log_msg_ret("sav", ret); - ret = cread_line_process_ch(&scn->cls, key); - ret = vidconsole_entry_save(cons, &scn->entry_save); - if (ret) - return log_msg_ret("sav", ret); - break; - } - } - - return 0; -} - bool scene_textline_within(const struct scene *scn, struct scene_obj_textline *tline, int x, int y) { diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index 3944bce9a96..d08b9e4ff0f 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -8,6 +8,7 @@ #define LOG_CATEGORY LOGC_EXPO +#include #include #include #include @@ -157,3 +158,51 @@ void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin, edit_bbox->valid = false; scene_bbox_union(scn, tin->edit_id, inset, edit_bbox); } + +int scene_txtin_send_key(struct scene_obj *obj, struct scene_txtin *tin, + int key, struct expo_action *event) +{ + const bool open = obj->flags & SCENEOF_OPEN; + struct scene *scn = obj->scene; + + log_debug("key=%d\n", key); + switch (key) { + case BKEY_QUIT: + if (open) { + event->type = EXPOACT_CLOSE; + event->select.id = obj->id; + + /* Copy the backup text from the scene buffer */ + memcpy(abuf_data(&tin->buf), abuf_data(&scn->buf), + abuf_size(&scn->buf)); + + scene_txtin_close(scn); + } else { + event->type = EXPOACT_QUIT; + log_debug("menu quit\n"); + } + break; + case BKEY_SELECT: + if (!open) + break; + event->type = EXPOACT_CLOSE; + event->select.id = obj->id; + key = '\n'; + fallthrough; + default: { + struct udevice *cons = scn->expo->cons; + int ret; + + ret = vidconsole_entry_restore(cons, &scn->entry_save); + if (ret) + return log_msg_ret("sav", ret); + ret = cread_line_process_ch(&scn->cls, key); + ret = vidconsole_entry_save(cons, &scn->entry_save); + if (ret) + return log_msg_ret("sav", ret); + break; + } + } + + return 0; +}