[PATCH 25/60] ui/console-vc: move vc_put_lf() to VT100 layer as vt100_put_lf()

Marc-André Lureau posted 60 patches 2 weeks, 6 days ago
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>, John Snow <jsnow@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Mauro Carvalho Chehab <mchehab+huawei@kernel.org>, Pierrick Bouvier <pierrick.bouvier@linaro.org>, Jan Kiszka <jan.kiszka@web.de>, Phil Dennis-Jordan <phil@philjordan.eu>, Richard Henderson <richard.henderson@linaro.org>, Helge Deller <deller@gmx.de>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Gerd Hoffmann <kraxel@redhat.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Samuel Tardieu <sam@rfc1149.net>, Igor Mitsyanko <i.mitsyanko@gmail.com>, "Hervé Poussineau" <hpoussin@reactos.org>, Aleksandar Rikalo <arikalo@gmail.com>, Laurent Vivier <laurent@vivier.eu>, Thomas Huth <th.huth+qemu@posteo.eu>, BALATON Zoltan <balaton@eik.bme.hu>, "Michael S. Tsirkin" <mst@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Dmitry Osipenko <dmitry.osipenko@collabora.com>, Dmitry Fleytman <dmitry.fleytman@gmail.com>, Stefano Stabellini <sstabellini@kernel.org>, Anthony PERARD <anthony@xenproject.org>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Alistair Francis <alistair@alistair23.me>, Alex Williamson <alex@shazbot.org>, "Cédric Le Goater" <clg@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Fabiano Rosas <farosas@suse.de>
[PATCH 25/60] ui/console-vc: move vc_put_lf() to VT100 layer as vt100_put_lf()
Posted by Marc-André Lureau 2 weeks, 6 days ago
Decouple the line-feed handling from VCChardev by operating on
QemuVT100 directly. The function no longer needs the chardev or
console pointers — callers pass &s->vt instead. This continues the
effort to make the VT100 terminal emulation self-contained.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/console-vc.c | 65 ++++++++++++++++++++++++++++-----------------------------
 1 file changed, 32 insertions(+), 33 deletions(-)

diff --git a/ui/console-vc.c b/ui/console-vc.c
index efb10c2f8f7..4ea9f88f55a 100644
--- a/ui/console-vc.c
+++ b/ui/console-vc.c
@@ -433,47 +433,46 @@ static void vt100_set_image(QemuVT100 *vt, pixman_image_t *image)
     vt->cells = cells;
 }
 
-static void vc_put_lf(VCChardev *vc)
+static void vt100_put_lf(QemuVT100 *vt)
 {
-    QemuTextConsole *s = vc->console;
     TextCell *c;
     int x, y1;
 
-    s->vt.y++;
-    if (s->vt.y >= s->vt.height) {
-        s->vt.y = s->vt.height - 1;
+    vt->y++;
+    if (vt->y >= vt->height) {
+        vt->y = vt->height - 1;
 
-        if (s->vt.y_displayed == s->vt.y_base) {
-            if (++s->vt.y_displayed == s->vt.total_height)
-                s->vt.y_displayed = 0;
+        if (vt->y_displayed == vt->y_base) {
+            if (++vt->y_displayed == vt->total_height)
+                vt->y_displayed = 0;
         }
-        if (++s->vt.y_base == s->vt.total_height)
-            s->vt.y_base = 0;
-        if (s->vt.backscroll_height < s->vt.total_height)
-            s->vt.backscroll_height++;
-        y1 = (s->vt.y_base + s->vt.height - 1) % s->vt.total_height;
-        c = &s->vt.cells[y1 * s->vt.width];
-        for(x = 0; x < s->vt.width; x++) {
+        if (++vt->y_base == vt->total_height)
+            vt->y_base = 0;
+        if (vt->backscroll_height < vt->total_height)
+            vt->backscroll_height++;
+        y1 = (vt->y_base + vt->height - 1) % vt->total_height;
+        c = &vt->cells[y1 * vt->width];
+        for(x = 0; x < vt->width; x++) {
             c->ch = ' ';
             c->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
             c++;
         }
-        if (s->vt.y_displayed == s->vt.y_base) {
-            s->vt.text_x[0] = 0;
-            s->vt.text_y[0] = 0;
-            s->vt.text_x[1] = s->vt.width - 1;
-            s->vt.text_y[1] = s->vt.height - 1;
-
-            image_bitblt(s->vt.image, 0, FONT_HEIGHT, 0, 0,
-                         s->vt.width * FONT_WIDTH,
-                         (s->vt.height - 1) * FONT_HEIGHT);
-            image_fill_rect(s->vt.image, 0, (s->vt.height - 1) * FONT_HEIGHT,
-                            s->vt.width * FONT_WIDTH, FONT_HEIGHT,
+        if (vt->y_displayed == vt->y_base) {
+            vt->text_x[0] = 0;
+            vt->text_y[0] = 0;
+            vt->text_x[1] = vt->width - 1;
+            vt->text_y[1] = vt->height - 1;
+
+            image_bitblt(vt->image, 0, FONT_HEIGHT, 0, 0,
+                         vt->width * FONT_WIDTH,
+                         (vt->height - 1) * FONT_HEIGHT);
+            image_fill_rect(vt->image, 0, (vt->height - 1) * FONT_HEIGHT,
+                            vt->width * FONT_WIDTH, FONT_HEIGHT,
                             color_table_rgb[0][TEXT_ATTRIBUTES_DEFAULT.bgcol]);
-            s->vt.update_x0 = 0;
-            s->vt.update_y0 = 0;
-            s->vt.update_x1 = s->vt.width * FONT_WIDTH;
-            s->vt.update_y1 = s->vt.height * FONT_HEIGHT;
+            vt->update_x0 = 0;
+            vt->update_y0 = 0;
+            vt->update_x1 = vt->width * FONT_WIDTH;
+            vt->update_y1 = vt->height * FONT_HEIGHT;
         }
     }
 }
@@ -664,7 +663,7 @@ static void vc_put_one(VCChardev *vc, int ch)
     if (s->vt.x >= s->vt.width) {
         /* line wrap */
         s->vt.x = 0;
-        vc_put_lf(vc);
+        vt100_put_lf(&s->vt);
     }
     y1 = (s->vt.y_base + s->vt.y) % s->vt.total_height;
     c = &s->vt.cells[y1 * s->vt.width + s->vt.x];
@@ -842,7 +841,7 @@ static void vc_putchar(VCChardev *vc, int ch)
             s->vt.x = 0;
             break;
         case '\n':  /* newline */
-            vc_put_lf(vc);
+            vt100_put_lf(&s->vt);
             break;
         case '\b':  /* backspace */
             if (s->vt.x > 0)
@@ -851,7 +850,7 @@ static void vc_putchar(VCChardev *vc, int ch)
         case '\t':  /* tabspace */
             if (s->vt.x + (8 - (s->vt.x % 8)) > s->vt.width) {
                 s->vt.x = 0;
-                vc_put_lf(vc);
+                vt100_put_lf(&s->vt);
             } else {
                 s->vt.x = s->vt.x + (8 - (s->vt.x % 8));
             }

-- 
2.53.0


Re: [PATCH 25/60] ui/console-vc: move vc_put_lf() to VT100 layer as vt100_put_lf()
Posted by Philippe Mathieu-Daudé 5 days, 15 hours ago
On 17/3/26 09:50, Marc-André Lureau wrote:
> Decouple the line-feed handling from VCChardev by operating on
> QemuVT100 directly. The function no longer needs the chardev or
> console pointers — callers pass &s->vt instead. This continues the
> effort to make the VT100 terminal emulation self-contained.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   ui/console-vc.c | 65 ++++++++++++++++++++++++++++-----------------------------
>   1 file changed, 32 insertions(+), 33 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>