Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
6043 leency 1
 
2
{
3
	list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, Form.cheight-TOOLBAR_H, label.size.pt+2);
6053 leency 4
	strcpy(#title, history.current()+strrchr(history.current(),'/'));
5
	//get font chars width, need to increase performance
6043 leency 6
	get_label_symbols_size();
6053 leency 7
	ChangeCharset(charsets[encoding], "CP866", io.buffer_data);
8
	if (strstri(io.buffer_data, "
9
		debugln("no  found");
6043 leency 10
		DrawProgress(STEP_2_COUNT_PAGE_HEIGHT);     ParceTxt(false);   //get page height to calculate buffer size
6053 leency 11
		DrawProgress(STEP_3_DRAW_PAGE_INTO_BUFFER); ParceTxt(true);    //draw text in buffer
12
	} else {
13
		debugln(" tag found");
6043 leency 14
		DrawProgress(STEP_2_COUNT_PAGE_HEIGHT);     ParceHtml(false);  //get page height to calculate buffer size
6053 leency 15
		DrawProgress(STEP_3_DRAW_PAGE_INTO_BUFFER); ParceHtml(true);   //draw text in buffer
16
	}
17
	strcat(#title, " - Aelia");
18
	DrawTitle(#title);
19
	DrawProgress(STEP_4_SMOOTH_FONT);           label.apply_smooth();
20
	DrawProgress(STEP_5_STOP);                  DrawPage();
21
}
6043 leency 22
23
 
24
{
25
byte ch, zeroch=0;
26
dword bufoff, buflen, line_start, srch_pos;
27
int stroka_y=5, line_length=0;
28
29
 
30
	buflen = strlen(io.buffer_data) + io.buffer_data;
31
	for (bufoff=io.buffer_data; bufoff
32
	{
33
		ch = ESBYTE[bufoff];
34
		line_length += char_width[ch];
35
		if (line_length>=list.w-30) || (ch==10) {
36
			srch_pos = bufoff;
37
			loop()
38
			{
39
				if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
40
				if (srch_pos == line_start) break; //no white space found in whole line
41
				srch_pos--;
42
			}
43
			if (draw==true) {
44
				ESBYTE[bufoff] >< zeroch; //set line end
45
				WriteTextIntoBuf(8, stroka_y, 0x000000, line_start);
6053 leency 46
				ESBYTE[bufoff] >< zeroch; //restore line
6043 leency 47
			}
48
			stroka_y += list.item_h;
49
			line_start = bufoff;
50
			line_length = 0;
51
		}
52
	}
53
	if (draw==false) {
54
		list.count = stroka_y/list.item_h+2;
55
		if (list.count < list.visible) list.count = list.visible;
56
		label.size.height = list.count+1*list.item_h;
57
		label.raw_size = 0;
58
	}
59
	if (draw==true) WriteTextIntoBuf(8, stroka_y, 0x000000, line_start);
6053 leency 60
}
6043 leency 61
62
 
63
 
64
=                                                        =
65
=                        HTML                            =
66
=                                                        =
67
========================================================*/
68
69
 
6053 leency 70
6043 leency 71
 
72
	dword start;
73
	dword end;
74
	dword len;
75
};
76
77
 
78
	bool b, u, i, s;
79
	bool h1, h2, h3, h4, h5, h6;
80
	bool a;
81
	bool pre;
82
	bool ignore;
6053 leency 83
	dword color;
84
} style;
6043 leency 85
86
 
6053 leency 87
	dword start;
88
	int x, y;
89
};
90
91
 
6043 leency 92
	dword start;
93
	dword name;
94
	dword param[10];
95
	dword value[10];
96
	void parce();
97
	int nameis();
6053 leency 98
};
6043 leency 99
100
 
101
{
102
	dword o = name = start;
6053 leency 103
	while (ESBYTE[o]!=' ') && (ESBYTE[o]) o++; //searching for a space after tag name
104
	ESBYTE[o] = '\0';
105
	strlwr(name);
106
}
6043 leency 107
108
 
6053 leency 109
{
6043 leency 110
	if (strcmp(_in_tag_name, name)==0) return true;
6053 leency 111
	return false;
112
}
6043 leency 113
114
 
6053 leency 115
#define HTML_PADDING_Y 5;
116
6043 leency 117
 
6053 leency 118
 
6043 leency 119
{
120
int stroka_x = HTML_PADDING_X;
6053 leency 121
int stroka_y = HTML_PADDING_Y;
122
dword line_break;
123
byte ch, zeroch;
124
_DOM DOM;
6043 leency 125
_text text;
126
_tag tag;
127
dword DOM_pos;
128
129
 
130
	debugln("creating DOM");
6053 leency 131
	DOM.len = strlen(io.buffer_data);
6043 leency 132
	DOM.start = malloc(DOM.len);
133
	DOM.end = DOM.start + DOM.len;
134
	strlcpy(DOM.start, io.buffer_data, DOM.len);
135
136
 
137
	debugln("starting DOM parce...");
6053 leency 138
	text.start = DOM_pos;
6043 leency 139
	for (DOM_pos=DOM.start; DOM_pos
140
	{
141
		if (ESBYTE[DOM_pos]==0x0D) || (ESBYTE[DOM_pos]==0x0A) ESBYTE[DOM_pos]=' ';
6053 leency 142
		ch = ESBYTE[DOM_pos];
6043 leency 143
		//debugch(ch);
6053 leency 144
		if (ch=='<') {
6043 leency 145
			ESBYTE[DOM_pos] = '\0';
6053 leency 146
			tag.start = DOM_pos + 1;
6043 leency 147
			if (style.ignore) continue;
6053 leency 148
			if (tag.nameis("title")) {
149
				strcpy(#title, text.start);
150
				continue;
151
			}
152
			while (get_label_len(text.start) + stroka_x + 30 > list.w)
153
			{
154
				//debugln("long line cut");
155
				zeroch = 0;
156
				for (line_break=tag.start-1; line_break>text.start; line_break--;)
157
				{
158
					ESBYTE[line_break] >< zeroch; //set line end
159
					if (get_label_len(text.start) + stroka_x + 30 <= list.w) break;
160
					ESBYTE[line_break] >< zeroch; //restore line
161
				}
162
				if (draw==true) {
163
					if (style.a) label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
164
					WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
165
				}
166
				ESBYTE[line_break] >< zeroch; //restore line
167
				text.start = line_break;
168
				stroka_x = HTML_PADDING_X;
169
				stroka_y += list.item_h;
170
			}
171
			if (draw==true) {
172
				if (style.a) label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
173
				WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
174
			}
175
			stroka_x += get_label_len(text.start);
176
		}
6043 leency 177
		if (ch=='>') {
178
			ESBYTE[DOM_pos] = '\0';
6053 leency 179
			text.start = DOM_pos + 1;
6043 leency 180
			tag.parce();
181
			if (tag.nameis("br")) || (tag.nameis("p")) || (tag.nameis("div")) || (tag.nameis("h1")) || (tag.nameis("h2")) {
6053 leency 182
				stroka_y+= list.item_h;
183
				stroka_x = HTML_PADDING_X;
184
				continue;
185
			}
186
			if (tag.nameis("script")) || (tag.nameis("style")) style.ignore = true;
187
			if (tag.nameis("/script")) || (tag.nameis("/style")) style.ignore = false;
188
			if (tag.nameis("a"))  { style.a = true;  style.color=0x0000FF; }
189
			if (tag.nameis("/a")) { style.a = false; style.color=0x000000; }
190
		}
6043 leency 191
	}
192
	if (draw==false) {
6053 leency 193
		list.count = stroka_y/list.item_h+2;
194
		if (list.count < list.visible) list.count = list.visible;
195
		label.size.height = list.count+1*list.item_h;
196
		label.raw_size = 0;
197
	}
198
	free(DOM.start);
6043 leency 199
}
200