/
consolestructs.h
126 lines (101 loc) · 3.48 KB
/
consolestructs.h
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* xbuf */
typedef unsigned int xint;
typedef unsigned long xlong;
struct structXBUF {
xint ns, ms, shift;
xlong dim, av;
char *b, **s, *free;
int *user;
};
typedef struct structXBUF *xbuf;
/* console */
struct structConsoleData {
int kind; /* console or pager */
int rows, cols; /* dimension in char */
int w, h; /* dimensions in pixel */
font f; /* font */
int fw, fh;
int top, right; /* borders */
rgb bg, fg, ufg; /* colours */
int fv, fc; /* first line and first char visible */
int r, c; /* cursor position */
int overwrite; /* overwrite mode */
int sel, mx0, my0, mx1, my1; /* selection */
xbuf lbuf; /* lines buffer */
int firstkey, numkeys; /* keys buffer */
char *kbuf;
int already; /* number of keys in buffer to be processed
before clipb. */
char *clp; /* data from the clipboard */
int pclp;
int lazyupdate, needredraw, newfv, newfc; /* updating and redrawing */
bitmap bm;
int input, cur_pos, max_pos, prompt_len; /* editing */
char chbrk, modbrk; /* hook for user's break */
void (*fbrk) ();
menuitem mcopy, mpaste, mpopcopy, mpoppaste;
};
typedef struct structConsoleData *ConsoleData;
#define CONSOLE 1
#define PAGER 2
#define DATAEDITOR 3
#define BM (p->bm)
#define ROWS (p->rows)
#define COLS (p->cols)
#define WIDTH (p->w)
#define HEIGHT (p->h)
#define BORDERX (p->right)
#define BORDERY (p->top)
#define FW (p->fw)
#define FH (p->fh)
#define FV (p->fv)
#define FC (p->fc)
#define NEWFV (p->newfv)
#define NEWFC (p->newfc)
#define NUMLINES (p->lbuf->ns)
#define LINE(i) (p->lbuf->s[i])
#define USER(i) (p->lbuf->user[i])
#define VLINE(i) ((strlen(LINE(i))>FC) ? &LINE(i)[FC] : "")
#define RLINE(i) (rect(0, BORDERY + (i)*FH, WIDTH, FH))
#define RMLINES(i,j) (rect(0, BORDERY + (i)*FH, WIDTH, (j-i+1)*FH))
#define cur_pos (p->cur_pos)
#define max_pos (p->max_pos)
#define prompt_len (p->prompt_len)
#define WRITELINE(i, j) writeline(p, i, j)
#define REDRAW drawconsole(c, getrect(c))
#define FBEGIN { \
ConsoleData p; \
p = getdata(c); \
{
#define FEND(result) } return result;}
#define FVOIDEND }}
#define FVOIDRETURN { return; }
#define FRETURN(result) {return result;}
#define RSHOW(r) {gbitblt(c, p->bm, topleft(r), r);}
ConsoleData newconsoledata(font f, int rows, int cols,
int bufbytes, int buflines,
rgb fg, rgb ufg, rgb bg, int kind);
void freeConsoleData(ConsoleData p);
void setfirstvisible(control c, int fv);
void setfirstcol(control c, int newcol);
void console_sbf(control c, int pos);
void console_mousedrag(control c, int button, point pt);
void console_mouserep(control c, int button, point pt);
void console_mousedown(control c, int button, point pt);
void consoleresize(console c, rect r);
void console_ctrlkeyin(control c, int key);
void console_normalkeyin(control c, int k);
font consolefn;
int fontsty, pointsize;
int consoler, consolec;
int pagerrow, pagercol;
rgb consolebg, consolefg, consoleuser, pagerhighlight;
#define DIMLBUF 64*1024 /* console buffer size in chars */
#define MLBUF 8*1024 /* console buffer size in lines */
#define SLBUF 512 /* console buffer shift in lines */
#define NKEYS 512 /* 8Kb paste buffer */
#define TABSIZE 8
xbuf newxbuf(xlong dim, xint ms, xint shift);
void xbufgrow(xbuf p, xlong dim, xint ms);
void xbufdel(xbuf p);
void xbufaddc(xbuf p, char c);