From 357d9ddc7ba6ffcee059b550de69328607b1ce37 Mon Sep 17 00:00:00 2001 From: Jiri Svoboda Date: Mon, 30 Sep 2024 20:39:04 +0200 Subject: [PATCH] The 'state' in vt100_state_t is unnecessary --- uspace/lib/vt/include/vt/vt100.h | 32 ++++++++++++++++---------------- uspace/lib/vt/src/vt100.c | 32 ++++++++++++++++---------------- uspace/srv/hid/output/ctl/serial.c | 32 ++++++++++++++++---------------- uspace/srv/hid/remcons/remcons.c | 2 +- uspace/srv/hid/remcons/remcons.h | 2 +- 5 files changed, 50 insertions(+), 50 deletions(-) diff --git a/uspace/lib/vt/include/vt/vt100.h b/uspace/lib/vt/include/vt/vt100.h index 17517aded..ae4f13d77 100644 --- a/uspace/lib/vt/include/vt/vt100.h +++ b/uspace/lib/vt/include/vt/vt100.h @@ -88,26 +88,26 @@ typedef struct { vt100_putuchar_t putuchar; vt100_control_puts_t control_puts; vt100_flush_t flush; -} vt100_state_t; +} vt100_t; extern sgr_color_index_t color_map[]; -extern vt100_state_t *vt100_state_create(void *, sysarg_t, sysarg_t, +extern vt100_t *vt100_create(void *, sysarg_t, sysarg_t, vt100_putuchar_t, vt100_control_puts_t, vt100_flush_t); -extern void vt100_state_destroy(vt100_state_t *); - -extern errno_t vt100_yield(vt100_state_t *); -extern errno_t vt100_claim(vt100_state_t *); -extern void vt100_get_dimensions(vt100_state_t *, sysarg_t *, sysarg_t *); - -extern void vt100_cls(vt100_state_t *); -extern void vt100_set_pos(vt100_state_t *, sysarg_t, sysarg_t); -extern void vt100_goto(vt100_state_t *, sysarg_t, sysarg_t); -extern void vt100_set_sgr(vt100_state_t *, char_attrs_t); -extern void vt100_set_attr(vt100_state_t *, char_attrs_t); -extern void vt100_cursor_visibility(vt100_state_t *, bool); -extern void vt100_putuchar(vt100_state_t *, char32_t); -extern void vt100_flush(vt100_state_t *); +extern void vt100_destroy(vt100_t *); + +extern errno_t vt100_yield(vt100_t *); +extern errno_t vt100_claim(vt100_t *); +extern void vt100_get_dimensions(vt100_t *, sysarg_t *, sysarg_t *); + +extern void vt100_cls(vt100_t *); +extern void vt100_set_pos(vt100_t *, sysarg_t, sysarg_t); +extern void vt100_goto(vt100_t *, sysarg_t, sysarg_t); +extern void vt100_set_sgr(vt100_t *, char_attrs_t); +extern void vt100_set_attr(vt100_t *, char_attrs_t); +extern void vt100_cursor_visibility(vt100_t *, bool); +extern void vt100_putuchar(vt100_t *, char32_t); +extern void vt100_flush(vt100_t *); #endif diff --git a/uspace/lib/vt/src/vt100.c b/uspace/lib/vt/src/vt100.c index d69eb00ac..2527eefe9 100644 --- a/uspace/lib/vt/src/vt100.c +++ b/uspace/lib/vt/src/vt100.c @@ -48,13 +48,13 @@ sgr_color_index_t color_map[] = { [COLOR_WHITE] = CI_WHITE }; -void vt100_cls(vt100_state_t *state) +void vt100_cls(vt100_t *state) { state->control_puts(state->arg, "\033[2J"); } /** ECMA-48 Set Graphics Rendition. */ -static void vt100_sgr(vt100_state_t *state, unsigned int mode) +static void vt100_sgr(vt100_t *state, unsigned int mode) { char control[MAX_CONTROL]; @@ -63,7 +63,7 @@ static void vt100_sgr(vt100_state_t *state, unsigned int mode) } /** Set Graphics Rendition with 5 arguments. */ -static void vt100_sgr5(vt100_state_t *state, unsigned a1, unsigned a2, +static void vt100_sgr5(vt100_t *state, unsigned a1, unsigned a2, unsigned a3, unsigned a4, unsigned a5) { char control[MAX_CONTROL]; @@ -73,7 +73,7 @@ static void vt100_sgr5(vt100_state_t *state, unsigned a1, unsigned a2, state->control_puts(state->arg, control); } -void vt100_set_pos(vt100_state_t *state, sysarg_t col, sysarg_t row) +void vt100_set_pos(vt100_t *state, sysarg_t col, sysarg_t row) { char control[MAX_CONTROL]; @@ -82,7 +82,7 @@ void vt100_set_pos(vt100_state_t *state, sysarg_t col, sysarg_t row) state->control_puts(state->arg, control); } -void vt100_set_sgr(vt100_state_t *state, char_attrs_t attrs) +void vt100_set_sgr(vt100_t *state, char_attrs_t attrs) { unsigned color; @@ -146,11 +146,11 @@ void vt100_set_sgr(vt100_state_t *state, char_attrs_t attrs) } } -vt100_state_t *vt100_state_create(void *arg, sysarg_t cols, sysarg_t rows, +vt100_t *vt100_create(void *arg, sysarg_t cols, sysarg_t rows, vt100_putuchar_t putuchar_fn, vt100_control_puts_t control_puts_fn, vt100_flush_t flush_fn) { - vt100_state_t *state = malloc(sizeof(vt100_state_t)); + vt100_t *state = malloc(sizeof(vt100_t)); if (state == NULL) return NULL; @@ -171,29 +171,29 @@ vt100_state_t *vt100_state_create(void *arg, sysarg_t cols, sysarg_t rows, return state; } -void vt100_state_destroy(vt100_state_t *state) +void vt100_destroy(vt100_t *state) { free(state); } -void vt100_get_dimensions(vt100_state_t *state, sysarg_t *cols, +void vt100_get_dimensions(vt100_t *state, sysarg_t *cols, sysarg_t *rows) { *cols = state->cols; *rows = state->rows; } -errno_t vt100_yield(vt100_state_t *state) +errno_t vt100_yield(vt100_t *state) { return EOK; } -errno_t vt100_claim(vt100_state_t *state) +errno_t vt100_claim(vt100_t *state) { return EOK; } -void vt100_goto(vt100_state_t *state, sysarg_t col, sysarg_t row) +void vt100_goto(vt100_t *state, sysarg_t col, sysarg_t row) { if ((col >= state->cols) || (row >= state->rows)) return; @@ -205,7 +205,7 @@ void vt100_goto(vt100_state_t *state, sysarg_t col, sysarg_t row) } } -void vt100_set_attr(vt100_state_t *state, char_attrs_t attrs) +void vt100_set_attr(vt100_t *state, char_attrs_t attrs) { if (!attrs_same(state->cur_attrs, attrs)) { vt100_set_sgr(state, attrs); @@ -213,7 +213,7 @@ void vt100_set_attr(vt100_state_t *state, char_attrs_t attrs) } } -void vt100_cursor_visibility(vt100_state_t *state, bool visible) +void vt100_cursor_visibility(vt100_t *state, bool visible) { if (visible) state->control_puts(state->arg, "\033[?25h"); @@ -221,7 +221,7 @@ void vt100_cursor_visibility(vt100_state_t *state, bool visible) state->control_puts(state->arg, "\033[?25l"); } -void vt100_putuchar(vt100_state_t *state, char32_t ch) +void vt100_putuchar(vt100_t *state, char32_t ch) { state->putuchar(state->arg, ch == 0 ? ' ' : ch); state->cur_col++; @@ -232,7 +232,7 @@ void vt100_putuchar(vt100_state_t *state, char32_t ch) } } -void vt100_flush(vt100_state_t *state) +void vt100_flush(vt100_t *state) { state->flush(state->arg); } diff --git a/uspace/srv/hid/output/ctl/serial.c b/uspace/srv/hid/output/ctl/serial.c index c93f4ec24..bf1b23bf9 100644 --- a/uspace/srv/hid/output/ctl/serial.c +++ b/uspace/srv/hid/output/ctl/serial.c @@ -52,7 +52,7 @@ * @param row Vertical screen position. * */ -static void draw_char(vt100_state_t *state, charfield_t *field, +static void draw_char(vt100_t *state, charfield_t *field, sysarg_t col, sysarg_t row) { vt100_goto(state, col, row); @@ -62,14 +62,14 @@ static void draw_char(vt100_state_t *state, charfield_t *field, static errno_t serial_yield(outdev_t *dev) { - vt100_state_t *state = (vt100_state_t *) dev->data; + vt100_t *state = (vt100_t *) dev->data; return vt100_yield(state); } static errno_t serial_claim(outdev_t *dev) { - vt100_state_t *state = (vt100_state_t *) dev->data; + vt100_t *state = (vt100_t *) dev->data; return vt100_claim(state); } @@ -77,7 +77,7 @@ static errno_t serial_claim(outdev_t *dev) static void serial_get_dimensions(outdev_t *dev, sysarg_t *cols, sysarg_t *rows) { - vt100_state_t *state = (vt100_state_t *) dev->data; + vt100_t *state = (vt100_t *) dev->data; vt100_get_dimensions(state, cols, rows); } @@ -91,7 +91,7 @@ static console_caps_t serial_get_caps(outdev_t *dev) static void serial_cursor_update(outdev_t *dev, sysarg_t prev_col, sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible) { - vt100_state_t *state = (vt100_state_t *) dev->data; + vt100_t *state = (vt100_t *) dev->data; vt100_goto(state, col, row); vt100_cursor_visibility(state, visible); @@ -99,7 +99,7 @@ static void serial_cursor_update(outdev_t *dev, sysarg_t prev_col, static void serial_char_update(outdev_t *dev, sysarg_t col, sysarg_t row) { - vt100_state_t *state = (vt100_state_t *) dev->data; + vt100_t *state = (vt100_t *) dev->data; charfield_t *field = chargrid_charfield_at(dev->backbuf, col, row); @@ -108,7 +108,7 @@ static void serial_char_update(outdev_t *dev, sysarg_t col, sysarg_t row) static void serial_flush(outdev_t *dev) { - vt100_state_t *state = (vt100_state_t *) dev->data; + vt100_t *state = (vt100_t *) dev->data; vt100_flush(state); } @@ -127,22 +127,22 @@ errno_t serial_init(vt100_putuchar_t putuchar_fn, vt100_control_puts_t control_puts_fn, vt100_flush_t flush_fn) { char_attrs_t attrs; - vt100_state_t *state = - vt100_state_create(NULL, SERIAL_COLS, SERIAL_ROWS, putuchar_fn, + vt100_t *vt100 = + vt100_create(NULL, SERIAL_COLS, SERIAL_ROWS, putuchar_fn, control_puts_fn, flush_fn); - if (state == NULL) + if (vt100 == NULL) return ENOMEM; - state->enable_rgb = true; + vt100->enable_rgb = true; - vt100_cursor_visibility(state, false); + vt100_cursor_visibility(vt100, false); attrs.type = CHAR_ATTR_STYLE; attrs.val.style = STYLE_NORMAL; - vt100_set_attr(state, attrs); - vt100_cls(state); + vt100_set_attr(vt100, attrs); + vt100_cls(vt100); - outdev_t *dev = outdev_register(&serial_ops, state); + outdev_t *dev = outdev_register(&serial_ops, vt100); if (dev == NULL) { - vt100_state_destroy(state); + vt100_destroy(vt100); return ENOMEM; } diff --git a/uspace/srv/hid/remcons/remcons.c b/uspace/srv/hid/remcons/remcons.c index 542489784..850fa11ab 100644 --- a/uspace/srv/hid/remcons/remcons.c +++ b/uspace/srv/hid/remcons/remcons.c @@ -567,7 +567,7 @@ static void remcons_new_conn(tcp_listener_t *lst, tcp_conn_t *conn) remcons->curs_visible = true; - remcons->vt = vt100_state_create((void *)remcons, 80, 25, + remcons->vt = vt100_create((void *)remcons, 80, 25, remcons_vt_putchar, remcons_vt_cputs, remcons_vt_flush); assert(remcons->vt != NULL); // XXX remcons->vt->enable_rgb = remcons->enable_rgb; diff --git a/uspace/srv/hid/remcons/remcons.h b/uspace/srv/hid/remcons/remcons.h index 23d64acf2..09de4e618 100644 --- a/uspace/srv/hid/remcons/remcons.h +++ b/uspace/srv/hid/remcons/remcons.h @@ -46,7 +46,7 @@ /** Remote console */ typedef struct { telnet_user_t *user; /**< telnet user */ - vt100_state_t *vt; /**< virtual terminal driver */ + vt100_t *vt; /**< virtual terminal driver */ bool enable_ctl; /**< enable escape control sequences */ bool enable_rgb; /**< enable RGB color setting */ sysarg_t ucols; /**< number of columns in user buffer */ -- 2.11.4.GIT