#include #include #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; }