Subversion Repositories Kolibri OS

Rev

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

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