Subversion Repositories Kolibri OS

Rev

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

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