Subversion Repositories Kolibri OS

Rev

Rev 7274 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7274 Rev 8996
Line 6... Line 6...
6
*/
6
*/
7
:int DrawTextViewArea(int x,y,w,h, dword buf_start, bg_col, text_col)
7
:int DrawTextViewArea(int x,y,w,h, dword buf_start, bg_col, text_col)
8
{
8
{
9
	dword write_start;
9
	dword write_start;
10
	dword buf_end;
10
	dword buf_end;
11
	int line_h = 15;
11
	#define LINE_H 17
12
	int label_length_max;
12
	int label_length_max;
13
	int write_length;
13
	int write_length;
14
	bool end_found;
14
	bool end_found;
Line 15... Line 15...
15
 
15
 
16
	write_start = buf_start;
16
	write_start = buf_start;
17
	buf_end = strlen(buf_start) + buf_start;
17
	buf_end = strlen(buf_start) + buf_start;
Line 18... Line 18...
18
	label_length_max  = w / 8; // 8 big font char width
18
	label_length_max  = w / 8; // 8 big font char width
19
 
19
 
20
	loop() 
20
	loop() 
21
	{
21
	{
22
		if (bg_col!=-1) DrawBar(x, y, w+1, line_h, bg_col);
22
		if (bg_col!=-1) DrawBar(x, y, w+1, LINE_H, bg_col);
23
		end_found = false;
23
		end_found = false;
24
		write_length = strchr(write_start, '\n') - write_start; //search normal line break
24
		write_length = strchr(write_start, '\n') - write_start +1; //search normal line break
25
		if (write_length > label_length_max) || (write_length<=0) //check its position: exceeds maximum line length or not found
25
		if (write_length > label_length_max) || (write_length<=0) //check its position: exceeds maximum line length or not found
26
		{ 
26
		{ 
27
			if (buf_end - write_start < label_length_max) //check does current line the last
27
			if (buf_end - write_start < label_length_max) //check does current line the last
Line 44... Line 44...
44
		WriteText(x, y, 0x10, text_col, write_start);
44
		WriteText(x, y, 0x10, text_col, write_start);
45
		// if (editpos >= write_start-buf_start) && (editpos <= write_start-buf_start + write_length) {
45
		// if (editpos >= write_start-buf_start) && (editpos <= write_start-buf_start + write_length) {
46
		// 	WriteTextB(-write_start+buf_start+editpos * 8 + x - 5 +1, y, 0x90, 0xFF0000, "|");
46
		// 	WriteTextB(-write_start+buf_start+editpos * 8 + x - 5 +1, y, 0x90, 0xFF0000, "|");
47
		// }
47
		// }
48
		write_start += write_length + 1;
48
		write_start += write_length + 1;
49
		y += line_h;
49
		y += LINE_H;
50
		if (write_start >= buf_end) break;
50
		if (write_start >= buf_end) break;
51
	}
51
	}
52
	if (bg_col!=-1) DrawBar(x,y,w+1,h-y+line_h-4,bg_col);
52
	if (bg_col!=-1) DrawBar(x,y,w+1,h-y+LINE_H-4,bg_col);
53
	return y+line_h;
53
	return y+LINE_H;
54
}
54
}