Subversion Repositories Kolibri OS

Rev

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

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