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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
typedef struct Box Box;
typedef struct Cimage Cimage;
typedef struct Column Column;
typedef struct Exec Exec;
typedef struct Line Line;
typedef struct Page Page;
typedef struct Row Row;
typedef struct Runestr Runestr;
typedef struct Text Text;
typedef struct Timer Timer;
typedef struct Url Url;
typedef struct Window Window;
struct Runestr
{
Rune *r;
int nr;
};
enum
{
Rowtag,
Columntag,
Tag,
Urltag,
Statustag,
Entry,
Textarea,
};
struct Text
{
Frame;
uint org;
uint q0;
uint q1;
int what;
Window *w;
Rectangle scrollr;
Rectangle lastsr;
Rectangle all;
Row *row;
Column *col;
Runestr rs;
};
uint textbacknl(Text*, uint, uint);
int textbswidth(Text*, Rune);
int textclickmatch(Text*, int, int, int, uint*);
void textclose(Text*);
void textdelete(Text*, uint, uint);
void textdoubleclick(Text*, uint*, uint*);
void textfill(Text*);
void textframescroll(Text*, int);
void textinit(Text *, Image *, Rectangle, Font *, Image **);
void textinsert(Text*, uint, Rune*, uint);
void textredraw(Text *, Rectangle, Font *, Image *);
int textresize(Text *, Image *, Rectangle);
void textscrdraw(Text*);
void textscroll(Text*, int);
void textselect(Text*);
int textselect2(Text *, uint *, uint *, Text **);
int textselect3(Text *, uint *, uint *);
void textset(Text *, Rune *, int);
void textsetorigin(Text*, uint, int);
void textsetselect(Text*, uint, uint);
void textshow(Text*, uint, uint, int);
void texttype(Text*, Rune);
void textmouse(Text *, Point, int);
struct Line
{
Rectangle r;
int state;
int hastext;
int hastable;
Box *boxes;
Box *lastbox;
Line *prev;
Line *next;
};
struct Box
{
Item *i;
Rectangle r;
void (*draw)(Box *, Page *, Image *);
void (*mouse)(Box *, Page *, int);
void (*key)(Box *, Page *, Rune);
Box *prev;
Box *next;
};
Box* boxalloc(Line *, Item *, Rectangle);
void boxinit(Box *);
struct Lay
{
Rectangle r;
int width;
int xwall;
Line *lines;
Line *lastline;
Font *font;
Ifloat *floats;
int laying;
};
void laypage(Page *p);
Lay* layitems(Item *, Rectangle, int);
void laydraw(Page *, Image *, Lay *);
void layfree(Lay *);
struct Cimage
{
Ref;
Image *i;
Memimage *mi;
Url *url;
Cimage *next;
};
struct Url
{
Ref; /* urls in window.url[] are not freed */
int id;
int method; /* HGet or HPost */
Runestr src; /* requested url */
Runestr act; /* actual url (redirection) */
Runestr post; /* only set if method==HPost */
Runestr ctype; /* content type */
};
Url* urlalloc(Runestr *, Runestr *, int);
void urlfree(Url *);
Url* urldup(Url *);
int urlopen(Url *);
struct Page
{
Url *url;
Runestr title;
Window *w;
Image *b;
Rectangle r;
Rectangle all;
Rectangle vscrollr;
Rectangle hscrollr;
Row *row;
Column *col;
Docinfo *doc;
Kidinfo *kidinfo;
Item *items;
Lay *lay;
Point pos;
int selecting;
Point top, bot;
Box *topbx, *botbx;
int aborting;
int changed;
int loading;
Rune *status;
Page *parent;
Page *child;
Page *next;
Cimage **cimage;
int ncimage;
struct{
long t;
Runestr rs;
}refresh;
};
void pageget(Page *, Runestr *, Runestr *, int, int);
void pageload(Page *, Url *, int);
void pageclose(Page *);
void pageredraw(Page *);
void pagerender(Page *);
void pagemouse(Page *, Point, int);
void pagetype(Page *, Rune, Point);
void pagescrldraw(Page *);
void pagescroll(Page *, int, int);
int pagescrollxy(Page *, int, int);
int pageabort(Page *);
void pagesnarf(Page *);
void pagesetrefresh(Page *);
int pagerefresh(Page *);
struct Window
{
Ref;
QLock;
Text tag;
Text url;
Page page;
Text status;
int owner;
int inpage;
Rectangle r;
Column *col;
struct{
Url **url;
int nurl;
int cid;
}history;
};
void wininit(Window *, Window *, Rectangle);
int winclean(Window *, int);
void winclose(Window *);
int winresize(Window *, Rectangle, int);
Text* wintext(Window *, Point);
void winlock(Window *, int);
void winunlock(Window *);
void winaddhist(Window *, Url *);
void wingohist(Window *, int);
void winsettag(Window *);
void winseturl(Window *);
void winsetstatus(Window *w, Rune *);
Text* wintype(Window *, Point, Rune);
Text* winmouse(Window *, Point, int);
void winmousebut(Window *);
void windebug(Window *);
struct Column
{
Rectangle r;
Text tag;
Row *row;
Window **w;
int nw;
int safe;
};
void colinit(Column*, Rectangle);
Window* coladd(Column*, Window*, Window*, int);
void colclose(Column*, Window*, int);
void colcloseall(Column*);
void colresize(Column*, Rectangle);
Text* colwhich(Column*, Point, Rune, int);
void coldragwin(Column*, Window*, int);
void colgrow(Column*, Window*, int);
int colclean(Column*);
void colsort(Column*);
void colmousebut(Column*);
struct Row
{
QLock;
Rectangle r;
Text tag;
Column **col;
int ncol;
};
void rowinit(Row*, Rectangle);
Column* rowadd(Row*, Column *c, int);
void rowclose(Row*, Column*, int);
Text* rowwhich(Row*, Point, Rune, int);
Column* rowwhichcol(Row*, Point);
void rowresize(Row*, Rectangle);
void rowdragcol(Row*, Column*, int but);
struct Exec
{
char *cmd;
int p[2]; /* p[1] is write to program; p[0] set to prog fd 0*/
int q[2]; /* q[0] is read from program; q[1] set to prog fd 1 */
Channel *sync; /* chan(ulong) */
};
struct Timer
{
int dt;
int cancel;
Channel *c; /* chan(int) */
Timer *next;
};
enum
{
Scrollsize = 12,
Scrollgap = 4,
Margin = 4,
Border = 2,
Space = 2,
Tabspace = 30,
Boxsize = 12,
WFont = FntR*NumSize+Tiny,
Panspeed = 4,
Maxtab = 8,
BUFSIZE = 1024*8,
RBUFSIZE = BUFSIZE/sizeof(Rune),
STACK = 64*1024,
};
enum
{
FALSE,
TRUE,
XXX,
};
enum
{
Light = 0xEEEEEE,
Dark = 0x666666,
Red = 0xBB0000,
Back = 0xCCCCCC,
};
Mouse *mouse;
Mousectl *mousectl;
Keyboardctl *keyboardctl;
Image *tagcols[NCOL];
Image *textcols[NCOL];
Image *but2col;
Image *but3col;
Image *button;
Image *colbutton;
Font *passfont;
Cursor boxcursor;
Row row;
Text *argtext;
Text *seltext;
Text *typetext;
Page *selpage;
Column *activecol;
char *webmountpt;
int plumbsendfd;
int webctlfd;
char *charset;
int procstderr;
enum
{
Kscrolloneup = KF|0x20,
Kscrollonedown = KF|0x21,
};
Channel *cplumb; /* chan(Plumbmsg*) */
Channel *cexit; /* chan(int) */
Channel *crefresh; /* chan(page *) */
|