aboutsummaryrefslogtreecommitdiff
path: root/sys/libterm/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/libterm/window.c')
-rw-r--r--sys/libterm/window.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/sys/libterm/window.c b/sys/libterm/window.c
new file mode 100644
index 0000000..fec3997
--- /dev/null
+++ b/sys/libterm/window.c
@@ -0,0 +1,44 @@
+#include <u.h>
+#include <libn.h>
+
+#include "term.h"
+
+typedef struct Rect Rect;
+
+struct Rect
+{
+ int top, left, rows, cols;
+};
+
+struct Window
+{
+ Buffer buffer[2], *buf;
+ Rect area; /* on screen */
+ Pen pen, spen; /* current and saved pen */
+ uint curvis : 1;
+ uint damage : 1;
+};
+
+/* functions */
+
+Window *
+makewindow(Window *root, Rect area, int history)
+{
+ Window *w;
+ w = calloc(1, sizeof(*w));
+ if (!w)
+ panicf("out of memory");
+
+ w->pen = (Pen) {
+ .state = PenNormal,
+ .col = {-1, -1},
+ };
+
+ if (!binit(w->buffer+0, area.rows, area.cols, history) ||
+ !binit(w->buffer+1, area.rows, area.cols, 0)) {
+ free(w);
+ return nil;
+ }
+ w->buf = w->buffer;
+ return w;
+}