Subversion Repositories Kolibri OS

Rev

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