ui/console-vc: extract vt100_input() from vc_chr_write()
Move the VT100 input processing logic out of vc_chr_write() into a new vt100_input() function that operates on QemuVT100 directly, rather than going through the Chardev/VCChardev layers. This continues the effort to decouple the VT100 emulation from the chardev backend, making the VT100 layer self-contained and reusable. vc_chr_write() becomes a thin wrapper that extracts the QemuVT100 from the chardev and delegates to vt100_input(). Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Marc-André Lureau committed
Feb 19, 2026 at 22:18 UTC
61420f141562810d542bdb90f20a2b1371ddbf6a
1 file changed
+20
-14
ui/console-vc.c
+20
-14
@@ -1059,29 +1059,35 @@ static void vt100_putchar(QemuVT100 *vt, int ch)
1059
DECLARE_INSTANCE_CHECKER(VCChardev, VC_CHARDEV,
1060
TYPE_CHARDEV_VC)
1061
1062
-static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len)
1062
+static size_t vt100_input(QemuVT100 *vt, const uint8_t *buf, size_t len)
1063
{
1064
- VCChardev *drv = VC_CHARDEV(chr);
1065
- QemuTextConsole *s = drv->console;
1064
int i;
1065
1068
- s->vt.update_x0 = s->vt.width * FONT_WIDTH;
1069
- s->vt.update_y0 = s->vt.height * FONT_HEIGHT;
1070
- s->vt.update_x1 = 0;
1071
- s->vt.update_y1 = 0;
1072
- vt100_show_cursor(&s->vt, 0);
1066
+ vt->update_x0 = vt->width * FONT_WIDTH;
1067
+ vt->update_y0 = vt->height * FONT_HEIGHT;
1068
+ vt->update_x1 = 0;
1069
+ vt->update_y1 = 0;
1070
+ vt100_show_cursor(vt, 0);
1071
for(i = 0; i < len; i++) {
1074
- vt100_putchar(&s->vt, buf[i]);
1072
+ vt100_putchar(vt, buf[i]);
1073
}
1076
- vt100_show_cursor(&s->vt, 1);
1077
- if (s->vt.update_x0 < s->vt.update_x1) {
1078
- vt100_image_update(&s->vt, s->vt.update_x0, s->vt.update_y0,
1079
- s->vt.update_x1 - s->vt.update_x0,
1080
- s->vt.update_y1 - s->vt.update_y0);
1074
+ vt100_show_cursor(vt, 1);
1075
+ if (vt->update_x0 < vt->update_x1) {
1076
+ vt100_image_update(vt, vt->update_x0, vt->update_y0,
1077
+ vt->update_x1 - vt->update_x0,
1078
+ vt->update_y1 - vt->update_y0);
1079
}
1080
return len;
1081
}
1082
1083
+static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len)
1084
+{
1085
+ VCChardev *drv = VC_CHARDEV(chr);
1086
+ QemuTextConsole *s = drv->console;
1087
+
1088
+ return vt100_input(&s->vt, buf, len);
1089
+}
1090
+
1091
void vt100_update_cursor(void)
1092
{
1093
QemuVT100 *vt;