Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
6003 leency 1
enum {
2
	COUNT_BUF_HEIGHT,
3
	DRAW_BUF
4
};
5
 
6
void Parcer(byte mode)
5980 leency 7
{
6003 leency 8
dword bufoff, buflen;
9
byte ch;
10
char line[4096]=0;
11
int srch_pos;
12
dword stroka_y=5;
13
dword line_length=30;
14
dword line_start=io.buffer_data;
5995 leency 15
 
16
	buflen = strlen(io.buffer_data) + io.buffer_data;
17
	for (bufoff=io.buffer_data; bufoff
5980 leency 18
	{
19
		ch = ESBYTE[bufoff];
7286 leency 20
		line_length += kfont_char_width[ch];
5980 leency 21
		if (line_length>=list.w) || (ch==10) {
22
			srch_pos = bufoff;
23
			loop()
24
			{
25
				if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
26
				if (srch_pos == line_start) break; //no white space found in whole line
27
				srch_pos--;
28
			}
6003 leency 29
			if (mode==COUNT_BUF_HEIGHT) {
30
				line_start = bufoff;
31
				line_length = 30;
32
				list.count++;
33
			}
34
			if (mode==DRAW_BUF) {
35
				EBX = bufoff-line_start;
36
				strlcpy(#line, line_start, EBX);
7462 leency 37
				kfont.WriteIntoBuffer(8,stroka_y,list.w,kfont.size.height, bg_color, text_color, kfont.size.pt, #line);
6003 leency 38
				stroka_y += list.item_h;
39
				line_start = bufoff;
40
				line_length = 30;
41
			}
5980 leency 42
		}
43
	}
6753 leency 44
	if (mode==COUNT_BUF_HEIGHT) list.count+=2;
7462 leency 45
	if (mode==DRAW_BUF) kfont.WriteIntoBuffer(8,stroka_y,list.w,kfont.size.height, bg_color, text_color, kfont.size.pt, line_start);
6003 leency 46
}
47
 
48
void PreparePage()
49
{
50
	list.w = Form.cwidth-scroll.size_x-1;
51
	list.count=0;
52
	Parcer(COUNT_BUF_HEIGHT);
53
 
5980 leency 54
	//draw text in buffer
6806 leency 55
	list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, kfont.size.pt+4);
5980 leency 56
	if (list.count < list.visible) list.count = list.visible;
6806 leency 57
	kfont.size.height = list.count+1*list.item_h;
58
	kfont.raw_size = 0;
6003 leency 59
	Parcer(DRAW_BUF);
5980 leency 60
 
6808 leency 61
	if (list.count > list.visible * 10) DrawPage();
6003 leency 62
	//draw result
6806 leency 63
	kfont.ApplySmooth();
5980 leency 64
	DrawPage();
65
}