Subversion Repositories Kolibri OS

Rev

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

Rev 2825 Rev 2839
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.94e";
11
char version[]=" Text-based Browser 0.94u";
Line 12... Line 12...
12
 
12
 
13
 
13
 
14
struct TWebBrowser {
14
struct TWebBrowser {
Line 28... Line 28...
28
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text,
28
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text,
29
	link, ignor_text, li_tab, first_line_drawed;
29
	link, ignor_text, li_tab, first_line_drawed;
Line 30... Line 30...
30
 
30
 
31
 
31
 
32
dword text_colors[30],
32
dword text_colors[300],
33
	text_color_index,
33
	text_color_index,
Line 34... Line 34...
34
	link_color,
34
	link_color,
35
	bg_color;
35
	bg_color;
36
 
36
 
Line -... Line 37...
-
 
37
int stroka,
-
 
38
	stolbec,
-
 
39
	tab_len;
37
int stroka,
40
 
38
	stolbec,
41
char anchor[256];
39
	tab_len;
42
int anchor_line_num;
40
	
43
	
41
char line[500],
44
char line[500],
Line 42... Line -...
42
	tag[100],
-
 
43
	tagparam[10000],
-
 
44
	parametr[1200],
-
 
Line 45... Line 45...
45
	options[1000];
45
	tag[100],
46
 
46
	tagparam[10000],
47
char anchor[256];
47
	parametr[1200],
48
int anchor_line_num;
48
	options[1000];
Line 63... Line 63...
63
		
63
		
Line 64... Line 64...
64
		//#1
64
		//#1
65
		if (URL[0] == '#')
65
		if (URL[0] == '#')
66
		{
66
		{
67
			strcpy(#anchor, #URL+find_symbol(#URL, '#'));
67
			strcpy(#anchor, #URL+strrchr(#URL, '#'));
Line 68... Line 68...
68
			
68
			
Line 69... Line 69...
69
			strcpy(#URL, BrowserHistory.CurrentUrl());
69
			strcpy(#URL, BrowserHistory.CurrentUrl());
70
			
70
			
71
			lines.first=lines.all-lines.visible;
71
			lines.first=lines.all-lines.visible;
72
			ShowPage();
72
			ShowPage();
73
			return;
73
			return;
74
		}
74
		}
75
		//liner.ru#1
75
		//liner.ru#1
76
		if (find_symbol(#URL, '#')<>-1)
76
		if (strrchr(#URL, '#')<>-1)
77
		{
77
		{
78
			strcpy(#anchor, #URL+find_symbol(#URL, '#'));
78
			strcpy(#anchor, #URL+strrchr(#URL, '#'));
Line 79... Line 79...
79
			URL[find_symbol(#URL, '#')-1] = 0x00; //çàãëóøêà
79
			URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà
Line 80... Line 80...
80
		}
80
		}
Line 195... Line 195...
195
		strcpy(#editURL, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
195
		strcpy(#editURL, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
196
		
196
		
Line 197... Line 197...
197
		_CUT_ST_LEVEL_MARK:
197
		_CUT_ST_LEVEL_MARK:
Line 198... Line 198...
198
		
198
		
199
		if (editURL[find_symbol(#editURL, '/')-2]<>'/')  // åñëè íå http://pagename.ua <-- íàõðåíà ýòà ñòðîêà???
199
		if (editURL[strrchr(#editURL, '/')-2]<>'/')  // åñëè íå http://pagename.ua <-- íàõðåíà ýòà ñòðîêà???
200
		{
200
		{
201
			editURL[find_symbol(#editURL, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
201
			editURL[strrchr(#editURL, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
Line 202... Line 202...
202
		}
202
		}
203
		
203
		
204
		IF (!strcmp(get_URL_part(3),"../")) //íà óðîâåíü ââåðõ
204
		IF (!strcmp(get_URL_part(3),"../")) //íà óðîâåíü ââåðõ
205
		{
205
		{
206
			strcpy(#URL,#URL+3);
206
			strcpy(#URL,#URL+3);
207
			editURL[find_symbol(#editURL, '/')-1] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
207
			editURL[strrchr(#editURL, '/')-1] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
Line 208... Line 208...
208
			goto _CUT_ST_LEVEL_MARK;
208
			goto _CUT_ST_LEVEL_MARK;
209
		}
209
		}
Line 316... Line 316...
316
 
316
 
Line 317... Line 317...
317
	if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
317
	if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
318
	if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
318
	if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
Line 319... Line -...
319
	
-
 
320
	#ifdef DEBUG_ON
319
	
321
		debug("Start parsing");
-
 
Line 322... Line 320...
322
	#endif
320
	debug("Start parsing");
323
	
321
	
324
	for ( ; buf+filesize > bword; bword++;) {//ESBYTE[bword]
322
	for ( ; buf+filesize > bword; bword++;) {//ESBYTE[bword]
325
	  bukva = ESBYTE[bword];
323
	  bukva = ESBYTE[bword];
Line 436... Line 434...
436
			if (!pre_text) && (bukva == ' ') && (line[strlen(#line)-1]==' ') break;
434
			if (!pre_text) && (bukva == ' ') && (line[strlen(#line)-1]==' ') break;
437
			//
435
			//
438
			if (stolbec + strlen(#line) > lines.column_max)
436
			if (stolbec + strlen(#line) > lines.column_max)
439
			{
437
			{
440
				perenos_num = find_symbol(#line, ' ');
438
				perenos_num = strrchr(#line, ' ');
441
				strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
439
				strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
442
				line[perenos_num] = 0x00;
440
				line[perenos_num] = 0x00;
443
			NEXT_MARK:
441
			NEXT_MARK:
444
				if (stroka >= lines.visible) && (lines.first <>0) break 1; //óõîäèì...
442
				if (stroka >= lines.visible) && (lines.first <>0) break 1; //óõîäèì...
445
				WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //âûâîä ñòðîêè
443
				WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //âûâîä ñòðîêè
446
				TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
444
				TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
Line 463... Line 461...
463
		lines.first=anchor_line_num;
461
		lines.first=anchor_line_num;
464
		ParseHTML(buf);
462
		ParseHTML(buf);
465
	}
463
	}
466
 
464
 
Line 467... Line -...
467
	#ifdef DEBUG_ON
-
 
468
		debug("End parsing");
465
	debug("End parsing");
469
	#endif
-
 
470
	DrawScroller(); //ðèñóåì ñêðîëë
466
	DrawScroller(); //ðèñóåì ñêðîëë
471
}
467
}
Line 472... Line 468...
472
 
468
 
Line 566... Line 562...
566
	if (!chTag("a"))
562
	if (!chTag("a"))
567
	{
563
	{
568
		if (rez)
564
		if (rez)
569
		{
565
		{
570
			_A_MARK:
566
			text_color_index++;
-
 
567
			text_colors[text_color_index] = text_colors[text_color_index-1];
-
 
568
 
-
 
569
			_A_MARK:
571
			if (!strcmp(#parametr, "href="))
570
			if (!strcmp(#parametr, "href="))
572
			{
571
			{
573
				if (stroka - 1 > lines.visible) || (stroka < -2) return;
572
				if (stroka - 1 > lines.visible) || (stroka < -2) return;
574
				if (link == 1) text_color_index--; //åñëè êàêîé-òî äîëáî¸á íå çàêðûë òýã
573
				if (link) && (text_color_index > 0) text_color_index--; //åñëè íå çàêðûò òýã
575
				link = 1;
574
				link = 1;
576
				blink++;
575
				blink++;
577
				text_color_index++;
576
				text_colors[text_color_index] = link_color;
578
				text_colors[text_color_index] = link_color;
-
 
579
				strcat(#page_links, #options);
577
				strcat(#page_links, #options);
580
				strcat(#page_links, "|");
578
				strcat(#page_links, "|");
581
			}
579
			}
582
			if (anchor) && (!strcmp(#parametr, "name="))
580
			if (anchor) && (!strcmp(#parametr, "name="))
583
			{
581
			{
Line 600... Line 598...
600
	}
598
	}
601
	/////////////////////////
599
	/////////////////////////
602
	if (!chTag("font"))
600
	if (!chTag("font"))
603
	{
601
	{
604
		IF (stroka - 1 > lines.visible) return;
602
		if (rez)
-
 
603
		{
-
 
604
			text_color_index++;
-
 
605
			text_colors[text_color_index] = text_colors[text_color_index-1];
605
		COL_MARK:
606
		
-
 
607
			COL_MARK:
606
		if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
608
			if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
607
		{
609
			{
608
			text_color_index++;
610
				text_colors[text_color_index] = GetColor(#options);
609
			text_colors[text_color_index] = GetColor(#options);
-
 
610
		}
611
			}
611
		IF(tagparam) {
612
			IF(tagparam) {
612
			GetNextParam();
613
				GetNextParam();
613
			GOTO COL_MARK;
614
				GOTO COL_MARK;
614
		}
615
			}
615
		IF(!rez) && (text_color_index > 0) text_color_index--;
616
		}
-
 
617
		else
-
 
618
			if (text_color_index > 0) text_color_index--;
616
		return;
619
		return;
617
	}
620
	}
618
	//////////////////////////
621
	//////////////////////////
619
	if(!chTag("tr")) || (!chTag("br")) {
622
	if(!chTag("tr")) || (!chTag("br")) {
620
		TextGoDown(left1, top1, width1);
623
		TextGoDown(left1, top1, width1);
621
		return;
624
		return;
Line 692... Line 695...
692
		IMG_TAG:
695
		IMG_TAG:
693
			if (!strcmp(#parametr,"src="))   //íàäî îáúåäèíèòü ñ GetNewUrl()
696
			if (!strcmp(#parametr,"src="))   //íàäî îáúåäèíèòü ñ GetNewUrl()
694
			{
697
			{
695
				strcpy(#temp, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
698
				strcpy(#temp, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
696
				temp[find_symbol(#temp, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
699
				temp[strrchr(#temp, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
697
				strcat(#temp, #options);
700
				strcat(#temp, #options);
698
				image=load_image(#temp);
701
				image=load_image(#temp);
699
				w=DSWORD[image+4];
702
				w=DSWORD[image+4];
700
				h=DSWORD[image+8];
703
				h=DSWORD[image+8];
701
			}
704
			}
702
  			if (!strcmp(#parametr,"alt="))
705
  			/*if (!strcmp(#parametr,"alt="))
703
			{
706
			{
704
				strcpy(#tag, "[Image: ");
707
				strcpy(#tag, "[Image: ");
705
				strcat(#tag, #options);
708
				strcat(#tag, #options);
706
				strcat(#tag, "]");
709
				strcat(#tag, "]");
707
			}
710
			}*/
708
 
711
 
Line 709... Line 712...
709
		IF(tagparam)
712
		IF(tagparam)
710
		{
713
		{
711
			GetNextParam();
714
			GetNextParam();
712
			GOTO IMG_TAG;
715
			GOTO IMG_TAG;
Line 756... Line 759...
756
	{
759
	{
757
		META:
760
		META:
758
		if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
761
		if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
759
		{
762
		{
760
			strcpy(#options, #options[find_symbol(#options, '=')]); //ïîèñê â content=
763
			strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
761
 
764
 
Line 762... Line 765...
762
			if (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8"))		ReadHtml(_UTF);
765
			if (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8"))		ReadHtml(_UTF);
763
			if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))	ReadHtml(_KOI);
766
			if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))	ReadHtml(_KOI);
764
			if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866"))		ReadHtml(_DOS);
767
			if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866"))		ReadHtml(_DOS);
765
		}
768
		}