Subversion Repositories Kolibri OS

Rev

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

Rev 3061 Rev 3062
Line 6... Line 6...
6
	blink;
6
	blink;
7
 
7
 
Line 8... Line 8...
8
char download_path[]="/rd/1/.download";
8
char download_path[]="/rd/1/.download";
9
char search_path[]="http://nigma.ru/index.php?s=";
9
char search_path[]="http://nigma.ru/index.php?s=";
10
char version[]=" Text-based Browser 0.97.7";
10
char version[]=" Text-based Browser 0.98";
Line 11... Line 11...
11
 
11
 
12
 
12
 
13
struct TWebBrowser {
13
struct TWebBrowser {
Line 117... Line 117...
117
		case 001:
117
		case 001:
118
			if (!pre_text) pre_text=2;
118
			if (!pre_text) pre_text=2;
119
				else pre_text=0;
119
				else pre_text=0;
120
			break;
120
			break;
121
		case 005: //truetype
121
		case 002: //free img cache
-
 
122
			FreeImgCache();
-
 
123
			break;			
-
 
124
		case 005: //truetype
122
			if (use_truetype == 2) 
125
			if (use_truetype == 2) 
123
			{
126
			{
124
				RunProgram("@notify", "Library does not exists /rd/1/lib/truetype.obj"w);
127
				RunProgram("@notify", "Library does not exists /rd/1/lib/truetype.obj"w);
125
				return;
128
				return;
126
			}
129
			}
Line 423... Line 426...
423
					bword++;
426
					bword++;
424
					if (ESBYTE[bword] <>'-') goto HH_;
427
					if (ESBYTE[bword] <>'-') goto HH_;
425
				}
428
				}
426
			}
429
			}
427
			while (ESBYTE[bword] <>'>') && (bword < buf + filesize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
430
			while (ESBYTE[bword] !='>') && (bword < buf + filesize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
428
			{
431
			{
429
				bukva = ESBYTE[bword];
432
				bukva = ESBYTE[bword];
430
				if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
433
				if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
431
				if (!ignor_param) && (bukva <>' ')
434
				if (!ignor_param) && (bukva <>' ')
432
				{
435
				{
Line 494... Line 497...
494
		DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color);
497
		DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color);
495
	if (stroka * 10 + 15 <= height)
498
	if (stroka * 10 + 15 <= height)
496
		DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
499
		DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
497
	if (lines.first == 0) lines.all = stroka;
500
	if (lines.first == 0) lines.all = stroka;
498
	if (anchor)
501
	if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
499
	{
-
 
-
 
502
	{
500
		//åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
503
		anchor=NULL;
501
		anchor=NULL;
-
 
502
		lines.first=anchor_line_num;
504
		lines.first=anchor_line_num;
503
		ParseHTML(buf);
505
		ParseHTML(buf);
504
	}
506
	}
505
 
507
	DrawScroller();
506
	DrawScroller();
-
 
507
}
508
}
508
 
509
 
Line 509... Line 510...
509
void TWebBrowser::DrawPage() //ðåçàòü çäåñü!!1!
510
void TWebBrowser::DrawPage() //ðåçàòü çäåñü!!1!
510
{
511
{
Line 524... Line 525...
524
		{
525
		{
525
			strcpy(#header, #line);
526
			strcpy(#header, #line);
526
			line=0;
527
			line=0;
527
		}
528
		}
528
			
529
		strcat(#header, " -");
529
		strcat(#header, " -");
-
 
530
		strcat(#header, #version);
530
		strcat(#header, #version);
531
		return;
531
		return;
532
	}
532
	}
533
	
533
	
Line 568... Line 568...
568
char oldtag[100];
568
char oldtag[100];
569
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
569
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
570
	dword hr_color;
570
	dword hr_color;
Line 571... Line -...
571
 
-
 
572
    dword image;
-
 
573
    char temp[4096], alt[4096];
-
 
574
    int w=0, h=0, img_lines_first=0;
-
 
575
 
571
 
576
	//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
572
	//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
577
	if (tag[0] == '/') 
573
	if (tag[0] == '/') 
578
	{
574
	{
579
		 rez = 0;
575
		 rez = 0;
Line 599... Line 595...
599
	if (ignor_text) return;
595
	if (ignor_text) return;
Line 600... Line -...
600
 
-
 
601
 
596
 
Line 602... Line -...
602
 
-
 
603
	
597
 
604
	IF(!chTag("q")) strcat(#line, "\"");
598
	
605
 
599
	IF(!chTag("q")) strcat(#line, "\"");
606
 
600
 
Line 615... Line 609...
615
			if (!strcmp(#parametr, "link=")) link_color = GetColor(#options);
609
			if (!strcmp(#parametr, "link=")) link_color = GetColor(#options);
616
			if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options);
610
			if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options);
617
			if (!strcmp(#parametr, "bgcolor=")) bg_color=GetColor(#options);
611
			if (!strcmp(#parametr, "bgcolor=")) bg_color=GetColor(#options);
618
		} while(GetNextParam());
612
		} while(GetNextParam());
619
		
613
		return;
620
		return;
-
 
621
	}
614
	}
622
 
615
 
Line 623... Line 616...
623
	if (!chTag("a"))
616
	if (!chTag("a"))
624
	{
617
	{
Line 655... Line 648...
655
		}
648
		}
656
		return;
649
		return;
657
	}
650
	}
658
 
651
 
Line 659... Line -...
659
 
-
 
660
	if (!chTag("font"))
652
	if (!chTag("font"))
661
	{
653
	{
662
		if (rez)
654
		if (rez)
663
		{
655
		{
664
			text_color_index++;
656
			text_color_index++;
Line 674... Line 666...
674
		else
666
		else
675
			if (text_color_index > 0) text_color_index--;
667
			if (text_color_index > 0) text_color_index--;
676
		return;
668
		return;
677
	}
669
	}
678
 
670
	if(!chTag("tr")) || (!chTag("br")) {
679
	if(!chTag("tr")) || (!chTag("br")) {
-
 
680
		TextGoDown(left1, top1, width1);
671
		TextGoDown(left1, top1, width1);
681
		return;
672
		return;
682
	}
673
	}
683
	if (!chTag("div")) {
674
	if (!chTag("div")) {
684
		IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
675
		IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
Line 689... Line 680...
689
		TextGoDown(left1, top1, width1);
680
		TextGoDown(left1, top1, width1);
690
		IF(rez) TextGoDown(left1, top1 + 10, width1);
681
		IF(rez) TextGoDown(left1, top1 + 10, width1);
691
		return;
682
		return;
692
	}
683
	}
693
 
684
	if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) {
694
	if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) {
-
 
695
		TextGoDown(left1, top1, width1);
685
		TextGoDown(left1, top1, width1);
696
		IF(rez) TextGoDown(left1, top1 + 10, width1);
686
		IF(rez) TextGoDown(left1, top1 + 10, width1);
697
		b_text = rez;
687
		b_text = rez;
698
		strcpy(#oldtag, #tag);
688
		strcpy(#oldtag, #tag);
699
		return;
689
		return;
Line 704... Line 694...
704
	if (!chTag("b")) || (!chTag("strong")) || (!chTag("big")) {
694
	if (!chTag("b")) || (!chTag("strong")) || (!chTag("big")) {
705
		b_text = rez;
695
		b_text = rez;
706
		return;
696
		return;
707
	}
697
	}
708
	////////////////////////////
-
 
709
	if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) {
698
	if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) {
710
		i_text = rez;
699
		i_text = rez;
711
		return;
700
		return;
712
	}	
701
	}	
713
	////////////////////////////
-
 
714
	if (!chTag("dt"))
702
	if (!chTag("dt"))
715
	{
703
	{
716
		li_text = rez;
704
		li_text = rez;
717
		IF(rez == 0) return;
705
		IF(rez == 0) return;
718
		TextGoDown(left1, top1, width1);
706
		TextGoDown(left1, top1, width1);
719
		return;
707
		return;
720
	}
708
	}
721
	/////////////////////////////
-
 
722
	if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
709
	if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
723
	{
710
	{
724
		li_text = rez;
711
		li_text = rez;
725
		IF(rez == 0) return;
712
		IF(rez == 0) return;
726
		TextGoDown(left1, top1, width1);
713
		TextGoDown(left1, top1, width1);
727
		IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0);
714
		IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0);
728
		return;
715
		return;
729
	}
716
	}
730
	////////////////////////////
-
 
731
	IF(!chTag("u")) || (!chTag("ins")) u_text = rez;
717
	if (!chTag("u")) || (!chTag("ins")) u_text = rez;
732
	IF(!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez;
718
	if (!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez;
733
	IF(!chTag("ul")) || (!chTag("ol")) IF(!rez) {
719
	if (!chTag("ul")) || (!chTag("ol")) IF(!rez)
-
 
720
	{
734
		li_text = rez;
721
		li_text = rez;
735
		li_tab--;
722
		li_tab--;
736
		TextGoDown(left1, top1, width1);
723
		TextGoDown(left1, top1, width1);
737
	} ELSE li_tab++;
724
	} ELSE li_tab++;
738
	IF(!chTag("dd")) stolbec += 5;
725
	if (!chTag("dd")) stolbec += 5;
739
	IF(!chTag("blockquote")) blq_text = rez;
726
	if (!chTag("blockquote")) blq_text = rez;
740
	IF(!chTag("pre")) pre_text = rez; 
727
	if (!chTag("pre")) pre_text = rez; 
741
	IF(!chTag("hr")) {
728
	if (!chTag("hr"))
-
 
729
	{
742
		TextGoDown(left1, top1, width1);
730
		TextGoDown(left1, top1, width1);
743
		TextGoDown(left1, top1 + 10, width1);
731
		TextGoDown(left1, top1 + 10, width1);
744
		IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options);
732
		IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options);
745
		ELSE hr_color = 0x999999;
733
		ELSE hr_color = 0x999999;
746
		IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color);
734
		IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color);
747
	}
735
	}
748
 
-
 
749
	if (!chTag("img"))
736
	if (!chTag("img"))
750
	{
737
	{
-
 
738
		Images( left1, top1, width1);
-
 
739
		return;
-
 
740
	}
-
 
741
	if (!chTag("meta")) || (!chTag("?xml"))
-
 
742
	{
-
 
743
		do{
-
 
744
			if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
-
 
745
			{
-
 
746
				strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
-
 
747
				if (!strcmp(#options,"utf-8"))   || (!strcmp(#options,"utf8"))      ReadHtml(_UTF);
-
 
748
				if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))   ReadHtml(_KOI);
-
 
749
				if (!strcmp(#options, "dos"))    || (!strcmp(#options, "cp-866"))   ReadHtml(_DOS);
-
 
750
			}
-
 
751
		} while(GetNextParam());
-
 
752
		return;
-
 
753
	}
-
 
754
}
-
 
755
 
-
 
756
 
-
 
757
void TextGoDown(int left1, top1, width1)
-
 
758
{
-
 
759
	if (!stroka) && (!stolbec) && (!first_line_drawed)
-
 
760
	{
-
 
761
		DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
-
 
762
		first_line_drawed=1;
-
 
763
	}
-
 
764
	stroka++;
-
 
765
	if (blq_text) stolbec = 8;
-
 
766
	ELSE stolbec = 0;
-
 
767
	if (li_text) stolbec = li_tab * 5;
-
 
768
	IF(stroka >= 0) && (stroka - 2 < lines.visible)  && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
-
 
769
}
-
 
770
 
-
 
771
 
-
 
772
struct s_image
-
 
773
{
-
 
774
	dword *image;
-
 
775
	char path[4096];
-
 
776
};
-
 
777
s_image pics[100]; //pics = mem_Alloc( 100*sizeof(s_image) );
-
 
778
int num_of_pics;
-
 
779
 
-
 
780
int GetOrSetPicNum(dword i_path)
-
 
781
{
-
 
782
	int i;
-
 
783
	for (i=0; i
-
 
784
	{
-
 
785
		if (!strcmp(#pics[i].path, i_path)) return i;
-
 
786
	}
-
 
787
	num_of_pics++;
-
 
788
	return num_of_pics;
-
 
789
}
-
 
790
 
-
 
791
void FreeImgCache()
-
 
792
{
-
 
793
	int i;
-
 
794
	for (i=0; i<=num_of_pics; i++)
-
 
795
	{
-
 
796
		mem_Free(pics[num_of_pics].image);
-
 
797
		pics[num_of_pics].path=NULL;
-
 
798
	}
-
 
799
	num_of_pics=0;
-
 
800
}
-
 
801
 
-
 
802
 
-
 
803
void Images(int left1, top1, width1)
-
 
804
{
-
 
805
	dword image;
-
 
806
    char img_path[4096], alt[4096];
-
 
807
    int w=0, h=0, img_lines_first=0, cur_pic=0;
-
 
808
	
751
		if (GetFileInfo(libimg)<>0) return;  //åñëè áèáëèîòåêè íåò
809
	if (GetFileInfo(libimg)<>0) return;  //åñëè áèáëèîòåêè íåò
752
		do{
810
		do{
753
			if (!strcmp(#parametr,"src="))   //íàäî îáúåäèíèòü ñ GetNewUrl()
811
			if (!strcmp(#parametr,"src="))   //íàäî îáúåäèíèòü ñ GetNewUrl()
754
			{
812
			{
755
				if (downloader_id) strcpy(#temp, #history_list[history_current-1].Item);
813
				if (downloader_id) strcpy(#img_path, #history_list[history_current-1].Item);
756
					else strcpy(#temp, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
814
					else strcpy(#img_path, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
-
 
815
				
757
				if (strcmpn(#temp, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
816
				if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
758
				{
817
				{
759
					temp[strrchr(#temp, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
818
					img_path[strrchr(#img_path, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
760
					strcat(#temp, #options);
819
					strcat(#img_path, #options);
-
 
820
					
761
					image=load_image(#temp);
821
					cur_pic=GetOrSetPicNum(#img_path);
762
					w=DSWORD[image+4];
822
					if (!pics[cur_pic].path)
-
 
823
					{
-
 
824
						pics[cur_pic].image=load_image(#img_path);
763
					h=DSWORD[image+8];
825
						strcpy(#pics[cur_pic].path, #img_path);
-
 
826
					}
764
				}
827
				}
765
			}
828
			}
766
  			if (!strcmp(#parametr,"alt="))
829
  			if (!strcmp(#parametr,"alt="))
767
			{
830
			{
768
				strcpy(#alt, "[");
831
				strcpy(#alt, "[");
Line 771... Line 834...
771
			}
834
			}
772
 
835
 
Line 773... Line 836...
773
		} while(GetNextParam());
836
		} while(GetNextParam());
Line 774... Line 837...
774
		
837
		
775
		if (!image) 
838
		if (!pics[cur_pic].image) 
776
		{
839
		{
777
			if (alt) && (link) strcat(#line, #alt);
840
			if (alt) && (link) strcat(#line, #alt);
778
			return;
841
			return;
Line -... Line 842...
-
 
842
		}
-
 
843
		
779
		}
844
		w=DSWORD[pics[cur_pic].image+4];
Line 780... Line 845...
780
		
845
		h=DSWORD[pics[cur_pic].image+8];
781
		if (w>width1) w=width1;
846
		if (w>width1) w=width1;
782
		
847
		
783
		if (stroka==0) DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
848
		if (stroka==0) DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
784
		stroka+=h/10;
849
		stroka+=h/10;
785
		if (top1+hWB1.top+WB1.height-10) return; //åñëè ÂѨ èçîáðàæåíèå óøëî ÂÅÐÕ èëè ÂÍÈÇ
850
		if (top1+hWB1.top+WB1.height-10) return; //åñëè ÂѨ èçîáðàæåíèå óøëî ÂÅÐÕ èëè ÂÍÈÇ
786
		if (top1
851
		if (top1
787
		{
852
		{
788
			DrawBar(left, top, width-15, 10, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
853
			DrawBar(WB1.left, WB1.top, WB1.width-15, 10, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
789
			img_lines_first=WB1.top-top1;
854
			img_lines_first=WB1.top-top1;
790
			h=h-img_lines_first;
855
			h=h-img_lines_first;
Line 796... Line 861...
796
		}	
861
		}	
797
		if (h<=0) return;
862
		if (h<=0) return;
798
		if (anchor) return;
863
		if (anchor) return;
799
		
864
		
Line 800... Line 865...
800
		img_draw stdcall (image,left1-5,top1+10,w, h,0,img_lines_first);
865
		img_draw stdcall (pics[cur_pic].image,left1-5,top1+10,w, h,0,img_lines_first);
801
		DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color);
866
		DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color);
802
		IF (link) DefineButton(left1 - 5, top1+10, w, h, blink + BT_HIDE, 0xB5BFC9);
867
		IF (link) DefineButton(left1 - 5, top1+10, w, h, blink + BT_HIDE, 0xB5BFC9);
803
		return;
-
 
804
	}
-
 
805
 
-
 
806
	if (!chTag("meta")) || (!chTag("?xml"))
-
 
807
	{
-
 
808
		do{
-
 
809
			if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
-
 
810
			{
-
 
811
				strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
-
 
812
 
-
 
813
				if (!strcmp(#options,"utf-8"))   || (!strcmp(#options,"utf8"))      ReadHtml(_UTF);
-
 
814
				if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))   ReadHtml(_KOI);
-
 
815
				if (!strcmp(#options, "dos"))    || (!strcmp(#options, "cp-866"))   ReadHtml(_DOS);
-
 
816
			}
-
 
817
		} while(GetNextParam());
-
 
818
		return;
-
 
819
	}
-
 
820
}
-
 
821
 
-
 
822
 
-
 
823
void TextGoDown(int left1, top1, width1)
-
 
824
{
-
 
825
	if (!stroka) && (!stolbec) && (!first_line_drawed)
-
 
826
	{
-
 
827
		DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
-
 
828
		first_line_drawed=1;
-
 
829
	}
-
 
830
	stroka++;
-
 
831
	if (blq_text) stolbec = 8;
-
 
832
	ELSE stolbec = 0;
-
 
833
	if (li_text) stolbec = li_tab * 5;
-
 
834
	IF(stroka >= 0) && (stroka - 2 < lines.visible)  && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
-
 
835
}
868
}
Line 836... Line 869...
836
 
869
 
837
 
870