Subversion Repositories Kolibri OS

Rev

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