Subversion Repositories Kolibri OS

Rev

Rev 3992 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3992 Rev 4026
1
int	downloader_id;
1
int	downloader_id;
2
 
2
 
3
dword
3
dword
4
	buf,
4
	buf,
5
	filesize,
5
	filesize,
6
	blink;
6
	blink;
7
 
7
 
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
 
10
 
11
#ifndef AUTOBUILD
-
 
12
	#include "lang.h--"
-
 
13
#endif
-
 
14
 
-
 
15
#ifdef LANG_RUS
-
 
16
	char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.07";
-
 
17
#else
-
 
18
	char version[]=" Text-based Browser 0.99.07";
-
 
19
#endif
-
 
20
 
-
 
21
 
-
 
22
 
-
 
23
 
11
 
24
struct TWebBrowser {
12
struct TWebBrowser {
25
	int left, top, width, height, line_h;
13
	int left, top, width, height, line_h;
26
	void Scan(int);
14
	void Scan(int);
27
	void GetNewUrl();
15
	void GetNewUrl();
28
	void OpenPage();
16
	void OpenPage();
29
	void ReadHtml(byte);
17
	void ReadHtml(byte);
30
	void ShowPage();
18
	void ShowPage();
31
	void ParseHTML(dword);
19
	void ParseHTML(dword);
32
	void WhatTextStyle(int left1, top1, width1);
20
	void WhatTextStyle(int left1, top1, width1);
33
	void DrawPage();
21
	void DrawPage();
34
	void DrawScroller();
22
	void DrawScroller();
35
};	
23
};	
36
TWebBrowser WB1;
24
TWebBrowser WB1;
37
 
25
 
38
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text,
26
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text,
39
	link, ignor_text, li_tab, cur_encoding;
27
	link, ignor_text, li_tab, cur_encoding;
40
 
28
 
41
dword text_colors[300],
29
dword text_colors[300],
42
	text_color_index,
30
	text_color_index,
43
	link_color,
31
	link_color,
44
	bg_color;
32
	bg_color;
45
 
33
 
46
int stroka,
34
int stroka,
47
	stolbec,
35
	stolbec,
48
	tab_len,
36
	tab_len,
49
	anchor_line_num;
37
	anchor_line_num;
50
	
38
	
51
char line[500],
39
char line[500],
52
	tag[100],
40
	tag[100],
53
	tagparam[10000],
41
	tagparam[10000],
54
	parametr[1200],
42
	parametr[1200],
55
	options[4096],
43
	options[4096],
56
	anchor[256];
44
	anchor[256];
57
 
45
 
58
#include "include\history.h"
46
#include "include\history.h"
59
#include "include\colors.h"
47
#include "include\colors.h"
60
#include "include\unicode_tags.h"
48
#include "include\unicode_tags.h"
61
#include "include\img_cache.h"
49
#include "include\img_cache.h"
62
#include "include\some_code.h"
50
#include "include\some_code.h"
63
#include "include\parce_tag.h"
51
#include "include\parce_tag.h"
64
 
52
 
65
//=======================================================================
53
//=======================================================================
66
dword drawbuf;
54
dword drawbuf;
67
void DrawBufInit()
55
void DrawBufInit()
68
{
56
{
69
	free(drawbuf);
57
	free(drawbuf);
70
	drawbuf = malloc(WB1.width * WB1.line_h +4 * 4 + 8); //+1 for good luck
58
	drawbuf = malloc(WB1.width * WB1.line_h +4 * 4 + 8); //+1 for good luck
71
	ESDWORD[drawbuf] = WB1.width;
59
	ESDWORD[drawbuf] = WB1.width;
72
	ESDWORD[drawbuf+4] = WB1.line_h;
60
	ESDWORD[drawbuf+4] = WB1.line_h;
73
}
61
}
74
void DrawBufFill()
62
void DrawBufFill()
75
{
63
{
76
	int i;
64
	int i;
77
	for (i=0; i
65
	for (i=0; i
78
}
66
}
79
void DrawBufBar(dword x, y, w, h, color)
67
void DrawBufBar(dword x, y, w, h, color)
80
{
68
{
81
	int i, j;
69
	int i, j;
82
	for (j=0; j
70
	for (j=0; j
83
	{
71
	{
84
		for (i = y+j*WB1.width+x*4; i
72
		for (i = y+j*WB1.width+x*4; i
85
	}
73
	}
86
}
74
}
87
 
75
 
88
char shift[]={8,8,4,4};
76
char shift[]={8,8,4,4};
89
void DrawBufSkew(dword x, y, w, h)
77
void DrawBufSkew(dword x, y, w, h)
90
{
78
{
91
	int i, j;
79
	int i, j;
92
	stolbec++;
80
	stolbec++;
93
	for (j=0; j<=3; j++)
81
	for (j=0; j<=3; j++)
94
	{
82
	{
95
		for (i = y+j*WB1.width+x+w+h*4; i>y+j*WB1.width+x+h-12*4 ; i-=4)
83
		for (i = y+j*WB1.width+x+w+h*4; i>y+j*WB1.width+x+h-12*4 ; i-=4)
96
								ESDWORD[drawbuf+i+8] = ESDWORD[-shift[j]+drawbuf+i+8];
84
								ESDWORD[drawbuf+i+8] = ESDWORD[-shift[j]+drawbuf+i+8];
97
	}
85
	}
98
}
86
}
99
 
87
 
100
void TextGoDown(int left1, top1, width1)
88
void TextGoDown(int left1, top1, width1)
101
{
89
{
102
	if (!stroka) DrawBar(WB1.left, WB1.top, WB1.width, 5, bg_color); //çàêðàøèâàåì ôîí íàä ïåðâîé ñòðîêîé
90
	if (!stroka) DrawBar(WB1.left, WB1.top, WB1.width, 5, bg_color); //çàêðàøèâàåì ôîí íàä ïåðâîé ñòðîêîé
103
	stroka++;
91
	stroka++;
104
	if (blq_text) stolbec = 8; else stolbec = 0;
92
	if (blq_text) stolbec = 8; else stolbec = 0;
105
	if (li_text) stolbec = li_tab * 5;
93
	if (li_text) stolbec = li_tab * 5;
106
	if (top1>=WB1.top) && ( top1 < WB1.height+WB1.top-10)  && (!anchor)
94
	if (top1>=WB1.top) && ( top1 < WB1.height+WB1.top-10)  && (!anchor)
107
	{
95
	{
108
		PutPaletteImage(drawbuf+8, WB1.width, WB1.line_h, left1-5, top1, 32,0);
96
		PutPaletteImage(drawbuf+8, WB1.width, WB1.line_h, left1-5, top1, 32,0);
109
		DrawBufFill();
97
		DrawBufFill();
110
	}
98
	}
111
}
99
}
112
 
100
 
113
void TWebBrowser::DrawPage()
101
void TWebBrowser::DrawPage()
114
{
102
{
115
	int start_x, start_y, line_length, magrin_left=5;
103
	int start_x, start_y, line_length, magrin_left=5;
116
	
104
	
117
	if (!header)
105
	if (!header)
118
	{
106
	{
119
		strcpy(#header, #line);
107
		strcpy(#header, #line);
120
		strcat(#header, " -");
108
		strcat(#header, " -");
121
		strcat(#header, #version);
109
		strcat(#header, #version);
122
		line = 0;
110
		line = 0;
123
		return;
111
		return;
124
	}
112
	}
125
	
113
	
126
	if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor)
114
	if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor)
127
	{
115
	{
128
		start_x = stolbec * 6 + left + magrin_left;
116
		start_x = stolbec * 6 + left + magrin_left;
129
		start_y = stroka * 10 + top + magrin_left;
117
		start_y = stroka * 10 + top + magrin_left;
130
		line_length = strlen(#line) * 6;
118
		line_length = strlen(#line) * 6;
131
 
119
 
132
		if (use_truetype == 1)
-
 
133
		{
-
 
134
			//line_length =  get_length stdcall (#line,-1,16,line_length);
-
 
135
			text_out stdcall (#line, #fontlol, 17, text_colors[text_color_index], start_x, start_y-3);
-
 
136
		}
-
 
137
		else
-
 
138
		{
-
 
139
			WriteBufText(start_x, 0, 0x88, text_colors[text_color_index], #line, drawbuf);
120
		WriteBufText(start_x, 0, 0x88, text_colors[text_color_index], #line, drawbuf);
140
		}
-
 
141
		IF (b_text)	WriteBufText(start_x+1, 0, 0x88, text_colors[text_color_index], #line, drawbuf);
121
		IF (b_text)	WriteBufText(start_x+1, 0, 0x88, text_colors[text_color_index], #line, drawbuf);
142
		IF (i_text) DrawBufSkew(start_x, 0, line_length, line_h);
122
		IF (i_text) DrawBufSkew(start_x, 0, line_length, line_h);
143
		IF (s_text) DrawBufBar(start_x, 4, line_length, 1, text_colors[text_color_index]);
123
		IF (s_text) DrawBufBar(start_x, 4, line_length, 1, text_colors[text_color_index]);
144
		IF (u_text) DrawBufBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
124
		IF (u_text) DrawBufBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
145
		IF (link) {
125
		IF (link) {
146
			UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9);
126
			UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9);
147
			DrawBufBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
127
			DrawBufBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
148
		}
128
		}
149
		stolbec += strlen(#line);
129
		stolbec += strlen(#line);
150
	}
130
	}
151
}
131
}
152
//=======================================================================
132
//=======================================================================
153
 
133
 
154
void TWebBrowser::Scan(int id)
134
void TWebBrowser::Scan(int id)
155
{
135
{
156
	if (id >= 400)
136
	if (id >= 400)
157
	{
137
	{
158
		GetURLfromPageLinks(id);
138
		GetURLfromPageLinks(id);
159
		
139
		
160
		//#1
140
		//#1
161
		if (URL[0] == '#')
141
		if (URL[0] == '#')
162
		{
142
		{
163
			strcpy(#anchor, #URL+strrchr(#URL, '#'));
143
			strcpy(#anchor, #URL+strrchr(#URL, '#'));
164
			
144
			
165
			strcpy(#URL, BrowserHistory.CurrentUrl());
145
			strcpy(#URL, BrowserHistory.CurrentUrl());
166
			
146
			
167
			lines.first=lines.all-lines.visible;
147
			lines.first=lines.all-lines.visible;
168
			ShowPage();
148
			ShowPage();
169
			return;
149
			return;
170
		}
150
		}
171
		//liner.ru#1
151
		//liner.ru#1
172
		if (strrchr(#URL, '#')<>-1)
152
		if (strrchr(#URL, '#')<>-1)
173
		{
153
		{
174
			strcpy(#anchor, #URL+strrchr(#URL, '#'));
154
			strcpy(#anchor, #URL+strrchr(#URL, '#'));
175
			URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà
155
			URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà
176
		}
156
		}
177
		
157
		
178
		GetNewUrl();
158
		GetNewUrl();
179
		
159
		
180
		if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
160
		if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
181
		{
161
		{
182
			//if (strstr(#URL,"http:")) 
162
			//if (strstr(#URL,"http:")) 
183
			RunProgram("/sys/media/kiv", #URL);
163
			RunProgram("/sys/media/kiv", #URL);
184
			strcpy(#editURL, BrowserHistory.CurrentUrl());
164
			strcpy(#editURL, BrowserHistory.CurrentUrl());
185
			strcpy(#URL, BrowserHistory.CurrentUrl());
165
			strcpy(#URL, BrowserHistory.CurrentUrl());
186
			return;
166
			return;
187
		}
167
		}
188
		if (!strcmpn(#URL,"mailto:", 7))
168
		if (!strcmpn(#URL,"mailto:", 7))
189
		{
169
		{
190
			RunProgram("@notify", #URL);
170
			RunProgram("@notify", #URL);
191
			strcpy(#editURL, BrowserHistory.CurrentUrl());
171
			strcpy(#editURL, BrowserHistory.CurrentUrl());
192
			strcpy(#URL, BrowserHistory.CurrentUrl());
172
			strcpy(#URL, BrowserHistory.CurrentUrl());
193
			return;
173
			return;
194
		}
174
		}
195
 
175
 
196
		OpenPage();
176
		OpenPage();
197
		return;
177
		return;
198
	}
178
	}
199
	
179
	
200
	IF(lines.all < lines.visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
180
	IF(lines.all < lines.visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
201
	{ CASE 183: CASE 184: CASE 180: CASE 181: return; } 
181
	{ CASE 183: CASE 184: CASE 180: CASE 181: return; } 
202
	
182
	
203
	switch (id)
183
	switch (id)
204
	{
184
	{
205
		case 011: //Ctrk+K 
185
		case 011: //Ctrk+K 
206
			ReadHtml(_KOI);
186
			ReadHtml(_KOI);
207
			break;
187
			break;
208
		case 021: //Ctrl+U
188
		case 021: //Ctrl+U
209
			ReadHtml(_UTF);
189
			ReadHtml(_UTF);
210
			break;
190
			break;
211
		case 004: //Ctrl+D
191
		case 004: //Ctrl+D
212
			ReadHtml(_DOS);
192
			ReadHtml(_DOS);
213
			break;
193
			break;
214
		case 002: //free img cache
194
		case 002: //free img cache
215
			FreeImgCache();
195
			FreeImgCache();
216
			break;			
196
			break;			
217
		case 005: //truetype
197
		case BACK:
218
			if (use_truetype == 2) 
-
 
219
			{
-
 
220
				RunProgram("@notify", "Library does not exists /rd/1/lib/truetype.obj"w);
-
 
221
				return;
-
 
222
			}
-
 
223
			if (use_truetype == 1) use_truetype=0; else use_truetype=1;
-
 
224
			break;
-
 
225
		case BACK:
-
 
226
			if (!BrowserHistory.GoBack()) return;
198
			if (!BrowserHistory.GoBack()) return;
227
			OpenPage();
199
			OpenPage();
228
			return;
200
			return;
229
		case FORWARD:
201
		case FORWARD:
230
			if (!BrowserHistory.GoForward()) return;
202
			if (!BrowserHistory.GoForward()) return;
231
			OpenPage();
203
			OpenPage();
232
			return;
204
			return;
233
		case 052:  //F3
205
		case 052:  //F3
234
			if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL); else RunProgram("/rd/1/tinypad", #download_path);
206
			if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL); else RunProgram("/rd/1/tinypad", #download_path);
235
			return;
207
			return;
236
		case 054: //F5
208
		case 054: //F5
237
			IF(address_box.flags & 0b10) break;
209
			IF(address_box.flags & 0b10) break;
238
		case REFRESH:
210
		case REFRESH:
239
			if (GetProcessSlot(downloader_id)<>0)
211
			if (GetProcessSlot(downloader_id)<>0)
240
			{
212
			{
241
				KillProcess(downloader_id);
213
				KillProcess(downloader_id);
242
				pause(20);
214
				pause(20);
243
				Draw_Window();
215
				Draw_Window();
244
				return;
216
				return;
245
			}
217
			}
246
			anchor_line_num=lines.first; //âåñ¸ëûé êîñòûëü :Ð
218
			anchor_line_num=lines.first; //âåñ¸ëûé êîñòûëü :Ð
247
			anchor[0]='|';
219
			anchor[0]='|';
248
			OpenPage();
220
			OpenPage();
249
			return;
221
			return;
250
		case 014: //Ctrl+N íîâîå îêíî
222
		case 014: //Ctrl+N íîâîå îêíî
251
		case 020: //Ctrl+T íîâàÿ âêëàäêà
223
		case 020: //Ctrl+T íîâàÿ âêëàäêà
252
		case NEWTAB:
224
		case NEWTAB:
253
			MoveSize(190,80,OLD,OLD);
225
			MoveSize(190,80,OLD,OLD);
254
			RunProgram(#program_path, #URL);
226
			RunProgram(#program_path, #URL);
255
			return;
227
			return;
256
			
228
			
257
		case HOME:
229
		case HOME:
258
			strcpy(#editURL, "http://kolibrios.org/en/index.htm");
230
			strcpy(#editURL, "http://kolibrios.org/en/index.htm");
259
		case GOTOURL:
231
		case GOTOURL:
260
		case 0x0D: //enter
232
		case 0x0D: //enter
261
			//ïî÷åìó ttp://? Ãîñïîäà, îòëè÷íûé âîïðîñ. Äåëî â òîì, ÷òî ýòî õàê. 
233
			//ïî÷åìó ttp://? Ãîñïîäà, îòëè÷íûé âîïðîñ. Äåëî â òîì, ÷òî ýòî õàê. 
262
			//strstr() åñëè íå íàøëî âîçâðàùàåò 0 è â ñëó÷àå óñïåõà âîçâðàùàåò 0. Òàê ÷òî ýòî õàê.
234
			//strstr() åñëè íå íàøëî âîçâðàùàåò 0 è â ñëó÷àå óñïåõà âîçâðàùàåò 0. Òàê ÷òî ýòî õàê.
263
			if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0;
235
			if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0;
264
			strcat(#URL, #editURL);
236
			strcat(#URL, #editURL);
265
			OpenPage();
237
			OpenPage();
266
			return;
238
			return;
267
		case SEARCHWEB:
239
		case SEARCHWEB:
268
			strcpy(#URL, #search_path);
240
			strcpy(#URL, #search_path);
269
			strcat(#URL, #editURL);
241
			strcat(#URL, #editURL);
270
			OpenPage();
242
			OpenPage();
271
			return;
243
			return;
272
 
244
 
273
		case ID1: //ìîòàåì ââåðõ
245
		case ID1: //ìîòàåì ââåðõ
274
			IF(lines.first <= 0) return;
246
			IF(lines.first <= 0) return;
275
			lines.first--;
247
			lines.first--;
276
			break; 
248
			break; 
277
		case ID2: //ìîòàåì âíèç
249
		case ID2: //ìîòàåì âíèç
278
			IF(lines.visible + lines.first >= lines.all) return;
250
			IF(lines.visible + lines.first >= lines.all) return;
279
			lines.first++;
251
			lines.first++;
280
			break; 
252
			break; 
281
		case 183: //PgDown
253
		case 183: //PgDown
282
			IF(lines.first == lines.all - lines.visible) return;
254
			IF(lines.first == lines.all - lines.visible) return;
283
			lines.first += lines.visible + 2;
255
			lines.first += lines.visible + 2;
284
			IF(lines.visible + lines.first > lines.all) lines.first = lines.all - lines.visible;
256
			IF(lines.visible + lines.first > lines.all) lines.first = lines.all - lines.visible;
285
			break;
257
			break;
286
		case 184: //PgUp
258
		case 184: //PgUp
287
			IF(lines.first == 0) return;
259
			IF(lines.first == 0) return;
288
			lines.first -= lines.visible - 2;
260
			lines.first -= lines.visible - 2;
289
			IF(lines.first < 0) lines.first = 0;
261
			IF(lines.first < 0) lines.first = 0;
290
			break;
262
			break;
291
		case 180: //home
263
		case 180: //home
292
			IF(lines.first == 0) return;
264
			IF(lines.first == 0) return;
293
			lines.first = 0;
265
			lines.first = 0;
294
			break; 
266
			break; 
295
		case 181: //end
267
		case 181: //end
296
			IF (lines.first == lines.all - lines.visible) return;
268
			IF (lines.first == lines.all - lines.visible) return;
297
			lines.first = lines.all - lines.visible;
269
			lines.first = lines.all - lines.visible;
298
			break; 
270
			break; 
299
		default:
271
		default:
300
			return;
272
			return;
301
	}
273
	}
302
	ParseHTML(buf);
274
	ParseHTML(buf);
303
}
275
}
304
 
276
 
305
 
277
 
306
char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", 0};
278
char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", 0};
307
//dword TWebBrowser::GetNewUrl(dword CUR_URL, NEW_URL){
279
//dword TWebBrowser::GetNewUrl(dword CUR_URL, NEW_URL){
308
void TWebBrowser::GetNewUrl(){
280
void TWebBrowser::GetNewUrl(){
309
	int i, len;
281
	int i, len;
310
	
282
	
311
	for (i=0; ABSOLUTE_LINKS[i]; i++)
283
	for (i=0; ABSOLUTE_LINKS[i]; i++)
312
	{
284
	{
313
		len=strlen(ABSOLUTE_LINKS[i]);
285
		len=strlen(ABSOLUTE_LINKS[i]);
314
		if (!strcmpn(#URL, ABSOLUTE_LINKS[i], len)) return;
286
		if (!strcmpn(#URL, ABSOLUTE_LINKS[i], len)) return;
315
	}
287
	}
316
		
288
		
317
	IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); //èãíîðèì :)
289
	IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); //èãíîðèì :)
318
	strcpy(#editURL, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
290
	strcpy(#editURL, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
319
 
291
 
320
	if (URL[0] == '/')
292
	if (URL[0] == '/')
321
	{
293
	{
322
		i = strchr(#editURL+8, '/');
294
		i = strchr(#editURL+8, '/');
323
		editURL[i+7]=0;
295
		editURL[i+7]=0;
324
		strcpy(#URL, #URL+1);
296
		strcpy(#URL, #URL+1);
325
	}
297
	}
326
		
298
		
327
	_CUT_ST_LEVEL_MARK:
299
	_CUT_ST_LEVEL_MARK:
328
		
300
		
329
		if (editURL[strrchr(#editURL, '/')-2]<>'/')  // åñëè íå http://
301
		if (editURL[strrchr(#editURL, '/')-2]<>'/')  // åñëè íå http://
330
		{
302
		{
331
			editURL[strrchr(#editURL, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
303
			editURL[strrchr(#editURL, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
332
		}
304
		}
333
		
305
		
334
		IF (!strcmp(get_URL_part(3),"../")) //íà óðîâåíü ââåðõ
306
		IF (!strcmp(get_URL_part(3),"../")) //íà óðîâåíü ââåðõ
335
		{
307
		{
336
			strcpy(#URL,#URL+3);
308
			strcpy(#URL,#URL+3);
337
			editURL[strrchr(#editURL, '/')-1] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
309
			editURL[strrchr(#editURL, '/')-1] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
338
			goto _CUT_ST_LEVEL_MARK;
310
			goto _CUT_ST_LEVEL_MARK;
339
		}
311
		}
340
		
312
		
341
		if (editURL[strlen(#editURL)-1]<>'/') strcat(#editURL, "/"); 
313
		if (editURL[strlen(#editURL)-1]<>'/') strcat(#editURL, "/"); 
342
		
314
		
343
		strcat(#editURL, #URL); //êëåèì íîâûé àäðåñ
315
		strcat(#editURL, #URL); //êëåèì íîâûé àäðåñ
344
		strcpy(#URL, #editURL);
316
		strcpy(#URL, #editURL);
345
}
317
}
346
 
318
 
347
 
319
 
348
	
320
	
349
void TWebBrowser::ReadHtml(byte encoding)
321
void TWebBrowser::ReadHtml(byte encoding)
350
{
322
{
351
	if (!strcmp(get_URL_part(5),"http:"))) 
323
	if (!strcmp(get_URL_part(5),"http:"))) 
352
		file_size stdcall (#download_path);
324
		file_size stdcall (#download_path);
353
	else
325
	else
354
		file_size stdcall (#URL);
326
		file_size stdcall (#URL);
355
	
327
	
356
	filesize = EBX;
328
	filesize = EBX;
357
	if (!filesize) return;
329
	if (!filesize) return;
358
	
330
	
359
	mem_Free(buf);
331
	mem_Free(buf);
360
	buf = mem_Alloc(filesize);
332
	buf = mem_Alloc(filesize);
361
	if (!strcmp(get_URL_part(5),"http:"))) 
333
	if (!strcmp(get_URL_part(5),"http:"))) 
362
		ReadFile(0, filesize, buf, #download_path);
334
		ReadFile(0, filesize, buf, #download_path);
363
	else
335
	else
364
		ReadFile(0, filesize, buf, #URL);
336
		ReadFile(0, filesize, buf, #URL);
365
		
337
		
366
	cur_encoding = encoding;
338
	cur_encoding = encoding;
367
	if (encoding==_WIN) wintodos(buf);
339
	if (encoding==_WIN) wintodos(buf);
368
	if (encoding==_UTF) utf8rutodos(buf);
340
	if (encoding==_UTF) utf8rutodos(buf);
369
	if (encoding==_KOI) koitodos(buf);
341
	if (encoding==_KOI) koitodos(buf);
370
}
342
}
371
 
343
 
372
 
344
 
373
void TWebBrowser::OpenPage()
345
void TWebBrowser::OpenPage()
374
{
346
{
375
	if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
347
	if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
376
	KillProcess(downloader_id);
348
	KillProcess(downloader_id);
377
	strcpy(#editURL, #URL);
349
	strcpy(#editURL, #URL);
378
	BrowserHistory.AddUrl();
350
	BrowserHistory.AddUrl();
379
	strcpy(#header, #version);
351
	strcpy(#header, #version);
380
	pre_text =0;
352
	pre_text =0;
381
	if (!strcmp(get_URL_part(5),"http:")))
353
	if (!strcmp(get_URL_part(5),"http:")))
382
	{
354
	{
383
		KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
355
		KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
384
		DeleteFile(#download_path);
356
		DeleteFile(#download_path);
385
		IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=NULL;
357
		IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=NULL;
386
		downloader_id = RunProgram("/sys/network/downloader", #URL);
358
		downloader_id = RunProgram("/sys/network/downloader", #URL);
387
		//Browser Hack v2.0
359
		//Browser Hack v2.0
388
		/*
360
		/*
389
		pause(60);
361
		pause(60);
390
		if (GetProcessSlot(downloader_id)<>0)
362
		if (GetProcessSlot(downloader_id)<>0)
391
		{
363
		{
392
			debug("Browser Hack v2.0: Killing downloader and trying to run it one more!");
364
			debug("Browser Hack v2.0: Killing downloader and trying to run it one more!");
393
			KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
365
			KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
394
			downloader_id = RunProgram("/sys/network/downloader", #URL);
366
			downloader_id = RunProgram("/sys/network/downloader", #URL);
395
		}
367
		}
396
		*/
368
		*/
397
		IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable.");
369
		IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable.");
398
		Draw_Window();
370
		Draw_Window();
399
		return;
371
		return;
400
	}
372
	}
401
	lines.first = lines.all =0;
373
	lines.first = lines.all =0;
402
	ReadHtml(_WIN);
374
	ReadHtml(_WIN);
403
	WB1.ShowPage();
375
	WB1.ShowPage();
404
}
376
}
405
 
377
 
406
 
378
 
407
void TWebBrowser::ShowPage()
379
void TWebBrowser::ShowPage()
408
{
380
{
409
	address_box.size = address_box.pos = strlen(#editURL);
381
	address_box.size = address_box.pos = strlen(#editURL);
410
	address_box.offset=0;
382
	address_box.offset=0;
411
	edit_box_draw stdcall(#address_box);
383
	edit_box_draw stdcall(#address_box);
412
 
384
 
413
	if (!filesize)
385
	if (!filesize)
414
	{
386
	{
415
		DrawBar(left, top, width+scroll1.size_x+1, height, 0xFFFFFF); //fill all
387
		DrawBar(left, top, width+scroll1.size_x+1, height, 0xFFFFFF); //fill all
416
		if (GetProcessSlot(downloader_id)<>0) WriteText(left + 10, top + 18, 0x80, 0, "Loading...");
388
		if (GetProcessSlot(downloader_id)<>0) WriteText(left + 10, top + 18, 0x80, 0, "Loading...");
417
		else
389
		else
418
		{
390
		{
419
			WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.");
391
			WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.");
420
			if (!strcmp(get_URL_part(5),"http:"))) WriteText(left + 10, top + 32, 0x80, 0, "Or Internet unavilable for your configuration.");
392
			if (!strcmp(get_URL_part(5),"http:"))) WriteText(left + 10, top + 32, 0x80, 0, "Or Internet unavilable for your configuration.");
421
		}
393
		}
422
		//return;
394
		//return;
423
	}
395
	}
424
	else
396
	else
425
		ParseHTML(buf);
397
		ParseHTML(buf);
426
 
398
 
427
	if (!header) strcpy(#header, #version);
399
	if (!header) strcpy(#header, #version);
428
	if (!strcmp(#version, #header)) DrawTitle(#header);
400
	if (!strcmp(#version, #header)) DrawTitle(#header);
429
}
401
}
430
 
402
 
431
 
403
 
432
 
404
 
433
void TWebBrowser::ParseHTML(dword bword){
405
void TWebBrowser::ParseHTML(dword bword){
434
	word bukva[2];
406
	word bukva[2];
435
	int j, perenos_num;
407
	int j, perenos_num;
436
	byte ignor_param;
408
	byte ignor_param;
437
	char temp[768];
409
	char temp[768];
438
	
410
	
439
	if (blink<400) blink=400; else for ( ; blink>400; blink--;) DeleteButton(blink);
411
	if (blink<400) blink=400; else for ( ; blink>400; blink--;) DeleteButton(blink);
440
	b_text = i_text = u_text = s_text = blq_text = 
412
	b_text = i_text = u_text = s_text = blq_text = 
441
	li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
413
	li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
442
	link_color = 0x0000FF;
414
	link_color = 0x0000FF;
443
	bg_color = 0xFFFFFF;
415
	bg_color = 0xFFFFFF;
444
	DrawBufFill();
416
	DrawBufFill();
445
	line = NULL;
417
	strcpy(#page_links,"|");
446
	strcpy(#page_links,"|");
-
 
447
	strcpy(#header, #version);
418
	strcpy(#header, #version);
448
	stroka = -lines.first;
419
	stroka = -lines.first;
449
	stolbec = 0;
420
	stolbec = 0;
450
 
421
	line = 0;
-
 
422
 
451
	if (pre_text<>2)
423
	if (pre_text<>2)
452
	{
424
	{
453
		pre_text=0;
425
		pre_text=0;
454
		if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
426
		if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
455
		if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
427
		if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
456
	}
428
	}
457
	
429
	
458
	for ( ; buf+filesize > bword; bword++;)
430
	for ( ; buf+filesize > bword; bword++;)
459
	{
431
	{
460
		bukva = ESBYTE[bword];
432
		bukva = ESBYTE[bword];
461
		if (ignor_text) && (bukva<>'<') continue;
433
		if (ignor_text) && (bukva<>'<') continue;
462
		switch (bukva)
434
		switch (bukva)
463
		{
435
		{
464
		case 0x0a:
436
		case 0x0a:
465
			if (pre_text)
437
			if (pre_text)
466
			{
438
			{
467
				bukva = temp = NULL;
439
				bukva = temp = NULL;
468
				goto NEXT_MARK;
440
				goto NEXT_MARK;
469
			}
441
			}
470
		case '\9':
442
		case '\9':
471
			if (pre_text) //èíà÷å èä¸ì íà 0x0d	
443
			if (pre_text) //èíà÷å èä¸ì íà 0x0d	
472
			{
444
			{
473
				tab_len=strlen(#line)/8;
445
				tab_len=strlen(#line)/8;
474
				tab_len=tab_len*8;
446
				tab_len=tab_len*8;
475
				tab_len=8+tab_len-strlen(#line);
447
				tab_len=8+tab_len-strlen(#line);
476
				for (j=0; j
448
				for (j=0; j
477
				break;
449
				break;
478
			}
450
			}
479
			goto DEFAULT_MARK;		
451
			goto DEFAULT_MARK;		
480
		case '=': //quoted printable
452
		case '=': //quoted printable
481
			if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
453
			if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
482
 
454
 
483
			temp[0] = ESBYTE[bword+1];
455
			temp[0] = ESBYTE[bword+1];
484
			temp[1] = ESBYTE[bword+2];
456
			temp[1] = ESBYTE[bword+2];
485
			temp[2] = '\0';
457
			temp[2] = '\0';
486
			if (bukva = Hex2Symb(#temp))
458
			if (bukva = Hex2Symb(#temp))
487
			{
459
			{
488
				bword+=2;
460
				bword+=2;
489
				goto DEFAULT_MARK;
461
				goto DEFAULT_MARK;
490
			}
462
			}
491
			break;
463
			break;
492
			
464
			
493
		case '&': //  and so on
465
		case '&': //  and so on
494
			bword++;
466
			bword++;
495
			tag=0;
467
			tag=0;
496
			for (j=0; (ESBYTE[bword]<>';') && (j<7);   j++, bword++;)
468
			for (j=0; (ESBYTE[bword]<>';') && (j<7);   j++, bword++;)
497
			{
469
			{
498
				bukva = ESBYTE[bword];
470
				bukva = ESBYTE[bword];
499
				chrcat(#tag, bukva);
471
				chrcat(#tag, bukva);
500
			}
472
			}
501
			
473
			
502
			bukva = GetUnicodeSymbol();
474
			bukva = GetUnicodeSymbol();
503
			if (bukva) goto DEFAULT_MARK;
475
			if (bukva) goto DEFAULT_MARK;
504
			break;
476
			break;
505
		case '<':
477
		case '<':
506
			bword++; //ïðîìîòàåì ñèìâîë <
478
			bword++; //ïðîìîòàåì ñèìâîë <
507
			tag = parametr = tagparam = ignor_param = NULL;
479
			tag = parametr = tagparam = ignor_param = NULL;
508
			if (ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè , äåðçêî
480
			if (ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè , äåðçêî
509
			{
481
			{
510
				bword++;
482
				bword++;
511
				if (ESBYTE[bword] == '-')
483
				if (ESBYTE[bword] == '-')
512
				{
484
				{
513
				HH_:
485
				HH_:
514
					do
486
					do
515
					{
487
					{
516
						bword++;
488
						bword++;
517
						if (buf + filesize <= bword) break 2;
489
						if (buf + filesize <= bword) break 2;
518
					}
490
					}
519
					while (ESBYTE[bword] <>'-');
491
					while (ESBYTE[bword] <>'-');
520
					
492
					
521
					bword++;
493
					bword++;
522
					if (ESBYTE[bword] <>'-') goto HH_;
494
					if (ESBYTE[bword] <>'-') goto HH_;
523
				}
495
				}
524
			}
496
			}
525
			while (ESBYTE[bword] !='>') && (bword < buf + filesize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
497
			while (ESBYTE[bword] !='>') && (bword < buf + filesize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
526
			{
498
			{
527
				bukva = ESBYTE[bword];
499
				bukva = ESBYTE[bword];
528
				if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
500
				if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
529
				if (!ignor_param) && (bukva <>' ')
501
				if (!ignor_param) && (bukva <>' ')
530
				{
502
				{
531
					if (strlen(#tag)
503
					if (strlen(#tag)
532
				}
504
				}
533
				else
505
				else
534
				{
506
				{
535
					ignor_param = true;
507
					ignor_param = true;
536
					if (!ignor_text) && (strlen(#tagparam)+1
508
					if (!ignor_text) && (strlen(#tagparam)+1
537
				}
509
				}
538
				bword++;
510
				bword++;
539
			}
511
			}
540
			strlwr(#tag);
512
			strlwr(#tag);
541
			strlwr(#tagparam);
513
			strlwr(#tagparam);
542
 
514
 
543
			if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
515
			if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
544
			if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
516
			if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
545
 
517
 
546
			if (stolbec + strlen(#line) > lines.column_max) //============the same as NEXT_MARK
518
			if (stolbec + strlen(#line) > lines.column_max) //============the same as NEXT_MARK
547
			{
519
			{
548
				perenos_num = strrchr(#line, ' ');
520
				perenos_num = strrchr(#line, ' ');
549
				if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max;
521
				if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max;
550
				strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
522
				strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
551
				line[perenos_num] = 0x00;
523
				line[perenos_num] = 0x00;
552
				if (stroka-1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
524
				if (stroka-1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
553
				DrawPage();
525
				DrawPage();
554
				strcpy(#line, #temp);				
526
				strcpy(#line, #temp);				
555
				TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
527
				TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
556
			}
528
			}
557
			DrawPage();
529
			DrawPage();
558
			line=NULL;
530
			line=NULL;
559
 
531
 
560
			if (tag) WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //îáðàáîòêà òåãîâ
532
			if (tag) WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //îáðàáîòêà òåãîâ
561
 
533
 
562
			tag = parametr = tagparam = ignor_param = NULL;
534
			tag = parametr = tagparam = ignor_param = NULL;
563
			break;
535
			break;
564
		default:
536
		default:
565
			DEFAULT_MARK:
537
			DEFAULT_MARK:
566
			if (bukva<=15) bukva=' ';
538
			if (bukva<=15) bukva=' ';
567
			if (!pre_text) && (bukva == ' ')
539
			if (!pre_text) && (bukva == ' ')
568
			{
540
			{
569
				if (line[strlen(#line)-1]==' ') break; //óáðàòü 2 ïðîáåëà ïîäðÿä
541
				if (line[strlen(#line)-1]==' ') break; //óáðàòü 2 ïðîáåëà ïîäðÿä
570
				if (!stolbec) && (!line) break; //ñòðîêà íå ìîæåò íà÷èíàòüñÿ ñ ïðîáåëà
542
				if (!stolbec) && (!line) break; //ñòðîêà íå ìîæåò íà÷èíàòüñÿ ñ ïðîáåëà
571
			}
543
			}
572
			if (strlen(#line)
544
			if (strlen(#line)
573
 
545
 
574
			if (stolbec + strlen(#line) > lines.column_max)
546
			if (stolbec + strlen(#line) > lines.column_max)
575
			{
547
			{
576
			NEXT_MARK:
548
			NEXT_MARK:
577
				perenos_num = strrchr(#line, ' ');
549
				perenos_num = strrchr(#line, ' ');
578
				if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max;
550
				if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max;
579
				strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
551
				strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
580
				line[perenos_num] = 0x00;
552
				line[perenos_num] = 0x00;
581
				if (stroka-1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
553
				if (stroka-1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
582
				DrawPage();
554
				DrawPage();
583
				strcpy(#line, #temp);			
555
				strcpy(#line, #temp);			
584
				TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
556
				TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
585
			}
557
			}
586
		}
558
		}
587
	}
559
	}
588
 
560
 
589
	DrawPage(); //ðèñóåò ïîñëåäíþþ ñòðîêó, ïîòîì ýòî íàäî óáðàòü, îïòèìèçèðîâàâ êîä
561
	DrawPage(); //ðèñóåò ïîñëåäíþþ ñòðîêó, ïîòîì ýòî íàäî óáðàòü, îïòèìèçèðîâàâ êîä
590
	TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
562
	TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
591
 
563
 
592
	if (lines.visible * 10 + 25 <= height)
564
	if (lines.visible * 10 + 25 <= height)
593
		DrawBar(left, lines.visible * 10 + top + 25, width, -lines.visible * 10 + height - 25, bg_color);
565
		DrawBar(left, lines.visible * 10 + top + 25, width, -lines.visible * 10 + height - 25, bg_color);
594
	if (stroka * 10 + 5 <= height)
566
	if (stroka * 10 + 5 <= height)
595
		DrawBar(left, stroka * 10 + top + 5, width, -stroka * 10 + height - 5, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
567
		DrawBar(left, stroka * 10 + top + 5, width, -stroka * 10 + height - 5, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
596
	if (lines.first == 0) lines.all = stroka;
568
	if (lines.first == 0) lines.all = stroka;
597
	if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
569
	if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
598
	{
570
	{
599
		anchor=NULL;
571
		anchor=NULL;
600
		lines.first=anchor_line_num;
572
		lines.first=anchor_line_num;
601
		ParseHTML(buf);
573
		ParseHTML(buf);
602
	}
574
	}
603
	DrawScroller();
575
	DrawScroller();
604
}
576
}
605
 
577
 
606
 
578
 
607
 
579
 
608
char oldtag[100];
580
char oldtag[100];
609
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
581
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
610
	dword hr_color;
582
	dword hr_color;
611
 
583
 
612
	//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
584
	//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
613
	if (tag[0] == '/') 
585
	if (tag[0] == '/') 
614
	{
586
	{
615
		 rez = 0;
587
		 rez = 0;
616
		 strcpy(#tag, #tag+1);
588
		 strcpy(#tag, #tag+1);
617
	}
589
	}
618
	else rez = 1;
590
	else rez = 1;
619
		
591
		
620
	if (!chTag("html"))
592
	if (!chTag("html"))
621
	{
593
	{
622
		IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0;
594
		IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0;
623
		return;
595
		return;
624
	}
596
	}
625
 
597
 
626
	if (!chTag("script")) || (!chTag("style")) || (!chTag("binary")) ignor_text = rez;
598
	if (!chTag("script")) || (!chTag("style")) || (!chTag("binary")) ignor_text = rez;
627
 
599
 
628
	if(!chTag("title"))
600
	if(!chTag("title"))
629
	{
601
	{
630
		if (rez) header=NULL;
602
		if (rez) header=NULL;
631
		else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó
603
		else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó
632
		return;
604
		return;
633
	}
605
	}
634
 
606
 
635
	if (ignor_text) return;
607
	if (ignor_text) return;
636
 
608
 
637
 
609
 
638
	
610
	
639
	IF(!chTag("q")) strcat(#line, "\"");
611
	IF(!chTag("q")) strcat(#line, "\"");
640
 
612
 
641
	if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
613
	if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
642
	{
614
	{
643
		if (!strcmp(#anchor, #options))	anchor_line_num=lines.first+stroka;
615
		if (!strcmp(#anchor, #options))	anchor_line_num=lines.first+stroka;
644
	}
616
	}
645
	
617
	
646
	if (!chTag("body"))
618
	if (!chTag("body"))
647
	{
619
	{
648
		do{
620
		do{
649
			if (!strcmp(#parametr, "link=")) link_color = GetColor(#options);
621
			if (!strcmp(#parametr, "link=")) link_color = GetColor(#options);
650
			if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options);
622
			if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options);
651
			if (!strcmp(#parametr, "bgcolor="))
623
			if (!strcmp(#parametr, "bgcolor="))
652
			{
624
			{
653
				bg_color=GetColor(#options);
625
				bg_color=GetColor(#options);
654
				DrawBufFill();
626
				DrawBufFill();
655
			}
627
			}
656
		} while(GetNextParam());
628
		} while(GetNextParam());
657
		return;
629
		return;
658
	}
630
	}
659
 
631
 
660
	if (!chTag("a"))
632
	if (!chTag("a"))
661
	{
633
	{
662
		if (rez)
634
		if (rez)
663
		{
635
		{
664
			if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
636
			if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
665
 
637
 
666
			do{
638
			do{
667
				if (!strcmp(#parametr, "href="))
639
				if (!strcmp(#parametr, "href="))
668
				{
640
				{
669
					if (stroka - 1 > lines.visible) || (stroka < -2) return;
641
					if (stroka - 1 > lines.visible) || (stroka < -2) return;
670
					
642
					
671
					text_color_index++;
643
					text_color_index++;
672
					text_colors[text_color_index] = text_colors[text_color_index-1];
644
					text_colors[text_color_index] = text_colors[text_color_index-1];
673
					
645
					
674
					link = 1;
646
					link = 1;
675
					blink++;
647
					blink++;
676
					text_colors[text_color_index] = link_color;
648
					text_colors[text_color_index] = link_color;
677
					strcat(#page_links, #options);
649
					strcat(#page_links, #options);
678
					strcat(#page_links, "|");
650
					strcat(#page_links, "|");
679
				}
651
				}
680
				if (anchor) && (!strcmp(#parametr, "name="))
652
				if (anchor) && (!strcmp(#parametr, "name="))
681
				{
653
				{
682
					if (!strcmp(#anchor, #options))
654
					if (!strcmp(#anchor, #options))
683
					{
655
					{
684
						anchor_line_num=lines.first+stroka;
656
						anchor_line_num=lines.first+stroka;
685
					}
657
					}
686
				}
658
				}
687
			} while(GetNextParam());
659
			} while(GetNextParam());
688
		}
660
		}
689
		else {
661
		else {
690
			link = 0;
662
			link = 0;
691
			IF(text_color_index > 0) text_color_index--;
663
			IF(text_color_index > 0) text_color_index--;
692
		}
664
		}
693
		return;
665
		return;
694
	}
666
	}
695
 
667
 
696
	if (!chTag("font"))
668
	if (!chTag("font"))
697
	{
669
	{
698
		if (rez)
670
		if (rez)
699
		{
671
		{
700
			text_color_index++;
672
			text_color_index++;
701
			text_colors[text_color_index] = text_colors[text_color_index-1];
673
			text_colors[text_color_index] = text_colors[text_color_index-1];
702
		
674
		
703
			do{
675
			do{
704
				if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
676
				if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
705
				{
677
				{
706
					text_colors[text_color_index] = GetColor(#options);
678
					text_colors[text_color_index] = GetColor(#options);
707
				}
679
				}
708
			} while(GetNextParam());
680
			} while(GetNextParam());
709
		}
681
		}
710
		else
682
		else
711
			if (text_color_index > 0) text_color_index--;
683
			if (text_color_index > 0) text_color_index--;
712
		return;
684
		return;
713
	}
685
	}
714
	if(!chTag("tr")) || (!chTag("br")) {
686
	if(!chTag("tr")) || (!chTag("br")) {
715
		TextGoDown(left1, top1, width1);
687
		TextGoDown(left1, top1, width1);
716
		return;
688
		return;
717
	}
689
	}
718
	if (!chTag("div")) {
690
	if (!chTag("div")) {
719
		IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
691
		IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
720
		return;
692
		return;
721
	}
693
	}
722
	if (!chTag("p")) {
694
	if (!chTag("p")) {
723
		IF(oldtag[0] == 'h') return;
695
		IF(oldtag[0] == 'h') return;
724
		TextGoDown(left1, top1, width1);
696
		TextGoDown(left1, top1, width1);
725
		IF(rez) TextGoDown(left1, top1 + 10, width1);
697
		IF(rez) TextGoDown(left1, top1 + 10, width1);
726
		return;
698
		return;
727
	}
699
	}
728
	if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) {
700
	if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) {
729
		TextGoDown(left1, top1, width1);
701
		TextGoDown(left1, top1, width1);
730
		IF(rez) TextGoDown(left1, top1 + 10, width1);
702
		IF(rez) TextGoDown(left1, top1 + 10, width1);
731
		b_text = rez;
703
		b_text = rez;
732
		strcpy(#oldtag, #tag);
704
		strcpy(#oldtag, #tag);
733
		return;
705
		return;
734
	}
706
	}
735
	else
707
	else
736
		oldtag=NULL;
708
		oldtag=NULL;
737
		
709
		
738
	if (!chTag("b")) || (!chTag("strong")) || (!chTag("big")) {
710
	if (!chTag("b")) || (!chTag("strong")) || (!chTag("big")) {
739
		b_text = rez;
711
		b_text = rez;
740
		return;
712
		return;
741
	}
713
	}
742
	if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) {
714
	if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) {
743
		i_text = rez;
715
		i_text = rez;
744
		return;
716
		return;
745
	}	
717
	}	
746
	if (!chTag("dt"))
718
	if (!chTag("dt"))
747
	{
719
	{
748
		li_text = rez;
720
		li_text = rez;
749
		IF(rez == 0) return;
721
		IF(rez == 0) return;
750
		TextGoDown(left1, top1, width1);
722
		TextGoDown(left1, top1, width1);
751
		return;
723
		return;
752
	}
724
	}
753
	if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
725
	if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
754
	{
726
	{
755
		li_text = rez;
727
		li_text = rez;
756
		if (rez)
728
		if (rez)
757
		{
729
		{
758
			TextGoDown(left1, top1, width1);
730
			TextGoDown(left1, top1, width1);
759
			if (stroka > -1) && (stroka - 2 < lines.visible) DrawBufBar(li_tab * 5 * 6 + left1 - 5, line_h/2-3, 2, 2, 0x555555);
731
			if (stroka > -1) && (stroka - 2 < lines.visible) DrawBufBar(li_tab * 5 * 6 + left1 - 5, line_h/2-3, 2, 2, 0x555555);
760
		}
732
		}
761
		return;
733
		return;
762
	}
734
	}
763
	if (!chTag("u")) || (!chTag("ins")) u_text = rez;
735
	if (!chTag("u")) || (!chTag("ins")) u_text = rez;
764
	if (!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez;
736
	if (!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez;
765
	if (!chTag("ul")) || (!chTag("ol")) IF(!rez)
737
	if (!chTag("ul")) || (!chTag("ol")) IF(!rez)
766
	{
738
	{
767
		li_text = rez;
739
		li_text = rez;
768
		li_tab--;
740
		li_tab--;
769
		TextGoDown(left1, top1, width1);
741
		TextGoDown(left1, top1, width1);
770
	} ELSE li_tab++;
742
	} ELSE li_tab++;
771
	if (!chTag("dd")) stolbec += 5;
743
	if (!chTag("dd")) stolbec += 5;
772
	if (!chTag("blockquote")) blq_text = rez;
744
	if (!chTag("blockquote")) blq_text = rez;
773
	if (!chTag("pre")) pre_text = rez; 
745
	if (!chTag("pre")) pre_text = rez; 
774
	if (!chTag("hr"))
746
	if (!chTag("hr"))
775
	{
747
	{
776
		if (anchor) || (stroka < -1)
748
		if (anchor) || (stroka < -1)
777
		{
749
		{
778
			stroka+=2;
750
			stroka+=2;
779
			return;
751
			return;
780
		}
752
		}
781
		if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999;
753
		if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999;
782
		TextGoDown(left1, top1, width1);
754
		TextGoDown(left1, top1, width1);
783
		DrawBufBar(5, WB1.line_h/2, WB1.width-10, 1, hr_color);
755
		DrawBufBar(5, WB1.line_h/2, WB1.width-10, 1, hr_color);
784
		TextGoDown(left1, top1+WB1.line_h, width1);
756
		TextGoDown(left1, top1+WB1.line_h, width1);
785
	}
757
	}
786
	/*
758
	if (!chTag("img"))
787
	if (!chTag("input"))
-
 
788
	{
-
 
789
		do{
-
 
790
			if (!strcmp(#parametr, "type="))
-
 
791
			{
-
 
792
				if ((!strcmp(#options, "radio")) || (!strcmp(#options, "checkbox")))
-
 
793
				{
-
 
794
					if (!anchor) && (stroka > 0) CheckBox(stolbec*6 + left1,top1-2,10,10, 0, "\0", 0x888888, text_colors[text_color_index], 0);
-
 
795
					stolbec+=2;
-
 
796
				}
-
 
797
				if ((!strcmp(#options, "text")) || (!strcmp(#options, "password")))
-
 
798
				{
-
 
799
					if (!anchor) && (stroka > 0) CheckBox(stolbec*6 + left1,top1-2,90,10, 0, "\0", 0x555555, 0, 0);
-
 
800
					stolbec+=16;
-
 
801
				}
-
 
802
				if ((!strcmp(#options, "button")) || (!strcmp(#options, "file")) || (!strcmp(#options, "submit")))
-
 
803
				{
-
 
804
					if (!anchor) && (stroka > 0) DrawCaptButton(stolbec*6 + left1,top1-2,60,10, 0, 0xCCCccc, 0, "Button");
-
 
805
					stolbec+=21;
-
 
806
				}
-
 
807
			}
-
 
808
		} while(GetNextParam());
-
 
809
	}
-
 
810
	*/
-
 
811
	if (!chTag("img"))
-
 
812
	{
759
	{
813
		Images( left1, top1, width1);
760
		Images( left1, top1, width1);
814
		return;
761
		return;
815
	}
762
	}
816
	if (!chTag("meta")) || (!chTag("?xml"))
763
	if (!chTag("meta")) || (!chTag("?xml"))
817
	{
764
	{
818
		do{
765
		do{
819
			if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
766
			if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
820
			{
767
			{
821
				strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
768
				strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
822
				if (!strcmp(#options,"utf-8"))   || (!strcmp(#options,"utf8"))      ReadHtml(_UTF);
769
				if (!strcmp(#options,"utf-8"))   || (!strcmp(#options,"utf8"))      ReadHtml(_UTF);
823
				if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))   ReadHtml(_KOI);
770
				if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))   ReadHtml(_KOI);
824
				if (!strcmp(#options, "dos"))    || (!strcmp(#options, "cp-866"))   ReadHtml(_DOS);
771
				if (!strcmp(#options, "dos"))    || (!strcmp(#options, "cp-866"))   ReadHtml(_DOS);
825
			}
772
			}
826
		} while(GetNextParam());
773
		} while(GetNextParam());
827
		return;
774
		return;
828
	}
775
	}
829
}
776
}
830
 
777
 
831
 
778
 
832
 
779
 
833
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
780
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
834
{
781
{
835
	scroll1.max_area = lines.all;
782
	scroll1.max_area = lines.all;
836
	scroll1.cur_area = lines.visible;
783
	scroll1.cur_area = lines.visible;
837
	scroll1.position = lines.first;
784
	scroll1.position = lines.first;
838
 
785
 
839
	scroll1.all_redraw=1;
786
	scroll1.all_redraw=1;
840
	scroll1.start_x = WB1.left + WB1.width;
787
	scroll1.start_x = WB1.left + WB1.width;
841
	scroll1.size_y=WB1.height;
788
	scroll1.size_y=WB1.height;
842
 
789
 
843
	scrollbar_v_draw(#scroll1);
790
	scrollbar_v_draw(#scroll1);
844
}
791
}
845
>
792
>
846
>
793
>