aboutsummaryrefslogtreecommitdiff
path: root/ui-terminal-vt100.c
diff options
context:
space:
mode:
authorRandy Palamar <randy@rnpnr.xyz>2024-05-21 10:23:25 -0600
committerRandy Palamar <randy@rnpnr.xyz>2024-05-21 20:21:46 -0600
commit7e85064ac77ea43e84d88eb910b0adb6f07d5d12 (patch)
tree60087cfc22d2e8c67b2d83a7202a8bbb2a5c1c1e /ui-terminal-vt100.c
parent486e8631ce9269d34c00c07038e04013640f8825 (diff)
downloadvis-7e85064ac77ea43e84d88eb910b0adb6f07d5d12.tar.gz
vis-7e85064ac77ea43e84d88eb910b0adb6f07d5d12.tar.xz
remove some ui pointer chasing
There only exists a single Ui so there is no need to force a pointer redirection for accessing it. The Ui member was moved down in vis-core.h to punt around an issue with the way lua checks for existing objects. It may show up again as I flatten more structs.
Diffstat (limited to 'ui-terminal-vt100.c')
-rw-r--r--ui-terminal-vt100.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/ui-terminal-vt100.c b/ui-terminal-vt100.c
index dffc235..a1c92f3 100644
--- a/ui-terminal-vt100.c
+++ b/ui-terminal-vt100.c
@@ -59,11 +59,6 @@
#define CELL_ATTR_ITALIC (1 << 4)
#define CELL_ATTR_DIM (1 << 5)
-typedef struct {
- Ui uiterm;
- Buffer buf;
-} UiVt100;
-
static inline bool cell_color_equal(CellColor c1, CellColor c2) {
if (c1.index != (uint8_t)-1 || c2.index != (uint8_t)-1)
return c1.index == c2.index;
@@ -97,7 +92,7 @@ static void cursor_visible(bool visible) {
}
static void ui_term_backend_blit(Ui *tui) {
- Buffer *buf = &((UiVt100*)tui)->buf;
+ Buffer *buf = tui->ctx;
buffer_clear(buf);
CellAttr attr = CELL_ATTR_NORMAL;
CellColor fg = CELL_COLOR_DEFAULT, bg = CELL_COLOR_DEFAULT;
@@ -199,18 +194,20 @@ static bool ui_term_backend_init(Ui *tui, char *term) {
return true;
}
-static Ui *ui_term_backend_new(void) {
- UiVt100 *vtui = calloc(1, sizeof *vtui);
- if (!vtui)
- return NULL;
- buffer_init(&vtui->buf);
- return (Ui*)vtui;
+static bool ui_backend_init(Ui *ui) {
+ Buffer *buf = calloc(1, sizeof(Buffer));
+ if (!buf)
+ return false;
+ buffer_init(buf);
+ ui->ctx = buf;
+ return true;
}
static void ui_term_backend_free(Ui *tui) {
- UiVt100 *vtui = (UiVt100*)tui;
+ Buffer *buf = tui->ctx;
ui_term_backend_suspend(tui);
- buffer_release(&vtui->buf);
+ buffer_release(buf);
+ free(buf);
}
static bool is_default_color(CellColor c) {