aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/dvtm/window.c
blob: 44690c9050f7bbbedb29bdb3a308b5d09e61bc13 (plain)
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
#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;
	}