From 6d7320a10ded22619ee49eb71e8380fd514b849b Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Sat, 10 Aug 2019 15:47:59 -0400 Subject: Rewrite terminal emulator --- view.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'view.c') diff --git a/view.c b/view.c index a5861c4..7a40123 100644 --- a/view.c +++ b/view.c @@ -27,7 +27,7 @@ #include #include -#include "stream.h" +#include "term.h" #ifndef A_ITALIC #define A_ITALIC A_UNDERLINE @@ -86,10 +86,10 @@ static attr_t styleAttr(struct Style style) { return attr; } -static void render(WINDOW *win, struct Display term) { - for (uint y = 0; y < term.rows; ++y) { - for (uint x = 0; x < term.cols; ++x) { - struct Cell cell = term.cells[term.cols * y + x]; +static void render(WINDOW *win, const struct Term *term) { + for (uint y = 0; y < term->rows; ++y) { + for (uint x = 0; x < term->cols; ++x) { + struct Cell cell = term->cells[term->cols * y + x]; if (!cell.ch) continue; wattr_set( win, @@ -100,9 +100,9 @@ static void render(WINDOW *win, struct Display term) { mvwaddnwstr(win, y, x, &cell.ch, 1); } } - curs_set(term.cursor); - leaveok(win, !term.cursor); - wmove(win, term.y, term.x); + curs_set(!!(term->mode & Cursor)); + leaveok(win, !(term->mode & Cursor)); + wmove(win, term->y, term->x); } int main(void) { @@ -111,7 +111,7 @@ int main(void) { // TODO: Read info from file. const char *path = "example.sock"; - termInit(24, 80); + struct Term *term = termAlloc(24, 80); int client = socket(PF_LOCAL, SOCK_STREAM, 0); if (client < 0) err(EX_OSERR, "socket"); @@ -134,11 +134,11 @@ int main(void) { wchar_t ch; int n = mbtowc(&ch, &buf[pos], len - pos); if (n <= 0) break; - termUpdate(ch); + termUpdate(term, ch); pos += n; } - render(win, termDisplay()); + render(win, term); wrefresh(win); } } -- cgit 1.4.1