Subversion Repositories Kolibri OS

Rev

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