Subversion Repositories Kolibri OS

Rev

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

Rev 2811 Rev 2818
Line 7... Line 7...
7
int i;
7
int i;
8
 
8
 
Line 9... Line 9...
9
char download_path[]="/rd/1/.download";
9
char download_path[]="/rd/1/.download";
10
char search_path[]="http://nigma.ru/index.php?s=";
10
char search_path[]="http://nigma.ru/index.php?s=";
11
char version[]=" Text-based Browser 0.94b";
11
char version[]=" Text-based Browser 0.94c";
Line 12... Line 12...
12
 
12
 
13
 
13
 
14
struct TWebBrowser {
14
struct TWebBrowser {
Line 23... Line 23...
23
};
23
};
24
 
24
 
Line 25... Line 25...
25
TWebBrowser WB1;
25
TWebBrowser WB1;
Line 26... Line 26...
26
 
26
 
-
 
27
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text,
Line 27... Line 28...
27
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, link, ignor_text, li_tab, body_present;
28
	link, ignor_text, li_tab, first_line_drawed;
28
 
29
 
29
 
30
 
Line 292... Line 293...
292
 
293
 
293
 
294
 
294
void TWebBrowser::ParseHTML(dword bword, fsize){
295
void TWebBrowser::ParseHTML(dword bword, fsize){
295
	word bukva[1];
296
	word bukva[1];
296
	int j;
297
	int j, perenos_num;
Line 297... Line 298...
297
	byte ignor_param = 0;
298
	byte ignor_param = 0;
298
	char temp[768];
299
	char temp[768];
Line 299... Line 300...
299
	
300
	
300
	stroka = -lines.first;
301
	stroka = -lines.first;
Line 301... Line 302...
301
	stolbec = 0;
302
	stolbec = 0;
302
	
303
	
303
	for (j = 400; j < blink + 1; j++;) DeleteButton(j);
304
	for (j = 400; j < blink + 1; j++;) DeleteButton(j);
304
	blink = 400;
305
	blink = 400;
305
 
306
 
306
	b_text = i_text = u_text = s_text = pre_text = blq_text = body_present =
307
	b_text = i_text = u_text = s_text = pre_text = blq_text = first_line_drawed =
307
	li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
308
	li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
308
	link_color = 0x0000FF;
-
 
309
	bg_color = 0xFFFFFF;
309
	link_color = 0x0000FF;
310
	line = '';
-
 
311
	strcpy(#page_links,"|");
310
	bg_color = 0xFFFFFF;
312
	strcpy(#header,#version);
-
 
313
	if (!strcmp(#URL + strlen(#URL) - 4, ".txt"))
311
	line = '';
-
 
312
	strcpy(#page_links,"|");
-
 
313
	strcpy(#header,#version);
-
 
314
 
314
	{
315
	if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
315
		DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
316
	if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
316
		pre_text = 1; //çà÷¸òíîå îòîáðàæåíèå òåêñòà 
317
	
317
	}
318
	debug("Start parsing");
318
	if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
319
	
-
 
320
	for ( ; buf+fsize > bword; bword++;) {//ESBYTE[bword]
319
	for (bword = buf; buf + fsize > bword; bword++;) {
321
	  bukva = ESBYTE[bword];
320
	  bukva = ESBYTE[bword];
322
	  switch (bukva) {
321
	  switch (bukva) {
323
		case 0x0a:
322
		case 0x0a:
324
			if (pre_text)
323
			IF(pre_text == 1) {
325
			{
324
				bukva = '';
326
				bukva = '';
325
				temp = '';
327
				temp = '';
326
				goto NEXT_MARK;
328
				goto NEXT_MARK;
327
			}
329
			}
328
		case '\9':
330
		case '\9':
329
			if (pre_text == 1) //èíà÷å èä¸ì íà 0x0d	
331
			if (pre_text) //èíà÷å èä¸ì íà 0x0d	
Line 342... Line 344...
342
			if (ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè , äåðçêî
344
			if (ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè , äåðçêî
343
			{
345
			{
344
				bword++;
346
				bword++;
345
				if (ESBYTE[bword] == '-') {
347
				if (ESBYTE[bword] == '-') {
346
					HH_: do {
348
					HH_:
347
						bword++;
349
					do
-
 
350
					{
-
 
351
						bword++;
348
						IF(bword >= buf + fsize) break 1;
352
						if (bword >= buf + fsize) break 1;
349
					} while (ESBYTE[bword] <>'-');
353
					}
-
 
354
					while (ESBYTE[bword] <>'-');
350
					bword++;
355
					
-
 
356
					bword++;
351
					if (ESBYTE[bword] <>'-') goto HH_;
357
					if (ESBYTE[bword] <>'-') goto HH_;
352
				}
358
				}
353
			}
359
			}
354
			while (ESBYTE[bword] <>'>') && (bword < buf + fsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
360
			while (ESBYTE[bword] <>'>') && (bword < buf + fsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
355
			{
361
			{
Line 418... Line 424...
418
			strcat(#line,#tag); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò
424
			strcat(#line,#tag); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò
419
			break;
425
			break;
420
		default:
426
		default:
421
			DEFAULT_MARK:
427
			DEFAULT_MARK:
422
			IF(ignor_text) break;
428
			if (ignor_text) break;
423
			IF(!pre_text) && (bukva == ' ') && (!strcmp(#line + strlen(#line) - 1, " ")) continue;
429
			if (!pre_text) && (bukva == ' ') && (line[strlen(#line)-1]==' ') break;
424
			//
430
			//
425
			if (stolbec + strlen(#line) >lines.column_max)
431
			if (stolbec + strlen(#line) > lines.column_max)
426
			{
432
			{
427
				strcpy(#temp, #line + find_symbol(#line, ' ')); //ïåðåíîñ ïî ñëîâàì
433
				perenos_num = find_symbol(#line, ' ');
-
 
434
				strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
428
				line[find_symbol(#line, ' ')] = 0x00;
435
				line[perenos_num] = 0x00;
429
			NEXT_MARK:
436
			NEXT_MARK:
430
				IF(stroka - 1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
437
				if (stroka >= lines.visible) && (lines.first <>0) break 1; //óõîäèì...
431
				WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //âûâîä ñòðîêè
438
				WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //âûâîä ñòðîêè
432
				TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
439
				TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
433
				strcpy(#line, #temp);
440
				strcpy(#line, #temp);
434
			}
441
			}
435
			if (!pre_text) && (bukva == ' ') && (!stolbec) && (!line) CONTINUE;
442
			if (!pre_text) && (bukva == ' ') && (!stolbec) && (!line) break;
436
			strcat(#line, #bukva);
443
			strcat(#line, #bukva);
437
	  }
444
	  }
438
	}
445
	}
439
	if (strcmp(#URL + strlen(#URL) - 4, ".txt")<>0) && (!body_present)
446
 
440
		DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó åñëè êàêîé-òî ðàõèò íå ñîçäàë òåã áîäè
-
 
441
 
-
 
Line 442... Line 447...
442
	if (lines.visible * 10 + 25 <= height)
447
	if (lines.visible * 10 + 25 <= height)
443
		DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color);
448
		DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color);
444
	if (stroka * 10 + 15 <= height)
449
	if (stroka * 10 + 15 <= height)
445
		DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
450
		DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
Line 451... Line 456...
451
		lines.first=anchor_line_num;
456
		lines.first=anchor_line_num;
452
		ParseHTML(buf, filesize);
457
		ParseHTML(buf, filesize);
453
	}
458
	}
454
 
459
	
Line -... Line 460...
-
 
460
	debug("End parsing");
455
	DrawScroller(); //ðèñóåì ñêðîëë
461
	DrawScroller(); //ðèñóåì ñêðîëë
456
}
462
}
Line 457... Line 463...
457
 
463
 
Line 539... Line 545...
539
	
545
	
Line 540... Line 546...
540
	//âûâîä íà ýêðàí
546
	//âûâîä íà ýêðàí
541
	if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor)
547
	if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor)
542
	{
548
	{
-
 
549
		if (stroka==0) && (stolbec==0)
-
 
550
		{
-
 
551
			DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
-
 
552
			first_line_drawed=1;
-
 
553
		}
543
		WriteText(stolbec * 6 + left1, top1, 0x80, text_colors[text_color_index], #line, 0); //ìîæåò òóò ðèñîâàòü áåëóþ ñòðîêó?
554
		WriteText(stolbec * 6 + left1, top1, 0x80, text_colors[text_color_index], #line, 0); //ìîæåò òóò ðèñîâàòü áåëóþ ñòðîêó?
-
 
555
		//text_out stdcall (#line, -1, 16, text_colors[text_color_index], stolbec * 6 + left1, top1);
544
		IF (b_text)	{ $add ebx, 1<<16   $int 0x40 }
556
		IF (b_text)	{ $add ebx, 1<<16   $int 0x40 }
545
		IF (i_text) Skew(stolbec * 6 + left1, top1, strlen(#line)+1*6, 10); //íàêëîííûé òåêñò
557
		IF (i_text) Skew(stolbec * 6 + left1, top1, strlen(#line)+1*6, 10); //íàêëîííûé òåêñò
546
		IF (s_text) DrawBar(stolbec * 6 + left1, top1 + 4, strlen(#line) * 6, 1, text_colors[text_color_index]); //çà÷¸ðêíóòûé
558
		IF (s_text) DrawBar(stolbec * 6 + left1, top1 + 4, strlen(#line) * 6, 1, text_colors[text_color_index]); //çà÷¸ðêíóòûé
547
		IF (u_text) DrawBar(stolbec * 6 + left1, top1 + 8, strlen(#line) * 6, 1, text_colors[text_color_index]); //ïîä÷¸ðêíóòûé
559
		IF (u_text) DrawBar(stolbec * 6 + left1, top1 + 8, strlen(#line) * 6, 1, text_colors[text_color_index]); //ïîä÷¸ðêíóòûé
548
		IF (link) {
560
		IF (link) {
Line 583... Line 595...
583
			GetNextParam();
595
			GetNextParam();
584
			GOTO BODY_MARK;
596
			GOTO BODY_MARK;
585
		}
597
		}
586
		
598
		
Line 587... Line -...
587
		body_present = 1; //åñëè êàëè÷ íå ñîçäàë òåã áîäè íóæíî èçâðàùàòüñÿ
-
 
588
 
-
 
589
		if (rez) DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
-
 
590
		return;
599
		return;
591
	}
600
	}
592
	//////////////////////////
601
	//////////////////////////
593
	if (!chTag("a"))
602
	if (!chTag("a"))
594
	{
603
	{
Line 792... Line 801...
792
 
801
 
Line 793... Line 802...
793
 
802
 
794
void TextGoDown(int left1, top1, width1)
803
void TextGoDown(int left1, top1, width1)
-
 
804
{
-
 
805
	if (!stroka) && (!stolbec) && (!first_line_drawed)
-
 
806
	{
-
 
807
		DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
-
 
808
		first_line_drawed=1;
795
{
809
	}
796
	stroka++;
810
	stroka++;
797
	IF(blq_text == 1) stolbec = 8;
811
	if (blq_text) stolbec = 8;
798
	ELSE stolbec = 0;
812
	ELSE stolbec = 0;
799
	IF(li_text == 1) stolbec = li_tab * 5;
813
	if (li_text) stolbec = li_tab * 5;
800
	IF(stroka >= 0) && (stroka - 2 < lines.visible)  && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
814
	IF(stroka >= 0) && (stroka - 2 < lines.visible)  && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
Line 801... Line 815...
801
}
815
}
Line 812... Line 826...
812
	scroll1.start_x=Form.width-28; //left + width - 15
826
	scroll1.start_x=Form.width-28; //left + width - 15
813
	scroll1.size_y=WB1.height;
827
	scroll1.size_y=WB1.height;
814
 
828
 
Line 815... Line 829...
815
	scrollbar_v_draw(#scroll1);
829
	scrollbar_v_draw(#scroll1);
816
 
-
 
817
	DefineButton(scroll1.start_x+1, scroll1.start_y+1, 16, 16, ID1+BT_HIDE, 0xE4DFE1);
-
 
818
	DefineButton(scroll1.start_x+1, scroll1.start_y+scroll1.size_y-18, 16, 16, ID2+BT_HIDE, 0xE4DFE1);
-
 
819
}
830
}
820
>
831
>