[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/52] ui/vc: replace variable with static text attributes default
From: |
marcandre . lureau |
Subject: |
[PULL 13/52] ui/vc: replace variable with static text attributes default |
Date: |
Mon, 4 Sep 2023 15:52:10 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20230830093843.3531473-14-marcandre.lureau@redhat.com>
---
ui/console.c | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index 5c8e3ad1df..d1855f3fcf 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -52,6 +52,11 @@ typedef struct TextAttributes {
uint8_t unvisible:1;
} TextAttributes;
+#define TEXT_ATTRIBUTES_DEFAULT ((TextAttributes) { \
+ .fgcol = QEMU_COLOR_WHITE, \
+ .bgcol = QEMU_COLOR_BLACK \
+})
+
typedef struct TextCell {
uint8_t ch;
TextAttributes t_attrib;
@@ -104,7 +109,6 @@ struct QemuConsole {
int x_saved, y_saved;
int y_displayed;
int y_base;
- TextAttributes t_attrib_default; /* default text attributes */
TextAttributes t_attrib; /* currently active text attributes */
TextCell *cells;
int text_x[2], text_y[2], cursor_invalidate;
@@ -413,7 +417,7 @@ static void text_console_resize(QemuConsole *s)
}
for(x = w1; x < s->width; x++) {
c->ch = ' ';
- c->t_attrib = s->t_attrib_default;
+ c->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
c++;
}
}
@@ -486,7 +490,7 @@ static void console_show_cursor(QemuConsole *s, int show)
if (y < s->height) {
c = &s->cells[y1 * s->width + x];
if (show && cursor_visible_phase) {
- TextAttributes t_attrib = s->t_attrib_default;
+ TextAttributes t_attrib = TEXT_ATTRIBUTES_DEFAULT;
t_attrib.invers = !(t_attrib.invers); /* invert fg and bg */
vga_putcharxy(s, x, y, c->ch, &t_attrib);
} else {
@@ -577,7 +581,7 @@ static void console_put_lf(QemuConsole *s)
c = &s->cells[y1 * s->width];
for(x = 0; x < s->width; x++) {
c->ch = ' ';
- c->t_attrib = s->t_attrib_default;
+ c->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
c++;
}
if (s->y_displayed == s->y_base) {
@@ -591,7 +595,7 @@ static void console_put_lf(QemuConsole *s)
(s->height - 1) * FONT_HEIGHT);
vga_fill_rect(s, 0, (s->height - 1) * FONT_HEIGHT,
s->width * FONT_WIDTH, FONT_HEIGHT,
- color_table_rgb[0][s->t_attrib_default.bgcol]);
+ color_table_rgb[0][TEXT_ATTRIBUTES_DEFAULT.bgcol]);
s->update_x0 = 0;
s->update_y0 = 0;
s->update_x1 = s->width * FONT_WIDTH;
@@ -611,7 +615,7 @@ static void console_handle_escape(QemuConsole *s)
for (i=0; i<s->nb_esc_params; i++) {
switch (s->esc_params[i]) {
case 0: /* reset all console attributes to default */
- s->t_attrib = s->t_attrib_default;
+ s->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
break;
case 1:
s->t_attrib.bold = 1;
@@ -705,7 +709,7 @@ static void console_clear_xy(QemuConsole *s, int x, int y)
}
TextCell *c = &s->cells[y1 * s->width + x];
c->ch = ' ';
- c->t_attrib = s->t_attrib_default;
+ c->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
update_xy(s, x, y);
}
@@ -2419,16 +2423,8 @@ static void text_console_do_init(Chardev *chr)
s->hw_ops = &text_console_ops;
s->hw = s;
- /* Set text attribute defaults */
- s->t_attrib_default.bold = 0;
- s->t_attrib_default.uline = 0;
- s->t_attrib_default.blink = 0;
- s->t_attrib_default.invers = 0;
- s->t_attrib_default.unvisible = 0;
- s->t_attrib_default.fgcol = QEMU_COLOR_WHITE;
- s->t_attrib_default.bgcol = QEMU_COLOR_BLACK;
/* set current text attributes to default */
- s->t_attrib = s->t_attrib_default;
+ s->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
text_console_resize(s);
if (chr->label) {
@@ -2438,7 +2434,7 @@ static void text_console_do_init(Chardev *chr)
msg = g_strdup_printf("%s console\r\n", chr->label);
qemu_chr_write(chr, (uint8_t *)msg, strlen(msg), true);
g_free(msg);
- s->t_attrib = s->t_attrib_default;
+ s->t_attrib = TEXT_ATTRIBUTES_DEFAULT;
}
qemu_chr_be_event(chr, CHR_EVENT_OPENED);
--
2.41.0
- [PULL 04/52] ui/vc: replace vc_chr_write() with generic qemu_chr_write(), (continued)
- [PULL 04/52] ui/vc: replace vc_chr_write() with generic qemu_chr_write(), marcandre . lureau, 2023/09/04
- [PULL 05/52] ui/vc: drop have_text, marcandre . lureau, 2023/09/04
- [PULL 06/52] ui/console: console_select() regardless of have_gfx, marcandre . lureau, 2023/09/04
- [PULL 07/52] ui/console: call dpy_gfx_update() regardless of have_gfx, marcandre . lureau, 2023/09/04
- [PULL 08/52] ui/console: drop have_gfx, marcandre . lureau, 2023/09/04
- [PULL 09/52] ui/console: get the DisplayState from new_console(), marcandre . lureau, 2023/09/04
- [PULL 10/52] ui/console: new_console() cannot fail, marcandre . lureau, 2023/09/04
- [PULL 11/52] ui/vc: VC always has a DisplayState now, marcandre . lureau, 2023/09/04
- [PULL 12/52] ui/vc: move VCChardev declaration at the top, marcandre . lureau, 2023/09/04
- [PULL 14/52] ui/vc: fold text_update_xy(), marcandre . lureau, 2023/09/04
- [PULL 13/52] ui/vc: replace variable with static text attributes default,
marcandre . lureau <=
- [PULL 15/52] ui/vc: pass VCCharDev to VC-specific functions, marcandre . lureau, 2023/09/04
- [PULL 16/52] ui/vc: move VCCharDev specific fields out of QemuConsole, marcandre . lureau, 2023/09/04
- [PULL 17/52] ui/console: use OBJECT_DEFINE_TYPE for QemuConsole, marcandre . lureau, 2023/09/04
- [PULL 18/52] ui/console: change new_console() to use object initialization, marcandre . lureau, 2023/09/04
- [PULL 20/52] ui/console: instantiate a specific console type, marcandre . lureau, 2023/09/04
- [PULL 19/52] ui/console: introduce different console objects, marcandre . lureau, 2023/09/04
- [PULL 21/52] ui/console: register the console from qemu_console_init(), marcandre . lureau, 2023/09/04
- [PULL 23/52] ui/console: specialize console_lookup_unused(), marcandre . lureau, 2023/09/04
- [PULL 26/52] ui/vc: move cursor_timer initialization to QemuTextConsole class, marcandre . lureau, 2023/09/04
- [PULL 27/52] ui/console: free more QemuConsole resources, marcandre . lureau, 2023/09/04