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.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/sys/cmd/dvtm/window.c b/sys/cmd/dvtm/window.c
index 44690c9..fec3997 100644
--- a/sys/cmd/dvtm/window.c
+++ b/sys/cmd/dvtm/window.c
@@ -1,15 +1,13 @@
#include <u.h>
#include <libn.h>
-#include "buffer.h"
+#include "term.h"
typedef struct Rect Rect;
-typedef struct Window Window;
-/* origin upper left corner */
struct Rect
{
- int r0, c0, rows, cols;
+ int top, left, rows, cols;
};
struct Window
@@ -17,26 +15,30 @@ 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;
-}
+ uint curvis : 1;
+ uint damage : 1;
+};
/* functions */
Window *
-makewindow(
+makewindow(Window *root, Rect area, int history)
+{
+ Window *w;
+ w = calloc(1, sizeof(*w));
+ if (!w)
+ panicf("out of memory");
- t->pen = (Pen) {
+ w->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);
+ 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;
+}