Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

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