Subversion Repositories Kolibri OS

Rev

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