summary refs log tree commit diff
path: root/term.h
diff options
context:
space:
mode:
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);