Subversion Repositories Kolibri OS

Rev

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

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