forked from KolibriOS/kolibrios
WTB: small structure improvements
git-svn-id: svn://kolibrios.org@4540 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
da432de99f
commit
862f49c057
@ -1,8 +1,8 @@
|
|||||||
#include "..\TWB\links.h"
|
#include "..\TWB\links.h"
|
||||||
|
|
||||||
|
|
||||||
dword buf;
|
dword bufpointer;
|
||||||
dword filesize;
|
dword bufsize;
|
||||||
|
|
||||||
#define URL param
|
#define URL param
|
||||||
|
|
||||||
@ -10,12 +10,10 @@ scroll_bar scroll_wv = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555
|
|||||||
|
|
||||||
char header[2048];
|
char header[2048];
|
||||||
|
|
||||||
int downloader_id;
|
|
||||||
|
|
||||||
char download_path[]="/rd/1/.download";
|
char download_path[]="/rd/1/.download";
|
||||||
|
|
||||||
struct TWebBrowser {
|
struct TWebBrowser {
|
||||||
llist list; //need #include "..\lib\list_box.h"
|
llist list;
|
||||||
DrawBufer DrawBuf;
|
DrawBufer DrawBuf;
|
||||||
void GetNewUrl();
|
void GetNewUrl();
|
||||||
void ReadHtml();
|
void ReadHtml();
|
||||||
@ -151,20 +149,20 @@ void TWebBrowser::ReadHtml(byte encoding)
|
|||||||
else
|
else
|
||||||
file_size stdcall (#URL);
|
file_size stdcall (#URL);
|
||||||
|
|
||||||
filesize = EBX;
|
bufsize = EBX;
|
||||||
if (!filesize) return;
|
if (!bufsize) return;
|
||||||
|
|
||||||
mem_Free(buf);
|
mem_Free(bufpointer);
|
||||||
buf = mem_Alloc(filesize);
|
bufpointer = mem_Alloc(bufsize);
|
||||||
if (!strncmp(#URL,"http:",5))
|
if (!strncmp(#URL,"http:",5))
|
||||||
ReadFile(0, filesize, buf, #download_path);
|
ReadFile(0, bufsize, bufpointer, #download_path);
|
||||||
else
|
else
|
||||||
ReadFile(0, filesize, buf, #URL);
|
ReadFile(0, bufsize, bufpointer, #URL);
|
||||||
|
|
||||||
cur_encoding = encoding;
|
cur_encoding = encoding;
|
||||||
if (encoding==_WIN) wintodos(buf);
|
if (encoding==_WIN) wintodos(bufpointer);
|
||||||
if (encoding==_UTF) utf8rutodos(buf);
|
if (encoding==_UTF) utf8rutodos(bufpointer);
|
||||||
if (encoding==_KOI) koitodos(buf);
|
if (encoding==_KOI) koitodos(bufpointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -197,7 +195,7 @@ void TWebBrowser::ParseHTML(dword bufpos){
|
|||||||
if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
|
if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; bufstart+filesize > bufpos; bufpos++;)
|
for ( ; bufstart+bufsize > bufpos; bufpos++;)
|
||||||
{
|
{
|
||||||
bukva = ESBYTE[bufpos];
|
bukva = ESBYTE[bufpos];
|
||||||
if (ignor_text) && (bukva!='<') continue;
|
if (ignor_text) && (bukva!='<') continue;
|
||||||
@ -255,7 +253,7 @@ void TWebBrowser::ParseHTML(dword bufpos){
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
bufpos++;
|
bufpos++;
|
||||||
if (bufstart + filesize <= bufpos) break 2;
|
if (bufstart + bufsize <= bufpos) break 2;
|
||||||
}
|
}
|
||||||
while (ESBYTE[bufpos] <>'-');
|
while (ESBYTE[bufpos] <>'-');
|
||||||
|
|
||||||
@ -263,7 +261,7 @@ void TWebBrowser::ParseHTML(dword bufpos){
|
|||||||
if (ESBYTE[bufpos] <>'-') goto HH_;
|
if (ESBYTE[bufpos] <>'-') goto HH_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (ESBYTE[bufpos] !='>') && (bufpos < bufstart + filesize) //ïîëó÷àåì òåã è åãî ïàğàìåòğû
|
while (ESBYTE[bufpos] !='>') && (bufpos < bufstart + bufsize) //ïîëó÷àåì òåã è åãî ïàğàìåòğû
|
||||||
{
|
{
|
||||||
bukva = ESBYTE[bufpos];
|
bukva = ESBYTE[bufpos];
|
||||||
if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
|
if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
|
||||||
|
@ -43,9 +43,8 @@ void ImageCache::Images(int left1, top1, width1)
|
|||||||
do{
|
do{
|
||||||
if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl()
|
if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl()
|
||||||
{
|
{
|
||||||
if (downloader_id) strcpy(#img_path, #history_list[history_current-1].Item);
|
//if (downloader_id) strcpy(#img_path, #history_list[history_current-1].Item); else
|
||||||
else strcpy(#img_path, BrowserHistory.CurrentUrl()); //äîńňŕ¸ě ŕäđĺń ňĺęóůĺé ńňđŕíčöű
|
strcpy(#img_path, BrowserHistory.CurrentUrl());
|
||||||
|
|
||||||
if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
|
if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
|
||||||
{
|
{
|
||||||
//get path: absolute or relative
|
//get path: absolute or relative
|
||||||
|
@ -58,6 +58,8 @@ int action_buf;
|
|||||||
dword http_transfer = 0;
|
dword http_transfer = 0;
|
||||||
dword http_buffer;
|
dword http_buffer;
|
||||||
|
|
||||||
|
int downloader_id;
|
||||||
|
|
||||||
#include "..\TWB\TWB.c"
|
#include "..\TWB\TWB.c"
|
||||||
#include "menu_rmb.h"
|
#include "menu_rmb.h"
|
||||||
|
|
||||||
@ -80,6 +82,7 @@ void main()
|
|||||||
if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
|
if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
|
||||||
if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
|
if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
|
||||||
if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
|
if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
|
||||||
|
if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http");
|
||||||
|
|
||||||
if (!URL) strcpy(#URL, "/sys/index.htm");
|
if (!URL) strcpy(#URL, "/sys/index.htm");
|
||||||
Form.width=WIN_W;
|
Form.width=WIN_W;
|
||||||
@ -101,7 +104,7 @@ void main()
|
|||||||
m.get();
|
m.get();
|
||||||
PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color);
|
PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color);
|
||||||
|
|
||||||
if (m.y>WB1.list.y) && (m.y<Form.height) && (filesize)
|
if (m.y>WB1.list.y) && (m.y<Form.height) && (bufsize)
|
||||||
{
|
{
|
||||||
if (m.pkm)
|
if (m.pkm)
|
||||||
{
|
{
|
||||||
@ -118,7 +121,7 @@ void main()
|
|||||||
|
|
||||||
if (m.vert)
|
if (m.vert)
|
||||||
{
|
{
|
||||||
if (WB1.list.MouseScroll(m.vert)) WB1.ParseHTML(buf);
|
if (WB1.list.MouseScroll(m.vert)) WB1.ParseHTML(bufpointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m.lkm) scroll_used=0;
|
if (!m.lkm) scroll_used=0;
|
||||||
@ -136,7 +139,7 @@ void main()
|
|||||||
btn=WB1.list.first;
|
btn=WB1.list.first;
|
||||||
WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
|
WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
|
||||||
if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
|
if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
|
||||||
if (btn<>WB1.list.first) WB1.ParseHTML(buf);
|
if (btn<>WB1.list.first) WB1.ParseHTML(bufpointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -167,28 +170,29 @@ void main()
|
|||||||
if (action_buf) { Scan(action_buf); action_buf=0;}
|
if (action_buf) { Scan(action_buf); action_buf=0;}
|
||||||
Draw_Window();
|
Draw_Window();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case evNetwork:
|
case evNetwork:
|
||||||
return;
|
return;
|
||||||
//open page
|
http_get stdcall (#search_path, 0);
|
||||||
http_get stdcall (#URL, 0);
|
|
||||||
http_transfer = EAX;
|
http_transfer = EAX;
|
||||||
IF (http_transfer<0) notify("Error from HTTP lib");
|
IF (http_transfer < 0) notify("Error from HTTP lib");
|
||||||
//
|
|
||||||
if (http_transfer != 0) {
|
if (http_transfer > 0) {
|
||||||
http_process stdcall (http_transfer);
|
http_process stdcall (http_transfer);
|
||||||
$push EAX
|
$push EAX
|
||||||
ESI = http_transfer;
|
ESI = http_transfer;
|
||||||
if (!ESI.http_msg.content_received) break;
|
bufpointer = ESI.http_msg.content_ptr;
|
||||||
buf = ESI.http_msg.content_ptr;
|
debug(bufpointer);
|
||||||
debug(buf);
|
//bufsize = ESI.http_msg.content_received;
|
||||||
filesize = ESI.http_msg.content_received;
|
bufsize = strlen(bufpointer)-2;
|
||||||
debugi(filesize);
|
debugi(bufsize);
|
||||||
WB1.ParseHTML(buf);
|
WB1.ParseHTML(bufpointer);
|
||||||
$pop EAX
|
$pop EAX
|
||||||
if (EAX == 0) {
|
if (EAX == 0) {
|
||||||
http_free stdcall (http_transfer);
|
http_free stdcall (http_transfer);
|
||||||
http_transfer=0;
|
http_transfer=0;
|
||||||
}
|
}
|
||||||
|
pause(10);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if (downloader_id<>0)
|
if (downloader_id<>0)
|
||||||
@ -256,28 +260,28 @@ void Scan(int id)
|
|||||||
{
|
{
|
||||||
case 011: //Ctrk+K
|
case 011: //Ctrk+K
|
||||||
WB1.ReadHtml(_KOI);
|
WB1.ReadHtml(_KOI);
|
||||||
WB1.ParseHTML(buf);
|
WB1.ParseHTML(bufpointer);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 021: //Ctrl+U
|
case 021: //Ctrl+U
|
||||||
WB1.ReadHtml(_UTF);
|
WB1.ReadHtml(_UTF);
|
||||||
WB1.ParseHTML(buf);
|
WB1.ParseHTML(bufpointer);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 004: //Ctrl+D
|
case 004: //Ctrl+D
|
||||||
WB1.ReadHtml(_DOS);
|
WB1.ReadHtml(_DOS);
|
||||||
WB1.ParseHTML(buf);
|
WB1.ParseHTML(bufpointer);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 005: //Win encoding
|
case 005: //Win encoding
|
||||||
WB1.ReadHtml(_WIN);
|
WB1.ReadHtml(_WIN);
|
||||||
WB1.ParseHTML(buf);
|
WB1.ParseHTML(bufpointer);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 009: //free img cache
|
case 009: //free img cache
|
||||||
ImgCache.Free();
|
ImgCache.Free();
|
||||||
notify(IMAGES_CACHE_CLEARED);
|
notify(IMAGES_CACHE_CLEARED);
|
||||||
WB1.ParseHTML(buf);
|
WB1.ParseHTML(bufpointer);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case BACK:
|
case BACK:
|
||||||
@ -293,7 +297,7 @@ void Scan(int id)
|
|||||||
else RunProgram("/rd/1/tinypad", #download_path);
|
else RunProgram("/rd/1/tinypad", #download_path);
|
||||||
return;
|
return;
|
||||||
case 054: //F5
|
case 054: //F5
|
||||||
IF(address_box.flags & 0b10) WB1.ParseHTML(buf);
|
IF(address_box.flags & 0b10) WB1.ParseHTML(bufpointer);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case REFRESH:
|
case REFRESH:
|
||||||
@ -334,7 +338,7 @@ void Scan(int id)
|
|||||||
IF(WB1.list.first == WB1.list.count - WB1.list.visible) return;
|
IF(WB1.list.first == WB1.list.count - WB1.list.visible) return;
|
||||||
WB1.list.first += WB1.list.visible + 2;
|
WB1.list.first += WB1.list.visible + 2;
|
||||||
IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible;
|
IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible;
|
||||||
WB1.ParseHTML(buf);
|
WB1.ParseHTML(bufpointer);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 184: //PgUp
|
case 184: //PgUp
|
||||||
@ -342,30 +346,30 @@ void Scan(int id)
|
|||||||
IF(WB1.list.first == 0) return;
|
IF(WB1.list.first == 0) return;
|
||||||
WB1.list.first -= WB1.list.visible - 2;
|
WB1.list.first -= WB1.list.visible - 2;
|
||||||
IF(WB1.list.first < 0) WB1.list.first = 0;
|
IF(WB1.list.first < 0) WB1.list.first = 0;
|
||||||
WB1.ParseHTML(buf);
|
WB1.ParseHTML(bufpointer);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 178:
|
case 178:
|
||||||
case BTN_UP: //ìîòàåì ââåðõ
|
case BTN_UP: //ìîòàåì ââåðõ
|
||||||
if (WB1.list.first <= 0) return;
|
if (WB1.list.first <= 0) return;
|
||||||
WB1.list.first--;
|
WB1.list.first--;
|
||||||
WB1.ParseHTML(buf);
|
WB1.ParseHTML(bufpointer);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 177:
|
case 177:
|
||||||
case BTN_DOWN: //ìîòàåì âíèç
|
case BTN_DOWN: //ìîòàåì âíèç
|
||||||
if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
|
if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
|
||||||
WB1.list.first++;
|
WB1.list.first++;
|
||||||
WB1.ParseHTML(buf);
|
WB1.ParseHTML(bufpointer);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 180: //home
|
case 180: //home
|
||||||
if (WB1.list.KeyHome()) WB1.ParseHTML(buf);
|
if (WB1.list.KeyHome()) WB1.ParseHTML(bufpointer);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 181: //end
|
case 181: //end
|
||||||
if (WB1.list.count < WB1.list.visible) return;
|
if (WB1.list.count < WB1.list.visible) return;
|
||||||
if (WB1.list.KeyEnd()) WB1.ParseHTML(buf);
|
if (WB1.list.KeyEnd()) WB1.ParseHTML(bufpointer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -456,31 +460,31 @@ void ShowPage()
|
|||||||
address_box.offset=0;
|
address_box.offset=0;
|
||||||
edit_box_draw stdcall(#address_box);
|
edit_box_draw stdcall(#address_box);
|
||||||
|
|
||||||
if (!filesize)
|
if (!bufsize)
|
||||||
{
|
{
|
||||||
PageLinks.Clear();
|
PageLinks.Clear();
|
||||||
if (GetProcessSlot(downloader_id)<>0)
|
if (GetProcessSlot(downloader_id)<>0)
|
||||||
{
|
{
|
||||||
filesize = sizeof(loading);
|
bufsize = sizeof(loading);
|
||||||
WB1.ParseHTML(#loading);
|
WB1.ParseHTML(#loading);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (strncmp(#URL,"http:",5)==0)
|
if (strncmp(#URL,"http:",5)==0)
|
||||||
{
|
{
|
||||||
filesize = sizeof(page_not_found_no_internet);
|
bufsize = sizeof(page_not_found_no_internet);
|
||||||
WB1.ParseHTML(#page_not_found_no_internet);
|
WB1.ParseHTML(#page_not_found_no_internet);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
filesize = sizeof(page_not_found);
|
bufsize = sizeof(page_not_found);
|
||||||
WB1.ParseHTML(#page_not_found);
|
WB1.ParseHTML(#page_not_found);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
WB1.ParseHTML(buf);
|
WB1.ParseHTML(bufpointer);
|
||||||
|
|
||||||
if (!header) strcpy(#header, #version);
|
if (!header) strcpy(#header, #version);
|
||||||
if (!strcmp(#version, #header)) DrawTitle(#header);
|
if (!strcmp(#version, #header)) DrawTitle(#header);
|
||||||
|
@ -355,8 +355,9 @@ void InitTWB() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DrawLetter() {
|
void DrawLetter() {
|
||||||
filesize = strlen(mdata);
|
pre_text = 2;
|
||||||
if (filesize) WB1.ParseHTML(mdata);
|
bufsize = strlen(mdata);
|
||||||
|
if (bufsize) WB1.ParseHTML(mdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user