diff options
author | June McEnroe <june@causal.agency> | 2019-08-10 15:47:59 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-08-10 15:47:59 -0400 |
commit | 6d7320a10ded22619ee49eb71e8380fd514b849b (patch) | |
tree | 40fa5e95e8c75e734cae9a33c10528a0aa68d845 /term.h | |
parent | Flip enumerator-constant order for sorting (diff) | |
download | stream-6d7320a10ded22619ee49eb71e8380fd514b849b.tar.gz stream-6d7320a10ded22619ee49eb71e8380fd514b849b.zip |
Rewrite terminal emulator
Diffstat (limited to '')
-rw-r--r-- | term.h (renamed from stream.h) | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/stream.h b/term.h index 4610647..03d9ac5 100644 --- a/stream.h +++ b/term.h @@ -21,6 +21,14 @@ typedef unsigned uint; +enum { + NUL, SOH, STX, ETX, EOT, ENQ, ACK, BEL, + BS, HT, NL, VT, NP, CR, SO, SI, + DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB, + CAN, EM, SUB, ESC, FS, GS, RS, US, + DEL = 0x7F, +}; + enum Attr { Bold = 1 << 0, Dim = 1 << 1, @@ -40,14 +48,34 @@ struct Cell { wchar_t ch; }; -struct Display { - bool cursor; +enum Mode { + Insert = 1 << 0, + Wrap = 1 << 1, + Cursor = 1 << 2, +}; + +enum { ParamCap = 16 }; + +struct Term { uint rows, cols; + char state; + struct { + bool q; + uint s[ParamCap]; + uint n, i; + } param; + enum Mode mode; + struct { + uint y, x; + } save; + struct { + uint top, bot; + } scroll; uint y, x; - const struct Cell *cells; + struct Style style; + struct Cell cells[]; }; -void termInit(uint rows, uint cols); -void termUpdate(wchar_t ch); -int termSnapshot(int fd); -struct Display termDisplay(void); +struct Term *termAlloc(uint rows, uint cols); +void termUpdate(struct Term *term, wchar_t ch); +int termSnapshot(struct Term *term, int fd); |