Subversion Repositories Kolibri OS

Rev

Rev 2420 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2420 leency 1
//Web-component, Leency & Veliant 2007-20012
2413 leency 2
//lev
3
 
4
//идея - левые файлы открывать соответствующими прогами
5
//ol - циферки
6
 
7
//из хттп-лоад в реадхтмл
8
 
9
int	downloader_id;
10
 
11
dword j,
12
	buf,
13
	filesize,
14
	blink = 400;
15
 int i;
16
 
17
 char download_path[]="/rd/1/.download";
18
//char search_path[]="http://nova.rambler.ru/search?words=";
19
 char search_path[]="http://nigma.ru/index.php?s=";
2420 leency 20
 char version[]=" Text-based Browser 0.77";
2413 leency 21
 
22
 
23
struct TWebBrowser {
24
	int left,
25
	top,
26
	width,
27
	height;
28
	void DrawScroller();
29
	void ShowPage();
30
	void ParseHTML(dword, dword);
31
	void Scan(dword);
32
	void WhatTextStyle(int left1, top1, width1);
33
};
34
 
35
TWebBrowser WB1;
36
 
2420 leency 37
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, link, ignor_text, li_tab, body_present;
2413 leency 38
 
39
 
40
dword text_colors[10],
41
	text_color_index = 0,
2420 leency 42
	link_color,
43
	bg_color=0xFFFFFF;
2413 leency 44
 
45
int stroka,
46
	stolbec,
47
	tab_len;
48
 
49
char line[330],
50
	tag[100],
51
	tagparam[10000],
52
	parametr[1200],
53
	options[1000];
54
 
55
 
56
#include "include\history.h"
57
#include "include\colors.h"
58
#include "include\unicode_tags.h"
59
#include "include\some_code.h"
60
 
61
 
62
void TWebBrowser::Scan(dword id) {
63
	if (id > 399)
64
	{
2428 leency 65
		GetURLfromPageLinks(id);
66
 
67
		//эту всю хрень нужно в GetNewUrl() переместить
2413 leency 68
		IF (URL[0] == '#') {  //мы не умеем переходить по ссылке внутри документа. Пока что...
69
			copystr(#editURL, #URL);
70
			return;
71
		}
72
 
73
		URL[find_symbol(#URL, '#')-1] = 0x00; //заглушка, лучше, чем ничего (хабр, например, будет работать)
2428 leency 74
 
2413 leency 75
		GetNewUrl();
76
 
2428 leency 77
		//прыгает изображение полоса, белая рисуется снизу
78
		if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
79
		{
80
			RunProgram("/sys/media/kiv", #URL);
81
			copystr(#editURL, #URL);
82
			return;
83
		}
84
 
2416 leency 85
		copystr(#URL, #editURL);
2418 leency 86
		za_kadrom = count = 0;
2428 leency 87
 
88
		if (!strcmp(get_URL_part(5),"http:")) HttpLoad();
89
 
2418 leency 90
		ShowPage(#URL);
2413 leency 91
		return;
92
	}
93
 
94
	//edit1.flags=64;
95
	IF(count < max_kolvo_strok) SWITCH(id) //если мало строк игнорируем некоторые кнопки
96
	{ CASE 183: CASE 184: CASE 180: CASE 181: return; }
97
 
98
	switch (id)
99
	{
100
		case 011: //Ctrk+K
101
			ReadHtml();
102
			koitodos(buf);
103
			break;
104
		case BACK:
105
			BrowserHistory.GoBack();
106
			return;
107
		case FORWARD:
108
			RunProgram("@notify", "Forward button is not realized yet");
109
			return;
110
		case 054: //F5
111
			IF(edit1.flags == 66) break;
112
		case REFRESH:
113
			if (GetProcessSlot(downloader_id)<>0)
114
			{
115
				KillProcess(downloader_id);
116
				Pause(20);
117
				Draw_Window();
118
				return;
119
			}
120
			copystr(#URL, #editURL);
121
			if (!strcmp(get_URL_part(5),"http:"))) HttpLoad();
122
			ShowPage(#URL);
123
			return;
124
		case 014: //Ctrl+N новое окно
125
		case 020: //Ctrl+T новая вкладка
126
		case NEWTAB:
127
			MoveSize(190,80,OLD,OLD);
128
			RunProgram(#program_path, #URL);
129
			return;
130
		case 052:  //Нажата F3
131
			IF(edit1.flags <> 66)
132
			IF (strcmp(get_URL_part(5),"http:")<>0) RunProgram("tinypad", #URL); ELSE RunProgram("tinypad", #download_path);
133
			return;
134
 
135
		case HOME:
136
			copystr("http://bash.org.ru", #editURL);
137
		case GOTOURL:
138
		case 0x0D: //enter
139
			copystr(#editURL, #URL);
140
			if (!strcmp(get_URL_part(5),"http:"))) HttpLoad();
2418 leency 141
			za_kadrom = count = 0;
2413 leency 142
			ShowPage(#URL);
143
			return;
144
		case 173:	//ctrl+enter
145
		case SEARCHWEB:
146
			copystr(#search_path, #URL);
147
			copystr(#editURL, #URL + strlen(#URL));
148
			if (!strcmp(get_URL_part(5),"http:"))) HttpLoad();
2418 leency 149
			za_kadrom = count = 0;
2413 leency 150
			ShowPage(#URL);
151
			return;
152
 
153
		case ID1: //мотаем вверх
154
			IF(za_kadrom <= 0) return;
155
			za_kadrom--;
156
			break;
157
		case ID2: //мотаем вниз
158
			IF(max_kolvo_strok + za_kadrom >= count) return;
159
			za_kadrom++;
160
			break;
161
		case 183: //PgDown
162
			IF(za_kadrom == count - max_kolvo_strok) return;
163
			za_kadrom += max_kolvo_strok + 2;
164
			IF(max_kolvo_strok + za_kadrom > count) za_kadrom = count - max_kolvo_strok;
165
			BREAK;
166
		case 184: //PgUp
167
			IF(za_kadrom == 0) RETURN;
168
			za_kadrom -= max_kolvo_strok - 2;
169
			IF(za_kadrom < 0) za_kadrom = 0;
170
			BREAK;
171
		case 180: //home
172
			IF(za_kadrom == 0) RETURN;
173
			za_kadrom = 0;
174
			BREAK;
175
		case 181: //end
176
			IF (za_kadrom == count - max_kolvo_strok) RETURN;
177
			za_kadrom = count - max_kolvo_strok;
178
			BREAK;
179
		default:
180
			RETURN;
181
	}
182
	ParseHTML(buf, filesize);
183
}
184
 
185
void GetNewUrl(){
2428 leency 186
	IF (!strcmp(get_URL_part(2),"./")) copystr(#URL+2,#URL);
187
 
188
	if (URL[0] <> '/')
2413 leency 189
	&& (strcmp(get_URL_part(5),"http:")<>0)	&& (strcmp(get_URL_part(5),"mailt")<>0)	&& (strcmp(get_URL_part(5),"ftp:/")<>0)
190
	{
191
		copystr(BrowserHistory.CurrentUrl(), #editURL); //достаём адрес текущей страницы
192
 
2428 leency 193
		_CUT_ST_LEVEL_MARK:
194
 
195
		IF (editURL[find_symbol(#editURL, '/')-2]<>'/')  // если не http://pagename.ua <-- нахрена эта строка???
2413 leency 196
		{
197
			editURL[find_symbol(#editURL, '/')] = 0x00; //обрезаем её урл до последнего /
198
		}
2428 leency 199
 
200
		IF (!strcmp(get_URL_part(3),"../")) //на уровень вверх
201
		{
202
			copystr(#URL+3,#URL);
203
			editURL[find_symbol(#editURL, '/')-1] = 0x00; //обрезаем её урл до последнего /
204
			goto _CUT_ST_LEVEL_MARK;
205
		}
206
 
2413 leency 207
		copystr(#URL, #editURL + strlen(#editURL)); //клеим новый адрес
208
		copystr(#editURL, #URL);
209
	}
210
}
211
 
212
 
213
void HttpLoad()
2418 leency 214
{
215
	//count = 0; я думаю ему место здесь
2420 leency 216
	copystr(#version, #header);
2413 leency 217
	KillProcess(downloader_id); //убиваем старый процесс
218
	DeleteFile(#download_path);
219
	IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]='';
220
	downloader_id = RunProgram("/sys/network/downloader", #URL);
221
	IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable.");
222
	Draw_Window();
223
}
224
 
225
 
226
void ReadHtml()
227
{
228
	if (!strcmp(get_URL_part(5),"http:")))
229
		file_size stdcall (#download_path);
230
	else
231
		file_size stdcall (#URL);
232
 
233
	filesize = EBX;
234
	if (!filesize) /*{Pause(200); ReadHtml();}*/ return;
235
	mem_Free(buf);
236
	buf = mem_Alloc(filesize);
237
	if (!strcmp(get_URL_part(5),"http:")))
238
		ReadFile(0, filesize, buf, #download_path);
239
	else
240
		ReadFile(0, filesize, buf, #URL);
241
}
242
 
243
 
244
 
245
void TWebBrowser::ShowPage(dword adress) {
246
	max_kolvo_stolbcov = width - 30 / 6;
247
	max_kolvo_strok = height - 3 / 10 - 2;
248
	edit1.size = edit1.pos = strlen(#editURL);
249
	edit_box_draw stdcall(#edit1); //рисуем строку адреса
250
 
2419 leency 251
	BrowserHistory.AddUrl();
252
 
2413 leency 253
	//LETS_LOAD
254
	ReadHtml();
255
 
256
	if (!filesize)
257
	{
258
		DrawBar(left, top, width+2, height, 0xFFFFFF); //закрашиваем всё донизу
259
		if (GetProcessSlot(downloader_id)<>0) WriteText(left + 10, top + 18, 0x80, 0, "Loading...", 0);
260
		else
261
		{
262
			WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.", 0);
263
			if (!strcmp(get_URL_part(5),"http:"))) WriteText(left + 10, top + 32, 0x80, 0, "Or Internet unavilable for your configuration.", 0);
264
		}
265
		DrawTitle(#version); //?
266
		return;
267
	}
268
 
269
	wintodos(buf);
270
	ParseHTML(buf, filesize);
271
	IF (!strcmp(#version, #header)) DrawTitle(#header);
272
}
273
 
274
 
275
 
276
void TWebBrowser::ParseHTML(dword bword, fsize){
277
	word bukva[1];
278
	byte ignor_param = 0;
279
	char temp[768];
280
	stroka = -za_kadrom;
281
	stolbec = 0;
282
	FOR(j = 400; j < blink + 1; j++;) DeleteButton(j);
2420 leency 283
	b_text = i_text = u_text = s_text = pre_text = blq_text = body_present =
2413 leency 284
	li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //обнуляем теги
285
	link_color = 0x0000FF;
2420 leency 286
	bg_color = 0xFFFFFF;
2413 leency 287
	blink = 400;
288
	line = '';
289
	copystr("|", #page_links);
2418 leency 290
	copystr(#version, #header);
2420 leency 291
	IF(!strcmp(#URL + strlen(#URL) - 4, ".txt"))
292
	{
293
		DrawBar(left, top, width-15, 15, bg_color); //закрашиваем первую строку
294
		pre_text = 1; //зачётное отображение текста
295
	}
2413 leency 296
	IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
297
	for (; buf + fsize > bword; bword++;) {
298
	  bukva = ESBYTE[bword];
299
	  switch (bukva) {
300
		case 0x0a:
301
			IF(pre_text == 1) {
302
				bukva = '';
303
				temp = '';
304
				goto NEXT_MARK;
305
			}
306
		CASE '\9':
307
			if (pre_text == 1) //иначе идём на 0x0d
308
			{
309
				tab_len=strlen(#line)/8;
310
				tab_len=tab_len*8;
311
				tab_len=8+tab_len-strlen(#line);
312
				for (i=0; i
313
				break;
314
			}
315
		case 0x0d:
316
			bukva = ' ';
317
			goto DEFAULT_MARK;
318
		case '<':
319
			bword++; //промотаем символ <
320
			IF(ESBYTE[bword] == '!') //фильтрация внутри , дерзко
321
			{
322
				bword++;
323
				IF(ESBYTE[bword] == '-') {
324
					HH_: do {
325
						bword++;
326
						IF(bword >= buf + fsize) break 1;
327
					} while (ESBYTE[bword] <>'-');
328
					bword++;
329
					IF(ESBYTE[bword] <>'-') GOTO HH_;
330
				}
331
			}
332
			WHILE (ESBYTE[bword] <>'>') && (bword < buf + fsize) //получаем тег и его параметры
333
			{
334
				bukva = ESBYTE[bword];
335
				IF(bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
336
				IF(!ignor_param) && (bukva <>' ') copystr(#bukva, #tag + strlen(#tag));
337
				ELSE {
338
					ignor_param = true;
339
					copystr(#bukva, #tagparam + strlen(#tagparam));
340
				}
341
				bword++;
342
			}
343
			lowcase(#tag);
344
			lowcase(#tagparam);
2418 leency 345
 
2413 leency 346
			IF (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=''; //небольшой фикс для работы с XHTML-тегами типа br/
347
			IF(strlen(#tagparam) > 0) && (strlen(#tagparam) < 4000) GetNextParam();
348
			WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //обработка тегов
349
 
350
			line = tag = parametr = tagparam = ignor_param = 0; //всё обнуляем
351
			break;
352
		case '=': //поддержка шайтанской кодировки страниц, сохранённых через ИЕ7
353
			IF(strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
354
 
355
			bword++;
356
			bukva=ESBYTE[bword];
357
			copystr(#bukva, #temp);
358
 
359
			bword++;
360
			bukva=ESBYTE[bword];
361
			copystr(#bukva, #temp + strlen(#temp));
362
 
363
			bukva=Hex2Symb(#temp);
364
			IF (bukva) goto DEFAULT_MARK;
365
			break;
366
 
367
		case '&': //обработка тегов типа  
368
			IF(ignor_text) break;
369
			bword++;
370
			tag='';
371
			FOR (j=0;   (ESBYTE[bword] <>';') && (j < 7);     j++; bword++;)
372
			{
373
				bukva = ESBYTE[bword];
374
				copystr(#bukva, #tag + strlen(#tag));
375
			}
376
 
377
			FOR (j=0; unicode_tags[j]!=0; j+=2;)
378
			{
379
				IF(!strcmp(#tag, unicode_tags[j]))
380
				{
381
					copystr(unicode_tags[j+1], #line + strlen(#line));
382
					break 1;
383
				}
384
			}
385
 
386
			rez = StrToInt(#tag + 1) - 1040;
387
			IF(tag[1] == '1') && (rez>=0) && (rez<=72) && (strlen(#tag) == 5)
388
				{
389
					bukva = unicode_chars[rez];
390
					GOTO DEFAULT_MARK; //обрабатываем букву
391
				}
392
 
393
			WriteDebug(#tag); //тэг не найден - выводим на доску отладки
394
			copystr(#tag, #line + strlen(#line)); //выводим на экран необработанный тег, так браузеры зачем-то делают
395
			break;
396
		default:
397
			DEFAULT_MARK:
398
			IF(ignor_text) break;
399
			IF(pre_text == 0) && (bukva == ' ') && (strcmp(#line + strlen(#line) - 1, " ") == 0) continue;
400
			//
401
			if (stolbec + strlen(#line) > max_kolvo_stolbcov)
402
			{
403
				copystr(#line + find_symbol(#line, ' '), #temp); //перенос по словам
404
				line[find_symbol(#line, ' ')] = 0x00;
405
				NEXT_MARK: IF(stroka - 1 > max_kolvo_strok) && (za_kadrom <>0) break 1; //уходим...
406
				WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //вывод строки
407
				TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //закрашиваем следущую строку
408
				copystr(#temp, #line);
409
			}
410
			IF(pre_text == 0) && (bukva == ' ') && (stolbec == 0) && (strlen(#line) == 0) CONTINUE;
411
			copystr(#bukva, #line + strlen(#line));
412
	  }
413
	}
2420 leency 414
	if (strcmp(#URL + strlen(#URL) - 4, ".txt")<>0) && (body_present==0)
415
		DrawBar(left, top, width-15, 15, bg_color); //закрашиваем первую строку если какой-то рахит не создал тег боди
416
 
417
	if (max_kolvo_strok * 10 + 25 <= height)
418
		DrawBar(left, max_kolvo_strok * 10 + top + 25, width - 15, -max_kolvo_strok * 10 + height - 25, bg_color);
419
	if (stroka * 10 + 15 <= height)
420
		DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //закрашиваем всё до конца
421
	if (za_kadrom == 0) count = stroka;
2413 leency 422
	DrawScroller(); //рисуем скролл
423
}
424
 
425
 
426
void GetNextParam()
427
{
428
	byte	kavichki = false;
429
	int		i = strlen(#tagparam) - 1;
430
 
431
	WHILE((i > 0) && ((tagparam[i] == '"') || (tagparam[i] == ' ') || (tagparam[i] == '\'') || (tagparam[i] == '/')))
432
	{
433
		IF (tagparam[i] == '"') || (tagparam[i] == '\'') kavichki=tagparam[i];
434
		tagparam[i] = 0x00;
435
		i--;
436
	}
437
 
438
	IF (kavichki)
439
	{
440
		i=find_symbol(#tagparam, kavichki);
441
		copystr(#tagparam + i, #options);
442
	}
443
	ELSE
444
	{
445
		WHILE((i > 0) && (tagparam[i] <>'=')) i--; //i=find_symbol(#tagparam, '=')+1;
446
		i++;
447
 
448
		copystr(#tagparam + i, #options); //копируем опцию
449
		WHILE (options[0] == ' ') copystr(#options + 1, #options);
450
	}
451
	tagparam[i] = 0x00;
452
 
453
	FOR ( ; ((tagparam[i] <>' ') && (i > 0); i--)
454
	{
455
		IF (tagparam[i] == '=') //дерзкая заглушка
456
		{
457
			//copystr(#tagparam+i+2,#options);
458
			tagparam[i + 1] = 0x00;
459
		}
460
	}
461
 
462
	copystr(#tagparam + i + 1, #parametr); //копируем параметр
463
	tagparam[i] = 0x00;
464
}
465
 
466
 
467
 
468
char oldtag[100];
469
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
470
	dword hr_color;
471
 
472
    dword image=0;
473
    char temp[4096];
474
    int w, h, img_za_kadrom=0;
475
 
476
	//проверяем тег открывается или закрывается
477
	IF(tag[0] == '/')
478
	{
479
		rez = 0;
480
		copystr(#tag + 1, #tag);
481
	}
482
	ELSE
483
		rez = 1;
484
 
485
	//
486
	IF(!chTag("html")) {
487
		IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0;
488
		return;
489
	}
490
	IF(!chTag("script")) || (!chTag("style")) ignor_text = rez;
491
 
2418 leency 492
	if(!chTag("title")) && (!rez)
2413 leency 493
	{
494
		copystr(#line, #header);
495
		copystr(" -", #header + strlen(#header));
496
		copystr(#version, #header + strlen(#header));
2418 leency 497
		if (stroka==0) DrawTitle(#header);
2413 leency 498
		return;
499
	}
500
 
2418 leency 501
	IF (ignor_text == 1) return;
2413 leency 502
	//
2418 leency 503
 
504
	//
2413 leency 505
	IF(!chTag("q")) copystr("\"", #line + strlen(#line));
506
 
507
	//вывод на экран
508
	if (stroka >= 0) && (stroka - 2 < max_kolvo_strok) && (line)
509
	{
510
		WriteText(stolbec * 6 + left1, top1, 0x80, text_colors[text_color_index], #line, 0);
511
		IF (b_text) WriteText(stolbec * 6 + left1 + 1, top1, 0x80, text_colors[text_color_index], #line, 0);
512
		IF (i_text) Skew(stolbec * 6 + left1, top1, strlen(#line)+1*6, 10); //наклонный текст
513
		IF (s_text) DrawBar(stolbec * 6 + left1, top1 + 4, strlen(#line) * 6, 1, text_colors[text_color_index]); //зачёркнутый
514
		IF (u_text) DrawBar(stolbec * 6 + left1, top1 + 8, strlen(#line) * 6, 1, text_colors[text_color_index]); //подчёркнутый
515
		IF (link) {
516
			DefineButton(stolbec * 6 + left1 - 2, top1, strlen(#line) * 6 + 3, 9, blink + BT_HIDE, 0xB5BFC9); //
517
			DrawBar(stolbec * 6 + left1, top1 + 8, strlen(#line) * 6, 1, text_colors[text_color_index]);
518
		}
519
	}
520
	//
521
	IF(!tag) return;
522
	stolbec += strlen(#line);
2420 leency 523
 
2413 leency 524
	if (!chTag("body"))
525
	{
526
		BODY_MARK:
527
 
528
		if (strcmp(#parametr, "link=") == 0)
529
			link_color = GetColor(#options);
530
 
2420 leency 531
		if (strcmp(#parametr, "text=") == 0)
2413 leency 532
		{
533
			text_colors[0]=GetColor(#options);
534
		}
535
 
536
		if (strcmp(#parametr, "bgcolor=") == 0)
537
		{
2420 leency 538
			bg_color=GetColor(#options);
539
		}
2413 leency 540
 
541
		IF(tagparam) {
542
			GetNextParam();
543
			GOTO BODY_MARK;
2420 leency 544
		}
545
 
546
		body_present = 1; //если калич не создал тег боди нужно извращаться
547
 
548
		if (rez) DrawBar(WB1.left, WB1.top, WB1.width-15, 15, bg_color); //закрашиваем первую строку
549
		return;
2413 leency 550
	}
551
	//////////////////////////
552
	if (!chTag("a")) {
553
		IF (stroka - 1 > max_kolvo_strok) || (stroka < -2) return;
554
		if (rez) {
555
			HREF: IF(strcmp(#parametr, "href=") == 0) {
556
				IF(link == 1) text_color_index--; //если какой-то долбоёб не закрыл тэг
557
				link = 1;
558
				blink++;
559
				text_color_index++;
560
				text_colors[text_color_index] = link_color;
561
				copystr(#options, #page_links + strlen(#page_links));
562
				copystr("|", #page_links + strlen(#page_links));
563
			}
564
			IF(tagparam) {
565
				GetNextParam();
566
				GOTO HREF;
567
			}
568
		}
569
		ELSE {
570
			link = 0;
571
			IF(text_color_index > 0) text_color_index--;
572
		}
573
		return;
574
	}
575
	/////////////////////////
576
	if (!chTag("font"))
577
	{
578
		IF(stroka < 0) || (stroka - 1 > max_kolvo_strok) return;
579
		COL_MARK:
580
		if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
581
		{
582
			text_color_index++;
583
			text_colors[text_color_index] = GetColor(#options);
584
		}
585
		IF(tagparam) {
586
			GetNextParam();
587
			GOTO COL_MARK;
588
		}
589
		IF(!rez) && (text_color_index > 0) text_color_index--;
590
		return;
591
	}
592
	//////////////////////////
593
	IF(!chTag("tr")) || (!chTag("br")) {
594
		TextGoDown(left1, top1, width1);
595
		return;
596
	}
597
	IF(!chTag("div")) {
598
		IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
599
		return;
600
	}
601
	IF(!chTag("p")) {
602
		IF(oldtag[0] == 'h') return;
603
		TextGoDown(left1, top1, width1);
604
		IF(rez) TextGoDown(left1, top1 + 10, width1);
605
		return;
606
	}
607
	////////////////////////////
608
	IF(!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) {
609
		TextGoDown(left1, top1, width1);
610
		IF(rez) TextGoDown(left1, top1 + 10, width1);
611
		b_text = rez;
612
		copystr(#tag, #oldtag);
613
		return;
614
	} ELSE copystr("", #oldtag);
615
	IF(!chTag("b")) || (!chTag("strong")) || (!chTag("big")) {
616
		b_text = rez;
617
		return;
618
	}
619
	////////////////////////////
620
	IF(!chTag("i")) || (!chTag("em")) {
621
		i_text = rez;
622
		return;
623
	}
624
	////////////////////////////
625
	if(!chTag("li")) || (!chTag("dt")) //надо сделать вложенные списки
626
	{
627
		li_text = rez;
628
		IF(rez == 0) return;
629
		TextGoDown(left1, top1, width1);
630
		IF(stroka > -1) && (stroka - 2 < max_kolvo_strok) IF(!chTag("li")) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0);
631
		return;
632
	}
633
	////////////////////////////
634
	IF(!chTag("u")) || (!chTag("ins")) u_text = rez;
635
	IF(!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez;
636
	IF(!chTag("ul")) || (!chTag("ol")) IF(!rez) {
637
		li_text = rez;
638
		li_tab--;
639
		TextGoDown(left1, top1, width1);
640
	} ELSE li_tab++;
641
	IF(!chTag("dd")) stolbec += 5;
642
	IF(!chTag("blockquote")) blq_text = rez;
643
	IF(!chTag("pre")) pre_text = rez;
644
	IF(!chTag("hr")) {
645
		TextGoDown(left1, top1, width1);
646
		TextGoDown(left1, top1 + 10, width1);
647
		IF(strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options);
648
		ELSE hr_color = 0x999999;
649
		IF(stroka > 0) DrawBar(left1, top1 + 14, width1 - 8, 1, hr_color);
650
	}
651
 
652
	if (!chTag("img"))
653
	{
654
		//IF (GetFileInfo(#libimg)<>0) return;  //если библиотеки нет
655
		IMG_TAG:
656
			IF (strcmp(#parametr,"src=")==0)   //надо объединить с GetNewUrl()
657
	          {
658
				copystr(BrowserHistory.CurrentUrl(), #temp); //достаём адрес текущей страницы
659
				temp[find_symbol(#temp, '/')] = 0x00; //обрезаем её урл до последнего /
660
				copystr(#options,#temp+strlen(#temp));
661
				image=load_image(#temp);
662
 
663
	                w=DSWORD[image+4];
664
	                h=DSWORD[image+8];
665
	          }
666
		IF(tagparam) {
667
			GetNextParam();
668
			GOTO IMG_TAG;
669
		}
670
 
671
		if (w>width1) w=width1;
672
 
673
        if (image)
674
        {
675
			stroka+=h/10;
676
 
677
			if (top1+hWB1.top+WB1.height-10) //если ВСЁ изображение ушло ВЕРХ или ВНИЗ
678
				return;
679
 
680
			if (top1
681
			{
682
				img_za_kadrom=WB1.top-top1;
683
				h=h-img_za_kadrom;
684
				top1=WB1.top-5;
685
			}
686
 
687
			if (top1>WB1.top+WB1.height-h-10) //если часть изображения снизу     IF (stroka - 2 < max_kolvo_strok)
688
			{
689
				h=WB1.top+WB1.height-top1-10;
690
			}
691
 
692
			IF (h<=0) return;
693
 
694
			img_draw stdcall (image,left1-5,top1+10,w, h,0,img_za_kadrom);
2420 leency 695
			DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color);
2413 leency 696
        }
697
		/*else
698
		{
699
			IF (strcmp(#parametr,"alt=")==0) copystr(#options,#line+strlen(#line));
700
		}*/
701
		return;
702
	}
703
 
704
	if (!chTag("meta"))
705
	{
706
		META:
707
		if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content="))
708
		{
709
			copystr(#options[find_symbol(#options, '=')],#options); //поиск в content=
710
 
711
			IF (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8"))
712
			{
713
				ReadHtml();
714
				utf8rutodos(buf);
715
			}
716
			IF(!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))
717
			{
718
				ReadHtml();
719
				koitodos(buf);
720
			}
721
			IF(!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866"))
722
			{
723
				ReadHtml();
724
			}
725
		}
726
		IF(tagparam)
727
		{
728
			GetNextParam();
729
			goto META;
730
		}
731
		return;
732
	}
733
}
734
 
735
 
736
void TextGoDown(int left1, top1, width1) {
737
	stroka++;
738
	IF(blq_text == 1) stolbec = 8;
739
	ELSE stolbec = 0;
740
	IF(li_text == 1) stolbec = li_tab * 5;
2420 leency 741
	IF(stroka >= 0) && (stroka - 2 < max_kolvo_strok) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
2413 leency 742
}
743
 
744
 
745
//скролл
746
void TWebBrowser::DrawScroller() {
747
	dword on_y;
748
	DrawBar(left + width - 15, top + 17, 1, height - 34, 0x94AECE); //линия слева от прокрутки
749
	DrawFlatButton(left + width - 15, top + height - 17, 16, 16, ID2, 0xE4DFE1, "\x19");
750
	DrawFlatButton(left + width - 15, top, 16, 16, ID1, 0xE4DFE1, "\x18");
751
 
752
	IF(count <= max_kolvo_strok) {
2418 leency 753
		DrawBar(left + width - 14, top+17, 16, height - 34, 0xCED0D0);
2413 leency 754
		return;
755
	}
756
 
757
	scroll_size = height - 16 * max_kolvo_strok / count - 3;
758
	IF(scroll_size < 10) scroll_size = 10;
759
	IF(za_kadrom + max_kolvo_strok >= count) on_y = height - scroll_size + top - 17;
760
	ELSE on_y = height - 32 * za_kadrom / count + top + 16;
761
	DrawFlatButton(left + width - 15, on_y, 16, scroll_size, 0, 0xE4DFE1, ""); //ползунок
762
	IF(on_y > top + 17) DrawBar(left + width - 14, top + 17, 16, on_y - top - 17, 0xCED0D0); //поле до ползунка
763
	IF(height - scroll_size + top - 17 > on_y)
764
		DrawBar(left + width - 14, on_y + scroll_size + 1, 16, height - scroll_size - on_y + top - 18, 0xCED0D0); //поле после ползунка
765
}