Subversion Repositories Kolibri OS

Rev

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

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