Subversion Repositories Kolibri OS

Rev

Rev 5995 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6003 leency 1
char char_width[255];
2
 
3
enum {
4
	COUNT_BUF_HEIGHT,
5
	DRAW_BUF
6
};
7
 
8
void Parcer(byte mode)
5980 leency 9
{
6003 leency 10
dword bufoff, buflen;
11
byte ch;
12
char line[4096]=0;
13
int srch_pos;
14
dword stroka=0;
15
dword stroka_y=5;
16
dword line_length=30;
17
dword line_start=io.buffer_data;
5995 leency 18
 
19
	buflen = strlen(io.buffer_data) + io.buffer_data;
20
	for (bufoff=io.buffer_data; bufoff
5980 leency 21
	{
22
		ch = ESBYTE[bufoff];
23
		line_length += char_width[ch];
24
		if (line_length>=list.w) || (ch==10) {
25
			srch_pos = bufoff;
26
			loop()
27
			{
28
				if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
29
				if (srch_pos == line_start) break; //no white space found in whole line
30
				srch_pos--;
31
			}
6003 leency 32
			if (mode==COUNT_BUF_HEIGHT) {
33
				line_start = bufoff;
34
				line_length = 30;
35
				list.count++;
36
			}
37
			if (mode==DRAW_BUF) {
38
				EBX = bufoff-line_start;
39
				strlcpy(#line, line_start, EBX);
40
				label.write_buf(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, #line);
41
				stroka_y += list.item_h;
42
				line_start = bufoff;
43
				line_length = 30;
44
			}
5980 leency 45
		}
46
	}
6003 leency 47
	if (mode==COUNT_BUF_HEIGHT) list.count++;
48
	if (mode==DRAW_BUF) label.write_buf(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, line_start);
49
}
50
 
51
void PreparePage()
52
{
53
	//get font chars width, need to increase performance
54
	int i;
55
	label.changeSIZE();
56
	for (i=0; i<256; i++) char_width[i] = label.symbol_size(i);
57
 
58
	//get font buffer height
59
	list.w = Form.cwidth-scroll.size_x-1;
60
	list.count=0;
61
	Parcer(COUNT_BUF_HEIGHT);
62
 
5980 leency 63
	//draw text in buffer
5987 leency 64
	list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, label.size.pt+1);
5980 leency 65
	if (list.count < list.visible) list.count = list.visible;
5987 leency 66
	label.size.height = list.count+1*list.item_h;
67
	label.raw_size = 0;
6003 leency 68
	Parcer(DRAW_BUF);
5980 leency 69
 
6003 leency 70
	//draw result
5987 leency 71
	label.apply_smooth();
5980 leency 72
	DrawPage();
73
}