summaryrefslogtreecommitdiff
path: root/win.h
blob: bf2f913a39ac827dea45e82834e57272ecacaa1d (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
43
44
45
46
47
#define rectx rect.x
#define recty rect.y
#define rectw rect.w
#define recth rect.h

typedef struct w W;

#define TagInit \
	"Look \n" \
	"Get \n" \
	"New\n" \
	"|fmt\n"

enum {
	TabWidth = 8,       /* tabulation width */
	MaxWidth = 500,     /* maximum number of characters on a line */
	MaxHeight = 500,    /* maximum number of lines */
	MaxWins = 6,        /* maximum number of windows */
	TagRatio = 3,       /* fraction of the screen for the tag */
};

struct w {
	unsigned l[MaxHeight]; /* line start offsets */
	int nl;                /* current number of lines */
	unsigned rev;          /* buffer revision used for line offsets */
	unsigned cu;           /* cursor offset */
	EBuf *eb;              /* underlying buffer object */
	GRect rect;            /* rectangle on the screen */
	int dirty: 1;          /* force redraw */
};

enum CursorLoc { CTop, CMid, CBot };

void win_init(struct gui *g);
W *win_new(void);
W *win_kill(W *);
unsigned win_at(W *w, int x, int y);
W *win_which(int x, int y);
W *win_edge(W *, int dir);
void win_move(W *, int x, int y);
void win_resize_frame(int w, int h);
void win_redraw_frame(W *focus, int insert);
void win_scroll(W *, int);
void win_show_cursor(W *, enum CursorLoc);
W *win_tag_toggle(W *);
W *win_text(W *);
void win_update(W *);