HTMLv 0.94: general code update

git-svn-id: svn://kolibrios.org@2810 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2012-06-20 17:22:56 +00:00
parent b409bc1b4a
commit e50cde95f6
5 changed files with 255 additions and 205 deletions

View File

@ -21,10 +21,10 @@ char URL[4096],
page_links[12000],
header[512];
int max_kolvo_strok, //lines_visible
max_kolvo_stolbcov,
count, //lines_all
za_kadrom, //lines_first
int lines_visible,
lines_all,
lines_first,
lines_column_max,
mouse_dd;
edit_box edit1= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,248,#editURL,#mouse_dd,2,19,19};
@ -42,7 +42,7 @@ void main()
{
int btn;
byte key;
int scroll_size;
int half_scroll_size;
mem_Init();
load_dll2(libio, #libio_init,1);
@ -50,9 +50,9 @@ void main()
load_dll2(boxlib, #edit_box_draw,0);
load_dll2(#abox_lib, #boxlib_init,0);
if (param) copystr(#param,#URL);
else copystr("/sys/index.htm",#URL);
copystr(#URL,#editURL);
if (param) strcpy(#URL, #param);
else strcpy(#URL, "/sys/index.htm");
strcpy(#editURL, #URL);
OpenPage();
@ -64,9 +64,9 @@ void main()
{
CASE evMouse:
/*scrollbar_v_mouse (#scroll1); //êîí÷åíûé ñêðîëë ïðèòîðìàæèìàåò, èä¸ì "ñâîèì ïóò¸ì"
if (za_kadrom <> scroll1.position)
if (lines_first <> scroll1.position)
{
za_kadrom = scroll1.position;
lines_first = scroll1.position;
WB1.ParseHTML(buf, filesize);
//break;
};*/
@ -85,33 +85,32 @@ void main()
IF (m.vert==65535) //ïðîêðóòêà êîë¸ñèêîì
{
IF (za_kadrom==0) break;
IF (za_kadrom>3) za_kadrom-=2; ELSE za_kadrom=1;
IF (lines_first==0) break;
IF (lines_first>3) lines_first-=2; ELSE lines_first=1;
WB1.Scan(ID1);
break;
}
IF (m.vert==1)
{
IF(max_kolvo_strok+za_kadrom+3>=count) WB1.Scan(181);
IF(lines_visible+lines_first+3>=lines_all) WB1.Scan(181);
ELSE {
za_kadrom+=2;
lines_first+=2;
WB1.Scan(ID2);
}
break;
}
IF (count<max_kolvo_strok) break;
scroll_size = WB1.height - 16 * max_kolvo_strok / count - 3;
IF (lines_all<lines_visible) break;
half_scroll_size = WB1.height - 16 * lines_visible / lines_all - 3 /2;
if (m.x>=WB1.width-14) && (m.x<=WB1.width+6)
&& (m.y>WB1.top+16) && (m.y<WB1.top+WB1.height-16)
&& (count>max_kolvo_strok) while (m.lkm)
&& (lines_all>lines_visible) while (m.lkm)
{
IF (scroll_size/2+WB1.top>m.y) || (m.y<0) || (m.y>4000) m.y=scroll_size/2+WB1.top; //åñëè êóðñîð íàä îêíîì
btn=za_kadrom; //ñîõðàíÿåì ñòàðîå êîëè÷åñòâî
j= scroll_size/2;
za_kadrom = m.y -j -WB1.top * count / WB1.height;
IF (max_kolvo_strok+za_kadrom>count) za_kadrom=count-max_kolvo_strok;
IF (btn<>za_kadrom) WB1.ParseHTML(buf, filesize); //÷òîá ëèøíèé ðàç íå ïåðåðèñîâûâàòü
IF (half_scroll_size/2+WB1.top>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size/2+WB1.top; //åñëè êóðñîð íàä îêíîì
btn=lines_first; //ñîõðàíÿåì ñòàðîå êîëè÷åñòâî
lines_first = m.y -half_scroll_size -WB1.top * lines_all / WB1.height;
IF (lines_visible+lines_first>lines_all) lines_first=lines_all-lines_visible;
IF (btn<>lines_first) WB1.ParseHTML(buf, filesize); //÷òîá ëèøíèé ðàç íå ïåðåðèñîâûâàòü
m.get();
}
@ -147,10 +146,10 @@ void main()
{
if (GetProcessSlot(downloader_id)<>0) break;
downloader_id=0;
lines_first = lines_all = 0;
ReadHtml();
if (filesize) wintodos(buf);
Draw_Window();
//WB1.ShowPage(#URL);
}
}
}
@ -159,16 +158,17 @@ void main()
void Draw_Window()
{
int j;
DefineAndDrawWindow(215,100,640,480,0x73,0x00E4DFE1,0,0,0);
GetProcessInfo(#Form, SelfInfo);
IF (Form.status_window>2) //åñëè ñâåðíóòî â çàãîëîâîê, íè÷åãî íå ðèñóåì
if (Form.status_window>2) //åñëè ñâåðíóòî â çàãîëîâîê, íè÷åãî íå ðèñóåì
{
DrawTitle(#header);
return;
}
IF (Form.height<120) MoveSize(OLD,OLD,OLD,120);
IF (Form.width<280) MoveSize(OLD,OLD,280,OLD);
if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
if (GetProcessSlot(downloader_id)<>0) PutImage(#stop_btn,24,24,88,10);
@ -176,7 +176,7 @@ void Draw_Window()
DrawBar(200,0,onLeft(200,9),43,0xE4DFE1); //çàêðàøèâàåì ôîí ïîä òóëáàðîì
DrawBar(0,42,onLeft(5,4),1,0xE2DBDC); //âûïóêëîñòü
DrawBar(0,43,onLeft(5,4),1,0xD2CED0); //âûïóêëîñòü
FOR (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0x00E4DFE1);
for (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0x00E4DFE1);
PutImage(#URLgoto,40,19,onLeft(57,0),14);
DefineButton(onLeft(37,0),15, 18, 16, GOTOURL+BT_HIDE, 0xE4DFE1);
DefineButton(onLeft(56,0),15, 17, 16, SEARCHWEB+BT_HIDE, 0xE4DFE1);
@ -187,8 +187,8 @@ void Draw_Window()
WB1.top=44;
WB1.width=Form.width-13;
WB1.height=onTop(43,5);
max_kolvo_stolbcov = WB1.width - 30 / 6;
max_kolvo_strok = WB1.height - 3 / 10 - 2;
lines_column_max = WB1.width - 30 / 6;
lines_visible = WB1.height - 3 / 10 - 2;
WB1.ShowPage(#URL);
}

View File

@ -1,15 +1,15 @@
int downloader_id;
dword j,
dword
buf,
filesize,
blink = 400;
blink;
int i;
char download_path[]="/rd/1/.download";
char search_path[]="http://nigma.ru/index.php?s=";
char version[]=" Text-based Browser 0.93e";
char version[]=" Text-based Browser 0.94";
struct TWebBrowser {
@ -60,20 +60,18 @@ void TWebBrowser::Scan(int id)
//#1
if (URL[0] == '#')
{
copystr(#URL+find_symbol(#URL, '#'), #anchor);
strcpy(#anchor, #URL+find_symbol(#URL, '#'));
copystr(BrowserHistory.CurrentUrl(), #URL);
//copystr(#editURL, #URL + strlen(#URL));
//copystr(#URL, #editURL);
strcpy(#URL, BrowserHistory.CurrentUrl());
za_kadrom=count-max_kolvo_strok;
lines_first=lines_all-lines_visible;
ShowPage(#URL);
return;
}
//liner.ru#1
if (find_symbol(#URL, '#')<>-1)
{
copystr(#URL+find_symbol(#URL, '#'), #anchor);
strcpy(#anchor, #URL+find_symbol(#URL, '#'));
URL[find_symbol(#URL, '#')-1] = 0x00; //çàãëóøêà
}
@ -82,7 +80,7 @@ void TWebBrowser::Scan(int id)
if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
{
RunProgram("/sys/media/kiv", #URL);
copystr(BrowserHistory.CurrentUrl(), #URL);
strcpy(#URL, BrowserHistory.CurrentUrl());
return;
}
@ -90,7 +88,7 @@ void TWebBrowser::Scan(int id)
return;
}
IF(count < max_kolvo_strok) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
IF(lines_all < lines_visible) SWITCH(id) //åñëè ìàëî ñòðîê èãíîðèðóåì íåêîòîðûå êíîïêè
{ CASE 183: CASE 184: CASE 180: CASE 181: return; }
switch (id)
@ -127,7 +125,7 @@ void TWebBrowser::Scan(int id)
Draw_Window();
return;
}
anchor_line_num=za_kadrom; //âåñ¸ëûé êîñòûëü :Ð
anchor_line_num=lines_first; //âåñ¸ëûé êîñòûëü :Ð
anchor[0]='|';
OpenPage();
return;
@ -139,44 +137,44 @@ void TWebBrowser::Scan(int id)
return;
case HOME:
copystr("http://kolibri-os.narod.ru", #editURL);
strcpy(#editURL, "http://kolibri-os.narod.ru");
case GOTOURL:
case 0x0D: //enter
copystr(#editURL, #URL);
strcpy(#URL, #editURL);
OpenPage();
return;
case 173: //ctrl+enter
case SEARCHWEB:
copystr(#search_path, #URL);
copystr(#editURL, #URL + strlen(#URL));
strcpy(#URL, #search_path);
strcat(#URL, #editURL);
OpenPage();
return;
case ID1: //ìîòàåì ââåðõ
IF(za_kadrom <= 0) return;
za_kadrom--;
IF(lines_first <= 0) return;
lines_first--;
break;
case ID2: //ìîòàåì âíèç
IF(max_kolvo_strok + za_kadrom >= count) return;
za_kadrom++;
IF(lines_visible + lines_first >= lines_all) return;
lines_first++;
break;
case 183: //PgDown
IF(za_kadrom == count - max_kolvo_strok) return;
za_kadrom += max_kolvo_strok + 2;
IF(max_kolvo_strok + za_kadrom > count) za_kadrom = count - max_kolvo_strok;
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(za_kadrom == 0) RETURN;
za_kadrom -= max_kolvo_strok - 2;
IF(za_kadrom < 0) za_kadrom = 0;
IF(lines_first == 0) RETURN;
lines_first -= lines_visible - 2;
IF(lines_first < 0) lines_first = 0;
BREAK;
case 180: //home
IF(za_kadrom == 0) RETURN;
za_kadrom = 0;
IF(lines_first == 0) RETURN;
lines_first = 0;
BREAK;
case 181: //end
IF (za_kadrom == count - max_kolvo_strok) RETURN;
za_kadrom = count - max_kolvo_strok;
IF (lines_first == lines_all - lines_visible) RETURN;
lines_first = lines_all - lines_visible;
BREAK;
default:
RETURN;
@ -187,12 +185,12 @@ void TWebBrowser::Scan(int id)
void GetNewUrl(){
IF (!strcmp(get_URL_part(2),"./")) copystr(#URL+2,#URL); //èãíîðèì :)
IF (!strcmp(get_URL_part(2),"./")) strcpy(#URL, #URL+2); //èãíîðèì :)
if (URL[0] <> '/')
&& (strcmp(get_URL_part(5),"http:")<>0) && (strcmp(get_URL_part(5),"mailt")<>0) && (strcmp(get_URL_part(5),"ftp:/")<>0)
{
copystr(BrowserHistory.CurrentUrl(), #editURL); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
strcpy(#editURL, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
_CUT_ST_LEVEL_MARK:
@ -203,14 +201,14 @@ void GetNewUrl(){
IF (!strcmp(get_URL_part(3),"../")) //íà óðîâåíü ââåðõ
{
copystr(#URL+3,#URL);
strcpy(#URL,#URL+3);
editURL[find_symbol(#editURL, '/')-1] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
goto _CUT_ST_LEVEL_MARK;
}
if (editURL[strlen(#editURL)-1]<>'/') copystr("/", #editURL + strlen(#editURL));
copystr(#URL, #editURL + strlen(#editURL)); //êëåèì íîâûé àäðåñ
copystr(#editURL, #URL);
if (editURL[strlen(#editURL)-1]<>'/') strcat(#editURL, "/");
strcat(#editURL, #URL); //êëåèì íîâûé àäðåñ
strcpy(#URL, #editURL);
}
}
@ -239,12 +237,10 @@ void OpenPage()
{
if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
KillProcess(downloader_id);
copystr(#URL, #editURL);
strcpy(#editURL, #URL);
BrowserHistory.AddUrl();
za_kadrom = count = 0;
if (!strcmp(get_URL_part(5),"http:")))
{
copystr(#version, #header);
KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ
DeleteFile(#download_path);
IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]='';
@ -262,6 +258,7 @@ void OpenPage()
Draw_Window();
return;
}
lines_first = lines_all = 0;
ReadHtml();
if (filesize) wintodos(buf);
WB1.ShowPage(#URL);
@ -294,25 +291,29 @@ void TWebBrowser::ShowPage(dword adress)
void TWebBrowser::ParseHTML(dword bword, fsize){
word bukva[1];
int j;
byte ignor_param = 0;
char temp[768];
stroka = -za_kadrom;
stroka = -lines_first;
stolbec = 0;
FOR(j = 400; j < blink + 1; j++;) DeleteButton(j);
for (j = 400; j < blink + 1; j++;) DeleteButton(j);
blink = 400;
b_text = i_text = u_text = s_text = pre_text = blq_text = body_present =
li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 0; //îáíóëÿåì òåãè
link_color = 0x0000FF;
bg_color = 0xFFFFFF;
blink = 400;
line = '';
copystr("|", #page_links);
copystr(#version, #header);
IF(!strcmp(#URL + strlen(#URL) - 4, ".txt"))
strcpy(#page_links,"|");
strcpy(#header,#version);
if (!strcmp(#URL + strlen(#URL) - 4, ".txt"))
{
DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
pre_text = 1; //çà÷¸òíîå îòîáðàæåíèå òåêñòà
}
IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
for (bword = buf; buf + fsize > bword; bword++;) {
bukva = ESBYTE[bword];
switch (bukva) {
@ -328,7 +329,7 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
tab_len=strlen(#line)/8;
tab_len=tab_len*8;
tab_len=8+tab_len-strlen(#line);
for (i=0; i<tab_len; i++;) copystr(" ", #line + strlen(#line));
for (i=0; i<tab_len; i++;) strcat(#line," ");
break;
}
case 0x0d:
@ -336,114 +337,116 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
goto DEFAULT_MARK;
case '<':
bword++; //ïðîìîòàåì ñèìâîë <
IF(ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
if (ESBYTE[bword] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
{
bword++;
IF(ESBYTE[bword] == '-') {
if (ESBYTE[bword] == '-') {
HH_: do {
bword++;
IF(bword >= buf + fsize) break 1;
} while (ESBYTE[bword] <>'-');
bword++;
IF(ESBYTE[bword] <>'-') GOTO HH_;
if (ESBYTE[bword] <>'-') goto HH_;
}
}
WHILE (ESBYTE[bword] <>'>') && (bword < buf + fsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
while (ESBYTE[bword] <>'>') && (bword < buf + fsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
{
bukva = ESBYTE[bword];
IF(bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
IF(!ignor_param) && (bukva <>' ') copystr(#bukva, #tag + strlen(#tag));
ELSE {
if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
if (!ignor_param) && (bukva <>' ') strcat(#tag, #bukva);
else
{
ignor_param = true;
copystr(#bukva, #tagparam + strlen(#tagparam));
strcat(#tagparam, #bukva);
}
bword++;
}
lowcase(#tag);
lowcase(#tagparam);
IF (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=''; //íåáîëüøîé ôèêñ äëÿ ðàáîòû ñ XHTML-òåãàìè òèïà br/
IF(strlen(#tagparam) > 0) && (strlen(#tagparam) < 4000) GetNextParam();
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=''; //íåáîëüøîé ôèêñ äëÿ ðàáîòû ñ XHTML-òåãàìè òèïà br/
if (strlen(#tagparam) > 0) && (strlen(#tagparam) < 4000) GetNextParam();
WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //îáðàáîòêà òåãîâ
line = tag = parametr = tagparam = ignor_param = 0; //âñ¸ îáíóëÿåì
break;
case '=': //ïîääåðæêà øàéòàíñêîé êîäèðîâêè ñòðàíèö, ñîõðàí¸ííûõ ÷åðåç ÈÅ7
IF(strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
bword++;
bukva=ESBYTE[bword];
copystr(#bukva, #temp);
strcpy(#temp,#bukva);
bword++;
bukva=ESBYTE[bword];
copystr(#bukva, #temp + strlen(#temp));
strcat(#temp,#bukva);
bukva=Hex2Symb(#temp);
IF (bukva) goto DEFAULT_MARK;
if (bukva) goto DEFAULT_MARK;
break;
case '&': //îáðàáîòêà òåãîâ òèïà &nbsp;
IF(ignor_text) break;
if (ignor_text) break;
bword++;
tag='';
FOR (j=0; (ESBYTE[bword] <>';') && (j < 7); j++; bword++;)
for (j=0; (ESBYTE[bword] <>';') && (j < 7); j++, bword++;)
{
bukva = ESBYTE[bword];
copystr(#bukva, #tag + strlen(#tag));
strcat(#tag, #bukva);
}
FOR (j=0; unicode_tags[j]!=0; j+=2;)
for (j=0; unicode_tags[j]!=0; j+=2;)
{
IF(!strcmp(#tag, unicode_tags[j]))
if (!strcmp(#tag, unicode_tags[j]))
{
copystr(unicode_tags[j+1], #line + strlen(#line));
strcat(#line, unicode_tags[j+1]);
break 1;
}
}
rez = StrToInt(#tag + 1) - 1040;
IF(tag[1] == '1') && (rez>=0) && (rez<=72) && (strlen(#tag) == 5)
if (tag[1] == '1') && (rez>=0) && (rez<=72) && (strlen(#tag) == 5)
{
bukva = unicode_chars[rez];
GOTO DEFAULT_MARK; //îáðàáàòûâàåì áóêâó
}
//WriteDebug(#tag); //òýã íå íàéäåí - âûâîäèì íà äîñêó îòëàäêè
copystr(#tag, #line + strlen(#line)); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò
//debug(#tag); //òýã íå íàéäåí - âûâîäèì íà äîñêó îòëàäêè
strcat(#line,#tag); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò
break;
default:
DEFAULT_MARK:
IF(ignor_text) break;
IF(pre_text == 0) && (bukva == ' ') && (strcmp(#line + strlen(#line) - 1, " ") == 0) continue;
IF(!pre_text) && (bukva == ' ') && (!strcmp(#line + strlen(#line) - 1, " ")) continue;
//
if (stolbec + strlen(#line) > max_kolvo_stolbcov)
if (stolbec + strlen(#line) >lines_column_max)
{
copystr(#line + find_symbol(#line, ' '), #temp); //ïåðåíîñ ïî ñëîâàì
strcpy(#temp, #line + find_symbol(#line, ' ')); //ïåðåíîñ ïî ñëîâàì
line[find_symbol(#line, ' ')] = 0x00;
NEXT_MARK: IF(stroka - 1 > max_kolvo_strok) && (za_kadrom <>0) break 1; //óõîäèì...
NEXT_MARK:
IF(stroka - 1 > lines_visible) && (lines_first <>0) break 1; //óõîäèì...
WhatTextStyle(left + 5, stroka * 10 + top + 5, width - 20); //âûâîä ñòðîêè
TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
copystr(#temp, #line);
strcpy(#line, #temp);
}
IF(pre_text == 0) && (bukva == ' ') && (stolbec == 0) && (strlen(#line) == 0) CONTINUE;
copystr(#bukva, #line + strlen(#line));
if (!pre_text) && (bukva == ' ') && (!stolbec) && (!line) CONTINUE;
strcat(#line, #bukva);
}
}
if (strcmp(#URL + strlen(#URL) - 4, ".txt")<>0) && (body_present==0)
if (strcmp(#URL + strlen(#URL) - 4, ".txt")<>0) && (!body_present)
DrawBar(left, top, width-15, 15, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó åñëè êàêîé-òî ðàõèò íå ñîçäàë òåã áîäè
if (max_kolvo_strok * 10 + 25 <= height)
DrawBar(left, max_kolvo_strok * 10 + top + 25, width - 15, -max_kolvo_strok * 10 + height - 25, bg_color);
if (lines_visible * 10 + 25 <= height)
DrawBar(left, lines_visible * 10 + top + 25, width - 15, -lines_visible * 10 + height - 25, bg_color);
if (stroka * 10 + 15 <= height)
DrawBar(left, stroka * 10 + top + 15, width - 15, -stroka * 10 + height - 15, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
if (za_kadrom == 0) count = stroka;
if (lines_first == 0) lines_all = stroka;
if (anchor)
{
anchor[0]='';
za_kadrom=anchor_line_num;
anchor='';
lines_first=anchor_line_num;
ParseHTML(buf, filesize);
}
@ -466,15 +469,15 @@ void GetNextParam()
IF (kavichki)
{
i=find_symbol(#tagparam, kavichki);
copystr(#tagparam + i, #options);
strcpy(#options, #tagparam + i);
}
ELSE
{
WHILE((i > 0) && (tagparam[i] <>'=')) i--; //i=find_symbol(#tagparam, '=')+1;
i++;
copystr(#tagparam + i, #options); //êîïèðóåì îïöèþ
WHILE (options[0] == ' ') copystr(#options + 1, #options);
strcpy(#options, #tagparam + i); //êîïèðóåì îïöèþ
WHILE (options[0] == ' ') strcpy(#options, #options+1);
}
tagparam[i] = 0x00;
@ -487,7 +490,7 @@ void GetNextParam()
}
}
copystr(#tagparam + i + 1, #parametr); //êîïèðóåì ïàðàìåòð
strcpy(#parametr, #tagparam + i + 1); //êîïèðóåì ïàðàìåòð
tagparam[i] = 0x00;
}
@ -499,13 +502,13 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
dword image=0;
char temp[4096];
int w, h, img_za_kadrom=0;
int w, h, img_lines_first=0;
//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
IF(tag[0] == '/')
{
rez = 0;
copystr(#tag + 1, #tag);
strcpy(#tag, #tag+1);
}
ELSE
rez = 1;
@ -519,9 +522,9 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
if(!chTag("title")) && (!rez)
{
copystr(#line, #header);
copystr(" -", #header + strlen(#header));
copystr(#version, #header + strlen(#header));
strcpy(#header, #line);
strcat(#header, " -");
strcat(#header, #version);
if (stroka==0) DrawTitle(#header);
return;
}
@ -530,10 +533,10 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
//
//
IF(!chTag("q")) copystr("\"", #line + strlen(#line));
IF(!chTag("q")) strcat(#line, "\"");
//âûâîä íà ýêðàí
if (stroka >= 0) && (stroka - 2 < max_kolvo_strok) && (line) && (!anchor)
if (stroka >= 0) && (stroka - 2 < lines_visible) && (line) && (!anchor)
{
WriteText(stolbec * 6 + left1, top1, 0x80, text_colors[text_color_index], #line, 0); //ìîæåò òóò ðèñîâàòü áåëóþ ñòðîêó?
IF (b_text) { $add ebx, 1<<16 $int 0x40 }
@ -553,7 +556,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
{
if (!strcmp(#anchor, #options))
{
anchor_line_num=za_kadrom+stroka;
anchor_line_num=lines_first+stroka;
}
}
@ -592,20 +595,20 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
_A_MARK:
if (!strcmp(#parametr, "href="))
{
if (stroka - 1 > max_kolvo_strok) || (stroka < -2) return;
if (stroka - 1 > lines_visible) || (stroka < -2) return;
if (link == 1) text_color_index--; //åñëè êàêîé-òî äîëáî¸á íå çàêðûë òýã
link = 1;
blink++;
text_color_index++;
text_colors[text_color_index] = link_color;
copystr(#options, #page_links + strlen(#page_links));
copystr("|", #page_links + strlen(#page_links));
strcat(#page_links, #options);
strcat(#page_links, "|");
}
if (anchor) && (!strcmp(#parametr, "name="))
{
if (!strcmp(#anchor, #options))
{
anchor_line_num=za_kadrom+stroka;
anchor_line_num=lines_first+stroka;
}
}
if (tagparam)
@ -623,7 +626,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
/////////////////////////
if (!chTag("font"))
{
IF (stroka - 1 > max_kolvo_strok) return;
IF (stroka - 1 > lines_visible) return;
COL_MARK:
if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
{
@ -638,34 +641,37 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
return;
}
//////////////////////////
IF(!chTag("tr")) || (!chTag("br")) {
if(!chTag("tr")) || (!chTag("br")) {
TextGoDown(left1, top1, width1);
return;
}
IF(!chTag("div")) {
if (!chTag("div")) {
IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
return;
}
IF(!chTag("p")) {
if (!chTag("p")) {
IF(oldtag[0] == 'h') return;
TextGoDown(left1, top1, width1);
IF(rez) TextGoDown(left1, top1 + 10, width1);
return;
}
////////////////////////////
IF(!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) {
if (!chTag("h1")) || (!chTag("h2")) || (!chTag("h3")) || (!chTag("h4")) {
TextGoDown(left1, top1, width1);
IF(rez) TextGoDown(left1, top1 + 10, width1);
b_text = rez;
copystr(#tag, #oldtag);
strcpy(#oldtag, #tag);
return;
} ELSE copystr("", #oldtag);
IF(!chTag("b")) || (!chTag("strong")) || (!chTag("big")) {
}
else
oldtag='';
if (!chTag("b")) || (!chTag("strong")) || (!chTag("big")) {
b_text = rez;
return;
}
////////////////////////////
IF(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) {
if(!chTag("i")) || (!chTag("em")) || (!chTag("subtitle")) {
i_text = rez;
return;
}
@ -683,7 +689,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
li_text = rez;
IF(rez == 0) return;
TextGoDown(left1, top1, width1);
IF(stroka > -1) && (stroka - 2 < max_kolvo_strok) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0);
IF(stroka > -1) && (stroka - 2 < lines_visible) DrawBar(li_tab * 5 * 6 + left1 - 5, top1 + 12, 2, 2, 0);
return;
}
////////////////////////////
@ -711,9 +717,9 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
IMG_TAG:
IF (strcmp(#parametr,"src=")==0) //íàäî îáúåäèíèòü ñ GetNewUrl()
{
copystr(BrowserHistory.CurrentUrl(), #temp); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
strcpy(#temp, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
temp[find_symbol(#temp, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
copystr(#options,#temp+strlen(#temp));
strcat(#temp, #options);
image=load_image(#temp);
w=DSWORD[image+4];
@ -735,19 +741,19 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
if (top1<WB1.top) //åñëè ÷àñòü èçîáðàæåíèÿ ñâåðõó
{
img_za_kadrom=WB1.top-top1;
h=h-img_za_kadrom;
img_lines_first=WB1.top-top1;
h=h-img_lines_first;
top1=WB1.top;
}
if (top1>WB1.top+WB1.height-h-15) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó IF (stroka - 2 < max_kolvo_strok)
if (top1>WB1.top+WB1.height-h-15) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó IF (stroka - 2 < lines_visible)
{
h=WB1.top+WB1.height-top1-15;
}
IF (h<=0) return;
img_draw stdcall (image,left1-5,top1+10,w, h,0,img_za_kadrom);
img_draw stdcall (image,left1-5,top1+10,w, h,0,img_lines_first);
DrawBar(left1+w - 5, top1 + 10, width1-w + 5, h, bg_color);
IF (link)
{
@ -767,7 +773,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
META:
if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
{
copystr(#options[find_symbol(#options, '=')],#options); //ïîèñê â content=
strcpy(#options, #options[find_symbol(#options, '=')]); //ïîèñê â content=
IF (!strcmp(#options,"utf-8")) || (!strcmp(#options,"utf8"))
{
@ -784,7 +790,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
ReadHtml();
}
}
IF(tagparam)
if (tagparam)
{
GetNextParam();
goto META;
@ -800,16 +806,16 @@ void TextGoDown(int left1, top1, width1)
IF(blq_text == 1) stolbec = 8;
ELSE stolbec = 0;
IF(li_text == 1) stolbec = li_tab * 5;
IF(stroka >= 0) && (stroka - 2 < max_kolvo_strok) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
IF(stroka >= 0) && (stroka - 2 < lines_visible) && (!anchor) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color);
}
//ñêðîëë
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
{
scroll1.max_area = count;
scroll1.cur_area = max_kolvo_strok;
scroll1.position = za_kadrom;
scroll1.max_area = lines_all;
scroll1.cur_area = lines_visible;
scroll1.position = lines_first;
scroll1.all_redraw=1;
scroll1.start_x=Form.width-28; //left + width - 15

View File

@ -30,11 +30,11 @@ void UrlsHistory::AddUrl() //
history_current/=2;
for (i=0; i<history_current; i++;)
{
copystr(#history_list[MAX_HISTORY_NUM-i].Item, #history_list[i].Item);
strcpy(#history_list[i].Item, #history_list[MAX_HISTORY_NUM-i].Item);
}
}
history_current++;
copystr(#URL,#history_list[history_current].Item);
strcpy(#history_list[history_current].Item, #URL);
history_num=history_current;
}
@ -44,7 +44,7 @@ byte UrlsHistory::GoBack()
if (history_current<=1) return 0;
history_current--;
copystr(#history_list[history_current].Item,#URL);
strcpy(#URL, #history_list[history_current].Item);
return 1;
}
@ -53,6 +53,6 @@ byte UrlsHistory::GoForward()
{
if (history_current==history_num) return 0;
history_current++;
copystr(#history_list[history_current].Item,#URL);
strcpy(#URL, #history_list[history_current].Item);
return 1;
}

View File

@ -17,7 +17,7 @@
dword get_URL_part(byte len) {
char temp1[1000];
copystr(#URL, #temp1);
strcpy(#temp1, #URL);
temp1[len] = 0x00;
return #temp1;
}
@ -27,14 +27,14 @@ inline byte chTag(dword text) {return strcmp(#tag,text);}
void GetURLfromPageLinks(int id)
{
j = 0;
int j = 0;
for (i = 0; i <= id - 401; i++)
{
do j++;
while (page_links[j] <>'|');
}
page_links[j] = 0x00;
copystr(#page_links[find_symbol(#page_links, '|')], #URL);
strcpy(#URL, #page_links[find_symbol(#page_links, '|')]);
}

View File

@ -30,7 +30,8 @@ char program_path[4096];
#define false 0
//-------------------------------------------------------------------------
struct mouse{
struct mouse
{
dword x,y,lkm,pkm,hor,vert;
void get();
};
@ -65,10 +66,12 @@ void mouse::get()
}
struct system_colors{
struct system_colors
{
dword frame,grab,grab_button,grab_button_text,grab_text,work,work_button,work_button_text,work_text,work_graph;
void get();
};
void system_colors::get()
{
EAX = 48;
@ -80,22 +83,25 @@ void system_colors::get()
//------------------------------------------------------------------------------
inline fastcall dword WaitEvent(){
inline fastcall dword WaitEvent()
{
$mov eax,10
$int 0x40
}
inline fastcall dword CheckEvent(){
inline fastcall dword CheckEvent()
{
$mov eax,11
$int 0x40
}
inline fastcall dword WaitEventTimeout(dword EBX){
inline fastcall dword WaitEventTimeout( EBX)
{
$mov eax,23
$int 0x40
}
inline fastcall SetEventMask(dword EBX)
inline fastcall SetEventMask( EBX)
{
$mov eax,40
$int 0x40
@ -109,7 +115,8 @@ inline fastcall ScancodesGeting(){
}
inline fastcall word GetKey(){ //Gluk fix
inline fastcall word GetKey() //+Gluk fix
{
$push edx
@getkey:
$mov eax,2
@ -127,21 +134,24 @@ inline fastcall word GetKey(){ //Gluk fix
}
inline fastcall Pause(dword EBX)
{ //<2F> ã§ , ¢ á®âëå ¤®«ïå ᥪ㭤ë EBX = value
inline fastcall Pause( EBX)
{
$mov eax, 5
$int 0x40
}
//==================================================================
//------------------------------------------------------------------------------
inline fastcall word GetButtonID(){
inline fastcall word GetButtonID()
{
$mov eax,17
$int 0x40
$shr eax,8
}
struct proc_info{
struct proc_info
{
#define SelfInfo -1
dword use_cpu;
word pos_in_stack,num_slot,rezerv1;
char name[11];
@ -150,18 +160,17 @@ struct proc_info{
word status_slot,rezerv3;
dword work_left,work_top,work_width,work_height;
char status_window;
void GetInfo(dword ECX);
void GetInfo( ECX);
byte reserved[1024-71];
#define SelfInfo -1
};
void GetProcessInfo(dword EBX, ECX)
void GetProcessInfo( EBX, ECX)
{
$mov eax,9;
$int 0x40
}
int GetProcessSlot(ECX) //ECX = process ID
int GetProcessSlot( ECX) //ECX = process ID
{
EAX = 18;
EBX = 21;
@ -176,28 +185,30 @@ inline fastcall int ActiveProcess()
}
inline fastcall ExitProcess(){
inline fastcall ExitProcess()
{
$mov eax,-1;
$int 0x40
}
inline fastcall int KillProcess(dword ECX){
inline fastcall int KillProcess( ECX)
{
$mov eax,18;
$mov ebx,18;
$int 0x40
}
//==================================================================
//------------------------------------------------------------------------------
//eax = ÿçûê ñèñòåìû (1=eng, 2=fi, 3=ger, 4=rus)
inline fastcall int GetSystemLanguage(){
inline fastcall int GetSystemLanguage()
{
EAX = 26;
EBX = 5;
$int 0x40
RETURN EAX;
}
inline fastcall void DrawTitle(dword ECX)
inline fastcall void DrawTitle( ECX)
{
EAX = 71;
EBX = 1;
@ -228,13 +239,13 @@ inline fastcall dword GetScreenWidth()
$and eax,0x0000FFFF
}
inline fastcall MoveSize(dword EBX,ECX,EDX,ESI)
inline fastcall MoveSize( EBX,ECX,EDX,ESI)
{
EAX = 67;
$int 0x40
}
inline fastcall dword LoadLibrary(dword ECX)
inline fastcall dword LoadLibrary( ECX)
{
$mov eax, 68
$mov ebx, 19
@ -242,32 +253,55 @@ inline fastcall dword LoadLibrary(dword ECX)
}
//------------------------------------------------------------------------------
inline fastcall dword strlen(dword EDI){
inline fastcall dword strlen( EDI)
{
EAX=0;
ECX=-1;
$REPNE $SCASB
EAX-=2+ECX;
}
inline fastcall copystr(dword ESI,EDI)
inline fastcall strcpy( EDI, ESI)
{
$cld
l1:
l2:
$lodsb
$stosb
$test al,al
$jnz l1
$jnz l2
}
byte fastcall TestBit(EAX, CL)
inline fastcall strcat( EDI, ESI)
{
$shr eax,cl
$and eax,1
asm {
MOV EBX, EDI
XOR ECX, ECX
XOR EAX, EAX
DEC ECX
REPNE SCASB
DEC EDI
MOV EDX, EDI
MOV EDI, ESI
XOR ECX, ECX
XOR EAX, EAX
DEC ECX
REPNE SCASB
XOR ECX, 0FFFFFFFFH
MOV EDI, EDX
MOV EDX, ECX
MOV EAX, EDI
SHR ECX, 2
REP MOVSD
MOV ECX, EDX
AND ECX, 3
REP MOVSB
MOV EAX, EBX
}
}
char buffer[11]="";
inline fastcall dword IntToStr(dword ESI)
inline fastcall dword IntToStr( ESI)
{
$mov edi, #buffer
$mov ecx, 10
@ -310,7 +344,7 @@ inline fastcall dword StrToInt()
}
inline fastcall int strcmp(ESI, EDI)
inline fastcall int strcmp( ESI, EDI)
{
loop()
{
@ -322,7 +356,7 @@ inline fastcall int strcmp(ESI, EDI)
}
}
inline fastcall unsigned int find_symbol(ESI,BL)
inline fastcall unsigned int find_symbol( ESI,BL)
{
int jj=0, last=-1;
do{
@ -334,7 +368,7 @@ inline fastcall unsigned int find_symbol(ESI,BL)
}
inline fastcall dword upcase(dword ESI)
inline fastcall dword upcase( ESI)
{
do{
AL=DSBYTE[ESI];
@ -343,7 +377,7 @@ inline fastcall dword upcase(dword ESI)
}while(AL!=0);
}
inline fastcall lowcase(ESI)
inline fastcall lowcase( ESI)
{
do{
$LODSB
@ -355,6 +389,15 @@ inline fastcall lowcase(ESI)
}while(AL!=0);
}
byte fastcall TestBit( EAX, CL)
{
$shr eax,cl
$and eax,1
}
//------------------------------------------------------------------------------
void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaColour,byte headerType,dword headerColour,EDI)
{
@ -375,14 +418,14 @@ void DefineAndDrawWindow(dword x,y,sizeX,sizeY,byte mainAreaType,dword mainAreaC
}
inline fastcall int CreateThread(dword ECX,EDX)
inline fastcall int CreateThread( ECX,EDX)
{
EAX = 51;
EBX = 1;
$int 0x40
}
inline fastcall int GetSlot(dword ECX)
inline fastcall int GetSlot( ECX)
{
EAX = 18;
EBX = 21;
@ -430,7 +473,8 @@ void PutPaletteImage(dword EBX,w,h,x,y,ESI,EDI)
$int 0x40
}
inline fastcall void PutPixel(dword EBX,ECX,EDX){
inline fastcall void PutPixel( EBX,ECX,EDX)
{
EAX=1;
$int 0x40
}
@ -455,7 +499,7 @@ void DefineButton(dword x,y,w,h,EDX,ESI)
$int 0x40
}
inline fastcall void DeleteButton(dword EDX)
inline fastcall void DeleteButton( EDX)
{
EAX = 8;
EDX += BT_DEL;
@ -500,7 +544,7 @@ void DrawFlatButton(dword x,y,width,height,id,color,text)
//------------------------------------------------------------------------------
inline fastcall void debug(dword EDX)
inline fastcall void debug( EDX)
{
$push ebx
$push ecx