Subversion Repositories Kolibri OS

Rev

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