[Concept,05/16] expo: Wire up putch callback for textline editing

Message ID 20260118204303.1982533-6-sjg@u-boot.org
State New
Headers
Series expo: Continue preparations for textedit (part D) |

Commit Message

Simon Glass Jan. 18, 2026, 8:42 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

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 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 boot/scene_textline.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
  

Patch

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);