Subversion Repositories Kolibri OS

Rev

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

Rev 2844 Rev 2874
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.95";
10
char version[]=" Text-based Browser 0.96b";
Line 11... Line 11...
11
 
11
 
12
 
12
 
13
struct TWebBrowser {
13
struct TWebBrowser {
Line 44... Line 44...
44
char line[500],
44
char line[500],
45
	tag[100],
45
	tag[100],
46
	tagparam[10000],
46
	tagparam[10000],
47
	parametr[1200],
47
	parametr[1200],
48
	options[1000];
48
	options[4096];
Line 49... Line 49...
49
 
49
 
50
#include "include\history.h"
50
#include "include\history.h"
51
#include "include\colors.h"
51
#include "include\colors.h"
52
#include "include\unicode_tags.h"
52
#include "include\unicode_tags.h"
Line 81... Line 81...
81
		GetNewUrl();
81
		GetNewUrl();
Line 82... Line 82...
82
		
82
		
83
		if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
83
		if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
-
 
84
		{
84
		{
85
			//if (strstr(#URL,"http:")) 
85
			RunProgram("/sys/media/kiv", #URL);
86
			RunProgram("/sys/media/kiv", #URL);
86
			strcpy(#editURL, BrowserHistory.CurrentUrl());
87
			strcpy(#editURL, BrowserHistory.CurrentUrl());
87
			strcpy(#URL, BrowserHistory.CurrentUrl());
88
			strcpy(#URL, BrowserHistory.CurrentUrl());
88
			return;
89
			return;
-
 
90
		}
-
 
91
		if (!strcmpn(#URL,"mailto:", 7))
-
 
92
		{
-
 
93
			RunProgram("@notify", #URL);
-
 
94
			strcpy(#editURL, BrowserHistory.CurrentUrl());
-
 
95
			strcpy(#URL, BrowserHistory.CurrentUrl());
-
 
96
			return;
Line 89... Line 97...
89
		}
97
		}
90
 
98
 
91
		OpenPage();
99
		OpenPage();
Line 102... Line 110...
102
			break;
110
			break;
103
		case 021: //Ctrl+U
111
		case 021: //Ctrl+U
104
			ReadHtml(_UTF);
112
			ReadHtml(_UTF);
105
			break;
113
			break;
106
		case BACK:
114
		case 004: //Ctrl+D
-
 
115
			ReadHtml(_DOS);
-
 
116
			break;
-
 
117
		case 001:
-
 
118
			if (!pre_text) pre_text=2;
-
 
119
				else pre_text=0;
-
 
120
			break;
-
 
121
		case BACK:
107
			if (!BrowserHistory.GoBack()) return;
122
			if (!BrowserHistory.GoBack()) return;
108
			OpenPage();
123
			OpenPage();
109
			return;
124
			return;
110
		case FORWARD:
125
		case FORWARD:
111
			if (!BrowserHistory.GoForward()) return;
126
			if (!BrowserHistory.GoForward()) return;
Line 184... Line 199...
184
	ParseHTML(buf);
199
	ParseHTML(buf);
185
}
200
}
186
 
201
 
Line -... Line 202...
-
 
202
 
Line -... Line 203...
-
 
203
char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/rd/", "/fd/", "/bd/", "/hd/", "/cd/", "/tmp/", 0};
187
 
204
 
-
 
205
//dword TWebBrowser::GetNewUrl(dword CUR_URL, NEW_URL){
-
 
206
void TWebBrowser::GetNewUrl(){
-
 
207
	int i;
-
 
208
	
-
 
209
	for (i=0; ABSOLUTE_LINKS[i]; i++)
188
 
210
		if (!strcmpn(#URL, ABSOLUTE_LINKS[i], strlen(ABSOLUTE_LINKS[i]))) return;
-
 
211
		
Line 189... Line -...
189
void TWebBrowser::GetNewUrl(){
-
 
190
	IF (!strcmp(get_URL_part(2),"./")) strcpy(#URL, #URL+2); //èãíîðèì :)
-
 
191
	
-
 
192
	if (URL[0] <> '/')
212
	IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); //èãíîðèì :)
Line 193... Line 213...
193
	&& (strcmp(get_URL_part(5),"http:")<>0)	&& (strcmp(get_URL_part(5),"mailt")<>0)	&& (strcmp(get_URL_part(5),"ftp:/")<>0) 
213
	if (URL[0] == '/') strcpy(#URL, #URL+1);
Line 194... Line 214...
194
	{
214
 
195
		strcpy(#editURL, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
215
	strcpy(#editURL, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
196
		
216
		
197
		_CUT_ST_LEVEL_MARK:
217
	_CUT_ST_LEVEL_MARK:
Line 198... Line 218...
198
		
218
		
Line 208... Line 228...
208
			goto _CUT_ST_LEVEL_MARK;
228
			goto _CUT_ST_LEVEL_MARK;
209
		}
229
		}
210
		
230
		
Line 211... Line 231...
211
		if (editURL[strlen(#editURL)-1]<>'/') strcat(#editURL, "/"); 
231
		if (editURL[strlen(#editURL)-1]<>'/') strcat(#editURL, "/"); 
-
 
232
		
212
		strcat(#editURL, #URL); //êëåèì íîâûé àäðåñ
233
		strcat(#editURL, #URL); //êëåèì íîâûé àäðåñ
213
		strcpy(#URL, #editURL);
234
		strcpy(#URL, #editURL);
214
	}
235
}
215
}
-
 
Line 216... Line 236...
216
 
236
 
217
 
237
 
Line 245... Line 265...
245
	KillProcess(downloader_id);
265
	KillProcess(downloader_id);
246
	strcpy(#editURL, #URL);
266
	strcpy(#editURL, #URL);
247
	BrowserHistory.AddUrl();
267
	BrowserHistory.AddUrl();
248
	strcpy(#header, #version);
268
	strcpy(#header, #version);
249
	if (!strcmp(get_URL_part(5),"http:")))
269
	pre_text =0;
-
 
270
	if (!strcmp(get_URL_part(5),"http:")))
250
	{
271
	{
251
		KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
272
		KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
252
		DeleteFile(#download_path);
273
		DeleteFile(#download_path);
253
		IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]='';
274
		IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]='';
254
		downloader_id = RunProgram("/sys/network/downloader", #URL);
275
		downloader_id = RunProgram("/sys/network/downloader", #URL);
Line 273... Line 294...
273
 
294
 
274
void TWebBrowser::ShowPage()
295
void TWebBrowser::ShowPage()
275
{
296
{
-
 
297
	edit1.size = edit1.pos = strlen(#editURL);
276
	edit1.size = edit1.pos = strlen(#editURL);
298
	edit1.offset=0;
Line 277... Line 299...
277
	edit_box_draw stdcall(#edit1); //ðèñóåì ñòðîêó àäðåñà
299
	edit_box_draw stdcall(#edit1); //ðèñóåì ñòðîêó àäðåñà
278
	
300
	
279
	if (!filesize)
301
	if (!filesize)
Line 307... Line 329...
307
	
329
	
Line 308... Line 330...
308
	for (j = 400; j < blink + 1; j++;) DeleteButton(j);
330
	for (j = 400; j < blink + 1; j++;) DeleteButton(j);
309
	blink = 400;
331
	blink = 400;
Line 310... Line 332...
310
 
332
 
311
	b_text = i_text = u_text = s_text = pre_text = blq_text = first_line_drawed =
333
	b_text = i_text = u_text = s_text = blq_text = first_line_drawed =
312
	li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
334
	li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
313
	link_color = 0x0000FF;
335
	link_color = 0x0000FF;
314
	bg_color = 0xFFFFFF;
336
	bg_color = 0xFFFFFF;
315
	line = '';
337
	line = '';
316
	strcpy(#page_links,"|");
338
	strcpy(#page_links,"|");
Line -... Line 339...
-
 
339
	strcpy(#header, #version);
-
 
340
 
-
 
341
	if (pre_text<>2)
317
	strcpy(#header, #version);
342
	{
318
 
343
		pre_text=0;
319
	if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
344
		if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
320
	if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
-
 
Line 321... Line 345...
321
	
345
		if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
322
	debug("Start parsing");
346
	}
323
	
347
	
324
	for ( ; buf+filesize > bword; bword++;)
348
	for ( ; buf+filesize > bword; bword++;)
Line 460... Line 484...
460
		DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color);
484
		DrawBar(left, lines.visible * 10 + top + 25, width - 15, -lines.visible * 10 + height - 25, bg_color);
461
	if (stroka * 10 + 15 <= height)
485
	if (stroka * 10 + 15 <= height)
462
		DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
486
		DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
463
	if (lines.first == 0) lines.all = stroka;
487
	if (lines.first == 0) lines.all = stroka;
464
	debug ("Pre end - anchor");
488
	if (anchor)
465
	if (anchor)
-
 
466
	{
489
	{
467
		//åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
490
		//åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
468
		anchor='';
491
		anchor='';
469
		lines.first=anchor_line_num;
492
		lines.first=anchor_line_num;
470
		ParseHTML(buf);
493
		ParseHTML(buf);
471
	}
494
	}
472
	debug("End parsing");
495
 
473
 
-
 
Line 474... Line 496...
474
	DrawScroller();
496
	DrawScroller();
475
}
497
}
Line 476... Line 498...
476
 
498
 
Line 485... Line 507...
485
		{
507
		{
486
			//line = 123456789
508
			//line = 123456789
487
			//header = 1234
509
			//header = 1234
488
			//line = 56789
510
			//line = 56789
489
			debug("too long header");
511
			strcpy(#temp, #line);
490
			strcpy(#temp, #line);
-
 
491
			temp[sizeof(header)-strlen(#version)-2]=0;
512
			temp[sizeof(header)-strlen(#version)-2]=0;
492
			strcpy(#header, #temp);
513
			strcpy(#header, #temp);
493
			strcpy(#line, #line+strlen(#temp));
514
			strcpy(#line, #line+strlen(#temp));
494
		}
515
		}
495
		else
516
		else
496
		{
517
		{
497
			debug("normal header");
518
			strcpy(#header, #line);
498
			strcpy(#header, #line);
-
 
499
			line=0;
519
			line=0;
500
		}
520
		}
501
			
521
			
Line 502... Line 522...
502
		strcat(#header, " -");
522
		strcat(#header, " -");
Line 610... Line 630...
610
	if (!chTag("a"))
630
	if (!chTag("a"))
611
	{
631
	{
612
		if (rez)
632
		if (rez)
613
		{
633
		{
614
			text_color_index++;
-
 
-
 
634
			 
615
			text_colors[text_color_index] = text_colors[text_color_index-1];
635
			if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
Line 616... Line 636...
616
 
636
 
617
			_A_MARK:
637
			_A_MARK:
618
			if (!strcmp(#parametr, "href="))
638
			if (!strcmp(#parametr, "href="))
619
			{
639
			{
-
 
640
				if (stroka - 1 > lines.visible) || (stroka < -2) return;
-
 
641
				
620
				if (stroka - 1 > lines.visible) || (stroka < -2) return;
642
				text_color_index++;
-
 
643
				text_colors[text_color_index] = text_colors[text_color_index-1];
621
				if (link) && (text_color_index > 0) text_color_index--; //åñëè íå çàêðûò òýã
644
				
622
				link = 1;
645
				link = 1;
623
				blink++;
646
				blink++;
624
				text_colors[text_color_index] = link_color;
647
				text_colors[text_color_index] = link_color;
625
				strcat(#page_links, #options);
648
				strcat(#page_links, #options);
Line 743... Line 766...
743
		//if (GetFileInfo(#libimg)<>0) return;  //åñëè áèáëèîòåêè íåò
766
		//if (GetFileInfo(#libimg)<>0) return;  //åñëè áèáëèîòåêè íåò
744
		IMG_TAG:
767
		IMG_TAG:
745
			if (!strcmp(#parametr,"src="))   //íàäî îáúåäèíèòü ñ GetNewUrl()
768
			if (!strcmp(#parametr,"src="))   //íàäî îáúåäèíèòü ñ GetNewUrl()
746
			{
769
			{
747
				strcpy(#temp, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
770
				if (!strcmpn(#URL, "http:", 5)) || (!strcmpn(#options, "http:", 5)) return;
-
 
771
				strcpy(#temp, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
748
				temp[strrchr(#temp, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
772
				temp[strrchr(#temp, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
749
				strcat(#temp, #options);
773
				strcat(#temp, #options);
750
				image=load_image(#temp);
774
				image=load_image(#temp);
751
				w=DSWORD[image+4];
775
				w=DSWORD[image+4];
752
				h=DSWORD[image+8];
776
				h=DSWORD[image+8];