Browse Source

Add Browser component.

master
Alec Murphy 5 years ago
parent
commit
9273d46226
  1. 56
      Browser.HC

56
Browser.HC

@ -0,0 +1,56 @@
#include "::/Doc/Comm"
U8 *WebPageBuf[1048576];
I64 port = 2;
CComm *c=CommInit8n1(port,38400);
U0 Browser(U8 *url)
{
WinMax;
I64 WebPageBufSize=0;
I64 WebPageBufPos=0;
CommPutS(port, url);
CommPutS(port, "V5.02");
CommPutS(port, "^");
CDoc *WebPage = DocNew();
I64 b=0;
Bool load=FALSE;
Bool proc=FALSE;
Bool pad=TRUE;
progress1_max=100;
progress1=0;
StrCpy(progress1_desc, "Request sent, waiting for response");
while (!load) {
if (InU8(0x60)==0x01) { WebPageBufSize=0; break; };
Sleep(0);
while (FifoU8Rem(c->RX_fifo,&b)) {
if (b == 0xFF && !pad) { load=TRUE; break; };
if (b != 0xFF && pad) { pad=FALSE; };
if (b != 0xFF && !pad) {
if (!proc) { proc=TRUE; StrCpy(progress1_desc, "Processing DolDoc"); };
WebPageBuf[WebPageBufSize] = b;
WebPageBufSize++;
progress1++;
if (progress1>progress1_max) { progress1=0; };
}
}
}
ProgressBarsRst;
while (WebPageBufPos<WebPageBufSize) {
DocPrintPartial(WebPage, "%c", WebPageBuf[WebPageBufPos]);
WebPageBufPos++;
}
DocClear;
DocInsDoc(DocPut, WebPage);
DocTop;
DocDel(WebPage);
while (TRUE) {
GetStr;
}
DocBottom;
}
Loading…
Cancel
Save