aboutsummaryrefslogtreecommitdiff
path: root/terminal.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-06-15 20:22:44 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-06-15 20:22:44 +0000
commit2a4c08b94104a31a0944f4b0df6729029c1b55ba (patch)
treead1abe33fb9841d6571d16831223b2890812bc3b /terminal.h
parentTrack cell foreground and background colors (diff)
wip: vt parsing: initial csi/osc dispatching
Diffstat (limited to 'terminal.h')
-rw-r--r--terminal.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/terminal.h b/terminal.h
new file mode 100644
index 00000000..08e97824
--- /dev/null
+++ b/terminal.h
@@ -0,0 +1,70 @@
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stddef.h>
+
+struct cell {
+ char c[5];
+ uint32_t foreground;
+ uint32_t background;
+ bool dirty;
+};
+
+struct grid {
+ int cols;
+ int rows;
+ int cell_width;
+ int cell_height;
+
+ int cursor;
+ struct cell *cells;
+
+ uint32_t foreground;
+ uint32_t background;
+
+ bool dirty;
+ bool all_dirty;
+};
+
+struct vt {
+ int state; /* enum state */
+ struct {
+ struct {
+ unsigned value;
+ struct {
+ unsigned value[16];
+ size_t idx;
+ } sub;
+ } v[16];
+ size_t idx;
+ } params;
+ struct {
+ uint8_t data[2];
+ size_t idx;
+ } intermediates;
+ struct {
+ uint8_t data[1024];
+ size_t idx;
+ } osc;
+ struct {
+ uint8_t data[4];
+ size_t idx;
+ size_t left;
+ } utf8;
+ bool bold;
+ bool dim;
+ bool italic;
+ bool underline;
+ bool strikethrough;
+ bool blink;
+ bool conceal;
+ bool reverse;
+ uint32_t foreground;
+ uint32_t background;
+};
+
+struct terminal {
+ struct vt vt;
+ struct grid grid;
+};