Subversion Repositories Kolibri OS

Rev

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