WebView 2.0 beta 1:

- rewrite tag parsing procedure to use collections
- completely refactor TWB component
- fix a couple of issues: broken tabs in <pre>, mishandle of local page not found, anchors memory leak
- so finally all id's and names are included as anchors*
(*some anchors in web still don't work)

git-svn-id: svn://kolibrios.org@7752 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-03-26 00:12:32 +00:00
parent 00d0aad98e
commit d05eee0368
12 changed files with 393 additions and 365 deletions

View File

@ -1,10 +1,14 @@
#include "..\TWB\colors.h"
scroll_bar scroll_wv = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; #include "..\TWB\anchors.h"
#include "..\TWB\parce_tag.h"
#include "..\TWB\absolute_url.h"
char line[500];
#include "..\TWB\unicode_tags.h"
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
struct _style { struct _style {
bool bool
b, u, s, h, b, u, s, h,
pre, pre,
blq, blq,
@ -13,18 +17,19 @@ bool
button, button,
image, image,
align; align;
dword dword bg_color;
bg_color;
}; };
struct TWebBrowser { struct TWebBrowser {
llist list; llist list;
_style style; _style style;
DrawBufer DrawBuf; DrawBufer DrawBuf;
dword draw_y, stolbec;
int zoom; int zoom;
bool opened; //is this a "start tag" or "end tag" dword o_bufpointer;
void SetPageDefaults(); void SetPageDefaults();
void Prepare(); void AddCharToTheLine();
void ParseHtml();
void SetStyle(); void SetStyle();
void DrawStyle(); void DrawStyle();
void DrawPage(); void DrawPage();
@ -34,6 +39,9 @@ struct TWebBrowser {
void BufEncode(); void BufEncode();
} WB1; } WB1;
dword link_color_inactive;
dword link_color_active;
dword page_bg;
bool bool
link, link,
@ -41,40 +49,19 @@ bool
t_html, t_html,
t_body; t_body;
#include "..\TWB\img_cache.h"
#include "..\TWB\links.h"
dword bufpointer=0; dword bufpointer=0;
dword o_bufpointer=0;
dword bufsize=0; dword bufsize=0;
dword text_colors[300]; int body_magrin=6;
dword text_color_index;
dword link_color_inactive;
dword link_color_active;
dword page_bg;
int draw_y;
int stolbec;
int tab_len;
int body_magrin=5;
int basic_line_h=22; int basic_line_h=22;
char URL[10000]; char header[150];
char header[2048];
char line[500];
char tagparam[10000];
char tag[100];
char oldtag[100]; char oldtag[100];
char attr[1200];
char val[4096];
#include "..\TWB\absolute_url.h"
#include "..\TWB\links.h"
#include "..\TWB\anchors.h"
#include "..\TWB\colors.h"
#include "..\TWB\unicode_tags.h"
#include "..\TWB\img_cache.h"
#include "..\TWB\parce_tag.h"
scroll_bar scroll_wv = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
//============================================================================================ //============================================================================================
void TWebBrowser::DrawStyle() void TWebBrowser::DrawStyle()
@ -83,7 +70,7 @@ void TWebBrowser::DrawStyle()
if (!header) if (!header)
{ {
strcpy(#header, #line); strncpy(#header, #line, sizeof(header)-1);
line = 0; line = 0;
return; return;
} }
@ -138,20 +125,39 @@ void TWebBrowser::SetPageDefaults()
style.bg_color = page_bg; style.bg_color = page_bg;
DrawBuf.Fill(0, page_bg); DrawBuf.Fill(0, page_bg);
PageLinks.Clear(); PageLinks.Clear();
strcpy(#header, #version); anchors.clear();
strncpy(#header, #version, sizeof(header)-1);
cur_encoding = CH_NULL; cur_encoding = CH_NULL;
draw_y = body_magrin; draw_y = body_magrin;
stolbec = 0; stolbec = 0;
line = 0; line = 0;
zoom = 1; zoom = 1;
if (o_bufpointer) free(o_bufpointer);
o_bufpointer = 0;
} }
//============================================================================================ //============================================================================================
void TWebBrowser::Prepare(){ void TWebBrowser::AddCharToTheLine(unsigned char _char)
word bukva[2]; {
dword j;
bool ignor_param;
dword bufpos;
dword line_len; dword line_len;
if (_char<=15) _char=' ';
line_len = strlen(#line);
if (!style.pre) && (_char == ' ')
{
if (line[line_len-1]==' ') return; //no double spaces
if (!stolbec) && (!line) return; //no paces at the beginning of the line
}
if (line_len < sizeof(line)) chrcat(#line, _char);
CheckForLineBreak();
}
//============================================================================================
void TWebBrowser::ParseHtml(){
word bukva[2];
char unicode_symbol[10];
dword unicode_symbol_result;
dword j;
bool ignor_param=false;
int tab_len;
dword bufpos;
SetPageDefaults(); SetPageDefaults();
if (strstri(bufpointer, "<body")==-1) { if (strstri(bufpointer, "<body")==-1) {
t_body = true; t_body = true;
@ -163,34 +169,33 @@ void TWebBrowser::Prepare(){
switch (bukva) switch (bukva)
{ {
case 0x0a: case 0x0a:
if (style.pre) if (style.pre) {
{
DrawStyle(); DrawStyle();
NewLine(); NewLine();
break; } else {
AddCharToTheLine(0x0a);
} }
goto DEFAULT_MARK; break;
case '\9': case 0x09:
if (style.pre) //otherwise go to 0x0d if (style.pre) {
{ tab_len = strlen(#line) + stolbec % 4;
tab_len = strlen(#line) % 4; if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len;
if (!tab_len) tab_len = 4;
for (j=0; j<tab_len; j++;) chrcat(#line,' '); for (j=0; j<tab_len; j++;) chrcat(#line,' ');
break; } else {
AddCharToTheLine(0x09);
} }
goto DEFAULT_MARK; break;
case '&': //&nbsp; and so on case '&': //&nbsp; and so on
for (j=1, tag=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++) for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++)
{ {
bukva = ESBYTE[bufpos+j]; bukva = ESBYTE[bufpos+j];
chrcat(#tag, bukva); chrcat(#unicode_symbol, bukva);
} }
if (bukva = GetUnicodeSymbol(#tag)) { if (bukva = GetUnicodeSymbol(#unicode_symbol)) {
bufpos += j; bufpos += j;
CheckForLineBreak(); CheckForLineBreak();
} else { } else {
bukva = '&'; AddCharToTheLine('&');
goto DEFAULT_MARK;
} }
break; break;
case '<': case '<':
@ -205,70 +210,56 @@ void TWebBrowser::Prepare(){
bufpos+=2; bufpos+=2;
break; break;
} }
tag = attr = tagparam = ignor_param = NULL; tag.reset();
if (ESBYTE[bufpos] == '/') {
tag.opened = false;
bufpos++;
}
ignor_param=false;
while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
{ {
bukva = ESBYTE[bufpos]; bukva = ESBYTE[bufpos];
if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
if (!ignor_param) && (bukva <>' ') if (!ignor_param) && (bukva <>' ')
{ {
if (strlen(#tag)+1<sizeof(tag)) chrcat(#tag, bukva); if (strlen(#tag.name)+1<sizeof(tag.name)) chrcat(#tag.name, bukva);
} }
else else
{ {
ignor_param = true; ignor_param = true;
if (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva); if (strlen(#tag.params)+1<sizeof(tag.params)) strcat(#tag.params, #bukva);
// chrncat(#tagparam, bukva, sizeof(tagparam)-1); // chrncat(#tag.params, bukva, sizeof(tag.params)-1);
} }
bufpos++; bufpos++;
} }
strlwr(#tag); strlwr(#tag.name);
// ignore text inside the next tags // ignore text inside the next tags
if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { if (tag.is("script")) || (tag.is("style")) || (tag.is("binary")) || (tag.is("select")) {
sprintf(#tagparam, "</%s>", #tag); sprintf(#tag.params, "</%s>", #tag.name);
j = strstri(bufpos, #tagparam); j = strstri(bufpos, #tag.params);
if (j!=-1) { if (j!=-1) bufpos = j-1;
bufpos = j-1;
}
tag = tagparam = NULL;
break; break;
} }
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/ if (tag.name[strlen(#tag.name)-1]=='/') tag.name[strlen(#tag.name)-1]=NULL; //for br/ !!!!!!!!
if (tagparam) GetNextParam(); if (tag.params) tag.parse_params();
if (tag[0] == '/') if (tag.name) && (!tag.is("i")) && (!tag.is("svg")) {
{
opened = 0;
strcpy(#tag, #tag+1);
}
else opened = 1;
if (tag) && (!istag("span")) && (!istag("i")) && (!istag("svg")) {
CheckForLineBreak(); CheckForLineBreak();
DrawStyle(); DrawStyle();
if (tag) SetStyle(); if (tag.name) SetStyle();
} }
strlcpy(#oldtag, #tag, sizeof(oldtag)-1); strncpy(#oldtag, #tag.name, sizeof(oldtag)-1);
tag = attr = tagparam = ignor_param = NULL;
break; break;
default: default:
DEFAULT_MARK: AddCharToTheLine(ESBYTE[bufpos]);
if (bukva<=15) bukva=' ';
line_len = strlen(#line);
if (!style.pre) && (bukva == ' ')
{
if (line[line_len-1]==' ') break; //no double spaces
if (!stolbec) && (!line) break; //no paces at the beginning of the line
}
if (line_len < sizeof(line)) chrcat(#line, bukva);
CheckForLineBreak();
} }
} }
DrawStyle(); DrawStyle();
NewLine(); NewLine();
if (list.first == 0) list.count = draw_y; list.count = draw_y;
DrawPage(); DrawPage();
} }
//============================================================================================ //============================================================================================
@ -297,122 +288,115 @@ bool TWebBrowser::CheckForLineBreak()
//============================================================================================ //============================================================================================
void TWebBrowser::SetStyle() { void TWebBrowser::SetStyle() {
char img_path[4096]=0; char img_path[4096]=0;
int left1 = body_magrin + list.x;
int meta_encoding; int meta_encoding;
if (istag("html")) {
t_html = opened; dword value;
if (tag.is("html")) {
t_html = tag.opened;
return; return;
} }
if(istag("title")) { if(tag.is("title")) {
if (opened) header=NULL; if (tag.opened) header=NULL;
return; return;
} }
IF(istag("q")) IF(tag.is("q"))
{ {
if (opened) { if (tag.opened) {
meta_encoding = strlen(#line); meta_encoding = strlen(#line);
if (line[meta_encoding-1] != ' ') chrcat(#line, ' '); if (line[meta_encoding-1] != ' ') chrcat(#line, ' ');
chrcat(#line, '\"'); chrcat(#line, '\"');
} }
if (!opened) strcat(#line, "\" "); if (!tag.opened) strcat(#line, "\" ");
return; return;
} }
if (isattr("id=")) || (isattr("name=")) { // TO FIX: works only if the param is the last if (value = tag.get_value_of("name=")) || (value = tag.get_value_of("id=")) {
anchors.add(#val, draw_y); anchors.add(value, draw_y);
} }
if (istag("body")) { if (tag.is("body")) {
t_body = opened; t_body = tag.opened;
do{ if (value = tag.get_value_of("link=")) link_color_inactive = GetColor(value);
if (isattr("link=")) link_color_inactive = GetColor(#val); if (value = tag.get_value_of("alink=")) link_color_active = GetColor(value);
if (isattr("alink=")) link_color_active = GetColor(#val); if (value = tag.get_value_of("text=")) text_colors[0]=GetColor(value);
if (isattr("text=")) text_colors[0]=GetColor(#val); if (value = tag.get_value_of("bgcolor=")) {
if (isattr("bgcolor=")) style.bg_color = page_bg = GetColor(value);
{ DrawBuf.Fill(0, page_bg);
style.bg_color = page_bg = GetColor(#val);
DrawBuf.Fill(0, page_bg);
}
} while(GetNextParam());
if (opened) && (cur_encoding==CH_NULL) {
cur_encoding = CH_CP866;
//BufEncode(CH_UTF8);
debugln("Document has no information about encoding!");
} }
if (opened) { if (tag.opened) {
if (strcmp(#header, #version) != 0) { if (cur_encoding==CH_NULL) {
cur_encoding = CH_CP866;
//BufEncode(CH_UTF8);
debugln("Document has no information about encoding!");
}
if (!streq(#header, #version)) {
ChangeCharset(charsets[cur_encoding], "CP866", #header); ChangeCharset(charsets[cur_encoding], "CP866", #header);
sprintf(#header, "%s - %s", #header, #version); strncat(#header, " - ", sizeof(header)-1);
strncat(#header, #version, sizeof(header)-1);
} }
DrawTitle(#header); DrawTitle(#header);
} }
return; return;
} }
if (istag("a")) { if (tag.is("a")) {
if (opened) if (tag.opened)
{ {
if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
do{ if (value = tag.get_value_of("href=")) && (!strstr(value,"javascript:"))
if (isattr("href=")) && (!strstr(#val,"javascript:")) {
{ text_color_index++;
text_color_index++; text_colors[text_color_index] = text_colors[text_color_index-1];
text_colors[text_color_index] = text_colors[text_color_index-1]; link = 1;
link = 1; text_colors[text_color_index] = link_color_inactive;
text_colors[text_color_index] = link_color_inactive; PageLinks.AddLink(value);
PageLinks.AddLink(#val); }
} } else {
} while(GetNextParam());
}
else {
link = 0; link = 0;
IF(text_color_index > 0) text_color_index--; IF(text_color_index > 0) text_color_index--;
} }
return; return;
} }
if (istag("font")) { if (tag.is("font")) {
style.bg_color = page_bg; style.bg_color = page_bg;
if (opened) if (tag.opened)
{ {
text_color_index++; text_color_index++;
text_colors[text_color_index] = text_colors[text_color_index-1]; text_colors[text_color_index] = text_colors[text_color_index-1];
do{ if (value = tag.get_value_of("color=")) text_colors[text_color_index] = GetColor(value);
if (isattr("color=")) text_colors[text_color_index] = GetColor(#val); if (value = tag.get_value_of("bg=")) style.bg_color = GetColor(value);
if (isattr("bg=")) style.bg_color = GetColor(#val);
} while(GetNextParam());
} }
else if (text_color_index > 0) text_color_index--; else if (text_color_index > 0) text_color_index--;
return; return;
} }
if (istag("div")) { if (tag.is("div")) {
if (streq(#oldtag,"div")) && (opened) return; if (streq(#oldtag,"div")) && (tag.opened) return;
NewLine(); NewLine();
//IF (oldtag[0] != 'h') //IF (oldtag[0] != 'h')
return; return;
} }
if (istag("header")) || (istag("article")) || (istag("footer")) || (istag("figure")) { if (tag.is("header")) || (tag.is("article")) || (tag.is("footer")) || (tag.is("figure")) {
NewLine(); NewLine();
return; return;
} }
if (istag("p")) { if (tag.is("p")) {
IF (oldtag[0] == 'h') || (streq(#oldtag,"td")) || (streq(#oldtag,"p")) return; IF (oldtag[0] == 'h') || (streq(#oldtag,"td")) || (streq(#oldtag,"p")) return;
NewLine(); NewLine();
//IF(opened) NewLine(); //IF(tag.opened) NewLine();
return; return;
} }
if (istag("br")) { NewLine(); return; } if (tag.is("br")) { NewLine(); return; }
if (istag("tr")) { if (opened) NewLine(); return; } if (tag.is("tr")) { if (tag.opened) NewLine(); return; }
if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } if (tag.is("b")) || (tag.is("strong")) || (tag.is("big")) { style.b = tag.opened; return; }
if (istag("button")) { style.button = opened; stolbec++; return; } if (tag.is("button")) { style.button = tag.opened; stolbec++; return; }
if (istag("u")) || (istag("ins")) { style.u=opened; return;} if (tag.is("u")) || (tag.is("ins")) { style.u=tag.opened; return;}
if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; } if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; }
if (istag("dd")) { stolbec += 5; return; } if (tag.is("dd")) { stolbec += 5; return; }
if (istag("blockquote")) { style.blq = opened; return; } if (tag.is("blockquote")) { style.blq = tag.opened; return; }
if (istag("pre")) || (istag("code")) { style.pre = opened; return; } if (tag.is("pre")) || (tag.is("code")) { style.pre = tag.opened; return; }
if (istag("img")) { if (tag.is("img")) {
do{ if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1);
if (isattr("src=")) strlcpy(#img_path, #val, sizeof(img_path)-1); if (value = tag.get_value_of("title=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value);
if (isattr("title=")) && (strlen(#val)<sizeof(line)-3) && (val) sprintf(#line, "[%s]", #val); if (value = tag.get_value_of("alt=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value);
if (isattr("alt=")) && (strlen(#val)<sizeof(line)-3) && (val) sprintf(#line, "[%s]", #val);
} while(GetNextParam());
if (!img_path) { line=0; return; } if (!img_path) { line=0; return; }
style.image = true; style.image = true;
text_color_index++; text_color_index++;
@ -427,25 +411,27 @@ void TWebBrowser::SetStyle() {
DrawStyle(); DrawStyle();
text_color_index--; text_color_index--;
style.image = false; style.image = false;
//ImgCache.Images( left1, draw_y, WB1.list.w); //ImgCache.Images( list.x, draw_y, WB1.list.w);
return; return;
} }
if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("caption")) { if (tag.is("h1")) || (tag.is("h2")) || (tag.is("h3")) || (tag.is("caption")) {
style.h = opened; style.h = tag.opened;
if (opened) if (tag.opened)
{ {
NewLine(); NewLine();
draw_y += 10; draw_y += 10;
WB1.zoom=2; WB1.zoom=2;
WB1.list.font_type |= 10011001b; WB1.list.font_type |= 10011001b;
if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; if (value = tag.get_value_of("align=")) {
if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; if (streq(value, "center")) style.align = ALIGN_CENTER;
if (streq(value, "right")) style.align = ALIGN_RIGHT;
}
list.item_h = basic_line_h * 2; list.item_h = basic_line_h * 2;
if (istag("h1")) style.b = true; if (tag.is("h1")) style.b = true;
} }
else else
{ {
if (istag("h1")) style.b = false; if (tag.is("h1")) style.b = false;
NewLine(); NewLine();
WB1.zoom=1; WB1.zoom=1;
WB1.list.font_type = 10011000b; WB1.list.font_type = 10011000b;
@ -454,15 +440,15 @@ void TWebBrowser::SetStyle() {
} }
return; return;
} }
if (istag("dt")) { if (tag.is("dt")) {
style.li = opened; style.li = tag.opened;
if (opened) NewLine(); if (tag.opened) NewLine();
return; return;
} }
if (istag("li")) || (istag("dt")) if (tag.is("li")) || (tag.is("dt"))
{ {
style.li = opened; style.li = tag.opened;
if (opened) if (tag.opened)
{ {
NewLine(); NewLine();
stolbec = style.li_tab * 5 - 2; stolbec = style.li_tab * 5 - 2;
@ -471,17 +457,17 @@ void TWebBrowser::SetStyle() {
} }
return; return;
} }
if (istag("ul")) || (istag("ol")) { if (tag.is("ul")) || (tag.is("ol")) {
if (!opened) if (!tag.opened)
{ {
style.li = opened; style.li = tag.opened;
style.li_tab--; style.li_tab--;
NewLine(); NewLine();
} }
else style.li_tab++; else style.li_tab++;
} }
if (istag("hr")) { if (tag.is("hr")) {
if (isattr("color=")) EDI = GetColor(#val); else EDI = 0x999999; if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999;
$push edi; $push edi;
NewLine(); NewLine();
$pop edi; $pop edi;
@ -491,20 +477,18 @@ void TWebBrowser::SetStyle() {
draw_y += 10; draw_y += 10;
return; return;
} }
if (istag("meta")) || (istag("?xml")) { if (tag.is("meta")) || (tag.is("?xml")) {
meta_encoding = CH_NULL; meta_encoding = CH_NULL;
do{ if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding="))
if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding=")) {
{ value += strrchr(value, '='); //search in content=
strcpy(#val, #val[strrchr(#val, '=')]); //search in content= strlwr(value);
strlwr(#val); if (streq(value,"utf-8")) || (streq(value,"utf8")) meta_encoding = CH_UTF8;
if (isval("utf-8")) || (isval("utf8")) meta_encoding = CH_UTF8; else if (streq(value,"windows-1251")) || (streq(value,"windows1251")) meta_encoding = CH_CP1251;
else if (isval("koi8-r")) || (isval("koi8-u")) meta_encoding = CH_KOI8; else if (streq(value,"dos")) || (streq(value,"cp-866")) meta_encoding = CH_CP866;
else if (isval("windows-1251")) || (isval("windows1251")) meta_encoding = CH_CP1251; else if (streq(value,"iso-8859-5")) || (streq(value,"iso8859-5")) meta_encoding = CH_ISO8859_5;
else if (isval("iso-8859-5")) || (isval("iso8859-5")) meta_encoding = CH_ISO8859_5; else if (streq(value,"koi8-r")) || (streq(value,"koi8-u")) meta_encoding = CH_KOI8;
else if (isval("dos")) || (isval("cp-866")) meta_encoding = CH_CP866; }
}
} while(GetNextParam());
if (meta_encoding!=CH_NULL) BufEncode(meta_encoding); if (meta_encoding!=CH_NULL) BufEncode(meta_encoding);
return; return;
} }
@ -513,13 +497,10 @@ void TWebBrowser::SetStyle() {
void TWebBrowser::BufEncode(dword set_new_encoding) void TWebBrowser::BufEncode(dword set_new_encoding)
{ {
if (cur_encoding == set_new_encoding) return; if (cur_encoding == set_new_encoding) return;
if (o_bufpointer==0) if (o_bufpointer==0) {
{
o_bufpointer = malloc(bufsize); o_bufpointer = malloc(bufsize);
strcpy(o_bufpointer, bufpointer); strcpy(o_bufpointer, bufpointer);
} } else {
else
{
strcpy(bufpointer, o_bufpointer); strcpy(bufpointer, o_bufpointer);
} }
//debugval("cur_encoding ", cur_encoding); //debugval("cur_encoding ", cur_encoding);
@ -566,10 +547,6 @@ void TWebBrowser::NewLine()
if (debug_mode) debugln(NULL); if (debug_mode) debugln(NULL);
} }
//============================================================================================ //============================================================================================
bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; }
bool isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; }
bool isval(dword text) { if (!strcmp(#val,text)) return true; else return false; }
//============================================================================================
void TWebBrowser::DrawPage() void TWebBrowser::DrawPage()
{ {
PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0); PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);

View File

@ -3,7 +3,7 @@ void GetAbsoluteURL(dword in_URL)
{ {
int i; int i;
dword orig_URL = in_URL; dword orig_URL = in_URL;
char newurl[sizeof(URL)]; char newurl[URL_SIZE];
while (i=strstr(in_URL, "&amp;")) while (i=strstr(in_URL, "&amp;"))
{ {

View File

@ -1,9 +1,11 @@
struct _anchors { struct _anchors {
char current_anchor_name[100];
collection anchor_name; collection anchor_name;
collection anchor_position; collection anchor_position;
void add(); void add();
int get_anchor_pos(); int get_pos_by_name();
void clear();
} anchors; } anchors;
void _anchors::add(dword _name, _pos) void _anchors::add(dword _name, _pos)
@ -12,10 +14,20 @@ void _anchors::add(dword _name, _pos)
anchor_position.add(itoa(_pos)); anchor_position.add(itoa(_pos));
} }
int _anchors::get_anchor_pos(dword _get_name) int _anchors::get_pos_by_name(dword _get_name)
{ {
dword pos_name = anchor_name.get_pos_by_name(_get_name); dword pos_name = anchor_name.get_pos_by_name(_get_name);
if (pos_name==-1) return -1; if (ESBYTE[_get_name]==NULL) return 0;
return atoi(anchor_position.get(pos_name)); if (pos_name==-1) {
return -1;
} else {
return atoi(anchor_position.get(pos_name));
}
}
void _anchors::clear()
{
anchor_name.drop();
anchor_position.drop();
} }

View File

@ -6,6 +6,9 @@ struct color_spec {
int rgb; int rgb;
}; };
dword text_colors[300];
dword text_color_index;
struct color_spec color_specs[] = { struct color_spec color_specs[] = {
"aliceblue", 0xF0F8FF, "aliceblue", 0xF0F8FF,
"antiquewhite", 0xFAEBD7, "antiquewhite", 0xFAEBD7,

View File

@ -5,7 +5,7 @@ dword CursorFile = FROM "../TWB/pointer.cur";
#define NOLINE 0 #define NOLINE 0
#define UNDERLINE 1 #define UNDERLINE 1
#define MAXLINKS 400 #define MAXLINKS 2000
struct array_link { struct array_link {
dword link; dword link;
@ -58,7 +58,7 @@ void LinksArray::Clear()
CursorPointer.Restore(); CursorPointer.Restore();
} }
char temp[sizeof(URL)]; char temp[URL_SIZE];
PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, #temp, 0}; PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, #temp, 0};
bool LinksArray::HoverAndProceed(dword mx, my) bool LinksArray::HoverAndProceed(dword mx, my)

View File

@ -1,55 +1,106 @@
bool GetNextParam()
struct _tag
{
char name[32];
char params[5000];
bool opened;
collection attributes;
collection values;
bool is();
bool reset();
bool parse_params();
bool get_next_param();
dword get_value_of();
} tag;
bool _tag::is(dword _text)
{
if ( !strcmp(#tag.name, _text) ) {
return true;
} else {
return false;
}
}
bool _tag::reset()
{
if (!name) return false;
name = NULL;
opened = true;
attributes.drop();
values.drop();
attributes.add("ZERO");
values.add("NULL");
return true;
}
bool _tag::parse_params()
{
bool result = false;
if (!name) return false;
if (debug_mode) {
debugln(" ");
debugln(" ");
debug("tag: "); debugln(#name);
debug("params: "); debugln(#params);
debugln(" ");
}
while (get_next_param()) {
result = true;
if (debug_mode) {
debug("attribute: "); debugln(attributes.get(attributes.count-1));
debug("value: "); debugln(values.get(values.count-1));
debugln(" ");
}
};
return result;
}
bool _tag::get_next_param()
{ {
byte quotes = NULL; byte quotes = NULL;
int i; int i;
unsigned char val[4000];
unsigned char attr[4000];
if (!params) return false;
if (!tagparam) return false; i = strlen(#params) - 1;
if (params[i] == '/') i--;
while (i>0) && (__isWhite(params[i])) i--;
if (debug_mode) { if (params[i] == '"') || (params[i] == '\'')
debug("tag: "); debugln(#tag);
debug("tagparam: "); debugln(#tagparam);
}
i = strlen(#tagparam) - 1;
if (tagparam[i] == '/') i--;
while (i>0) && (__isWhite(tagparam[i])) i--;
if (tagparam[i] == '"') || (tagparam[i] == '\'')
{ {
//find VAL end //remove quotes
quotes = tagparam[i]; quotes = params[i];
tagparam[i] = '\0'; i--; params[i] = EOS;
i--;
//find VAL start and copy //find VAL start and copy
i = strrchr(#tagparam, quotes); i = strrchr(#params, quotes);
strlcpy(#val, #tagparam + i, sizeof(val)-1); strlcpy(#val, #params + i, sizeof(val)-1);
tagparam[i] = '\0'; i--; params[i] = EOS;
i--;
//find ATTR end //find ATTR end
while (i > 0) && (tagparam[i] != '=') i--; while (i > 0) && (params[i] != '=') i--;
tagparam[i+1] = '\0'; params[i+1] = EOS;
} }
else else
{ {
//find VAL end
//already have
//find VAL start and copy //find VAL start and copy
while (i > 0) && (tagparam[i] != '=') i--; while (i > 0) && (params[i] != '=') i--;
i++; i++;
strlcpy(#val, #tagparam + i, sizeof(val)-1); strlcpy(#val, #params + i, sizeof(val)-1);
// tagparam[i] = '\0';
//find ATTR end //already have ATTR end
//already have
} }
//find ATTR start and copy //find ATTR start and copy
while (i>0) && (!__isWhite(tagparam[i])) i--; while (i>0) && (!__isWhite(params[i])) i--;
strlcpy(#attr, #tagparam + i + 1, sizeof(attr)-1); strlcpy(#attr, #params + i + 1, sizeof(attr)-1);
tagparam[i] = '\0'; strlwr(#attr);
params[i] = '\0';
//fix case: src=./images/KolibriOS_logo2.jpg?sid=e8ece8b38b //fix case: src=./images/KolibriOS_logo2.jpg?sid=e8ece8b38b
i = strchr(#attr,'='); i = strchr(#attr,'=');
@ -58,15 +109,18 @@ bool GetNextParam()
ESBYTE[i+1] = '\0'; ESBYTE[i+1] = '\0';
} }
strlwr(#attr); attributes.add(#attr);
values.add(#val);
if (debug_mode) {
debug("val: "); debugln(#val);
debug("attr: "); debugln(#attr);
debugln(" ");
}
return true; return true;
} }
dword _tag::get_value_of(dword _attr_name)
{
int pos = attributes.get_pos_by_name(_attr_name);
if (pos == -1) {
return 0;
} else {
return values.get(pos);
}
}

View File

@ -1,67 +1,53 @@
char *unicode_tags[]={ char *unicode_symbols[]={
"nbsp", " ", "#32", " ",
"#38", " ", "#34", "\"", "quot","\"",
"#160", " ", "#38", "&", "amp", "&",
"#39", "'",
"copy", "(c)", "#039","'",
"#169", "(c)", "#60", "<", "lt", "<",
"#62", ">", "gt", ">",
"#91", "[",
"#93", "]",
"#96", "'",
"#149","-",
"#151","-",
"#160"," ", "nbsp", " ",
"#169","(c)", "copy", "(c)",
"#171","<<", "laquo","<<",
"#174","(r)", "reg", "(r)",
"#187",">>", "raquo",">>",
"trade", "[TM]", "trade", "[TM]",
"reg", "(r)",
"#174", "(r)",
"bdquo", ",,", "bdquo", ",,",
"amp", "&",
"#38", "&",
"lt", "<",
"#60", "<",
"gt", ">",
"#62", ">",
"minus", "-", "minus", "-",
"ndash", "-", "ndash", "-",
"mdash", "-", //-- "mdash", "-", //--
"#8722", "-",
"#8211", "-",
"#151", "-",
"#149", "-",
"#9642", "-", //square in the middle of the line
"rsquo", "'", "rsquo", "'",
"#39", "'",
"#039", "'", "#1028", "\242",
"#96", "'", "#1030", "I",
"#1031", "\244",
"#8211", "-",
"#8217", "'", "#8217", "'",
"#8222", "\"", "ldquo", "\"",
"quot", "\"", "#8221", "\"", "rdquo", "\"",
"#34", "\"", "#8470", "N",
"ldquo", "\"", "#8722", "-",
"rdquo", "\"", "#9642", "-", //square in the middle of the line
"#8222", "\"",
"#8221", "\"",
"laquo", "<<",
"#171", "<<",
"raquo", ">>",
"#187", ">>",
"uarr", "\24", "uarr", "\24",
"darr", "\25", "darr", "\25",
"rarr", "\26", "rarr", "\26",
"larr", "\27", "larr", "\27",
"#1028", "\242", "bull", "\31",
"#1030", "I",
"#1031", "\244",
"#8470", "N",
"bull", "\31", //âîîáùå çäåñü òî÷êà
"percnt","%", "percnt","%",
"#xfeff", "",
0}; 0};
@ -71,18 +57,18 @@ bool GetUnicodeSymbol(dword in_tag)
{ {
int j, specia1040; int j, specia1040;
for (j=0; unicode_tags[j]!=0; j+=2;) for (j=0; unicode_symbols[j]!=0; j+=2;)
{ {
if (!strcmp(in_tag, unicode_tags[j])) if (!strcmp(in_tag, unicode_symbols[j]))
{ {
strcat(#line, unicode_tags[j+1]); strcat(#line, unicode_symbols[j+1]);
return true; return true;
} }
} }
specia1040 = atoi(in_tag + 1) - 1040; specia1040 = atoi(in_tag + 1) - 1040;
if (tag[1] == '1') && (specia1040>=0) if (ESBYTE[in_tag+1] == '1') && (specia1040>=0)
&& (specia1040<=72) && (strlen(in_tag) == 5) && (specia1040<=72) && (strlen(in_tag) == 5)
{ {
if (strlen(#line)<sizeof(line)-2) { if (strlen(#line)<sizeof(line)-2) {

View File

@ -29,7 +29,7 @@
#include "..\lib\patterns\simple_open_dialog.h" #include "..\lib\patterns\simple_open_dialog.h"
#ifdef LANG_RUS #ifdef LANG_RUS
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.94"; char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 2.0 beta1";
#define T_LOADING "‡ £à㧪  áâà ­¨æë..." #define T_LOADING "‡ £à㧪  áâà ­¨æë..."
#define T_RENDERING "<22>¥­¤¥à¨­£..." #define T_RENDERING "<22>¥­¤¥à¨­£..."
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
@ -45,7 +45,7 @@ char link_menu[] =
"Š®¯¨à®¢ âì áá뫪ã "Š®¯¨à®¢ âì áá뫪ã
ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨"; ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
#else #else
char version[]="Text-based Browser 1.94"; char version[]="Text-based Browser 2.0 beta1";
#define T_LOADING "Loading..." #define T_LOADING "Loading..."
#define T_RENDERING "Rendering..." #define T_RENDERING "Rendering..."
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
@ -62,6 +62,8 @@ char link_menu[] =
Download link contents"; Download link contents";
#endif #endif
#define URL_SIZE 4000;
dword col_bg = 0xE3E2E2; dword col_bg = 0xE3E2E2;
dword panel_color = 0xE3E2E2; dword panel_color = 0xE3E2E2;
dword border_color = 0x8C8C8C; dword border_color = 0x8C8C8C;
@ -108,8 +110,9 @@ enum {
char default_dir[] = "/rd/1"; char default_dir[] = "/rd/1";
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" }; od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
char editURL[sizeof(URL)]; char URL[URL_SIZE];
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(URL)-2,#editURL,0,NULL,19,19}; char editURL[URL_SIZE];
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#editURL,0,NULL,19,19};
#define SKIN_Y 24 #define SKIN_Y 24
@ -181,17 +184,17 @@ void main()
case evKey: case evKey:
GetKeys(); GetKeys();
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
if (key_scancode == SCAN_CODE_KEY_O) EventOpenDialog(); if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;}
if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY); if (key_scancode == SCAN_CODE_KEY_H) {ProcessEvent(VIEW_HISTORY);break;}
if (key_scancode == SCAN_CODE_KEY_U) EventViewSource(); if (key_scancode == SCAN_CODE_KEY_U) {EventViewSource();break;}
if (key_scancode == SCAN_CODE_KEY_T) if (key_scancode == SCAN_CODE_KEY_T)
|| (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL); || (key_scancode == SCAN_CODE_KEY_N) {RunProgram(#program_path, NULL);break;}
if (key_scancode == SCAN_CODE_KEY_W) ExitProcess(); if (key_scancode == SCAN_CODE_KEY_J) {ProcessEvent(DOWNLOAD_MANAGER);break;}
if (key_scancode == SCAN_CODE_KEY_J) ProcessEvent(DOWNLOAD_MANAGER); if (key_scancode == SCAN_CODE_KEY_R) {ProcessEvent(REFRESH_BUTTON);break;}
if (key_scancode == SCAN_CODE_KEY_R) ProcessEvent(REFRESH_BUTTON); if (key_scancode == SCAN_CODE_ENTER) {EventSeachWeb();break;}
if (key_scancode == SCAN_CODE_ENTER) EventSeachWeb(); if (key_scancode == SCAN_CODE_LEFT) {ProcessEvent(BACK_BUTTON);break;}
if (key_scancode == SCAN_CODE_LEFT) ProcessEvent(BACK_BUTTON); if (key_scancode == SCAN_CODE_RIGHT) {ProcessEvent(FORWARD_BUTTON);break;}
if (key_scancode == SCAN_CODE_RIGHT) ProcessEvent(FORWARD_BUTTON); if (key_scancode == SCAN_CODE_KEY_W) {ExitProcess();break;}
} }
if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON); if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON);
@ -268,7 +271,6 @@ void main()
bufpointer = http.content_pointer; bufpointer = http.content_pointer;
bufsize = http.content_received; bufsize = http.content_received;
http.free(); http.free();
SetPageDefaults();
DrawStatusBar(T_RENDERING); DrawStatusBar(T_RENDERING);
ShowPage(); ShowPage();
DrawStatusBar(NULL); DrawStatusBar(NULL);
@ -310,8 +312,10 @@ void draw_window()
img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 102, SKIN_Y); img_draw stdcall(skin.image, Form.cwidth-24, address_box.top-3, 17, skin.h, 102, SKIN_Y);
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg);
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color);
if (!header) if (!header) {
OpenPage(); OpenPage();
WB1.DrawScroller();
}
else { else {
WB1.DrawPage(); WB1.DrawPage();
DrawOmnibox(); DrawOmnibox();
@ -414,14 +418,6 @@ void StopLoading()
DrawOmnibox(); DrawOmnibox();
} }
void SetPageDefaults()
{
strcpy(#header, #version);
WB1.list.count = WB1.list.first = 0;
cur_encoding = CH_NULL;
if (o_bufpointer) o_bufpointer = free(o_bufpointer);
}
void ReplaceSpaceInUrl() { void ReplaceSpaceInUrl() {
int i; int i;
strcpy(#editURL, #URL); strcpy(#editURL, #URL);
@ -444,9 +440,8 @@ void OpenPage()
history.add(#URL); history.add(#URL);
if (!strncmp(#URL,"WebView:",8)) if (!strncmp(#URL,"WebView:",8))
{ {
SetPageDefaults(); if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage));
if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage)-1); else if (!strcmp(#URL, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help));
else if (!strcmp(#URL, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help)-1);
else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory(); else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
else {bufsize=0; ShowPage();} //page not found else {bufsize=0; ShowPage();} //page not found
DrawOmnibox(); DrawOmnibox();
@ -459,12 +454,11 @@ void OpenPage()
if (!strncmp(#URL,"http:",5)) { if (!strncmp(#URL,"http:",5)) {
http.get(#URL); http.get(#URL);
} } else if (!strncmp(#URL,"https://",8)) {
if (!strncmp(#URL,"https://",8)) {
sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #URL); sprintf(#getUrl, "http://gate.aspero.pro/?site=%s", #URL);
http.get(#getUrl); http.get(#getUrl);
} }
//http.get(#URL);
if (!http.transfer) if (!http.transfer)
{ {
StopLoading(); StopLoading();
@ -477,13 +471,13 @@ void OpenPage()
else else
{ {
file_size stdcall (#URL); file_size stdcall (#URL);
if (EBX) if (EBX) {
{
bufsize = EBX; bufsize = EBX;
free(bufpointer); free(bufpointer);
bufpointer = malloc(bufsize); bufpointer = malloc(bufsize);
SetPageDefaults();
ReadFile(0, bufsize, bufpointer, #URL); ReadFile(0, bufsize, bufpointer, #URL);
} else {
bufsize = bufpointer = 0;
} }
ShowPage(); ShowPage();
} }
@ -492,29 +486,20 @@ void OpenPage()
void ProcessAnchor() void ProcessAnchor()
{ {
char anchor[256]; char anchor[256];
int anchor_pos; dword anchor_pos;
anchor_pos = strrchr(#URL, '#')-1; anchor_pos = strrchr(#URL, '#')-1;
strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor)-1); strlcpy(#anchors.current_anchor_name, #URL+anchor_pos, sizeof(anchor)-1);
URL[anchor_pos] = 0x00; URL[anchor_pos] = 0x00;
//#1 if (URL[0] == NULL) {
if (URL[0] == NULL) //case when URL consists of anchor only
{ if (anchors.get_pos_by_name(#anchor+1)!=-1) WB1.list.first = anchors.get_pos_by_name(#anchor+1);
if (anchor[1] == NULL) {
WB1.list.first = 0;
}
else {
if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1);
}
strcpy(#URL, history.current()); strcpy(#URL, history.current());
} } else {
//liner.ru#1
else
{
GetAbsoluteURL(#URL); GetAbsoluteURL(#URL);
OpenPage(); OpenPage();
if (anchors.get_anchor_pos(#anchor+1)!=-1) WB1.list.first = anchors.get_anchor_pos(#anchor+1); if (anchors.get_pos_by_name(#anchor+1)!=-1) WB1.list.first = anchors.get_pos_by_name(#anchor+1);
} }
WB1.DrawPage(); WB1.DrawPage();
@ -536,7 +521,7 @@ void EventSubmitOmnibox()
strlcpy(#URL,"http://",7); strlcpy(#URL,"http://",7);
strcat(#URL, #editURL); strcat(#URL, #editURL);
} }
ProcessLink(); OpenPage();
} }
void EventClickLink() void EventClickLink()
@ -628,19 +613,22 @@ void DrawOmnibox()
img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
} }
void LoadInternalPage(dword bufpos, in_filesize){ void LoadInternalPage(dword _bufpos, _in_filesize){
bufsize = in_filesize; bufsize = _in_filesize;
bufpointer = bufpos; if (bufpointer!=_bufpos) free(bufpointer);
bufpointer = malloc(bufsize);
memmov(bufpointer, _bufpos, bufsize);
ShowPage(); ShowPage();
} }
void ShowPage() void ShowPage()
{ {
WB1.list.first = 0; //scroll page to the top
DrawOmnibox(); DrawOmnibox();
if (!bufsize) || (!bufpointer) { if (!bufsize) || (!bufpointer) {
LoadInternalPage(#page_not_found, sizeof(page_not_found)-1); LoadInternalPage(#page_not_found, sizeof(page_not_found));
} }
WB1.Prepare(); WB1.ParseHtml();
if (source_mode) { if (source_mode) {
source_mode = false; source_mode = false;
ShowSource(); ShowSource();

View File

@ -36,6 +36,7 @@ proc_info Form;
dword TOOLBAR_H = 40; dword TOOLBAR_H = 40;
dword STATUSBAR_H = 0; dword STATUSBAR_H = 0;
dword col_bg = 0xE3E2E2; dword col_bg = 0xE3E2E2;
dword panel_color = 0xE3E2E2; dword panel_color = 0xE3E2E2;
dword border_color = 0x8C8C8C; dword border_color = 0x8C8C8C;
@ -49,12 +50,14 @@ enum {
EDIT_SOURCE, EDIT_SOURCE,
}; };
#define URL_SIZE 4000;
#include "..\TWB\TWB.c" #include "..\TWB\TWB.c"
#include "show_src.h" #include "show_src.h"
char editURL[sizeof(URL)]; char URL[URL_SIZE];
char editURL[URL_SIZE];
int mouse_twb; int mouse_twb;
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(URL),#editURL,#mouse_twb,2,19,19}; edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#editURL,#mouse_twb,2,19,19};
#define SKIN_Y 24 #define SKIN_Y 24
@ -179,15 +182,14 @@ void EventGoToPage()
void SetPageDefaults() void SetPageDefaults()
{ {
strcpy(#header, #version); strncpy(#header, #version, sizeof(header)-1);
WB1.list.count = WB1.list.first = 0; WB1.list.count = WB1.list.first = 0;
cur_encoding = CH_NULL; cur_encoding = CH_NULL;
if (o_bufpointer) o_bufpointer = free(o_bufpointer);
} }
void OpenPage() void OpenPage()
{ {
char getUrl[sizeof(URL)]; char getUrl[URL_SIZE];
strcpy(#editURL, #URL); strcpy(#editURL, #URL);
history.add(#URL); history.add(#URL);
if (!strncmp(#URL,"CodeView:",8)) if (!strncmp(#URL,"CodeView:",8))
@ -236,7 +238,7 @@ void ShowPage()
{ {
DrawEditBoxWebView(); DrawEditBoxWebView();
if (!bufsize) LoadInternalPage(#page_not_found, sizeof(page_not_found)); if (!bufsize) LoadInternalPage(#page_not_found, sizeof(page_not_found));
WB1.Prepare(); WB1.ParseHtml();
} }
void DrawStatusBar() {return;}; void DrawStatusBar() {return;};

View File

@ -397,13 +397,17 @@ inline fastcall void strcat( EDI, ESI)
:void strncat(dword dst, src, dword len) :void strncat(dword dst, src, dword len)
{ {
while (ESBYTE[dst]) dst++; while (ESBYTE[dst]) && (len) {
dst++;
len--;
}
while (ESBYTE[src]) && (len) { while (ESBYTE[src]) && (len) {
ESBYTE[dst] = ESBYTE[src]; ESBYTE[dst] = ESBYTE[src];
dst++; dst++;
src++; src++;
len--; len--;
} }
ESBYTE[dst] = 0;
} }
inline fastcall void chrcat(ESI, DI) inline fastcall void chrcat(ESI, DI)

View File

@ -98,6 +98,8 @@ bool open_in_a_new_window = false;
progress_bar wv_progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F}; progress_bar wv_progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
#define URL_SIZE 4000;
int http_transfer; int http_transfer;
char version[]=" WebView 0.1"; char version[]=" WebView 0.1";
#include "..\TWB\TWB.c" #include "..\TWB\TWB.c"

View File

@ -362,7 +362,7 @@ void InitTWB() {
void DrawLetter() { void DrawLetter() {
bufsize = strlen(mdata); bufsize = strlen(mdata);
bufpointer = mdata; bufpointer = mdata;
if (bufsize) && (bufpointer) WB1.Prepare(); if (bufsize) && (bufpointer) WB1.ParseHtml();
DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, 0xFFFfff); DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, 0xFFFfff);
} }