Subversion Repositories Kolibri OS

Rev

Rev 4504 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4504 Rev 4508
Line 1... Line -...
1
#include "..\lib\draw_buf.h"
-
 
2
#include "..\lib\list_box.h"
-
 
3
#include "..\lib\cursor.h"
-
 
4
#include "..\TWB\links.h"
1
#include "..\TWB\links.h"
Line 5... Line 2...
5
 
2
 
Line 6... Line 3...
6
int	downloader_id;
3
int	downloader_id;
Line 23... Line 20...
23
struct TWebBrowser {
20
struct TWebBrowser {
24
	llist list; //need #include "..\lib\list_box.h"
21
	llist list; //need #include "..\lib\list_box.h"
25
	DrawBufer DrawBuf;
22
	DrawBufer DrawBuf;
26
	void GetNewUrl();
23
	void GetNewUrl();
27
	void ReadHtml();
24
	void ReadHtml();
28
	void ShowPage();
-
 
29
	void ParseHTML();
25
	void ParseHTML();
30
	void WhatTextStyle();
26
	void WhatTextStyle();
31
	void DrawPage();
27
	void DrawPage();
32
	void DrawScroller();
28
	void DrawScroller();
33
	void TextGoDown();
29
	void TextGoDown();
Line 173... Line 169...
173
	if (encoding==_UTF) utf8rutodos(buf);
169
	if (encoding==_UTF) utf8rutodos(buf);
174
	if (encoding==_KOI) koitodos(buf);
170
	if (encoding==_KOI) koitodos(buf);
175
}
171
}
Line 176... Line -...
176
 
-
 
177
 
-
 
178
void TWebBrowser::ShowPage()
-
 
179
{
-
 
180
	address_box.size = address_box.pos = strlen(#editURL);
-
 
181
	address_box.offset=0;
-
 
182
	edit_box_draw stdcall(#address_box);
-
 
183
	PageLinks.Clear();
-
 
184
 
-
 
185
	if (!filesize)
-
 
186
	{
-
 
187
		DrawBar(list.x, list.y, list.w+scroll_wv.size_x+1, list.h, 0xFFFFFF); //fill all
-
 
188
		if (GetProcessSlot(downloader_id)<>0) WriteText(list.x + 10, list.y + 18, 0x80, 0, "Loading...");
-
 
189
		else
-
 
190
		{
-
 
191
			WriteText(list.x + 10, list.y + 18, 0x80, 0, "Page not found. May be, URL contains some errors.");
-
 
192
			if (!strncmp(#URL,"http:",5)) WriteText(list.x + 10, list.y + 32, 0x80, 0, "Or Internet unavilable for your configuration.");
-
 
193
		}
-
 
194
		//return;
-
 
195
	}
-
 
196
	else
-
 
197
		ParseHTML(buf);
-
 
198
 
-
 
199
	if (!header) strcpy(#header, #version);
-
 
200
	if (!strcmp(#version, #header)) DrawTitle(#header);
-
 
201
}
-
 
202
 
-
 
203
 
172
 
204
 
173
 
205
void TWebBrowser::ParseHTML(dword bword){
174
void TWebBrowser::ParseHTML(dword bufpos){
206
	word bukva[2];
175
	word bukva[2];
207
	int j, perenos_num;
176
	int j, perenos_num;
-
 
177
	byte ignor_param;
Line 208... Line 178...
208
	byte ignor_param;
178
	char temp[768];
209
	char temp[768];
179
	dword bufstart = bufpos;
210
	
180
	
211
	b_text = i_text = u_text = s_text = blq_text = 
181
	b_text = i_text = u_text = s_text = blq_text = 
Line 228... Line 198...
228
		pre_text=0;
198
		pre_text=0;
229
		if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
199
		if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
230
		if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
200
		if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
231
	}
201
	}
Line 232... Line 202...
232
	
202
	
233
	for ( ; buf+filesize > bword; bword++;)
203
	for ( ; bufstart+filesize > bufpos; bufpos++;)
234
	{
204
	{
235
		bukva = ESBYTE[bword];
205
		bukva = ESBYTE[bufpos];
236
		if (ignor_text) && (bukva!='<') continue;
206
		if (ignor_text) && (bukva!='<') continue;
237
		if (condition_text_active) && (condition_text_val != condition_href) && (bukva!='<') continue;
207
		if (condition_text_active) && (condition_text_val != condition_href) && (bukva!='<') continue;
238
		switch (bukva)
208
		switch (bukva)
239
		{
209
		{
Line 254... Line 224...
254
			}
224
			}
255
			goto DEFAULT_MARK;		
225
			goto DEFAULT_MARK;		
256
		case '=': //quoted printable
226
		case '=': //quoted printable
257
			if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
227
			if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
Line 258... Line 228...
258
 
228
 
259
			temp[0] = ESBYTE[bword+1];
229
			temp[0] = ESBYTE[bufpos+1];
260
			temp[1] = ESBYTE[bword+2];
230
			temp[1] = ESBYTE[bufpos+2];
261
			temp[2] = '\0';
231
			temp[2] = '\0';
262
			if (bukva = Hex2Symb(#temp))
232
			if (bukva = Hex2Symb(#temp))
263
			{
233
			{
264
				bword+=2;
234
				bufpos+=2;
265
				goto DEFAULT_MARK;
235
				goto DEFAULT_MARK;
266
			}
236
			}
Line 267... Line 237...
267
			break;
237
			break;
268
			
238
			
269
		case '&': //  and so on
239
		case '&': //  and so on
270
			bword++;
240
			bufpos++;
271
			tag=0;
241
			tag=0;
272
			for (j=0; (ESBYTE[bword]<>';') && (j<7);   j++, bword++;)
242
			for (j=0; (ESBYTE[bufpos]<>';') && (j<7);   j++, bufpos++;)
273
			{
243
			{
274
				bukva = ESBYTE[bword];
244
				bukva = ESBYTE[bufpos];
275
				chrcat(#tag, bukva);
245
				chrcat(#tag, bukva);
276
			}
246
			}
277
			if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK;
247
			if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK;
278
			break;
248
			break;
279
		case '<':
249
		case '<':
280
			bword++; //ïðîìîòàåì ñèìâîë <
250
			bufpos++; //ïðîìîòàåì ñèìâîë <
281
			tag = parametr = tagparam = ignor_param = NULL;
251
			tag = parametr = tagparam = ignor_param = NULL;
282
			if (ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè , äåðçêî
252
			if (ESBYTE[bufpos] == '!') //ôèëüòðàöèÿ âíóòðè , äåðçêî
283
			{
253
			{
284
				bword++;
254
				bufpos++;
285
				if (ESBYTE[bword] == '-')
255
				if (ESBYTE[bufpos] == '-')
286
				{
256
				{
287
				HH_:
257
				HH_:
288
					do
258
					do
289
					{
259
					{
290
						bword++;
260
						bufpos++;
291
						if (buf + filesize <= bword) break 2;
261
						if (bufstart + filesize <= bufpos) break 2;
Line 292... Line 262...
292
					}
262
					}
293
					while (ESBYTE[bword] <>'-');
263
					while (ESBYTE[bufpos] <>'-');
294
					
264
					
295
					bword++;
265
					bufpos++;
296
					if (ESBYTE[bword] <>'-') goto HH_;
266
					if (ESBYTE[bufpos] <>'-') goto HH_;
297
				}
267
				}
298
			}
268
			}
299
			while (ESBYTE[bword] !='>') && (bword < buf + filesize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
269
			while (ESBYTE[bufpos] !='>') && (bufpos < bufstart + filesize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
300
			{
270
			{
301
				bukva = ESBYTE[bword];
271
				bukva = ESBYTE[bufpos];
302
				if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
272
				if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
303
				if (!ignor_param) && (bukva <>' ')
273
				if (!ignor_param) && (bukva <>' ')
304
				{
274
				{
305
					if (strlen(#tag)
275
					if (strlen(#tag)
306
				}
276
				}
307
				else
277
				else
308
				{
278
				{
309
					ignor_param = true;
279
					ignor_param = true;
310
					if (!ignor_text) && (strlen(#tagparam)+1
280
					if (!ignor_text) && (strlen(#tagparam)+1
311
				}
281
				}
312
				bword++;
282
				bufpos++;
Line 313... Line 283...
313
			}
283
			}
Line 374... Line 344...
374
	if (list.first == 0) list.count = stroka;
344
	if (list.first == 0) list.count = stroka;
375
	if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
345
	if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
376
	{
346
	{
377
		anchor=NULL;
347
		anchor=NULL;
378
		list.first=anchor_line_num;
348
		list.first=anchor_line_num;
379
		ParseHTML(buf);
349
		ParseHTML(bufstart);
380
	}
350
	}
381
	DrawScroller();
351
	DrawScroller();
382
}
352
}
Line 647... Line 617...
647
	scroll_wv.cur_area = list.visible;
617
	scroll_wv.cur_area = list.visible;
648
	scroll_wv.position = list.first;
618
	scroll_wv.position = list.first;
Line 649... Line 619...
649
 
619
 
650
	scroll_wv.all_redraw=1;
620
	scroll_wv.all_redraw=1;
-
 
621
	scroll_wv.start_x = list.x + list.w;
651
	scroll_wv.start_x = list.x + list.w;
622
	scroll_wv.start_y = list.y;
Line 652... Line 623...
652
	scroll_wv.size_y=list.h;
623
	scroll_wv.size_y=list.h;
653
 
624