1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
}
|