Subversion Repositories Kolibri OS

Rev

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