HTMLv code refactoring

git-svn-id: svn://kolibrios.org@4413 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2013-12-27 00:33:12 +00:00
parent 8f2e4dc9b3
commit e3a51a20f1
13 changed files with 156 additions and 1674 deletions

View File

@ -1,3 +1,5 @@
#include "..\lib\list_box.h"
int downloader_id;
@ -12,7 +14,7 @@ char search_path[]="http://nigma.ru/index.php?s=";
struct TWebBrowser {
int left, top, width, height, line_h;
void Scan(int);
llist list;
void GetNewUrl();
void OpenPage();
void ReadHtml(byte);
@ -46,7 +48,6 @@ char line[500],
options[4096],
anchor[256];
#include "..\TWB\history.h"
#include "..\TWB\colors.h"
#include "..\TWB\unicode_tags.h"
#include "..\TWB\img_cache.h"
@ -90,148 +91,6 @@ void TWebBrowser::DrawPage()
}
//=======================================================================
void TWebBrowser::Scan(int id)
{
if (id >= 400)
{
GetURLfromPageLinks(id);
//#1
if (URL[0] == '#')
{
strcpy(#anchor, #URL+strrchr(#URL, '#'));
strcpy(#URL, BrowserHistory.CurrentUrl());
lines.first=lines.all-lines.visible;
ShowPage();
return;
}
//liner.ru#1
if (strrchr(#URL, '#')<>-1)
{
strcpy(#anchor, #URL+strrchr(#URL, '#'));
URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà
}
GetNewUrl();
if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
{
//if (strstr(#URL,"http:"))
RunProgram("/sys/media/kiv", #URL);
strcpy(#editURL, BrowserHistory.CurrentUrl());
strcpy(#URL, BrowserHistory.CurrentUrl());
return;
}
if (!strcmpn(#URL,"mailto:", 7))
{
RunProgram("@notify", #URL);
strcpy(#editURL, BrowserHistory.CurrentUrl());
strcpy(#URL, BrowserHistory.CurrentUrl());
return;
}
OpenPage();
return;
}
IF(lines.all < lines.visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
{ CASE 183: CASE 184: CASE 180: CASE 181: return; }
switch (id)
{
case 011: //Ctrk+K
ReadHtml(_KOI);
break;
case 021: //Ctrl+U
ReadHtml(_UTF);
break;
case 004: //Ctrl+D
ReadHtml(_DOS);
break;
case 002: //free img cache
FreeImgCache();
break;
case BACK:
if (!BrowserHistory.GoBack()) return;
OpenPage();
return;
case FORWARD:
if (!BrowserHistory.GoForward()) return;
OpenPage();
return;
case 052: //F3
if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL); else RunProgram("/rd/1/tinypad", #download_path);
return;
case 054: //F5
IF(address_box.flags & 0b10) break;
case REFRESH:
if (GetProcessSlot(downloader_id)<>0)
{
KillProcess(downloader_id);
pause(20);
Draw_Window();
return;
}
anchor_line_num=lines.first; //âåñ¸ëûé êîñòûëü :Ð
anchor[0]='|';
OpenPage();
return;
case 014: //Ctrl+N íîâîå îêíî
case 020: //Ctrl+T íîâàÿ âêëàäêà
case NEWTAB:
MoveSize(190,80,OLD,OLD);
RunProgram(#program_path, #URL);
return;
case HOME:
strcpy(#editURL, "http://kolibrios.org/en/index.htm");
case GOTOURL:
case 0x0D: //enter
//ïî÷åìó ttp://? Ãîñïîäà, îòëè÷íûé âîïðîñ. Äåëî â òîì, ÷òî ýòî õàê.
//strstr() åñëè íå íàøëî âîçâðàùàåò 0 è â ñëó÷àå óñïåõà âîçâðàùàåò 0. Òàê ÷òî ýòî õàê.
if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0;
strcat(#URL, #editURL);
OpenPage();
return;
case SEARCHWEB:
strcpy(#URL, #search_path);
strcat(#URL, #editURL);
OpenPage();
return;
case ID1: //ìîòàåì ââåðõ
IF(lines.first <= 0) return;
lines.first--;
break;
case ID2: //ìîòàåì âíèç
IF(lines.visible + lines.first >= lines.all) return;
lines.first++;
break;
case 183: //PgDown
IF(lines.first == lines.all - lines.visible) return;
lines.first += lines.visible + 2;
IF(lines.visible + lines.first > lines.all) lines.first = lines.all - lines.visible;
break;
case 184: //PgUp
IF(lines.first == 0) return;
lines.first -= lines.visible - 2;
IF(lines.first < 0) lines.first = 0;
break;
case 180: //home
IF(lines.first == 0) return;
lines.first = 0;
break;
case 181: //end
IF (lines.first == lines.all - lines.visible) return;
lines.first = lines.all - lines.visible;
break;
default:
return;
}
ParseHTML(buf);
}
char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", 0};

View File

@ -1,78 +0,0 @@
dword drawbuf;
void DrawBufInit()
{
free(drawbuf);
drawbuf = malloc(WB1.width * WB1.line_h +4 * 4 + 8); //+1 for good luck
ESDWORD[drawbuf] = WB1.width;
ESDWORD[drawbuf+4] = WB1.line_h;
}
void DrawBufFill()
{
int i;
for (i=0; i<WB1.width* WB1.line_h +4 * 4; i+=4) ESDWORD[drawbuf+i+8] = bg_color;
}
void DrawBufBar(dword x, y, w, h, color)
{
int i, j;
for (j=0; j<h; j++)
{
for (i = y+j*WB1.width+x*4; i<y+j*WB1.width+x+w*4 ; i+=4) ESDWORD[drawbuf+i+8] = color;
}
}
char shift[]={8,8,4,4};
void DrawBufSkew(dword x, y, w, h)
{
int i, j;
stolbec++;
for (j=0; j<=3; j++)
{
for (i = y+j*WB1.width+x+w+h*4; i>y+j*WB1.width+x+h-12*4 ; i-=4)
ESDWORD[drawbuf+i+8] = ESDWORD[-shift[j]+drawbuf+i+8];
}
}
void DrawBufAlignRight(dword x,y,w,h)
{
int i, j, l;
int content_width = stolbec * 6;
int content_left = w - content_width / 2;
for (j=0; j<h; j++)
{
for (i=j*w+w-x*4, l=j*w+content_width+x*4; (i>=j*w+content_left*4) && (l>=j*w*4); i-=4, l-=4)
{
ESDWORD[drawbuf+8+i] >< ESDWORD[drawbuf+8+l];
}
}
}
void DrawBufAlignCenter(dword x,y,w,h)
{
int i, j, l;
int content_width = stolbec * 6;
int content_left = w - content_width / 2;
for (j=0; j<h; j++)
{
for (i=j*w+content_width+content_left*4, l=j*w+content_width+x*4; (i>=j*w+content_left*4) && (l>=j*w*4); i-=4, l-=4)
{
ESDWORD[drawbuf+8+i] >< ESDWORD[drawbuf+8+l];
}
}
}
void TextGoDown(int left1, top1, width1)
{
if (!stroka) DrawBar(WB1.left, WB1.top, WB1.width, 5, bg_color); //çàêðàøèâàåì ôîí íàä ïåðâîé ñòðîêîé
if (top1>=WB1.top) && ( top1 < WB1.height+WB1.top-10) && (!anchor)
{
if (text_align == ALIGN_CENTER) DrawBufAlignCenter(left1,top1,WB1.width,WB1.line_h);
if (text_align == ALIGN_RIGHT) DrawBufAlignRight(left1,top1,WB1.width,WB1.line_h);
PutPaletteImage(drawbuf+8, WB1.width, WB1.line_h, left1-5, top1, 32,0);
DrawBufFill();
}
stroka++;
if (blq_text) stolbec = 8; else stolbec = 0;
if (li_text) stolbec = li_tab * 5;
}

View File

@ -20,7 +20,6 @@
#include "..\lib\lib.obj\box_lib.h"
#include "..\lib\lib.obj\libio_lib.h"
#include "..\lib\lib.obj\libimg_lib.h"
#include "..\lib\list_box.h"
//images
#include "img\toolbar_icons.c"
#include "img\URLgoto.txt";
@ -60,6 +59,7 @@ mouse m;
int action_buf;
#include "history.h"
#include "..\TWB\TWB.c"
#include "menu_rmb.h"
@ -123,16 +123,16 @@ void main()
{
if (lines.first==0) break;
if (lines.first>3) lines.first-=2; ELSE lines.first=1;
WB1.Scan(ID1);
Scan(ID1);
break;
}
if (m.vert==1)
{
if(lines.visible+lines.first+3>=lines.all) WB1.Scan(181);
if(lines.visible+lines.first+3>=lines.all) Scan(181);
else
{
lines.first+=2;
WB1.Scan(ID2);
Scan(ID2);
}
break;
}
@ -165,7 +165,7 @@ void main()
}
ELSE
{
WB1.Scan(btn);
Scan(btn);
}
break;
case evKey:
@ -174,13 +174,13 @@ void main()
if (address_box.flags & 0b10) SWITCH(key) //åñëè àêòèâíà ñòðîêà àäðåñà èãíîðèðóåì íåêîòîðûå êíîïêè
{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; }
WB1.Scan(key);
Scan(key);
_EDIT_MARK:
if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);} //àäðåñíàÿ ñòðîêà
break;
case evReDraw:
if (action_buf) { WB1.Scan(action_buf); action_buf=0;}
if (action_buf) { Scan(action_buf); action_buf=0;}
Draw_Window();
break;
default:
@ -244,4 +244,150 @@ void Draw_Window()
}
void Scan(int id)
{
if (id >= 400)
{
GetURLfromPageLinks(id);
//#1
if (URL[0] == '#')
{
strcpy(#anchor, #URL+strrchr(#URL, '#'));
strcpy(#URL, BrowserHistory.CurrentUrl());
lines.first=lines.all-lines.visible;
WB1.ShowPage();
return;
}
//liner.ru#1
if (strrchr(#URL, '#')<>-1)
{
strcpy(#anchor, #URL+strrchr(#URL, '#'));
URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà
}
WB1.GetNewUrl();
if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
{
//if (strstr(#URL,"http:"))
RunProgram("/sys/media/kiv", #URL);
strcpy(#editURL, BrowserHistory.CurrentUrl());
strcpy(#URL, BrowserHistory.CurrentUrl());
return;
}
if (!strcmpn(#URL,"mailto:", 7))
{
RunProgram("@notify", #URL);
strcpy(#editURL, BrowserHistory.CurrentUrl());
strcpy(#URL, BrowserHistory.CurrentUrl());
return;
}
WB1.OpenPage();
return;
}
IF(lines.all < lines.visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
{ CASE 183: CASE 184: CASE 180: CASE 181: return; }
switch (id)
{
case 011: //Ctrk+K
WB1.ReadHtml(_KOI);
break;
case 021: //Ctrl+U
WB1.ReadHtml(_UTF);
break;
case 004: //Ctrl+D
WB1.ReadHtml(_DOS);
break;
case 002: //free img cache
FreeImgCache();
break;
case BACK:
if (!BrowserHistory.GoBack()) return;
WB1.OpenPage();
return;
case FORWARD:
if (!BrowserHistory.GoForward()) return;
WB1.OpenPage();
return;
case 052: //F3
if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL); else RunProgram("/rd/1/tinypad", #download_path);
return;
case 054: //F5
IF(address_box.flags & 0b10) break;
case REFRESH:
if (GetProcessSlot(downloader_id)<>0)
{
KillProcess(downloader_id);
pause(20);
Draw_Window();
return;
}
anchor_line_num=lines.first; //âåñ¸ëûé êîñòûëü :Ð
anchor[0]='|';
WB1.OpenPage();
return;
case 014: //Ctrl+N íîâîå îêíî
case 020: //Ctrl+T íîâàÿ âêëàäêà
case NEWTAB:
MoveSize(190,80,OLD,OLD);
RunProgram(#program_path, #URL);
return;
case HOME:
strcpy(#editURL, "http://kolibrios.org/en/index.htm");
case GOTOURL:
case 0x0D: //enter
//ïî÷åìó ttp://? Ãîñïîäà, îòëè÷íûé âîïðîñ. Äåëî â òîì, ÷òî ýòî õàê.
//strstr() åñëè íå íàøëî âîçâðàùàåò 0 è â ñëó÷àå óñïåõà âîçâðàùàåò 0. Òàê ÷òî ýòî õàê.
if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0;
strcat(#URL, #editURL);
WB1.OpenPage();
return;
case SEARCHWEB:
strcpy(#URL, #search_path);
strcat(#URL, #editURL);
WB1.OpenPage();
return;
case ID1: //ìîòàåì ââåðõ
IF(lines.first <= 0) return;
lines.first--;
break;
case ID2: //ìîòàåì âíèç
IF(lines.visible + lines.first >= lines.all) return;
lines.first++;
break;
case 183: //PgDown
IF(lines.first == lines.all - lines.visible) return;
lines.first += lines.visible + 2;
IF(lines.visible + lines.first > lines.all) lines.first = lines.all - lines.visible;
break;
case 184: //PgUp
IF(lines.first == 0) return;
lines.first -= lines.visible - 2;
IF(lines.first < 0) lines.first = 0;
break;
case 180: //home
IF(lines.first == 0) return;
lines.first = 0;
break;
case 181: //end
IF (lines.first == lines.all - lines.visible) return;
lines.first = lines.all - lines.visible;
break;
default:
return;
}
WB1.ParseHTML(buf);
}
stop:

View File

@ -1,773 +0,0 @@
int downloader_id;
dword
buf,
filesize,
blink;
char download_path[]="/rd/1/.download";
char search_path[]="http://nigma.ru/index.php?s=";
struct TWebBrowser {
int left, top, width, height, line_h;
void Scan(int);
void GetNewUrl();
void OpenPage();
void ReadHtml(byte);
void ShowPage();
void ParseHTML(dword);
void WhatTextStyle(int left1, top1, width1);
void DrawPage();
void DrawScroller();
};
TWebBrowser WB1;
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text,
link, ignor_text, li_tab, cur_encoding, text_align;
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
dword text_colors[300],
text_color_index,
link_color,
bg_color;
int stroka,
stolbec,
tab_len,
anchor_line_num;
char line[500],
tag[100],
tagparam[10000],
parametr[1200],
options[4096],
anchor[256];
#include "include\history.h"
#include "include\colors.h"
#include "include\unicode_tags.h"
#include "include\img_cache.h"
#include "include\some_code.h"
#include "include\parce_tag.h"
#include "DrawBuf.h"
//=======================================================================
void TWebBrowser::DrawPage()
{
int start_x, start_y, line_length, magrin_left=5;
if (!header)
{
strcpy(#header, #line);
strcat(#header, " -");
strcat(#header, #version);
line = 0;
return;
}
if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor)
{
start_x = stolbec * 6 + left + magrin_left;
start_y = stroka * 10 + top + magrin_left;
line_length = strlen(#line) * 6;
WriteBufText(start_x, 0, 0x88, text_colors[text_color_index], #line, drawbuf);
IF (b_text) WriteBufText(start_x+1, 0, 0x88, text_colors[text_color_index], #line, drawbuf);
IF (i_text) DrawBufSkew(start_x, 0, line_length, line_h);
IF (s_text) DrawBufBar(start_x, 4, line_length, 1, text_colors[text_color_index]);
IF (u_text) DrawBufBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
IF (link) {
UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, blink + BT_HIDE, 0xB5BFC9);
DrawBufBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
}
stolbec += strlen(#line);
}
}
//=======================================================================
void TWebBrowser::Scan(int id)
{
if (id >= 400)
{
GetURLfromPageLinks(id);
//#1
if (URL[0] == '#')
{
strcpy(#anchor, #URL+strrchr(#URL, '#'));
strcpy(#URL, BrowserHistory.CurrentUrl());
lines.first=lines.all-lines.visible;
ShowPage();
return;
}
//liner.ru#1
if (strrchr(#URL, '#')<>-1)
{
strcpy(#anchor, #URL+strrchr(#URL, '#'));
URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà
}
GetNewUrl();
if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
{
//if (strstr(#URL,"http:"))
RunProgram("/sys/media/kiv", #URL);
strcpy(#editURL, BrowserHistory.CurrentUrl());
strcpy(#URL, BrowserHistory.CurrentUrl());
return;
}
if (!strcmpn(#URL,"mailto:", 7))
{
RunProgram("@notify", #URL);
strcpy(#editURL, BrowserHistory.CurrentUrl());
strcpy(#URL, BrowserHistory.CurrentUrl());
return;
}
OpenPage();
return;
}
IF(lines.all < lines.visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
{ CASE 183: CASE 184: CASE 180: CASE 181: return; }
switch (id)
{
case 011: //Ctrk+K
ReadHtml(_KOI);
break;
case 021: //Ctrl+U
ReadHtml(_UTF);
break;
case 004: //Ctrl+D
ReadHtml(_DOS);
break;
case 002: //free img cache
FreeImgCache();
break;
case BACK:
if (!BrowserHistory.GoBack()) return;
OpenPage();
return;
case FORWARD:
if (!BrowserHistory.GoForward()) return;
OpenPage();
return;
case 052: //F3
if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL); else RunProgram("/rd/1/tinypad", #download_path);
return;
case 054: //F5
IF(address_box.flags & 0b10) break;
case REFRESH:
if (GetProcessSlot(downloader_id)<>0)
{
KillProcess(downloader_id);
pause(20);
Draw_Window();
return;
}
anchor_line_num=lines.first; //âåñ¸ëûé êîñòûëü :Ð
anchor[0]='|';
OpenPage();
return;
case 014: //Ctrl+N íîâîå îêíî
case 020: //Ctrl+T íîâàÿ âêëàäêà
case NEWTAB:
MoveSize(190,80,OLD,OLD);
RunProgram(#program_path, #URL);
return;
case HOME:
strcpy(#editURL, "http://kolibrios.org/en/index.htm");
case GOTOURL:
case 0x0D: //enter
//ïî÷åìó ttp://? Ãîñïîäà, îòëè÷íûé âîïðîñ. Äåëî â òîì, ÷òî ýòî õàê.
//strstr() åñëè íå íàøëî âîçâðàùàåò 0 è â ñëó÷àå óñïåõà âîçâðàùàåò 0. Òàê ÷òî ýòî õàê.
if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0;
strcat(#URL, #editURL);
OpenPage();
return;
case SEARCHWEB:
strcpy(#URL, #search_path);
strcat(#URL, #editURL);
OpenPage();
return;
case ID1: //ìîòàåì ââåðõ
IF(lines.first <= 0) return;
lines.first--;
break;
case ID2: //ìîòàåì âíèç
IF(lines.visible + lines.first >= lines.all) return;
lines.first++;
break;
case 183: //PgDown
IF(lines.first == lines.all - lines.visible) return;
lines.first += lines.visible + 2;
IF(lines.visible + lines.first > lines.all) lines.first = lines.all - lines.visible;
break;
case 184: //PgUp
IF(lines.first == 0) return;
lines.first -= lines.visible - 2;
IF(lines.first < 0) lines.first = 0;
break;
case 180: //home
IF(lines.first == 0) return;
lines.first = 0;
break;
case 181: //end
IF (lines.first == lines.all - lines.visible) return;
lines.first = lines.all - lines.visible;
break;
default:
return;
}
ParseHTML(buf);
}
char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", 0};
//dword TWebBrowser::GetNewUrl(dword CUR_URL, NEW_URL){
void TWebBrowser::GetNewUrl(){
int i, len;
for (i=0; ABSOLUTE_LINKS[i]; i++)
{
len=strlen(ABSOLUTE_LINKS[i]);
if (!strcmpn(#URL, ABSOLUTE_LINKS[i], len)) return;
}
IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); //èãíîðèì :)
strcpy(#editURL, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
if (URL[0] == '/')
{
i = strchr(#editURL+8, '/');
editURL[i+7]=0;
strcpy(#URL, #URL+1);
}
_CUT_ST_LEVEL_MARK:
if (editURL[strrchr(#editURL, '/')-2]<>'/') // åñëè íå http://
{
editURL[strrchr(#editURL, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
}
IF (!strcmp(get_URL_part(3),"../")) //íà óðîâåíü ââåðõ
{
strcpy(#URL,#URL+3);
editURL[strrchr(#editURL, '/')-1] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
goto _CUT_ST_LEVEL_MARK;
}
if (editURL[strlen(#editURL)-1]<>'/') strcat(#editURL, "/");
strcat(#editURL, #URL); //êëåèì íîâûé àäðåñ
strcpy(#URL, #editURL);
}
void TWebBrowser::ReadHtml(byte encoding)
{
if (!strcmp(get_URL_part(5),"http:")))
file_size stdcall (#download_path);
else
file_size stdcall (#URL);
filesize = EBX;
if (!filesize) return;
mem_Free(buf);
buf = mem_Alloc(filesize);
if (!strcmp(get_URL_part(5),"http:")))
ReadFile(0, filesize, buf, #download_path);
else
ReadFile(0, filesize, buf, #URL);
cur_encoding = encoding;
if (encoding==_WIN) wintodos(buf);
if (encoding==_UTF) utf8rutodos(buf);
if (encoding==_KOI) koitodos(buf);
}
void TWebBrowser::OpenPage()
{
if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
KillProcess(downloader_id);
strcpy(#editURL, #URL);
BrowserHistory.AddUrl();
strcpy(#header, #version);
pre_text =0;
if (!strcmp(get_URL_part(5),"http:")))
{
KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
DeleteFile(#download_path);
IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=NULL;
downloader_id = RunProgram("/sys/network/downloader", #URL);
//Browser Hack v2.0
/*
pause(60);
if (GetProcessSlot(downloader_id)<>0)
{
debug("Browser Hack v2.0: Killing downloader and trying to run it one more!");
KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
downloader_id = RunProgram("/sys/network/downloader", #URL);
}
*/
IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable.");
Draw_Window();
return;
}
lines.first = lines.all =0;
ReadHtml(_WIN);
WB1.ShowPage();
}
void TWebBrowser::ShowPage()
{
address_box.size = address_box.pos = strlen(#editURL);
address_box.offset=0;
edit_box_draw stdcall(#address_box);
if (!filesize)
{
DrawBar(left, top, width+scroll1.size_x+1, height, 0xFFFFFF); //fill all
if (GetProcessSlot(downloader_id)<>0) WriteText(left + 10, top + 18, 0x80, 0, "Loading...");
else
{
WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.");
if (!strcmp(get_URL_part(5),"http:"))) WriteText(left + 10, top + 32, 0x80, 0, "Or Internet unavilable for your configuration.");
}
//return;
}
else
ParseHTML(buf);
if (!header) strcpy(#header, #version);
if (!strcmp(#version, #header)) DrawTitle(#header);
}
void TWebBrowser::ParseHTML(dword bword){
word bukva[2];
int j, perenos_num;
byte ignor_param;
char temp[768];
if (blink<400) blink=400; else for ( ; blink>400; blink--;) DeleteButton(blink);
b_text = i_text = u_text = s_text = blq_text =
li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
text_align = ALIGN_LEFT;
link_color = 0x0000FF;
bg_color = 0xFFFFFF;
DrawBufFill();
strcpy(#page_links,"|");
strcpy(#header, #version);
stroka = -lines.first;
stolbec = 0;
line = 0;
if (pre_text<>2)
{
pre_text=0;
if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
}
for ( ; buf+filesize > bword; bword++;)
{
bukva = ESBYTE[bword];
if (ignor_text) && (bukva<>'<') continue;
switch (bukva)
{
case 0x0a:
if (pre_text)
{
bukva = temp = NULL;
goto NEXT_MARK;
}
case '\9':
if (pre_text) //èíà÷å èä¸ì íà 0x0d
{
tab_len=strlen(#line)/8;
tab_len=tab_len*8;
tab_len=8+tab_len-strlen(#line);
for (j=0; j<tab_len; j++;) chrcat(#line,' ');
break;
}
goto DEFAULT_MARK;
case '=': //quoted printable
if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
temp[0] = ESBYTE[bword+1];
temp[1] = ESBYTE[bword+2];
temp[2] = '\0';
if (bukva = Hex2Symb(#temp))
{
bword+=2;
goto DEFAULT_MARK;
}
break;
case '&': //&nbsp; and so on
bword++;
tag=0;
for (j=0; (ESBYTE[bword]<>';') && (j<7); j++, bword++;)
{
bukva = ESBYTE[bword];
chrcat(#tag, bukva);
}
bukva = GetUnicodeSymbol();
if (bukva) goto DEFAULT_MARK;
break;
case '<':
bword++; //ïðîìîòàåì ñèìâîë <
tag = parametr = tagparam = ignor_param = NULL;
if (ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
{
bword++;
if (ESBYTE[bword] == '-')
{
HH_:
do
{
bword++;
if (buf + filesize <= bword) break 2;
}
while (ESBYTE[bword] <>'-');
bword++;
if (ESBYTE[bword] <>'-') goto HH_;
}
}
while (ESBYTE[bword] !='>') && (bword < buf + filesize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
{
bukva = ESBYTE[bword];
if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
if (!ignor_param) && (bukva <>' ')
{
if (strlen(#tag)<sizeof(tag)) strcat(#tag, #bukva);
}
else
{
ignor_param = true;
if (!ignor_text) && (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
}
bword++;
}
strlwr(#tag);
strlwr(#tagparam);
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
if (stolbec + strlen(#line) > lines.column_max) //============the same as NEXT_MARK
{
perenos_num = strrchr(#line, ' ');
if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max;
strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
line[perenos_num] = 0x00;
if (stroka-1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
DrawPage();
strcpy(#line, #temp);
TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
}
DrawPage();
line=NULL;
if (tag) WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //îáðàáîòêà òåãîâ
tag = parametr = tagparam = ignor_param = NULL;
break;
default:
DEFAULT_MARK:
if (bukva<=15) bukva=' ';
if (!pre_text) && (bukva == ' ')
{
if (line[strlen(#line)-1]==' ') break; //óáðàòü 2 ïðîáåëà ïîäðÿä
if (!stolbec) && (!line) break; //ñòðîêà íå ìîæåò íà÷èíàòüñÿ ñ ïðîáåëà
}
if (strlen(#line)<sizeof(line)) chrcat(#line, bukva);
if (stolbec + strlen(#line) > lines.column_max)
{
NEXT_MARK:
perenos_num = strrchr(#line, ' ');
if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max;
strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
line[perenos_num] = 0x00;
if (stroka-1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì...
DrawPage();
strcpy(#line, #temp);
TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
}
}
}
DrawPage(); //ðèñóåò ïîñëåäíþþ ñòðîêó, ïîòîì ýòî íàäî óáðàòü, îïòèìèçèðîâàâ êîä
TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
if (lines.visible * 10 + 25 <= height)
DrawBar(left, lines.visible * 10 + top + 25, width, -lines.visible * 10 + height - 25, bg_color);
if (stroka * 10 + 5 <= height)
DrawBar(left, stroka * 10 + top + 5, width, -stroka * 10 + height - 5, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
if (lines.first == 0) lines.all = stroka;
if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
{
anchor=NULL;
lines.first=anchor_line_num;
ParseHTML(buf);
}
DrawScroller();
}
char oldtag[100];
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
dword hr_color;
//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
if (tag[0] == '/')
{
rez = 0;
strcpy(#tag, #tag+1);
}
else rez = 1;
if (!chTag("html"))
{
IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0;
return;
}
if (!chTag("script")) || (!chTag("style")) || (!chTag("binary")) ignor_text = rez;
if(!chTag("title"))
{
if (rez) header=NULL;
else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó
return;
}
if (ignor_text) return;
IF(!chTag("q")) chrcat(#line, '\"');
if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
{
if (!strcmp(#anchor, #options)) anchor_line_num=lines.first+stroka;
}
if (!chTag("body"))
{
do{
if (!strcmp(#parametr, "link=")) link_color = GetColor(#options);
if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options);
if (!strcmp(#parametr, "bgcolor="))
{
bg_color=GetColor(#options);
DrawBufFill();
}
} while(GetNextParam());
return;
}
if (!chTag("a"))
{
if (rez)
{
if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
do{
if (!strcmp(#parametr, "href="))
{
if (stroka - 1 > lines.visible) || (stroka < -2) return;
text_color_index++;
text_colors[text_color_index] = text_colors[text_color_index-1];
link = 1;
blink++;
text_colors[text_color_index] = link_color;
strcat(#page_links, #options);
strcat(#page_links, "|");
}
if (anchor) && (!strcmp(#parametr, "name="))
{
if (!strcmp(#anchor, #options))
{
anchor_line_num=lines.first+stroka;
}
}
} while(GetNextParam());
}
else {
link = 0;
IF(text_color_index > 0) text_color_index--;
}
return;
}
if (!chTag("font"))
{
if (rez)
{
text_color_index++;
text_colors[text_color_index] = text_colors[text_color_index-1];
do{
if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
{
text_colors[text_color_index] = GetColor(#options);
}
} while(GetNextParam());
}
else
if (text_color_index > 0) text_color_index--;
return;
}
if(!chTag("tr")) || (!chTag("br")) {
TextGoDown(left1, top1, width1);
return;
}
if (!chTag("div")) {
IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
return;
}
if (!chTag("p")) {
IF(oldtag[0] == 'h') return;
TextGoDown(left1, top1, width1);
IF(rez) TextGoDown(left1, top1 + 10, width1);
return;
}
if (!chTag("center"))
{
if (rez) text_align = ALIGN_CENTER;
if (!rez) text_align = ALIGN_LEFT;
return;
}
if (!chTag("right"))
{
if (rez) text_align = ALIGN_RIGHT;
if (!rez) text_align = ALIGN_LEFT;
return;
}
if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) {
TextGoDown(left1, top1, width1);
IF(rez) TextGoDown(left1, top1 + 10, width1);
strcpy(#oldtag, #tag);
if (rez)
{
if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"center")) text_align = ALIGN_CENTER;
if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"right")) text_align = ALIGN_RIGHT;
b_text = 1;
}
if (!rez)
{
text_align = ALIGN_LEFT;
b_text = 0;
}
return;
}
else
oldtag=NULL;
if (!chTag("b")) || (!chTag("strong")) || (!chTag("big")) {
b_text = rez;
return;
}
if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) {
i_text = rez;
return;
}
if (!chTag("dt"))
{
li_text = rez;
IF(rez == 0) return;
TextGoDown(left1, top1, width1);
return;
}
if(!chTag("li")) || (!chTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
{
li_text = rez;
if (rez)
{
TextGoDown(left1, top1, width1);
if (stroka > -1) && (stroka - 2 < lines.visible) DrawBufBar(li_tab * 5 * 6 + left1 - 5, line_h/2-3, 2, 2, 0x555555);
}
return;
}
if (!chTag("u")) || (!chTag("ins")) u_text = rez;
if (!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez;
if (!chTag("ul")) || (!chTag("ol")) IF(!rez)
{
li_text = rez;
li_tab--;
TextGoDown(left1, top1, width1);
} ELSE li_tab++;
if (!chTag("dd")) stolbec += 5;
if (!chTag("blockquote")) blq_text = rez;
if (!chTag("pre")) pre_text = rez;
if (!chTag("hr"))
{
if (anchor) || (stroka < -1)
{
stroka+=2;
return;
}
if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999;
TextGoDown(left1, top1, width1);
DrawBufBar(5, WB1.line_h/2, WB1.width-10, 1, hr_color);
TextGoDown(left1, top1+WB1.line_h, width1);
}
if (!chTag("img"))
{
Images( left1, top1, width1);
return;
}
if (!chTag("meta")) || (!chTag("?xml"))
{
do{
if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
{
strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
if (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8")) ReadHtml(_UTF);
if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI);
if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) ReadHtml(_DOS);
}
} while(GetNextParam());
return;
}
}
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
{
scroll1.max_area = lines.all;
scroll1.cur_area = lines.visible;
scroll1.position = lines.first;
scroll1.all_redraw=1;
scroll1.start_x = WB1.left + WB1.width;
scroll1.size_y=WB1.height;
scrollbar_v_draw(#scroll1);
}

View File

@ -1,88 +0,0 @@
<!--doctype html public "-//w3c//dtd html 4.0 transitional//ru"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Òåñò Acid 0.1</title>
</head>
<body bgcolor="#000000" link="#0066FF" text="#FFFFFF">
<h1 align=center>Ýòî òåñòîâàÿ ñòðàíèöà äëÿ ïðîâåðêè HTML Viewer</h1>
<br />
<p>Ýòà ïðîãðàììà ïîääåðæèâàåò âñå ïîïóëÿðíûå êîäèðîâêè:
cp1251, koi-8, cp866, unicode.</p>
<br />
<b>
<font color="#FF0000">C</font>
<font color="#FFC005">r</font>
<font color="#F6F574">e</font>
<font color="#9EFC36">a</font>
<font color="#29FDFD">t</font>
<font color="#36A8FC">e</font>
<font color="blueviolet">d </font>
<font color="#C911FF">b</font>
<font color= #C911FF >y </font>
<font color="#C911FF">L</font>
<font color="#36A8FC">e</font>
<font color="#29FDFD">e</font>
<font color="#9EFC36">n</font>
<font color="#FFC005">c</font>
<font color="red">y</font><br>
</b>
Æèòîìèð 2008-2013
<p>
Íåáîëüøîé ñïèñîê:<ol>
<li><q>Ýòîò òåêñò â êàâû÷êàõ</q></li>
<li><u>Ýòî ïîä÷åðêíóòûé òåêñò</u></li>
<li><s>Ýòî ïåðå÷åðêíóòûé òåêñò</s></li>
<li><i>Ýòî íàêëîííûé òåêñò</i></li>
<li><strong>Ýòî òåêñò ñ óñèëåííûì âûäåëåíèåì</strong></li>
<li><b><u><s><font color="#6495ED">Êó÷à òåãîâ</font></s></u></b></ol>
</p>
<br>
<center>
<pre>
Àòü!
Äâà!
Òðè!
Àâòîð ñåãî òâîðåíèÿ íå èçâåñòåí.
</pre>
</center>
<!--ýòîãî òåêñòà çäåñü <íåò>-->
<br>
<input type="text" size="30" /></label><br>
<label>Radio1: <input type="radio" name="sex" /></label>
<label>Radio2: <input type="radio" name="sex" /></label><br>
<br>
<img name="2.1.4" src="background.gif" alt="background">
<font color=#777777>
<a href='./index.htm'>./index.htm</a><br>
<a href='/sys/index.htm'>Íåçàêðûòûé òåã à - index.htm<br>
<a href="/sys/kernel.mnt">kernel.mnt</a><br>
<a href="#2.1.4">#2.1.4</a><br>
<a href="http://bash.im">http://bash.im</a><br>
<a href="mailto:leency@mail.ru">Mail to leency</a><br>
<a href="background.gif">Ôîíîâàÿ êàðòèíêà</a><br>
</font>
<a href='1111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111
'>Î÷åíü äëèííûé àäðåñ ñòðîêè</a><br>
<hr color="#758999">
 ýòîì òåêñòå åñòü ïåðåõîä íà ñëåäóþùóþ ñòðîêó, íî áðàóçåð
åãî äîëæåí ïðîèãíîðèðîâàòü. Åùå ìíîãî ïðîáåëîâ. À òóò åñòü
òàáû. Êîå-êàêèå ñèìâîëû: &quot; &amp; &lt; &gt; &#149;
&nbsp; &copy; &reg; &bdquo; &ldquo; &#151; ¯æà÷îê ³íøîãî áîêó ð. ªâôðàò ç'¿â ´ðóíò òà ºâðåéñüêèé ´åðáàëàéô.
<hr color="grey">
</body>
</html>

View File

@ -1,193 +0,0 @@
//Íàäî áóäåò ïåðåäåëàòü íà "äåðåâî ïîèñêà" èëè, ÷òî-òî ïîäîáíîå
//áóäåò íå÷èòàáåëüíî, çàòî ìåíüøå è áûñòåå
struct color_spec {
char *name;
int rgb;
};
struct color_spec color_specs[] = {
"aliceblue", 0xF0F8FF,
"antiquewhite", 0xFAEBD7,
"aqua", 0x00FFFF,
"aquamarine", 0x7FFFD4,
"azure", 0xF0FFFF,
"beige", 0xF5F5DC,
"bisque", 0xFFE4C4,
"black", 0x000000,
"blanchedalmond",0xFFEBCD,
"blue", 0x0000FF,
"blueviolet", 0x8A2BE2,
"brown", 0xA52A2A,
"burlywood", 0xDEB887,
"cadetblue", 0x5F9EA0,
"chartreuse", 0x7FFF00,
"chocolate", 0xD2691E,
"coral", 0xFF7F50,
"cornflowerblue",0x6495ED,
"cornsilk", 0xFFF8DC,
"crimson", 0xDC143C,
"cyan", 0x00FFFF,
"darkblue", 0x00008B,
"darkcyan", 0x008B8B,
"darkgoldenrod", 0xB8860B,
"darkgray", 0xA9A9A9,
"darkgreen", 0x006400,
"darkkhaki", 0xBDB76B,
"darkmagenta", 0x8B008B,
"darkolivegreen",0x556B2F,
"darkorange", 0xFF8C00,
"darkorchid", 0x9932CC,
"darkred", 0x8B0000,
"darksalmon", 0xE9967A,
"darkseagreen", 0x8FBC8F,
"darkslateblue", 0x483D8B,
"darkslategray", 0x2F4F4F,
"darkturquoise", 0x00CED1,
"darkviolet", 0x9400D3,
"deeppink", 0xFF1493,
"deepskyblue", 0x00BFFF,
"dimgray", 0x696969,
"dodgerblue", 0x1E90FF,
"firebrick", 0xB22222,
"floralwhite", 0xFFFAF0,
"forestgreen", 0x228B22,
"fuchsia", 0xFF00FF,
"gainsboro", 0xDCDCDC,
"ghostwhite", 0xF8F8FF,
"gold", 0xFFD700,
"goldenrod", 0xDAA520,
"gray", 0x808080,
"green", 0x008000,
"greenyellow", 0xADFF2F,
"honeydew", 0xF0FFF0,
"hotpink", 0xFF69B4,
"indianred", 0xCD5C5C,
"indigo", 0x4B0082,
"ivory", 0xFFFFF0,
"khaki", 0xF0E68C,
"lavender", 0xE6E6FA,
"lavenderblush", 0xFFF0F5,
"lawngreen", 0x7CFC00,
"lemonchiffon", 0xFFFACD,
"lightblue", 0xADD8E6,
"lightcoral", 0xF08080,
"lightcyan", 0xE0FFFF,
"lightgoldenrodyellow", 0xFAFAD2,
"lightgreen", 0x90EE90,
"lightgrey", 0xD3D3D3,
"lightpink", 0xFFB6C1,
"lightsalmon", 0xFFA07A,
"lightseagreen", 0x20B2AA,
"lightskyblue", 0x87CEFA,
"lightslategray",0x778899,
"lightsteelblue",0xB0C4DE,
"lightyellow", 0xFFFFE0,
"lime", 0x00FF00,
"limegreen", 0x32CD32,
"linen", 0xFAF0E6,
"magenta", 0xFF00FF,
"maroon", 0x800000,
"mediumaquamarine",0x66CDAA,
"mediumblue", 0x0000CD,
"mediumorchid", 0xBA55D3,
"mediumpurple", 0x9370DB,
"mediumseagreen",0x3CB371,
"mediumslateblue",0x7B68EE,
"mediumspringgreen",0x00FA9A,
"mediumturquoise",0x48D1CC,
"mediumvioletred",0xC71585,
"midnightblue", 0x191970,
"mintcream", 0xF5FFFA,
"mistyrose", 0xFFE4E1,
"moccasin", 0xFFE4B5,
"navajowhite", 0xFFDEAD,
"navy", 0x000080,
"oldlace", 0xFDF5E6,
"olive", 0x808000,
"olivedrab", 0x6B8E23,
"orange", 0xFFA500,
"orangered", 0xFF4500,
"orchid", 0xDA70D6,
"palegoldenrod", 0xEEE8AA,
"palegreen", 0x98FB98,
"paleturquoise", 0xAFEEEE,
"palevioletred", 0xDB7093,
"papayawhip", 0xFFEFD5,
"peachpuff", 0xFFDAB9,
"peru", 0xCD853F,
"pink", 0xFFC0CB,
"plum", 0xDDA0DD,
"powderblue", 0xB0E0E6,
"purple", 0x800080,
"red", 0xFF0000,
"rosybrown", 0xBC8F8F,
"royalblue", 0x4169E1,
"saddlebrown", 0x8B4513,
"salmon", 0xFA8072,
"sandybrown", 0xF4A460,
"seagreen", 0x2E8B57,
"seashell", 0xFFF5EE,
"sienna", 0xA0522D,
"silver", 0xC0C0C0,
"skyblue", 0x87CEEB,
"slateblue", 0x6A5ACD,
"slategray", 0x708090,
"snow", 0xFFFAFA,
"springgreen", 0x00FF7F,
"steelblue", 0x4682B4,
"tan", 0xD2B48C,
"teal", 0x008080,
"thistle", 0xD8BFD8,
"tomato", 0xFF6347,
"turquoise", 0x40E0D0,
"violet", 0xEE82EE,
"wheat", 0xF5DEB3,
"white", 0xFFFFFF,
"whitesmoke", 0xF5F5F5,
"yellow", 0xFFFF00,
"yellowgreen", 0x9ACD32,
0};
dword StrToCol(char* htmlcolor)
{
dword j=1,
color=0,
textlen=0;
char ch=0x00;
if (ESBYTE[htmlcolor]<>'#') return text_colors[0];
textlen = strlen(htmlcolor);
if (textlen==7) || (textlen==4)
{
FOR (; j<textlen; j++)
{
ch=ESBYTE[htmlcolor+j];
IF ((ch>='0') && (ch<='9')) ch -= '0';
IF ((ch>='A') && (ch<='F')) ch -= 'A'-10;
IF ((ch>='a') && (ch<='f')) ch -= 'a'-10;
color = color*0x10 + ch;
if (textlen==4) color = color*0x10 + ch; //#abc ->> #aabbcc (ñëàâà âèêèïåäèè!!1)
}
return color;
}
return text_colors[0];
}
dword GetColor(char* color_str)
{
int ii;
if (ESBYTE[color_str] == '#')
return StrToCol(color_str);
else
for (ii=0; color_specs[ii].name!=0; ii++)
{
if (!strcmp(color_str, color_specs[ii].name)) return color_specs[ii].rgb;
}
return text_colors[0];
}

View File

@ -1,59 +0,0 @@
struct UrlsHistory {
dword CurrentUrl();
void AddUrl();
byte GoBack();
byte GoForward();
};
UrlsHistory BrowserHistory;
struct path_string {
char Item[4096];
};
#define MAX_HISTORY_NUM 40
path_string history_list[MAX_HISTORY_NUM];
int history_num;
int history_current;
dword UrlsHistory::CurrentUrl()
{
return #history_list[history_current].Item;
}
void UrlsHistory::AddUrl() //òóò íóæåí ââîäèìûé ýëåìåíò - äëÿ óíèâåðñàëüíîñòè
{
int i;
if (history_num>0) && (!strcmp(#URL,#history_list[history_current].Item)) return;
if (history_current>=MAX_HISTORY_NUM-1)
{
history_current/=2;
for (i=0; i<history_current; i++;)
{
strlcpy(#history_list[i].Item, #history_list[MAX_HISTORY_NUM-i].Item, sizeof(history_list[0].Item));
}
}
history_current++;
strlcpy(#history_list[history_current].Item, #URL, sizeof(history_list[0].Item));
history_num=history_current;
}
byte UrlsHistory::GoBack()
{
if (history_current<=1) return 0;
history_current--;
strlcpy(#URL, #history_list[history_current].Item, sizeof(URL));
return 1;
}
byte UrlsHistory::GoForward()
{
if (history_current==history_num) return 0;
history_current++;
strlcpy(#URL, #history_list[history_current].Item, sizeof(URL));
return 1;
}

View File

@ -1,94 +0,0 @@
struct s_image
{
dword *image;
char path[4096];
};
s_image pics[100]; //pics = mem_Alloc( 100*sizeof(s_image) );
int num_of_pics;
int GetOrSetPicNum(dword i_path)
{
int i;
for (i=0; i<num_of_pics; i++)
{
if (!strcmp(#pics[i].path, i_path)) return i;
}
num_of_pics++;
return num_of_pics;
}
void FreeImgCache()
{
for ( ; num_of_pics>0; num_of_pics--)
{
if (pics[num_of_pics].image) img_destroy stdcall (pics[num_of_pics].image);
pics[num_of_pics].path = NULL;
}
notify(IMAGES_CACHE_CLEARED);
}
void Images(int left1, top1, width1)
{
dword image;
char img_path[4096], alt[4096];
int w=0, h=0, img_lines_first=0, cur_pic=0;
do{
if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl()
{
if (downloader_id) strcpy(#img_path, #history_list[history_current-1].Item);
else strcpy(#img_path, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
{
img_path[strrchr(#img_path, '/')] = '\0'; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
strcat(#img_path, #options);
cur_pic=GetOrSetPicNum(#img_path);
if (!pics[cur_pic].path)
{
pics[cur_pic].image=load_image(#img_path);
strcpy(#pics[cur_pic].path, #img_path);
}
}
}
if (!strcmp(#parametr,"alt="))
{
strcpy(#alt, "[");
strcat(#alt, #options);
strcat(#alt, "]");
}
} while(GetNextParam());
if (!pics[cur_pic].image)
{
if (alt) && (link) strcat(#line, #alt);
return;
}
w = DSWORD[pics[cur_pic].image+4];
h = DSWORD[pics[cur_pic].image+8];
if (w > width1) w = width1;
if (stroka==0) DrawBar(WB1.left, WB1.top, WB1.width-15, 5, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
stroka+=h/10;
if (top1+h<WB1.top) || (top1>WB1.top+WB1.height-10) return; //åñëè ÂѨ èçîáðàæåíèå óøëî ÂÅÐÕ èëè ÂÍÈÇ
if (top1<WB1.top) //åñëè ÷àñòü èçîáðàæåíèÿ ñâåðõó
{
img_lines_first=WB1.top-top1;
h=h-img_lines_first;
top1=WB1.top;
}
if (top1>WB1.top+WB1.height-h-5) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó
{
h=WB1.top+WB1.height-top1-5;
}
if (h<=0) return;
if (anchor) return;
img_draw stdcall (pics[cur_pic].image, left1-5, top1, w, h,0,img_lines_first);
DrawBar(left1+w - 5, top1, WB1.width-w, h, bg_color);
IF (link) UnsafeDefineButton(left1 - 5, top1, w, h-1, blink + BT_HIDE, 0xB5BFC9);
}

View File

@ -1,77 +0,0 @@
//Leency - 2012-2013
char *ITEMS_LIST[]={
"WIN F5",54,
"DOS Ctrl+D",04,
"KOI Ctrl+K",11,
"UTF Ctrl+U",21,
#ifdef LANG_RUS
"ˆá室­¨ª áâà ­¨æë F3",52,
"Žç¨áâ¨âì ªíè ª à⨭®ª" ,02,
#else
"View source F3",52,
"Free image cache" ,02,
#endif
0};
llist menu;
dword col_work = 0xE4DFE1;
dword col_border = 0x9098B0;
void menu_rmb()
{
mouse mm;
proc_info MenuForm;
int key;
menu.first = menu.current = 0;
while (ITEMS_LIST[menu.count*2]) menu.count++;
menu.SetSizes(2,2,165,menu.count*19,0,19);
SetEventMask(100111b);
loop() switch(WaitEvent())
{
case evMouse:
GetProcessInfo(#MenuForm, SelfInfo);
if (!CheckActiveProcess(MenuForm.ID)) ExitProcess();
mm.get();
if (menu.ProcessMouse(mm.x, mm.y)) DrawMenuList();
if (mm.lkm) || (mm.pkm) { action_buf = ITEMS_LIST[menu.current*2+1]; ExitProcess(); }
break;
case evKey:
key = GetKey();
if (key==27) ExitProcess();
if (menu.ProcessKey(key)) DrawMenuList();
if (key==13)
{
action_buf = ITEMS_LIST[menu.current*2+1];
ExitProcess();
}
break;
case evReDraw:
DefineAndDrawWindow(Form.left+m.x,Form.top+m.y+GetSkinHeight()+3,menu.w+2,menu.h+4,0x01, 0, 0, 0x01fffFFF);
DrawPopup(0,0,menu.w,menu.h+3,0, col_work,col_border);
DrawMenuList();
}
}
void DrawMenuList()
{
int N;
for (N=0; N<menu.count; N++;)
{
if (N==menu.current)
DrawBar(menu.x, N*menu.line_h+menu.y, menu.w-3, menu.line_h, 0x94AECE);
else
{
DrawBar(menu.x, N*menu.line_h+menu.y, menu.w-3, menu.line_h, col_work);
WriteText(19,N*menu.line_h+9,0x80,0xf2f2f2,ITEMS_LIST[N*2]);
}
WriteText(18,N*menu.line_h+8,0x80,0x000000,ITEMS_LIST[N*2]);
}
DrawBar(7, cur_encoding*menu.line_h+9, 4, 4, 0x444444); //show current encoding
}

View File

@ -1,38 +0,0 @@
unsigned int GetNextParam()
{
byte kavichki = false;
int i = strlen(#tagparam) - 1;
if (!tagparam) return 0;
WHILE((i > 0) && ((tagparam[i] == '"') || (tagparam[i] == ' ') || (tagparam[i] == '\'') || (tagparam[i] == '/')))
{
IF (tagparam[i] == '"') || (tagparam[i] == '\'') kavichki=tagparam[i];
tagparam[i] = 0x00;
i--;
}
if (kavichki)
{
i=strrchr(#tagparam, kavichki);
strlcpy(#options, #tagparam + i, sizeof(options));
}
else
{
WHILE((i > 0) && (tagparam[i] <>'=')) i--; //i=strrchr(#tagparam, '=')+1;
i++;
strlcpy(#options, #tagparam + i, sizeof(options));
WHILE (options[0] == ' ') strcpy(#options, #options+1);
}
tagparam[i] = 0x00;
FOR ( ; ((tagparam[i] <>' ') && (i > 0); i--)
{
IF (tagparam[i] == '=') //äåğçêàÿ çàãëóøêà
tagparam[i + 1] = 0x00;
}
strlcpy(#parametr, #tagparam + i + 1, sizeof(parametr));
tagparam[i] = 0x00;
return 1;
}

View File

@ -1,34 +0,0 @@
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT };
enum { _WIN, _DOS, _KOI, _UTF };
#define ID1 178
#define ID2 177
dword get_URL_part(int len) {
char temp1[sizeof(URL)];
strcpy(#temp1, #URL);
temp1[len] = 0x00;
return #temp1;
}
inline byte chTag(dword text) {return strcmp(#tag,text);}
void GetURLfromPageLinks(int id)
{
int i, j = 0;
for (i = 0; i <= id - 401; i++)
{
do
{
j++;
if (j>=strlen(#page_links)) return;
}
while (page_links[j] <>'|');
}
page_links[j] = 0x00;
strcpy(#URL, #page_links+strrchr(#page_links, '|'));
}

View File

@ -1,89 +0,0 @@
char *unicode_tags[]={
"nbsp", " ",
"#38", " ",
"#160", " ",
"copy", "(c)",
"#169", "(c)",
"trade", "[TM]",
"reg", "(r)",
"#174", "(r)",
"bdquo", ",,",
"amp", "&",
"#38", "&",
"lt", "<",
"#60", "<",
"gt", ">",
"#62", ">",
"minus", "-",
"ndash", "-",
"mdash", "-", //--
"#8722", "-",
"#8211", "-",
"#151", "-",
"#149", "-",
"rsquo", "'",
"#39", "'",
"#96", "'",
"#8217", "'",
"quot", "\"",
"#34", "\"",
"ldquo", "\"",
"rdquo", "\"",
"#8222", "\"",
"#8221", "\"",
"laquo", "<<",
"#171", "<<",
"raquo", ">>",
"#187", ">>",
"uarr", "\24",
"darr", "\25",
"rarr", "\26",
"larr", "\27",
"#1028", "\242",
"#1030", "I",
"#1031", "\244",
"#8470", "N",
"bull", "-", //âîîáùå çäåñü òî÷êà
"percnt","%",
0};
byte unicode_chars[] = "<EFBFBD>ƒ„…†‡ˆ‰ŠŒ<EFBFBD>Ž<EFBFBD><EFBFBD>“”•˜™šœ<EFBFBD>žŸ ¡¢£¤¥¦§¨©ª«¬­®¯àáâãäåæçèéêëìíîïðñh£\243i\105\244\0";
unsigned char GetUnicodeSymbol()
{
int j;
for (j=0; unicode_tags[j]!=0; j+=2;)
{
if (!strcmp(#tag, unicode_tags[j]))
{
strcat(#line, unicode_tags[j+1]);
return NULL;
}
}
j = atoi(#tag + 1) - 1040;
if (tag[1] == '1') && (j>=0) && (j<=72) && (strlen(#tag) == 5)
{
return unicode_chars[j];
}
strcat(#line,#tag); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò
return NULL;
}