aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/dvtm/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cmd/dvtm/window.c')
-rw-r--r--sys/cmd/dvtm/window.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/sys/cmd/dvtm/window.c b/sys/cmd/dvtm/window.c
new file mode 100644
index 0000000..44690c9
--- /dev/null
+++ b/sys/cmd/dvtm/window.c
@@ -0,0 +1,42 @@
+#include <u.h>
+#include <libn.h>
+
+#include "buffer.h"
+
+typedef struct Rect Rect;
+typedef struct Window Window;
+
+/* origin upper left corner */
+struct Rect
+{
+ int r0, c0, rows, cols;
+};
+
+struct Window
+{
+ Buffer buffer[2], *buf;
+ Rect area; /* on screen */
+ Pen pen, spen; /* current and saved pen */
+ struct {
+ uint visible : 1;
+ int row, col; /* saved cursor row/colmn (zero based) */
+ int srow, scol; /* saved cursor row/colmn (zero based) */
+ } c;
+}
+
+/* functions */
+
+Window *
+makewindow(
+
+ t->pen = (Pen) {
+ .state = PenNormal,
+ .col = {-1, -1},
+ };
+ t->buffer = &t->buf[0];
+
+ if (!binit(&t->buf[0], rows, cols, size) ||
+ !binit(&t->buf[1], rows, cols, 0)) {
+ free(t);
+ return nil;
+ }