From nobody Tue Apr 7 02:38:11 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1773737645; cv=none; d=zohomail.com; s=zohoarc; b=ZaOW+r7ygoJ/rM5+UnN69QYw/8eUZcCdOIaIrZB9OrsV6dxBziEwROUZiAupSO0sVDn8yEAZiRMS8BRnCXMnSi4reCfi295RqvI+T4P0VN8xD4MYlFswoC5+CNPOmGTXtZC5D1NJWiOoHGG3V3vwtRaFdopIfvqnfeX3oUEvixg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773737645; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=0mwFqxq0JX7/6dC/VcZ7+FFfCgrd1MnVl6PPRsnkg4w=; b=O7fvg8Nudrfjwwquc9AtskMZE2L3GAFvEtM9C1ZhxWv13dou5KnpL03GW35aS8wXGO2FQYXtyMAjshMkCppowbI7p5Et8Gfvn41aQkTsmRPzIWZUIRrFax4i7AwJM5dNSdx08uvjCQajxpgmoiCHH18WLAJt30Mi4QfdWgW+4Ko= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773737645621921.7590321170735; Tue, 17 Mar 2026 01:54:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w2QAQ-0006oJ-0H; Tue, 17 Mar 2026 04:52:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w2Q9t-0006Iv-Fd for qemu-devel@nongnu.org; Tue, 17 Mar 2026 04:52:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w2Q9q-000369-3d for qemu-devel@nongnu.org; Tue, 17 Mar 2026 04:52:12 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-d1_VKgmJPcmQu3tu1XEMFQ-1; Tue, 17 Mar 2026 04:52:07 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 60DA9195609E for ; Tue, 17 Mar 2026 08:52:06 +0000 (UTC) Received: from localhost (unknown [10.44.22.6]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7E2E430002DA for ; Tue, 17 Mar 2026 08:52:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773737528; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0mwFqxq0JX7/6dC/VcZ7+FFfCgrd1MnVl6PPRsnkg4w=; b=HOERUDGvxVIYD1DWr1g6r4O2t3PhaYxdjS7SEB10QPzxVa90ztGfKMg7otSXvqK/rzM9iD Yfrm4iY/kDurwxwceNAOLth0s8/ivjHK5mWTVMSCktmryCzko9jA0a5IuA0LEERs20e/7R guPRg0ohH2IRlXFptZVMPQbU8dQwFe4= X-MC-Unique: d1_VKgmJPcmQu3tu1XEMFQ-1 X-Mimecast-MFC-AGG-ID: d1_VKgmJPcmQu3tu1XEMFQ_1773737526 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Tue, 17 Mar 2026 12:50:29 +0400 Subject: [PATCH 15/60] ui/console-vc: introduce QemuVT100 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260317-qemu-vnc-v1-15-48eb1dcf7b76@redhat.com> References: <20260317-qemu-vnc-v1-0-48eb1dcf7b76@redhat.com> In-Reply-To: <20260317-qemu-vnc-v1-0-48eb1dcf7b76@redhat.com> To: qemu-devel@nongnu.org X-Developer-Signature: v=1; a=openpgp-sha256; l=26525; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=2mywc0fxiG7ETDbxolXVw6dLaR6CMEUA7+x2JF445So=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBpuRXaYHkioHPrBq/OdW71ozE8DwewtHngt9hkE 5uP0rhRYDGJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCabkV2gAKCRDa6OEJdZac 5fY0EACnjASdnCXxH/SCiaGUERJv3REsm4RqJis/rl4S+GkIcVgeL+feW5VYQp0fqi+sZLLIhS/ QYVs8WrqYvea539YuXHPUVUnSSqeCAiZ/gbsxpf4Bzqblbn2nsXG1oUEw/Ds6BxV/hC6uLhwIkx PVQJ9GrMEI40GDJUaL3W+95o0Kb0t0sYiL615DLTTbfJfVLYvSCe9wmntv28pIfoPJGlFCPJrnu HaqNK8SCYgSM39vYrJF5k/7dQ9m/MZN5aAF5MBJGyJdu+SQxHvVNSGJIAK8CsN8KK4TtdEfKmyL HcPXzBGecoiPGf1YAU2JuIMQSPvtjhAl/p0bK4gosFp70lZ2NXuL7nv7FzauKg+5Q80x/ylDb/7 vNV7Zty1zLA97H85P2bGS1te7x0sX9N8I9a0tcaj1/DvbElc7Ttg4l80CwSODuW9F+T9NAQc5/F fum/A6Nr8tJwffm1SBGgWeC6ufqPVcZJWU6NFgvwpJQr+iwPk/UVZXI8ZNnApKADtPlyUz8Tz97 lWHD/P5FjP/OfOz17eaBnNI562RUKKJrLUJW+RltpmY9uUm6tI/KZDaBy51lwIaahBM4ZIUZCof syCUsjiE01bAR1YiR+3uOQ5/Q51PI6gh6wjo+bjcA6pYV/63uWsXt5R6MxonIwObI+F6/QIkcSs 6Y2l1J+IbNd/l5A== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1773737666746158500 Start moving VT100 emulation specific code in a different structure. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- ui/console-vc.c | 381 ++++++++++++++++++++++++++++------------------------= ---- 1 file changed, 192 insertions(+), 189 deletions(-) diff --git a/ui/console-vc.c b/ui/console-vc.c index e83a0b04e3f..41436a38eb5 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -48,9 +48,7 @@ enum TTYState { TTY_STATE_OSC, }; =20 -typedef struct QemuTextConsole { - QemuConsole parent; - +typedef struct QemuVT100 { int width; int height; int total_height; @@ -66,7 +64,12 @@ typedef struct QemuTextConsole { int update_y0; int update_x1; int update_y1; +} QemuVT100; + +typedef struct QemuTextConsole { + QemuConsole parent; =20 + QemuVT100 vt; Chardev *chr; /* fifo for key pressed */ Fifo8 out_fifo; @@ -186,34 +189,34 @@ static void invalidate_xy(QemuTextConsole *s, int x, = int y) if (!qemu_console_is_visible(QEMU_CONSOLE(s))) { return; } - if (s->update_x0 > x * FONT_WIDTH) - s->update_x0 =3D x * FONT_WIDTH; - if (s->update_y0 > y * FONT_HEIGHT) - s->update_y0 =3D y * FONT_HEIGHT; - if (s->update_x1 < (x + 1) * FONT_WIDTH) - s->update_x1 =3D (x + 1) * FONT_WIDTH; - if (s->update_y1 < (y + 1) * FONT_HEIGHT) - s->update_y1 =3D (y + 1) * FONT_HEIGHT; + if (s->vt.update_x0 > x * FONT_WIDTH) + s->vt.update_x0 =3D x * FONT_WIDTH; + if (s->vt.update_y0 > y * FONT_HEIGHT) + s->vt.update_y0 =3D y * FONT_HEIGHT; + if (s->vt.update_x1 < (x + 1) * FONT_WIDTH) + s->vt.update_x1 =3D (x + 1) * FONT_WIDTH; + if (s->vt.update_y1 < (y + 1) * FONT_HEIGHT) + s->vt.update_y1 =3D (y + 1) * FONT_HEIGHT; } =20 static void console_show_cursor(QemuTextConsole *s, int show) { TextCell *c; int y, y1; - int x =3D s->x; + int x =3D s->vt.x; =20 - s->cursor_invalidate =3D 1; + s->vt.cursor_invalidate =3D 1; =20 - if (x >=3D s->width) { - x =3D s->width - 1; + if (x >=3D s->vt.width) { + x =3D s->vt.width - 1; } - y1 =3D (s->y_base + s->y) % s->total_height; - y =3D y1 - s->y_displayed; + y1 =3D (s->vt.y_base + s->vt.y) % s->vt.total_height; + y =3D y1 - s->vt.y_displayed; if (y < 0) { - y +=3D s->total_height; + y +=3D s->vt.total_height; } - if (y < s->height) { - c =3D &s->cells[y1 * s->width + x]; + if (y < s->vt.height) { + c =3D &s->vt.cells[y1 * s->vt.width + x]; if (show && cursor_visible_phase) { TextAttributes t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; t_attrib.invers =3D !(t_attrib.invers); /* invert fg and bg */ @@ -232,23 +235,23 @@ static void console_refresh(QemuTextConsole *s) int x, y, y1; =20 assert(surface); - s->text_x[0] =3D 0; - s->text_y[0] =3D 0; - s->text_x[1] =3D s->width - 1; - s->text_y[1] =3D s->height - 1; - s->cursor_invalidate =3D 1; + s->vt.text_x[0] =3D 0; + s->vt.text_y[0] =3D 0; + s->vt.text_x[1] =3D s->vt.width - 1; + s->vt.text_y[1] =3D s->vt.height - 1; + s->vt.cursor_invalidate =3D 1; =20 qemu_console_fill_rect(QEMU_CONSOLE(s), 0, 0, surface_width(surface), = surface_height(surface), color_table_rgb[0][QEMU_COLOR_BLACK]); - y1 =3D s->y_displayed; - for (y =3D 0; y < s->height; y++) { - c =3D s->cells + y1 * s->width; - for (x =3D 0; x < s->width; x++) { + y1 =3D s->vt.y_displayed; + for (y =3D 0; y < s->vt.height; y++) { + c =3D s->vt.cells + y1 * s->vt.width; + for (x =3D 0; x < s->vt.width; x++) { vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, &(c->t_attrib)); c++; } - if (++y1 =3D=3D s->total_height) { + if (++y1 =3D=3D s->vt.total_height) { y1 =3D 0; } } @@ -263,24 +266,24 @@ static void console_scroll(QemuTextConsole *s, int yd= elta) =20 if (ydelta > 0) { for(i =3D 0; i < ydelta; i++) { - if (s->y_displayed =3D=3D s->y_base) + if (s->vt.y_displayed =3D=3D s->vt.y_base) break; - if (++s->y_displayed =3D=3D s->total_height) - s->y_displayed =3D 0; + if (++s->vt.y_displayed =3D=3D s->vt.total_height) + s->vt.y_displayed =3D 0; } } else { ydelta =3D -ydelta; - i =3D s->backscroll_height; - if (i > s->total_height - s->height) - i =3D s->total_height - s->height; - y1 =3D s->y_base - i; + i =3D s->vt.backscroll_height; + if (i > s->vt.total_height - s->vt.height) + i =3D s->vt.total_height - s->vt.height; + y1 =3D s->vt.y_base - i; if (y1 < 0) - y1 +=3D s->total_height; + y1 +=3D s->vt.total_height; for(i =3D 0; i < ydelta; i++) { - if (s->y_displayed =3D=3D y1) + if (s->vt.y_displayed =3D=3D y1) break; - if (--s->y_displayed < 0) - s->y_displayed =3D s->total_height - 1; + if (--s->vt.y_displayed < 0) + s->vt.y_displayed =3D s->vt.total_height - 1; } } console_refresh(s); @@ -338,13 +341,13 @@ void qemu_text_console_handle_keysym(QemuTextConsole = *s, int keysym) *q++ =3D '\033'; *q++ =3D '['; *q++ =3D keysym & 0xff; - } else if (s->echo && (keysym =3D=3D '\r' || keysym =3D=3D '\n')) { + } else if (s->vt.echo && (keysym =3D=3D '\r' || keysym =3D=3D '\n'= )) { qemu_chr_write(s->chr, (uint8_t *)"\r", 1, true); *q++ =3D '\n'; } else { *q++ =3D keysym; } - if (s->echo) { + if (s->vt.echo) { qemu_chr_write(s->chr, buf, q - buf, true); } num_free =3D fifo8_num_free(&s->out_fifo); @@ -359,27 +362,27 @@ static void text_console_update(void *opaque, console= _ch_t *chardata) QemuTextConsole *s =3D QEMU_TEXT_CONSOLE(opaque); int i, j, src; =20 - if (s->text_x[0] <=3D s->text_x[1]) { - src =3D (s->y_base + s->text_y[0]) * s->width; - chardata +=3D s->text_y[0] * s->width; - for (i =3D s->text_y[0]; i <=3D s->text_y[1]; i ++) - for (j =3D 0; j < s->width; j++, src++) { + if (s->vt.text_x[0] <=3D s->vt.text_x[1]) { + src =3D (s->vt.y_base + s->vt.text_y[0]) * s->vt.width; + chardata +=3D s->vt.text_y[0] * s->vt.width; + for (i =3D s->vt.text_y[0]; i <=3D s->vt.text_y[1]; i ++) + for (j =3D 0; j < s->vt.width; j++, src++) { console_write_ch(chardata ++, - ATTR2CHTYPE(s->cells[src].ch, - s->cells[src].t_attrib.fgcol, - s->cells[src].t_attrib.bgcol, - s->cells[src].t_attrib.bold)); + ATTR2CHTYPE(s->vt.cells[src].ch, + s->vt.cells[src].t_attrib.fgc= ol, + s->vt.cells[src].t_attrib.bgc= ol, + s->vt.cells[src].t_attrib.bol= d)); } - dpy_text_update(QEMU_CONSOLE(s), s->text_x[0], s->text_y[0], - s->text_x[1] - s->text_x[0], i - s->text_y[0]); - s->text_x[0] =3D s->width; - s->text_y[0] =3D s->height; - s->text_x[1] =3D 0; - s->text_y[1] =3D 0; + dpy_text_update(QEMU_CONSOLE(s), s->vt.text_x[0], s->vt.text_y[0], + s->vt.text_x[1] - s->vt.text_x[0], i - s->vt.text_= y[0]); + s->vt.text_x[0] =3D s->vt.width; + s->vt.text_y[0] =3D s->vt.height; + s->vt.text_x[1] =3D 0; + s->vt.text_y[1] =3D 0; } - if (s->cursor_invalidate) { - dpy_text_cursor(QEMU_CONSOLE(s), s->x, s->y); - s->cursor_invalidate =3D 0; + if (s->vt.cursor_invalidate) { + dpy_text_cursor(QEMU_CONSOLE(s), s->vt.x, s->vt.y); + s->vt.cursor_invalidate =3D 0; } } =20 @@ -393,33 +396,33 @@ static void text_console_resize(QemuTextConsole *t) =20 w =3D surface_width(s->surface) / FONT_WIDTH; h =3D surface_height(s->surface) / FONT_HEIGHT; - if (w =3D=3D t->width && h =3D=3D t->height) { + if (w =3D=3D t->vt.width && h =3D=3D t->vt.height) { return; } =20 - last_width =3D t->width; - t->width =3D w; - t->height =3D h; + last_width =3D t->vt.width; + t->vt.width =3D w; + t->vt.height =3D h; =20 - w1 =3D MIN(t->width, last_width); + w1 =3D MIN(t->vt.width, last_width); =20 - cells =3D g_new(TextCell, t->width * t->total_height + 1); - for (y =3D 0; y < t->total_height; y++) { - c =3D &cells[y * t->width]; + cells =3D g_new(TextCell, t->vt.width * t->vt.total_height + 1); + for (y =3D 0; y < t->vt.total_height; y++) { + c =3D &cells[y * t->vt.width]; if (w1 > 0) { - c1 =3D &t->cells[y * last_width]; + c1 =3D &t->vt.cells[y * last_width]; for (x =3D 0; x < w1; x++) { *c++ =3D *c1++; } } - for (x =3D w1; x < t->width; x++) { + for (x =3D w1; x < t->vt.width; x++) { c->ch =3D ' '; c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; c++; } } - g_free(t->cells); - t->cells =3D cells; + g_free(t->vt.cells); + t->vt.cells =3D cells; } =20 static void vc_put_lf(VCChardev *vc) @@ -428,41 +431,41 @@ static void vc_put_lf(VCChardev *vc) TextCell *c; int x, y1; =20 - s->y++; - if (s->y >=3D s->height) { - s->y =3D s->height - 1; + s->vt.y++; + if (s->vt.y >=3D s->vt.height) { + s->vt.y =3D s->vt.height - 1; =20 - if (s->y_displayed =3D=3D s->y_base) { - if (++s->y_displayed =3D=3D s->total_height) - s->y_displayed =3D 0; + if (s->vt.y_displayed =3D=3D s->vt.y_base) { + if (++s->vt.y_displayed =3D=3D s->vt.total_height) + s->vt.y_displayed =3D 0; } - if (++s->y_base =3D=3D s->total_height) - s->y_base =3D 0; - if (s->backscroll_height < s->total_height) - s->backscroll_height++; - y1 =3D (s->y_base + s->height - 1) % s->total_height; - c =3D &s->cells[y1 * s->width]; - for(x =3D 0; x < s->width; x++) { + if (++s->vt.y_base =3D=3D s->vt.total_height) + s->vt.y_base =3D 0; + if (s->vt.backscroll_height < s->vt.total_height) + s->vt.backscroll_height++; + y1 =3D (s->vt.y_base + s->vt.height - 1) % s->vt.total_height; + c =3D &s->vt.cells[y1 * s->vt.width]; + for(x =3D 0; x < s->vt.width; x++) { c->ch =3D ' '; c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; c++; } - if (s->y_displayed =3D=3D s->y_base) { - s->text_x[0] =3D 0; - s->text_y[0] =3D 0; - s->text_x[1] =3D s->width - 1; - s->text_y[1] =3D s->height - 1; + if (s->vt.y_displayed =3D=3D s->vt.y_base) { + s->vt.text_x[0] =3D 0; + s->vt.text_y[0] =3D 0; + s->vt.text_x[1] =3D s->vt.width - 1; + s->vt.text_y[1] =3D s->vt.height - 1; =20 qemu_console_bitblt(QEMU_CONSOLE(s), 0, FONT_HEIGHT, 0, 0, - s->width * FONT_WIDTH, - (s->height - 1) * FONT_HEIGHT); - qemu_console_fill_rect(QEMU_CONSOLE(s), 0, (s->height - 1) * F= ONT_HEIGHT, - s->width * FONT_WIDTH, FONT_HEIGHT, + s->vt.width * FONT_WIDTH, + (s->vt.height - 1) * FONT_HEIGHT); + qemu_console_fill_rect(QEMU_CONSOLE(s), 0, (s->vt.height - 1) = * FONT_HEIGHT, + s->vt.width * FONT_WIDTH, FONT_HEIGHT, color_table_rgb[0][TEXT_ATTRIBUTES_DEFA= ULT.bgcol]); - s->update_x0 =3D 0; - s->update_y0 =3D 0; - s->update_x1 =3D s->width * FONT_WIDTH; - s->update_y1 =3D s->height * FONT_HEIGHT; + s->vt.update_x0 =3D 0; + s->vt.update_y0 =3D 0; + s->vt.update_x1 =3D s->vt.width * FONT_WIDTH; + s->vt.update_y1 =3D s->vt.height * FONT_HEIGHT; } } } @@ -570,21 +573,21 @@ static void vc_update_xy(VCChardev *vc, int x, int y) TextCell *c; int y1, y2; =20 - s->text_x[0] =3D MIN(s->text_x[0], x); - s->text_x[1] =3D MAX(s->text_x[1], x); - s->text_y[0] =3D MIN(s->text_y[0], y); - s->text_y[1] =3D MAX(s->text_y[1], y); + s->vt.text_x[0] =3D MIN(s->vt.text_x[0], x); + s->vt.text_x[1] =3D MAX(s->vt.text_x[1], x); + s->vt.text_y[0] =3D MIN(s->vt.text_y[0], y); + s->vt.text_y[1] =3D MAX(s->vt.text_y[1], y); =20 - y1 =3D (s->y_base + y) % s->total_height; - y2 =3D y1 - s->y_displayed; + y1 =3D (s->vt.y_base + y) % s->vt.total_height; + y2 =3D y1 - s->vt.y_displayed; if (y2 < 0) { - y2 +=3D s->total_height; + y2 +=3D s->vt.total_height; } - if (y2 < s->height) { - if (x >=3D s->width) { - x =3D s->width - 1; + if (y2 < s->vt.height) { + if (x >=3D s->vt.width) { + x =3D s->vt.width - 1; } - c =3D &s->cells[y1 * s->width + x]; + c =3D &s->vt.cells[y1 * s->vt.width + x]; vga_putcharxy(QEMU_CONSOLE(s), x, y2, c->ch, &(c->t_attrib)); invalidate_xy(s, x, y2); @@ -594,11 +597,11 @@ static void vc_update_xy(VCChardev *vc, int x, int y) static void vc_clear_xy(VCChardev *vc, int x, int y) { QemuTextConsole *s =3D vc->console; - int y1 =3D (s->y_base + y) % s->total_height; - if (x >=3D s->width) { - x =3D s->width - 1; + int y1 =3D (s->vt.y_base + y) % s->vt.total_height; + if (x >=3D s->vt.width) { + x =3D s->vt.width - 1; } - TextCell *c =3D &s->cells[y1 * s->width + x]; + TextCell *c =3D &s->vt.cells[y1 * s->vt.width + x]; c->ch =3D ' '; c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; vc_update_xy(vc, x, y); @@ -650,17 +653,17 @@ static void vc_put_one(VCChardev *vc, int ch) QemuTextConsole *s =3D vc->console; TextCell *c; int y1; - if (s->x >=3D s->width) { + if (s->vt.x >=3D s->vt.width) { /* line wrap */ - s->x =3D 0; + s->vt.x =3D 0; vc_put_lf(vc); } - y1 =3D (s->y_base + s->y) % s->total_height; - c =3D &s->cells[y1 * s->width + s->x]; + y1 =3D (s->vt.y_base + s->vt.y) % s->vt.total_height; + c =3D &s->vt.cells[y1 * s->vt.width + s->vt.x]; c->ch =3D ch; c->t_attrib =3D vc->t_attrib; - vc_update_xy(vc, s->x, s->y); - s->x++; + vc_update_xy(vc, s->vt.x, s->vt.y); + s->vt.x++; } =20 static void vc_respond_str(VCChardev *vc, const char *buf) @@ -681,15 +684,15 @@ static void vc_set_cursor(VCChardev *vc, int x, int y) if (y < 0) { y =3D 0; } - if (y >=3D s->height) { - y =3D s->height - 1; + if (y >=3D s->vt.height) { + y =3D s->vt.height - 1; } - if (x >=3D s->width) { - x =3D s->width - 1; + if (x >=3D s->vt.width) { + x =3D s->vt.width - 1; } =20 - s->x =3D x; - s->y =3D y; + s->vt.x =3D x; + s->vt.y =3D y; } =20 /** @@ -708,28 +711,28 @@ static void vc_csi_P(struct VCChardev *vc, unsigned i= nt nr) if (!nr) { nr =3D 1; } - if (nr > s->width - s->x) { - nr =3D s->width - s->x; + if (nr > s->vt.width - s->vt.x) { + nr =3D s->vt.width - s->vt.x; if (!nr) { return; } } =20 - x1 =3D s->x; - x2 =3D s->x + nr; - len =3D s->width - x2; + x1 =3D s->vt.x; + x2 =3D s->vt.x + nr; + len =3D s->vt.width - x2; if (len) { - y =3D (s->y_base + s->y) % s->total_height; - c1 =3D &s->cells[y * s->width + x1]; - c2 =3D &s->cells[y * s->width + x2]; + y =3D (s->vt.y_base + s->vt.y) % s->vt.total_height; + c1 =3D &s->vt.cells[y * s->vt.width + x1]; + c2 =3D &s->vt.cells[y * s->vt.width + x2]; memmove(c1, c2, len * sizeof(*c1)); for (end =3D x1 + len; x1 < end; x1++) { - vc_update_xy(vc, x1, s->y); + vc_update_xy(vc, x1, s->vt.y); } } /* Clear the rest */ - for (; x1 < s->width; x1++) { - vc_clear_xy(vc, x1, s->y); + for (; x1 < s->vt.width; x1++) { + vc_clear_xy(vc, x1, s->vt.y); } } =20 @@ -749,28 +752,28 @@ static void vc_csi_at(struct VCChardev *vc, unsigned = int nr) if (!nr) { nr =3D 1; } - if (nr > s->width - s->x) { - nr =3D s->width - s->x; + if (nr > s->vt.width - s->vt.x) { + nr =3D s->vt.width - s->vt.x; if (!nr) { return; } } =20 - x1 =3D s->x + nr; - x2 =3D s->x; - len =3D s->width - x1; + x1 =3D s->vt.x + nr; + x2 =3D s->vt.x; + len =3D s->vt.width - x1; if (len) { - y =3D (s->y_base + s->y) % s->total_height; - c1 =3D &s->cells[y * s->width + x1]; - c2 =3D &s->cells[y * s->width + x2]; + y =3D (s->vt.y_base + s->vt.y) % s->vt.total_height; + c1 =3D &s->vt.cells[y * s->vt.width + x1]; + c2 =3D &s->vt.cells[y * s->vt.width + x2]; memmove(c1, c2, len * sizeof(*c1)); for (end =3D x1 + len; x1 < end; x1++) { - vc_update_xy(vc, x1, s->y); + vc_update_xy(vc, x1, s->vt.y); } } /* Insert blanks */ - for (x1 =3D s->x; x1 < s->x + nr; x1++) { - vc_clear_xy(vc, x1, s->y); + for (x1 =3D s->vt.x; x1 < s->vt.x + nr; x1++) { + vc_clear_xy(vc, x1, s->vt.y); } } =20 @@ -781,8 +784,8 @@ static void vc_save_cursor(VCChardev *vc) { QemuTextConsole *s =3D vc->console; =20 - vc->x_saved =3D s->x; - vc->y_saved =3D s->y; + vc->x_saved =3D s->vt.x; + vc->y_saved =3D s->vt.y; vc->t_attrib_saved =3D vc->t_attrib; } =20 @@ -794,8 +797,8 @@ static void vc_restore_cursor(VCChardev *vc) { QemuTextConsole *s =3D vc->console; =20 - s->x =3D vc->x_saved; - s->y =3D vc->y_saved; + s->vt.x =3D vc->x_saved; + s->vt.y =3D vc->y_saved; vc->t_attrib =3D vc->t_attrib_saved; } =20 @@ -828,21 +831,21 @@ static void vc_putchar(VCChardev *vc, int ch) vc->utf8_state =3D UTF8_ACCEPT; switch(ch) { case '\r': /* carriage return */ - s->x =3D 0; + s->vt.x =3D 0; break; case '\n': /* newline */ vc_put_lf(vc); break; case '\b': /* backspace */ - if (s->x > 0) - s->x--; + if (s->vt.x > 0) + s->vt.x--; break; case '\t': /* tabspace */ - if (s->x + (8 - (s->x % 8)) > s->width) { - s->x =3D 0; + if (s->vt.x + (8 - (s->vt.x % 8)) > s->vt.width) { + s->vt.x =3D 0; vc_put_lf(vc); } else { - s->x =3D s->x + (8 - (s->x % 8)); + s->vt.x =3D s->vt.x + (8 - (s->vt.x % 8)); } break; case '\a': /* alert aka. bell */ @@ -910,32 +913,32 @@ static void vc_putchar(VCChardev *vc, int ch) if (vc->esc_params[0] =3D=3D 0) { vc->esc_params[0] =3D 1; } - vc_set_cursor(vc, s->x, s->y - vc->esc_params[0]); + vc_set_cursor(vc, s->vt.x, s->vt.y - vc->esc_params[0]); break; case 'B': /* move cursor down */ if (vc->esc_params[0] =3D=3D 0) { vc->esc_params[0] =3D 1; } - vc_set_cursor(vc, s->x, s->y + vc->esc_params[0]); + vc_set_cursor(vc, s->vt.x, s->vt.y + vc->esc_params[0]); break; case 'C': /* move cursor right */ if (vc->esc_params[0] =3D=3D 0) { vc->esc_params[0] =3D 1; } - vc_set_cursor(vc, s->x + vc->esc_params[0], s->y); + vc_set_cursor(vc, s->vt.x + vc->esc_params[0], s->vt.y); break; case 'D': /* move cursor left */ if (vc->esc_params[0] =3D=3D 0) { vc->esc_params[0] =3D 1; } - vc_set_cursor(vc, s->x - vc->esc_params[0], s->y); + vc_set_cursor(vc, s->vt.x - vc->esc_params[0], s->vt.y); break; case 'G': /* move cursor to column */ - vc_set_cursor(vc, vc->esc_params[0] - 1, s->y); + vc_set_cursor(vc, vc->esc_params[0] - 1, s->vt.y); break; case 'f': case 'H': @@ -946,9 +949,9 @@ static void vc_putchar(VCChardev *vc, int ch) switch (vc->esc_params[0]) { case 0: /* clear to end of screen */ - for (y =3D s->y; y < s->height; y++) { - for (x =3D 0; x < s->width; x++) { - if (y =3D=3D s->y && x < s->x) { + for (y =3D s->vt.y; y < s->vt.height; y++) { + for (x =3D 0; x < s->vt.width; x++) { + if (y =3D=3D s->vt.y && x < s->vt.x) { continue; } vc_clear_xy(vc, x, y); @@ -957,9 +960,9 @@ static void vc_putchar(VCChardev *vc, int ch) break; case 1: /* clear from beginning of screen */ - for (y =3D 0; y <=3D s->y; y++) { - for (x =3D 0; x < s->width; x++) { - if (y =3D=3D s->y && x > s->x) { + for (y =3D 0; y <=3D s->vt.y; y++) { + for (x =3D 0; x < s->vt.width; x++) { + if (y =3D=3D s->vt.y && x > s->vt.x) { break; } vc_clear_xy(vc, x, y); @@ -968,8 +971,8 @@ static void vc_putchar(VCChardev *vc, int ch) break; case 2: /* clear entire screen */ - for (y =3D 0; y < s->height; y++) { - for (x =3D 0; x < s->width; x++) { + for (y =3D 0; y < s->vt.height; y++) { + for (x =3D 0; x < s->vt.width; x++) { vc_clear_xy(vc, x, y); } } @@ -980,20 +983,20 @@ static void vc_putchar(VCChardev *vc, int ch) switch (vc->esc_params[0]) { case 0: /* clear to eol */ - for(x =3D s->x; x < s->width; x++) { - vc_clear_xy(vc, x, s->y); + for(x =3D s->vt.x; x < s->vt.width; x++) { + vc_clear_xy(vc, x, s->vt.y); } break; case 1: /* clear from beginning of line */ - for (x =3D 0; x <=3D s->x && x < s->width; x++) { - vc_clear_xy(vc, x, s->y); + for (x =3D 0; x <=3D s->vt.x && x < s->vt.width; x++) { + vc_clear_xy(vc, x, s->vt.y); } break; case 2: /* clear entire line */ - for(x =3D 0; x < s->width; x++) { - vc_clear_xy(vc, x, s->y); + for(x =3D 0; x < s->vt.width; x++) { + vc_clear_xy(vc, x, s->vt.y); } break; } @@ -1013,7 +1016,7 @@ static void vc_putchar(VCChardev *vc, int ch) case 6: /* report cursor position */ response =3D g_strdup_printf("\033[%d;%dR", - s->y + 1, s->x + 1); + s->vt.y + 1, s->vt.x + 1); vc_respond_str(vc, response); break; } @@ -1066,19 +1069,19 @@ static int vc_chr_write(Chardev *chr, const uint8_t= *buf, int len) QemuTextConsole *s =3D drv->console; int i; =20 - s->update_x0 =3D s->width * FONT_WIDTH; - s->update_y0 =3D s->height * FONT_HEIGHT; - s->update_x1 =3D 0; - s->update_y1 =3D 0; + s->vt.update_x0 =3D s->vt.width * FONT_WIDTH; + s->vt.update_y0 =3D s->vt.height * FONT_HEIGHT; + s->vt.update_x1 =3D 0; + s->vt.update_y1 =3D 0; console_show_cursor(s, 0); for(i =3D 0; i < len; i++) { vc_putchar(drv, buf[i]); } console_show_cursor(s, 1); - if (s->update_x0 < s->update_x1) { - dpy_gfx_update(QEMU_CONSOLE(s), s->update_x0, s->update_y0, - s->update_x1 - s->update_x0, - s->update_y1 - s->update_y0); + if (s->vt.update_x0 < s->vt.update_x1) { + dpy_gfx_update(QEMU_CONSOLE(s), s->vt.update_x0, s->vt.update_y0, + s->vt.update_x1 - s->vt.update_x0, + s->vt.update_y1 - s->vt.update_y0); } return len; } @@ -1137,7 +1140,7 @@ qemu_text_console_init(Object *obj) QemuTextConsole *c =3D QEMU_TEXT_CONSOLE(obj); =20 fifo8_create(&c->out_fifo, 16); - c->total_height =3D DEFAULT_BACKSCROLL; + c->vt.total_height =3D DEFAULT_BACKSCROLL; QEMU_CONSOLE(c)->hw_ops =3D &text_console_ops; QEMU_CONSOLE(c)->hw =3D c; } @@ -1168,12 +1171,12 @@ static void vc_chr_set_echo(Chardev *chr, bool echo) { VCChardev *drv =3D VC_CHARDEV(chr); =20 - drv->console->echo =3D echo; + drv->console->vt.echo =3D echo; } =20 void qemu_text_console_update_size(QemuTextConsole *c) { - dpy_text_resize(QEMU_CONSOLE(c), c->width, c->height); + dpy_text_resize(QEMU_CONSOLE(c), c->vt.width, c->vt.height); } =20 static bool vc_chr_open(Chardev *chr, ChardevBackend *backend, Error **err= p) --=20 2.53.0