Subversion Repositories Kolibri OS

Rev

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