mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-26 16:37:30 +03:00
HTMLv: some optimizations
git-svn-id: svn://kolibrios.org@1974 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
f1a2dfb7be
commit
5a347ee585
@ -2,18 +2,18 @@
|
|||||||
//Copyright 2007-2009 by Veliant & Leency
|
//Copyright 2007-2009 by Veliant & Leency
|
||||||
//Asper, Lrz, Nable, lev.
|
//Asper, Lrz, Nable, lev.
|
||||||
|
|
||||||
#include "..\lib\kolibri.h--"
|
#include "../lib/kolibri.h--"
|
||||||
#include "..\lib\memory.h--"
|
#include "../lib/memory.h--"
|
||||||
#include "..\lib\file_system.h--"
|
#include "../lib/file_system.h--"
|
||||||
#include "include\some_code.h--"
|
#include "include/some_code.h--"
|
||||||
#include "img\toolbar_icons.c--"
|
#include "img/toolbar_icons.c--"
|
||||||
#include "img\URLgoto.txt";
|
#include "img/URLgoto.txt";
|
||||||
//Asper
|
//Asper
|
||||||
#include "..\lib\mem.h--"
|
#include "../lib/mem.h--"
|
||||||
#include "..\lib\libio_lib.h--"
|
#include "../lib/libio_lib.h--"
|
||||||
#include "..\lib\libimg_lib.h--"
|
#include "../lib/libimg_lib.h--"
|
||||||
#include "..\lib\edit_box_lib.h--"
|
#include "../lib/edit_box_lib.h--"
|
||||||
#include "..\lib\dll.h--"
|
#include "../lib/dll.h--"
|
||||||
|
|
||||||
//ïåðåìåííûå
|
//ïåðåìåííûå
|
||||||
byte URL[4096]="/sys/html/index.htm",
|
byte URL[4096]="/sys/html/index.htm",
|
||||||
@ -94,12 +94,12 @@ void main()
|
|||||||
WB1.Scan(btn);
|
WB1.Scan(btn);
|
||||||
//WB1.HttpLoad(#URL);
|
//WB1.HttpLoad(#URL);
|
||||||
}
|
}
|
||||||
break;
|
BREAK;
|
||||||
case evKey:
|
case evKey:
|
||||||
key = GetKey();
|
key = GetKey();
|
||||||
WB1.Scan(key);
|
WB1.Scan(key);
|
||||||
if (key<>0x0d) && (key<>183) && (key<>184) && (key<>173) {EAX=key<<8; edit_box_key stdcall(#edit1);} //àäðåñíàÿ ñòðîêà
|
IF (key<>0x0d) && (key<>183) && (key<>184) && (key<>173) {EAX=key<<8; edit_box_key stdcall(#edit1);} //àäðåñíàÿ ñòðîêà
|
||||||
break;
|
BREAK;
|
||||||
case evReDraw:
|
case evReDraw:
|
||||||
Draw_Window();
|
Draw_Window();
|
||||||
break;
|
break;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
// wintodos(buf); -> â ïàğñå õòìë êàê è âñå êîäèğîâêè
|
// wintodos(buf); -> â ïàğñå õòìë êàê è âñå êîäèğîâêè
|
||||||
|
|
||||||
//ol - öèôåğêè
|
//ol - öèôåğêè
|
||||||
|
#define HTMLV_VERSION "HTML Viewer v0.63"
|
||||||
|
|
||||||
//óñêîğåíà çàãğóçêà ñòğàíèöû, ñîäåğæàùåé èçîáğàæåíèÿ
|
//óñêîğåíà çàãğóçêà ñòğàíèöû, ñîäåğæàùåé èçîáğàæåíèÿ
|
||||||
//óìåíüøåíî êîëè÷åñòâî ïåğåğèñîâîê çàãîëîâêà îêíà ïğè çàãğóçêå ñòğàíèöû
|
//óìåíüøåíî êîëè÷åñòâî ïåğåğèñîâîê çàãîëîâêà îêíà ïğè çàãğóçêå ñòğàíèöû
|
||||||
@ -42,7 +42,7 @@ TWebBrowser WB1;
|
|||||||
|
|
||||||
void TWebBrowser::Scan(dword id) {
|
void TWebBrowser::Scan(dword id) {
|
||||||
int i=0;
|
int i=0;
|
||||||
if (id > 399) {
|
IF (id > 399) {
|
||||||
j = 0;
|
j = 0;
|
||||||
FOR(i = 0; i <= id - 401; i++) {
|
FOR(i = 0; i <= id - 401; i++) {
|
||||||
do j++;
|
do j++;
|
||||||
@ -104,21 +104,21 @@ void TWebBrowser::Scan(dword id) {
|
|||||||
IF(za_kadrom == kolichestvo - max_kolvo_strok) return;
|
IF(za_kadrom == kolichestvo - max_kolvo_strok) return;
|
||||||
za_kadrom = za_kadrom + max_kolvo_strok + 2;
|
za_kadrom = za_kadrom + max_kolvo_strok + 2;
|
||||||
IF(max_kolvo_strok + za_kadrom > kolichestvo) za_kadrom = kolichestvo - max_kolvo_strok;
|
IF(max_kolvo_strok + za_kadrom > kolichestvo) za_kadrom = kolichestvo - max_kolvo_strok;
|
||||||
break;
|
BREAK;
|
||||||
case 184: //PgUp
|
case 184: //PgUp
|
||||||
IF(za_kadrom == 0) return;
|
IF(za_kadrom == 0) RETURN;
|
||||||
za_kadrom = za_kadrom - max_kolvo_strok - 2;
|
za_kadrom = za_kadrom - max_kolvo_strok - 2;
|
||||||
IF(za_kadrom < 0) za_kadrom = 0;
|
IF(za_kadrom < 0) za_kadrom = 0;
|
||||||
break;
|
BREAK;
|
||||||
case 180: //home
|
case 180: //home
|
||||||
IF (za_kadrom <>0) za_kadrom = 0;
|
IF (za_kadrom <>0) za_kadrom = 0;
|
||||||
ELSE return;
|
ELSE RETURN;
|
||||||
break;
|
BREAK;
|
||||||
case 181: //end
|
case 181: //end
|
||||||
za_kadrom = kolichestvo - max_kolvo_strok;
|
za_kadrom = kolichestvo - max_kolvo_strok;
|
||||||
break;
|
BREAK;
|
||||||
default:
|
default:
|
||||||
return;
|
RETURN;
|
||||||
}
|
}
|
||||||
IF(id == 11) koitodos(buf);
|
IF(id == 11) koitodos(buf);
|
||||||
ParseHTML(buf, filesize);
|
ParseHTML(buf, filesize);
|
||||||
@ -175,14 +175,14 @@ void ReadHtml(byte DO_LOAD) {
|
|||||||
IF(buf) free(buf);
|
IF(buf) free(buf);
|
||||||
buf = malloc(1048576);
|
buf = malloc(1048576);
|
||||||
|
|
||||||
if (!strcmp(get_URL_part(5),"http:")))
|
IF (!strcmp(get_URL_part(5),"http:")))
|
||||||
{
|
{
|
||||||
if (DO_LOAD) && (!WindowRePaint)
|
IF (DO_LOAD) && (!WindowRePaint)
|
||||||
{
|
{
|
||||||
DeleteFile(#download_path);
|
DeleteFile(#download_path);
|
||||||
IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]='';
|
IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]='';
|
||||||
RunProgram("/sys/downloader", #URL);
|
RunProgram("/sys/downloader", #URL);
|
||||||
return;
|
RETURN;
|
||||||
}
|
}
|
||||||
ReadFile(0, 1048576, buf, #download_path);
|
ReadFile(0, 1048576, buf, #download_path);
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ void ReadHtml(byte DO_LOAD) {
|
|||||||
|
|
||||||
|
|
||||||
void TWebBrowser::Load(dword adress) {
|
void TWebBrowser::Load(dword adress) {
|
||||||
if (URL[0] == '#') { //ìû íå óìååì ïåðåõîäèòü ïî ññûëêå âíóòðè äîêóìåíòà. Ïîêà ÷òî...
|
IF (URL[0] == '#') { //ìû íå óìååì ïåðåõîäèòü ïî ññûëêå âíóòðè äîêóìåíòà. Ïîêà ÷òî...
|
||||||
copystr(#editURL, #URL);
|
copystr(#editURL, #URL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -205,8 +205,8 @@ void TWebBrowser::Load(dword adress) {
|
|||||||
|
|
||||||
max_kolvo_stolbcov = width - 30 / 6;
|
max_kolvo_stolbcov = width - 30 / 6;
|
||||||
max_kolvo_strok = height - 3 / 10 - 2;
|
max_kolvo_strok = height - 3 / 10 - 2;
|
||||||
copystr(" HTML Viewer v0.63", #header);
|
copystr(" " + HTMLV_VERSION, #header);
|
||||||
if (!WindowRePaint) {
|
IF (!WindowRePaint) {
|
||||||
za_kadrom = 0;
|
za_kadrom = 0;
|
||||||
copystr(#URL, #editURL);
|
copystr(#URL, #editURL);
|
||||||
BrowserHistory.AddUrl();
|
BrowserHistory.AddUrl();
|
||||||
@ -227,7 +227,7 @@ void TWebBrowser::Load(dword adress) {
|
|||||||
WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.", 0);
|
WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
IF (!strcmp(" HTML Viewer v0.63", #header)) DrawTitle(#header);
|
IF (!strcmp(" " + HTMLV_VERSION, #header)) DrawTitle(#header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -272,12 +272,12 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
|
|||||||
temp = '';
|
temp = '';
|
||||||
goto NEXT_MARK;
|
goto NEXT_MARK;
|
||||||
}
|
}
|
||||||
case '\9':
|
CASE '\9':
|
||||||
case 0x0d:
|
CASE 0x0d:
|
||||||
//IF(pre_text == 1) {copystr(" ", #line + strlen(#line)); break;} ELSE
|
//IF(pre_text == 1) {copystr(" ", #line + strlen(#line)); break;} ELSE
|
||||||
bukva = ' ';
|
bukva = ' ';
|
||||||
goto DEFAULT_MARK;
|
goto DEFAULT_MARK;
|
||||||
case '<':
|
CASE '<':
|
||||||
bword++; //ïğîìîòàåì ñèìâîë <
|
bword++; //ïğîìîòàåì ñèìâîë <
|
||||||
IF(ESBYTE[bword] == '!') //ôèëüòğàöèÿ âíóòğè <!-- -->, äåğçêî
|
IF(ESBYTE[bword] == '!') //ôèëüòğàöèÿ âíóòğè <!-- -->, äåğçêî
|
||||||
{
|
{
|
||||||
@ -291,7 +291,7 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
|
|||||||
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];
|
bukva = ESBYTE[bword];
|
||||||
IF(bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
|
IF(bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
|
||||||
@ -397,7 +397,7 @@ void TWebBrowser::ParseHTML(dword bword, fsize){
|
|||||||
TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêğàøèâàåì ñòğîêó âêîíöå
|
TextGoDown(left + 5, stroka * 10 + top + 5, width - 20); //çàêğàøèâàåì ñòğîêó âêîíöå
|
||||||
copystr(#temp, #line);
|
copystr(#temp, #line);
|
||||||
}
|
}
|
||||||
IF(pre_text == 0) && (bukva == ' ') && (stolbec == 0) && (strlen(#line) == 0) continue;
|
IF(pre_text == 0) && (bukva == ' ') && (stolbec == 0) && (strlen(#line) == 0) CONTINUE;
|
||||||
copystr(#bukva, #line + strlen(#line));
|
copystr(#bukva, #line + strlen(#line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -422,18 +422,18 @@ void GetNextParam() {
|
|||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kavichki==1) // "
|
IF (kavichki==1) // "
|
||||||
{
|
{
|
||||||
i=find_symbol(#tagparam, '"');
|
i=find_symbol(#tagparam, '"');
|
||||||
copystr(#tagparam + i, #options);
|
copystr(#tagparam + i, #options);
|
||||||
}
|
}
|
||||||
else if (kavichki==2) // '
|
ELSE IF (kavichki==2) // '
|
||||||
{
|
{
|
||||||
i=find_symbol(#tagparam, '\'');
|
i=find_symbol(#tagparam, '\'');
|
||||||
copystr(#tagparam + i, #options);
|
copystr(#tagparam + i, #options);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
ELSE
|
||||||
{
|
{
|
||||||
//i=find_symbol(#tagparam, '=');
|
//i=find_symbol(#tagparam, '=');
|
||||||
WHILE((i > 0) && (tagparam[i] <>'=')) i--;
|
WHILE((i > 0) && (tagparam[i] <>'=')) i--;
|
||||||
@ -487,7 +487,7 @@ void TWebBrowser::WhatTextStyle(word left1, top1, width1) {
|
|||||||
w_title = 0;
|
w_title = 0;
|
||||||
stolbec = 0;
|
stolbec = 0;
|
||||||
copystr(#line, #header);
|
copystr(#line, #header);
|
||||||
copystr(" - HTML Viewer v0.63", #header + strlen(#header));
|
copystr(" - " + HTMLV_VERSION, #header + strlen(#header));
|
||||||
IF(stroka == 0) || (WindowRePaint == 1) DrawTitle(#header);
|
IF(stroka == 0) || (WindowRePaint == 1) DrawTitle(#header);
|
||||||
//äà, çíàş, 2 ğàçà âûõîäèò, íî, åñëè áîëüøàÿ ñòğàíèöà, òî òğóú
|
//äà, çíàş, 2 ğàçà âûõîäèò, íî, åñëè áîëüøàÿ ñòğàíèöà, òî òğóú
|
||||||
return;
|
return;
|
||||||
@ -620,7 +620,7 @@ void TWebBrowser::WhatTextStyle(word left1, top1, width1) {
|
|||||||
{
|
{
|
||||||
//IF (GetFileInfo(#libimg)<>0) return; //åñëè áèáëèîòåêè íåò
|
//IF (GetFileInfo(#libimg)<>0) return; //åñëè áèáëèîòåêè íåò
|
||||||
IMG_TAG:
|
IMG_TAG:
|
||||||
if (strcmp(#parametr,"src=")==0) //íàäî îáúåäèíèòü ñ GetNewUrl()
|
IF (strcmp(#parametr,"src=")==0) //íàäî îáúåäèíèòü ñ GetNewUrl()
|
||||||
{
|
{
|
||||||
copystr(BrowserHistory.CurrentUrl(), #temp); //äîñòà¸ì àäğåñ òåêóùåé ñòğàíèöû
|
copystr(BrowserHistory.CurrentUrl(), #temp); //äîñòà¸ì àäğåñ òåêóùåé ñòğàíèöû
|
||||||
temp[find_symbol(#temp, '/')] = 0x00; //îáğåçàåì å¸ óğë äî ïîñëåäíåãî /
|
temp[find_symbol(#temp, '/')] = 0x00; //îáğåçàåì å¸ óğë äî ïîñëåäíåãî /
|
||||||
@ -637,8 +637,8 @@ void TWebBrowser::WhatTextStyle(word left1, top1, width1) {
|
|||||||
|
|
||||||
if (image)
|
if (image)
|
||||||
{
|
{
|
||||||
if (width1<w) w=width1;
|
IF (width1<w) w=width1;
|
||||||
if (WB1.height<h) h=WB1.height;
|
IF (WB1.height<h) h=WB1.height;
|
||||||
IF (top1<WB1.top) {h=h-top1+WB1.top; top1=WB1.top;}
|
IF (top1<WB1.top) {h=h-top1+WB1.top; top1=WB1.top;}
|
||||||
TextGoDown2(left1+w,top1,width1-w,h);
|
TextGoDown2(left1+w,top1,width1-w,h);
|
||||||
IF (stroka - 2 < max_kolvo_strok) img_draw stdcall (image,left1-5,top1+10,w,-stroka * 10 + WB1.height -15 + h,0,0);
|
IF (stroka - 2 < max_kolvo_strok) img_draw stdcall (image,left1-5,top1+10,w,-stroka * 10 + WB1.height -15 + h,0,0);
|
||||||
|
@ -376,7 +376,7 @@ dword Hex2Symb(char* htmlcolor)
|
|||||||
FOR (;j<2;j++)
|
FOR (;j<2;j++)
|
||||||
{
|
{
|
||||||
ch=ESBYTE[htmlcolor+j];
|
ch=ESBYTE[htmlcolor+j];
|
||||||
IF (ch==0x0d) || (ch=='\9') return '';
|
IF (ch==0x0d) || (ch=='\9') RETURN '';
|
||||||
IF ((ch>='0') && (ch<='9')) ch -= '0';
|
IF ((ch>='0') && (ch<='9')) ch -= '0';
|
||||||
IF ((ch>='A') && (ch<='F')) ch -= 'A'-10;
|
IF ((ch>='A') && (ch<='F')) ch -= 'A'-10;
|
||||||
IF ((ch>='a') && (ch<='f')) ch -= 'a'-10;
|
IF ((ch>='a') && (ch<='f')) ch -= 'a'-10;
|
||||||
@ -430,32 +430,32 @@ inline fastcall int utf8rutodos(dword ESI) //-
|
|||||||
EDI+=2;
|
EDI+=2;
|
||||||
ESI++;
|
ESI++;
|
||||||
}
|
}
|
||||||
else IF (BL == 0xC2) && ((ESBYTE[ESI+1]==0xAB) || (ESBYTE[ESI+1]==0xBB)) // "
|
ELSE IF (BL == 0xC2) && ((ESBYTE[ESI+1]==0xAB) || (ESBYTE[ESI+1]==0xBB)) // "
|
||||||
{
|
{
|
||||||
ESBYTE[EDI] = '\"';
|
ESBYTE[EDI] = '\"';
|
||||||
ESI++;
|
ESI++;
|
||||||
}
|
}
|
||||||
else IF (BL == 0xC2) && (ESBYTE[ESI+1]==0xB7) // _
|
ELSE IF (BL == 0xC2) && (ESBYTE[ESI+1]==0xB7) // _
|
||||||
{
|
{
|
||||||
ESBYTE[EDI] = '_';
|
ESBYTE[EDI] = '_';
|
||||||
ESI++;
|
ESI++;
|
||||||
}
|
}
|
||||||
else IF (BL >= 0x90) && (BL <= 0xAF)
|
ELSE IF (BL >= 0x90) && (BL <= 0xAF)
|
||||||
{
|
{
|
||||||
BL -= 0x10;
|
BL -= 0x10;
|
||||||
ESBYTE[EDI] = BL;
|
ESBYTE[EDI] = BL;
|
||||||
}
|
}
|
||||||
else IF (BL >= 0x80) && (BL <= 0x8F)
|
ELSE IF (BL >= 0x80) && (BL <= 0x8F)
|
||||||
{
|
{
|
||||||
BL += 0x60;
|
BL += 0x60;
|
||||||
ESBYTE[EDI] = BL;
|
ESBYTE[EDI] = BL;
|
||||||
}
|
}
|
||||||
else IF (BL >= 0xB0) && (BL <= 0xBF)
|
ELSE IF (BL >= 0xB0) && (BL <= 0xBF)
|
||||||
{
|
{
|
||||||
BL -= 0x10;
|
BL -= 0x10;
|
||||||
ESBYTE[EDI] = BL;
|
ESBYTE[EDI] = BL;
|
||||||
}
|
}
|
||||||
else ESBYTE[EDI] = BL;
|
ELSE ESBYTE[EDI] = BL;
|
||||||
ESI++;
|
ESI++;
|
||||||
EDI++;
|
EDI++;
|
||||||
}
|
}
|
||||||
@ -574,7 +574,7 @@ void DrawFlatButton(dword x,y,width,height,id,color,text)
|
|||||||
void DrawCircle(int x, y, r)
|
void DrawCircle(int x, y, r)
|
||||||
{
|
{
|
||||||
int i; float px=0, py=r, ii = r * 3.1415926 * 2;
|
int i; float px=0, py=r, ii = r * 3.1415926 * 2;
|
||||||
for (i = 0; i < ii; i++)
|
FOR (i = 0; i < ii; i++)
|
||||||
{
|
{
|
||||||
PutPixel(px + x, y - py, 0);
|
PutPixel(px + x, y - py, 0);
|
||||||
px = py / r + px;
|
px = py / r + px;
|
||||||
|
Loading…
Reference in New Issue
Block a user