From 2674e91561efab3333fe5b5dd98d19716cab7080 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Mon, 5 Aug 2019 17:43:11 -0400 Subject: Add termDisplay --- stream.h | 20 ++++++++++++++++++++ term.c | 21 ++++++++++----------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/stream.h b/stream.h index 56889c2..0bb7507 100644 --- a/stream.h +++ b/stream.h @@ -14,10 +14,30 @@ * along with this program. If not, see . */ +#include #include +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + typedef unsigned uint; +struct Style { + bool bold, italic, underline, reverse; + int bg, fg; +}; + +struct Cell { + struct Style style; + wchar_t ch; +}; + +struct Display { + uint rows, cols; + uint y, x; + const struct Cell *cells; +}; + void termInit(uint rows, uint cols); void termUpdate(wchar_t ch); int termSnapshot(int fd); +struct Display termDisplay(void); diff --git a/term.c b/term.c index 97a3ee1..5d7a918 100644 --- a/term.c +++ b/term.c @@ -25,8 +25,6 @@ #include "stream.h" -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - enum { NUL, SOH, STX, ETX, EOT, ENQ, ACK, BEL, BS, HT, NL, VT, NP, CR, SO, SI, @@ -35,17 +33,8 @@ enum { DEL = 0x7F, }; -struct Style { - bool bold, italic, underline, reverse; - int bg, fg; -}; static const struct Style Default = { .bg = -1, .fg = -1 }; -struct Cell { - struct Style style; - wchar_t ch; -}; - static uint rows, cols; static uint y, x; @@ -470,3 +459,13 @@ fail: fclose(file); return -1; } + +struct Display termDisplay(void) { + return (struct Display) { + .rows = rows, + .cols = cols, + .y = y, + .x = x, + .cells = cells, + }; +} -- cgit 1.4.1