Subversion Repositories Kolibri OS

Rev

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

Rev 2810 Rev 2811
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.94";
11
char version[]=" Text-based Browser 0.94b";
Line 12... Line 12...
12
 
12
 
13
 
13
 
-
 
14
struct TWebBrowser {
-
 
15
	int left, top, width, height;
14
struct TWebBrowser {
16
	void Scan(int);
15
	int left, top, width, height;
17
	void OpenPage();
16
	void DrawScroller();
18
	void ReadHtml(byte);
17
	void ShowPage();
-
 
18
	void ParseHTML(dword, dword);
19
	void ShowPage();
-
 
20
	void ParseHTML(dword, dword);
19
	void Scan(int);
21
	void WhatTextStyle(int left1, top1, width1);
Line 20... Line 22...
20
	void WhatTextStyle(int left1, top1, width1);
22
	void DrawScroller();
Line 21... Line 23...
21
};
23
};
Line 62... Line 64...
62
			strcpy(#anchor, #URL+find_symbol(#URL, '#'));
64
			strcpy(#anchor, #URL+find_symbol(#URL, '#'));
63
			
65
			
Line 64... Line 66...
64
			strcpy(#URL, BrowserHistory.CurrentUrl());
66
			strcpy(#URL, BrowserHistory.CurrentUrl());
Line 65... Line 67...
65
			
67
			
66
			lines_first=lines_all-lines_visible;
68
			lines.first=lines.all-lines.visible;
67
			ShowPage(#URL);
69
			ShowPage();
68
			return;
70
			return;
69
		}
71
		}
70
		//liner.ru#1
72
		//liner.ru#1
71
		if (find_symbol(#URL, '#')<>-1)
73
		if (find_symbol(#URL, '#')<>-1)
Line 86... Line 88...
86
		OpenPage();
88
		OpenPage();
87
		return;
89
		return;
88
	}
90
	}
Line 89... Line 91...
89
	
91
	
90
	IF(lines_all < lines_visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
92
	IF(lines.all < lines.visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
Line 91... Line 93...
91
	{ CASE 183: CASE 184: CASE 180: CASE 181: return; } 
93
	{ CASE 183: CASE 184: CASE 180: CASE 181: return; } 
92
	
94
	
93
	switch (id)
95
	switch (id)
94
	{
96
	{
95
		case 011: //Ctrk+K 
-
 
96
			ReadHtml();
97
		case 011: //Ctrk+K 
97
			koitodos(buf);
98
			ReadHtml(_KOI);
98
			break;
99
			break;
99
		case 021: //Ctrl+U
-
 
100
			ReadHtml();
100
		case 021: //Ctrl+U
101
			utf8rutodos(buf);
101
			ReadHtml(_UTF);
102
			break;
102
			break;
103
		case BACK:
103
		case BACK:
104
			if (!BrowserHistory.GoBack()) return;
104
			if (!BrowserHistory.GoBack()) return;
Line 123... Line 123...
123
				Pause(20);
123
				Pause(20);
124
				Draw_Window();
124
				Draw_Window();
125
				return;
125
				return;
126
			}
126
			}
127
			anchor_line_num=lines_first; //âåñ¸ëûé êîñòûëü :Ð
127
			anchor_line_num=lines.first; //âåñ¸ëûé êîñòûëü :Ð
128
			anchor[0]='|';
128
			anchor[0]='|';
129
			OpenPage();
129
			OpenPage();
130
			return;
130
			return;
131
		case 014: //Ctrl+N íîâîå îêíî
131
		case 014: //Ctrl+N íîâîå îêíî
132
		case 020: //Ctrl+T íîâàÿ âêëàäêà
132
		case 020: //Ctrl+T íîâàÿ âêëàäêà
133
		case NEWTAB:
133
		case NEWTAB:
Line 149... Line 149...
149
			OpenPage();
149
			OpenPage();
150
			return;
150
			return;
151
 
151
 
Line 152... Line 152...
152
		case ID1: //ìîòàåì ââåðõ
152
		case ID1: //ìîòàåì ââåðõ
153
			IF(lines_first <= 0) return;
153
			IF(lines.first <= 0) return;
154
			lines_first--;
154
			lines.first--;
155
			break; 
155
			break; 
156
		case ID2: //ìîòàåì âíèç
156
		case ID2: //ìîòàåì âíèç
157
			IF(lines_visible + lines_first >= lines_all) return;
157
			IF(lines.visible + lines.first >= lines.all) return;
158
			lines_first++;
158
			lines.first++;
159
			break; 
159
			break; 
160
		case 183: //PgDown
160
		case 183: //PgDown
161
			IF(lines_first == lines_all - lines_visible) return;
161
			IF(lines.first == lines.all - lines.visible) return;
162
			lines_first += lines_visible + 2;
162
			lines.first += lines.visible + 2;
163
			IF(lines_visible + lines_first > lines_all) lines_first = lines_all - lines_visible;
163
			IF(lines.visible + lines.first > lines.all) lines.first = lines.all - lines.visible;
164
			BREAK;
164
			BREAK;
165
		case 184: //PgUp
165
		case 184: //PgUp
166
			IF(lines_first == 0) RETURN;
166
			IF(lines.first == 0) RETURN;
167
			lines_first -= lines_visible - 2;
167
			lines.first -= lines.visible - 2;
168
			IF(lines_first < 0) lines_first = 0;
168
			IF(lines.first < 0) lines.first = 0;
169
			BREAK;
169
			BREAK;
170
		case 180: //home
170
		case 180: //home
171
			IF(lines_first == 0) RETURN;
171
			IF(lines.first == 0) RETURN;
172
			lines_first = 0;
172
			lines.first = 0;
173
			BREAK; 
173
			BREAK; 
174
		case 181: //end
174
		case 181: //end
175
			IF (lines_first == lines_all - lines_visible) RETURN;
175
			IF (lines.first == lines.all - lines.visible) RETURN;
176
			lines_first = lines_all - lines_visible;
176
			lines.first = lines.all - lines.visible;
177
			BREAK; 
177
			BREAK; 
178
		default:
178
		default:
179
			RETURN;
179
			RETURN;
180
	}
180
	}
181
	ParseHTML(buf, filesize);
181
	ParseHTML(buf, filesize);
Line 212... Line 212...
212
}
212
}
213
 
213
 
Line 214... Line 214...
214
 
214
 
215
	
215
	
216
void ReadHtml()
216
void TWebBrowser::ReadHtml(byte dest)
217
{
217
{
218
	if (!strcmp(get_URL_part(5),"http:"))) 
218
	if (!strcmp(get_URL_part(5),"http:"))) 
219
		file_size stdcall (#download_path);
219
		file_size stdcall (#download_path);
Line 228... Line 228...
228
	if (!strcmp(get_URL_part(5),"http:"))) 
228
	if (!strcmp(get_URL_part(5),"http:"))) 
229
		ReadFile(0, filesize, buf, #download_path);
229
		ReadFile(0, filesize, buf, #download_path);
230
	else
230
	else
231
		ReadFile(0, filesize, buf, #URL);
231
		ReadFile(0, filesize, buf, #URL);
232
}
232
		
-
 
233
	if (dest==_WIN) wintodos(buf);
-
 
234
	if (dest==_UTF) utf8rutodos(buf);
-
 
235
	if (dest==_KOI) koitodos(buf);
-
 
236
}
233
 
237
 
Line 234... Line 238...
234
 
238
 
235
void OpenPage()
239
void TWebBrowser::OpenPage()
236
{
240
{
237
	if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
241
	if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
238
	KillProcess(downloader_id);
242
	KillProcess(downloader_id);
239
	strcpy(#editURL, #URL);
243
	strcpy(#editURL, #URL);
Line 256... Line 260...
256
		IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable.");
260
		IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable.");
257
		Draw_Window();
261
		Draw_Window();
258
		return;
262
		return;
259
	}
263
	}
260
	lines_first = lines_all = 0;
264
	lines.first = lines.all = 0;
261
	ReadHtml();
265
	ReadHtml(_WIN);
262
	if (filesize) wintodos(buf);
266
	WB1.ShowPage();
263
	WB1.ShowPage(#URL);
-
 
264
}
267
}
265
 
268
 
Line 266... Line 269...
266
 
269
 
267
void TWebBrowser::ShowPage(dword adress)
270
void TWebBrowser::ShowPage()
268
{
271
{
269
	edit1.size = edit1.pos = strlen(#editURL);
272
	edit1.size = edit1.pos = strlen(#editURL);
Line 270... Line 273...
270
	edit_box_draw stdcall(#edit1); //ðèñóåì ñòðîêó àäðåñà
273
	edit_box_draw stdcall(#edit1); //ðèñóåì ñòðîêó àäðåñà
Line 293... Line 296...
293
	int j;
296
	int j;
294
	byte ignor_param = 0;
297
	byte ignor_param = 0;
295
	char temp[768];
298
	char temp[768];
296
	
299
	
Line 297... Line 300...
297
	stroka = -lines_first;
300
	stroka = -lines.first;
298
	stolbec = 0;
301
	stolbec = 0;
Line 299... Line 302...
299
	
302
	
300
	for (j = 400; j < blink + 1; j++;) DeleteButton(j);
303
	for (j = 400; j < blink + 1; j++;) DeleteButton(j);
Line 418... Line 421...
418
			DEFAULT_MARK:
421
			DEFAULT_MARK:
419
			IF(ignor_text) break;
422
			IF(ignor_text) break;
420
			IF(!pre_text) && (bukva == ' ') && (!strcmp(#line + strlen(#line) - 1, " ")) continue;
423
			IF(!pre_text) && (bukva == ' ') && (!strcmp(#line + strlen(#line) - 1, " ")) continue;
421
			//
424
			//
422
			if (stolbec + strlen(#line) >lines_column_max)
425
			if (stolbec + strlen(#line) >lines.column_max)
423
			{
426
			{
424
				strcpy(#temp, #line + find_symbol(#line, ' ')); //ïåðåíîñ ïî ñëîâàì
427
				strcpy(#temp, #line + find_symbol(#line, ' ')); //ïåðåíîñ ïî ñëîâàì
425
				line[find_symbol(#line, ' ')] = 0x00;
428
				line[find_symbol(#line, ' ')] = 0x00;
426
			NEXT_MARK:
429
			NEXT_MARK:
427
				IF(stroka - 1 > lines_visible) && (lines_first <>0) break 1; //óõîäèì...
430
				IF(stroka - 1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
428
				WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //âûâîä ñòðîêè
431
				WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //âûâîä ñòðîêè
429
				TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
432
				TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
430
				strcpy(#line, #temp);
433
				strcpy(#line, #temp);
431
			}
434
			}
432
			if (!pre_text) && (bukva == ' ') && (!stolbec) && (!line) CONTINUE;
435
			if (!pre_text) && (bukva == ' ') && (!stolbec) && (!line) CONTINUE;
433
			strcat(#line, #bukva);
436
			strcat(#line, #bukva);
Line 435... Line 438...
435
	}
438
	}
436
	if (strcmp(#URL + strlen(#URL) - 4, ".txt")<>0) && (!body_present)
439
	if (strcmp(#URL + strlen(#URL) - 4, ".txt")<>0) && (!body_present)
437
		DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó åñëè êàêîé-òî ðàõèò íå ñîçäàë òåã áîäè
440
		DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó åñëè êàêîé-òî ðàõèò íå ñîçäàë òåã áîäè
438
 
441
 
Line 439... Line 442...
439
	if (lines_visible * 10 + 25 <= height)
442
	if (lines.visible * 10 + 25 <= height)
440
		DrawBar(left, lines_visible * 10 + top + 25, width - 15, -lines_visible * 10 + height - 25, bg_color);
443
		DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color);
441
	if (stroka * 10 + 15 <= height)
444
	if (stroka * 10 + 15 <= height)
442
		DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
445
		DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
443
	if (lines_first == 0) lines_all = stroka;
446
	if (lines.first == 0) lines.all = stroka;
Line 444... Line 447...
444
	
447
	
445
	if (anchor)
448
	if (anchor)
446
	{
449
	{
447
		anchor='';
450
		anchor='';
448
		lines_first=anchor_line_num;
451
		lines.first=anchor_line_num;
449
		ParseHTML(buf, filesize);
452
		ParseHTML(buf, filesize);
Line 450... Line 453...
450
	}
453
	}
451
 
454
 
Line 534... Line 537...
534
	//
537
	//
535
	IF(!chTag("q")) strcat(#line, "\"");
538
	IF(!chTag("q")) strcat(#line, "\"");
Line 536... Line 539...
536
	
539
	
537
	//âûâîä íà ýêðàí
540
	//âûâîä íà ýêðàí
538
	if (stroka >= 0) && (stroka - 2 < lines_visible) && (line) && (!anchor)
541
	if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor)
539
	{
542
	{
540
		WriteText(stolbec * 6 + left1, top1, 0x80, text_colors[text_color_index], #line, 0); //ìîæåò òóò ðèñîâàòü áåëóþ ñòðîêó?
543
		WriteText(stolbec * 6 + left1, top1, 0x80, text_colors[text_color_index], #line, 0); //ìîæåò òóò ðèñîâàòü áåëóþ ñòðîêó?
541
		IF (b_text)	{ $add ebx, 1<<16   $int 0x40 }
544
		IF (b_text)	{ $add ebx, 1<<16   $int 0x40 }
542
		IF (i_text) Skew(stolbec * 6 + left1, top1, strlen(#line)+1*6, 10); //íàêëîííûé òåêñò
545
		IF (i_text) Skew(stolbec * 6 + left1, top1, strlen(#line)+1*6, 10); //íàêëîííûé òåêñò
Line 554... Line 557...
554
	if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
557
	if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
555
	{
558
	{
556
		if (!strcmp(#anchor, #options))
559
		if (!strcmp(#anchor, #options))
557
		{
560
		{
558
			anchor_line_num=lines_first+stroka;
561
			anchor_line_num=lines.first+stroka;
559
		}
562
		}
560
	}
563
	}
Line 561... Line 564...
561
 
564
 
562
	if (!chTag("body"))
565
	if (!chTag("body"))
Line 593... Line 596...
593
		{
596
		{
594
			_A_MARK:
597
			_A_MARK:
595
			if (!strcmp(#parametr, "href="))
598
			if (!strcmp(#parametr, "href="))
596
			{
599
			{
597
				if (stroka - 1 > lines_visible) || (stroka < -2) return;
600
				if (stroka - 1 > lines.visible) || (stroka < -2) return;
598
				if (link == 1) text_color_index--; //åñëè êàêîé-òî äîëáî¸á íå çàêðûë òýã
601
				if (link == 1) text_color_index--; //åñëè êàêîé-òî äîëáî¸á íå çàêðûë òýã
599
				link = 1;
602
				link = 1;
600
				blink++;
603
				blink++;
601
				text_color_index++;
604
				text_color_index++;
602
				text_colors[text_color_index] = link_color;
605
				text_colors[text_color_index] = link_color;
603
				strcat(#page_links, #options);
606
				strcat(#page_links, #options);
Line 606... Line 609...
606
			if (anchor) && (!strcmp(#parametr, "name="))
609
			if (anchor) && (!strcmp(#parametr, "name="))
607
			{
610
			{
608
				if (!strcmp(#anchor, #options))
611
				if (!strcmp(#anchor, #options))
609
				{
612
				{
610
					anchor_line_num=lines_first+stroka;
613
					anchor_line_num=lines.first+stroka;
611
				}
614
				}
612
			}
615
			}
613
			if (tagparam)
616
			if (tagparam)
614
			{
617
			{
615
				GetNextParam();
618
				GetNextParam();
616
				GOTO _A_MARK;
619
				GOTO _A_MARK;
Line 624... Line 627...
624
	}
627
	}
625
	/////////////////////////
628
	/////////////////////////
626
	if (!chTag("font"))
629
	if (!chTag("font"))
627
	{
630
	{
628
		IF (stroka - 1 > lines_visible) return;
631
		IF (stroka - 1 > lines.visible) return;
629
		COL_MARK:
632
		COL_MARK:
630
		if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
633
		if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
631
		{
634
		{
632
			text_color_index++;
635
			text_color_index++;
633
			text_colors[text_color_index] = GetColor(#options);
636
			text_colors[text_color_index] = GetColor(#options);
634
		}
637
		}
Line 687... Line 690...
687
	{
690
	{
688
		li_text = rez;
691
		li_text = rez;
689
		IF(rez == 0) return;
692
		IF(rez == 0) return;
690
		TextGoDown(left1, top1, width1);
693
		TextGoDown(left1, top1, width1);
691
		IF(stroka > -1) && (stroka - 2 < lines_visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0);
694
		IF(stroka > -1) && (stroka - 2 < lines.visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0);
692
		return;
695
		return;
693
	}
696
	}
694
	////////////////////////////
697
	////////////////////////////
695
	IF(!chTag("u")) || (!chTag("ins")) u_text = rez;
698
	IF(!chTag("u")) || (!chTag("ins")) u_text = rez;
696
	IF(!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez;
699
	IF(!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez;
697
	IF(!chTag("ul")) || (!chTag("ol")) IF(!rez) {
700
	IF(!chTag("ul")) || (!chTag("ol")) IF(!rez) {
Line 744... Line 747...
744
				h=h-img_lines_first;
747
				h=h-img_lines_first;
745
				top1=WB1.top;
748
				top1=WB1.top;
746
			}
749
			}
747
			
750
			
Line 748... Line 751...
748
			if (top1>WB1.top+WB1.height-h-15) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó     IF (stroka - 2 < lines_visible)
751
			if (top1>WB1.top+WB1.height-h-15) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó     IF (stroka - 2 < lines.visible)
749
			{
752
			{
750
				h=WB1.top+WB1.height-top1-15;
753
				h=WB1.top+WB1.height-top1-15;
751
			}	
754
			}	
Line 752... Line 755...
752
 
755
 
Line 773... Line 776...
773
		if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
776
		if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
774
		{
777
		{
775
			strcpy(#options, #options[find_symbol(#options, '=')]); //ïîèñê â content=
778
			strcpy(#options, #options[find_symbol(#options, '=')]); //ïîèñê â content=
776
 
779
 
Line 777... Line 780...
777
			IF (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8"))
780
			if (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8"))		ReadHtml(_UTF);
778
			{
-
 
779
				ReadHtml();
-
 
780
				utf8rutodos(buf);
-
 
781
			}
-
 
782
			IF(!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))
781
			if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))	ReadHtml(_KOI);
783
			{
-
 
784
				ReadHtml();
-
 
785
				koitodos(buf);
-
 
786
			}
-
 
787
			IF(!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866"))
782
			if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866"))		ReadHtml(_DOS);
788
			{
-
 
789
				ReadHtml();
-
 
790
			}
-
 
791
		}
783
		}
792
		if (tagparam)
784
		if (tagparam)
793
		{
785
		{
794
			GetNextParam();
786
			GetNextParam();
795
			goto META;
787
			goto META;
Line 804... Line 796...
804
	stroka++;
796
	stroka++;
805
	IF(blq_text == 1) stolbec = 8;
797
	IF(blq_text == 1) stolbec = 8;
806
	ELSE stolbec = 0;
798
	ELSE stolbec = 0;
807
	IF(li_text == 1) stolbec = li_tab * 5;
799
	IF(li_text == 1) stolbec = li_tab * 5;
808
	IF(stroka >= 0) && (stroka - 2 < lines_visible)  && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
800
	IF(stroka >= 0) && (stroka - 2 < lines.visible)  && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
809
}
801
}
810
 
802
 
Line 811... Line 803...
811
 
803
 
812
//ñêðîëë
804
//ñêðîëë
813
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
805
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
814
{
806
{
815
	scroll1.max_area = lines_all;
807
	scroll1.max_area = lines.all;
816
	scroll1.cur_area = lines_visible;
808
	scroll1.cur_area = lines.visible;
Line 817... Line 809...
817
	scroll1.position = lines_first;
809
	scroll1.position = lines.first;
818
 
810
 
819
	scroll1.all_redraw=1;
811
	scroll1.all_redraw=1;