forked from KolibriOS/kolibrios
WebView: better code #1
git-svn-id: svn://kolibrios.org@5746 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
383b55f4be
commit
0b5a2b2056
@ -2,17 +2,25 @@ dword bufpointer;
|
|||||||
dword o_bufpointer;
|
dword o_bufpointer;
|
||||||
dword bufsize;
|
dword bufsize;
|
||||||
|
|
||||||
char URL[10000];
|
|
||||||
|
|
||||||
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};
|
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};
|
||||||
|
|
||||||
char header[2048];
|
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
|
||||||
|
|
||||||
|
struct _style {
|
||||||
|
byte
|
||||||
|
b, i, u, s,
|
||||||
|
pre,
|
||||||
|
blq,
|
||||||
|
li,
|
||||||
|
li_tab,
|
||||||
|
align;
|
||||||
|
};
|
||||||
|
|
||||||
struct TWebBrowser {
|
struct TWebBrowser {
|
||||||
llist list;
|
llist list;
|
||||||
|
_style style;
|
||||||
dword draw_line_width;
|
dword draw_line_width;
|
||||||
DrawBufer DrawBuf;
|
DrawBufer DrawBuf;
|
||||||
void Prepare();
|
|
||||||
void Parse();
|
void Parse();
|
||||||
void SetTextStyle();
|
void SetTextStyle();
|
||||||
void DrawPage();
|
void DrawPage();
|
||||||
@ -22,11 +30,26 @@ struct TWebBrowser {
|
|||||||
byte end_parsing;
|
byte end_parsing;
|
||||||
} WB1;
|
} WB1;
|
||||||
|
|
||||||
byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab,
|
|
||||||
link, ignor_text, cur_encoding, text_align, t_html, t_body;
|
|
||||||
|
byte
|
||||||
|
link,
|
||||||
|
ignor_text,
|
||||||
|
cur_encoding,
|
||||||
|
t_html,
|
||||||
|
t_body;
|
||||||
|
/*
|
||||||
|
struct _condition {
|
||||||
|
byte
|
||||||
|
text_active,
|
||||||
|
text_val,
|
||||||
|
href,
|
||||||
|
max
|
||||||
|
} condition;
|
||||||
|
*/
|
||||||
|
|
||||||
byte condition_text_active, condition_text_val, condition_href, condition_max;
|
byte condition_text_active, condition_text_val, condition_href, condition_max;
|
||||||
|
|
||||||
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
|
|
||||||
|
|
||||||
dword text_colors[300];
|
dword text_colors[300];
|
||||||
dword text_color_index;
|
dword text_color_index;
|
||||||
@ -39,11 +62,13 @@ int stolbec;
|
|||||||
int tab_len;
|
int tab_len;
|
||||||
int anchor_line_num;
|
int anchor_line_num;
|
||||||
|
|
||||||
|
char URL[10000];
|
||||||
|
char header[2048];
|
||||||
char line[500];
|
char line[500];
|
||||||
char tag[100];
|
|
||||||
char tagparam[10000];
|
char tagparam[10000];
|
||||||
char parametr[1200];
|
char tag[100];
|
||||||
char options[4096];
|
char attr[1200];
|
||||||
|
char val[4096];
|
||||||
char anchor[256];
|
char anchor[256];
|
||||||
|
|
||||||
#include "..\TWB\history.h"
|
#include "..\TWB\history.h"
|
||||||
@ -81,10 +106,10 @@ void TWebBrowser::DrawPage()
|
|||||||
line_length = stolbec_len * list.font_w * DrawBuf.zoom;
|
line_length = stolbec_len * list.font_w * DrawBuf.zoom;
|
||||||
|
|
||||||
WriteBufText(start_x, 0, list.font_type, text_colors[text_color_index], #line, buf_data);
|
WriteBufText(start_x, 0, list.font_type, text_colors[text_color_index], #line, buf_data);
|
||||||
if (b_text) WriteBufText(start_x+1, 0, list.font_type, text_colors[text_color_index], #line, buf_data);
|
if (style.b) WriteBufText(start_x+1, 0, list.font_type, text_colors[text_color_index], #line, buf_data);
|
||||||
if (i_text) { stolbec++; DrawBuf.Skew(start_x, 0, line_length, list.line_h); } // bug with zoom>1
|
if (style.i) { stolbec++; DrawBuf.Skew(start_x, 0, line_length, list.line_h); } // bug with zoom>1
|
||||||
if (s_text) DrawBuf.DrawBar(start_x, list.line_h / 2 - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
if (style.s) DrawBuf.DrawBar(start_x, list.line_h / 2 - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
||||||
if (u_text) DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
if (style.u) DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
||||||
if (link) {
|
if (link) {
|
||||||
DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
||||||
UnsafeDefineButton(start_x-2, start_y-1, line_length + 3, DrawBuf.zoom * list.font_h, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
|
UnsafeDefineButton(start_x-2, start_y-1, line_length + 3, DrawBuf.zoom * list.font_h, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
|
||||||
@ -96,13 +121,6 @@ void TWebBrowser::DrawPage()
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
|
|
||||||
void TWebBrowser::Prepare(dword bufpos, in_filesize){
|
|
||||||
bufsize = in_filesize;
|
|
||||||
bufpointer = bufpos;
|
|
||||||
Parse();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TWebBrowser::Parse(){
|
void TWebBrowser::Parse(){
|
||||||
word bukva[2];
|
word bukva[2];
|
||||||
int j;
|
int j;
|
||||||
@ -111,12 +129,12 @@ void TWebBrowser::Parse(){
|
|||||||
dword bufpos = bufpointer;
|
dword bufpos = bufpointer;
|
||||||
int line_len;
|
int line_len;
|
||||||
|
|
||||||
b_text = i_text = u_text = s_text = blq_text = t_html = t_body =
|
style.b = style.i = style.u = style.s = style.blq = t_html = t_body =
|
||||||
li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab =
|
style.li = link = ignor_text = text_color_index = text_colors[0] =
|
||||||
condition_text_val = condition_text_active = 0; //îáíóëÿåì òåãè
|
style.li_tab = condition_text_val = condition_text_active = 0; //îáíóëÿåì òåãè
|
||||||
end_parsing = false;
|
end_parsing = false;
|
||||||
condition_max = 255;
|
condition_max = 255;
|
||||||
text_align = ALIGN_LEFT;
|
style.align = ALIGN_LEFT;
|
||||||
link_color_inactive = 0x0000FF;
|
link_color_inactive = 0x0000FF;
|
||||||
link_color_active = 0xFF0000;
|
link_color_active = 0xFF0000;
|
||||||
bg_color = 0xFFFFFF;
|
bg_color = 0xFFFFFF;
|
||||||
@ -129,11 +147,8 @@ void TWebBrowser::Parse(){
|
|||||||
|
|
||||||
draw_line_width = list.w * DrawBuf.zoom;
|
draw_line_width = list.w * DrawBuf.zoom;
|
||||||
|
|
||||||
if (pre_text<>2)
|
style.pre = 1;
|
||||||
{
|
if (strstri(bufpointer, "html")) style.pre = 0;
|
||||||
pre_text=0;
|
|
||||||
if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;)
|
for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;)
|
||||||
{
|
{
|
||||||
@ -144,7 +159,7 @@ void TWebBrowser::Parse(){
|
|||||||
switch (bukva)
|
switch (bukva)
|
||||||
{
|
{
|
||||||
case 0x0a:
|
case 0x0a:
|
||||||
if (pre_text)
|
if (style.pre)
|
||||||
{
|
{
|
||||||
chrcat(#line, ' ');
|
chrcat(#line, ' ');
|
||||||
bukva = temp = NULL;
|
bukva = temp = NULL;
|
||||||
@ -152,7 +167,7 @@ void TWebBrowser::Parse(){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '\9':
|
case '\9':
|
||||||
if (pre_text) //èíà÷å èä¸ì íà 0x0d
|
if (style.pre) //èíà÷å èä¸ì íà 0x0d
|
||||||
{
|
{
|
||||||
tab_len = strlen(#line) % 4;
|
tab_len = strlen(#line) % 4;
|
||||||
if (!tab_len) tab_len = 4;
|
if (!tab_len) tab_len = 4;
|
||||||
@ -173,7 +188,7 @@ void TWebBrowser::Parse(){
|
|||||||
break;
|
break;
|
||||||
case '<':
|
case '<':
|
||||||
bufpos++; //ïðîìîòàåì ñèìâîë <
|
bufpos++; //ïðîìîòàåì ñèìâîë <
|
||||||
tag = parametr = tagparam = ignor_param = NULL;
|
tag = attr = tagparam = ignor_param = NULL;
|
||||||
if (ESBYTE[bufpos] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
|
if (ESBYTE[bufpos] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
|
||||||
{
|
{
|
||||||
bufpos++;
|
bufpos++;
|
||||||
@ -219,13 +234,13 @@ void TWebBrowser::Parse(){
|
|||||||
DrawPage();
|
DrawPage();
|
||||||
line = NULL;
|
line = NULL;
|
||||||
if (tag) SetTextStyle(WB1.DrawBuf.zoom * 5 + list.x, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ
|
if (tag) SetTextStyle(WB1.DrawBuf.zoom * 5 + list.x, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ
|
||||||
tag = parametr = tagparam = ignor_param = NULL;
|
tag = attr = tagparam = ignor_param = NULL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DEFAULT_MARK:
|
DEFAULT_MARK:
|
||||||
if (bukva<=15) bukva=' ';
|
if (bukva<=15) bukva=' ';
|
||||||
line_len = utf8_strlen(#line);
|
line_len = utf8_strlen(#line);
|
||||||
if (!pre_text) && (bukva == ' ')
|
if (!style.pre) && (bukva == ' ')
|
||||||
{
|
{
|
||||||
if (line[line_len-1]==' ') break; //no double spaces
|
if (line[line_len-1]==' ') break; //no double spaces
|
||||||
if (!stolbec) && (!line) break; //no paces at the beginning of the line
|
if (!stolbec) && (!line) break; //no paces at the beginning of the line
|
||||||
@ -276,16 +291,16 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
|
|||||||
}
|
}
|
||||||
else opened = 1;
|
else opened = 1;
|
||||||
|
|
||||||
if (isTag("html"))
|
if (istag("html"))
|
||||||
{
|
{
|
||||||
t_html = opened;
|
t_html = opened;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTag("script")) || (isTag("style")) || (isTag("binary")) || (isTag("select")) ignor_text = opened;
|
if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) ignor_text = opened;
|
||||||
if (isTag("form")) if (!opened) ignor_text = false;
|
if (istag("form")) if (!opened) ignor_text = false;
|
||||||
|
|
||||||
if(isTag("title"))
|
if(istag("title"))
|
||||||
{
|
{
|
||||||
if (opened) header=NULL;
|
if (opened) header=NULL;
|
||||||
else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó
|
else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó
|
||||||
@ -294,36 +309,28 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
|
|||||||
|
|
||||||
if (ignor_text) return;
|
if (ignor_text) return;
|
||||||
|
|
||||||
IF(isTag("q"))
|
IF(istag("q"))
|
||||||
{
|
{
|
||||||
if (opened)
|
if (opened) strcat(#line, " \"");
|
||||||
{
|
if (!opened) strcat(#line, "\" ");
|
||||||
NewLine();
|
|
||||||
strcat(#line, ' \"');
|
|
||||||
}
|
|
||||||
if (!opened)
|
|
||||||
{
|
|
||||||
chrcat(#line, '\"');
|
|
||||||
NewLine();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
|
if (anchor) && (isattr("id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
|
||||||
{
|
{
|
||||||
if (!strcmp(#anchor, #options)) anchor_line_num=list.first+stroka;
|
if (!strcmp(#anchor, #val)) anchor_line_num=list.first+stroka;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTag("body"))
|
if (istag("body"))
|
||||||
{
|
{
|
||||||
t_body = opened;
|
t_body = opened;
|
||||||
do{
|
do{
|
||||||
if (!strcmp(#parametr, "condition_max=")) condition_max = atoi(#options);
|
if (isattr("condition_max=")) condition_max = atoi(#val);
|
||||||
if (!strcmp(#parametr, "link=")) link_color_inactive = GetColor(#options);
|
if (isattr("link=")) link_color_inactive = GetColor(#val);
|
||||||
if (!strcmp(#parametr, "alink=")) link_color_active = GetColor(#options);
|
if (isattr("alink=")) link_color_active = GetColor(#val);
|
||||||
if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options);
|
if (isattr("text=")) text_colors[0]=GetColor(#val);
|
||||||
if (!strcmp(#parametr, "bgcolor="))
|
if (isattr("bgcolor="))
|
||||||
{
|
{
|
||||||
bg_color=GetColor(#options);
|
bg_color=GetColor(#val);
|
||||||
DrawBuf.Fill(bg_color);
|
DrawBuf.Fill(bg_color);
|
||||||
}
|
}
|
||||||
} while(GetNextParam());
|
} while(GetNextParam());
|
||||||
@ -335,14 +342,14 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTag("a"))
|
if (istag("a"))
|
||||||
{
|
{
|
||||||
if (opened)
|
if (opened)
|
||||||
{
|
{
|
||||||
if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
|
if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
|
||||||
|
|
||||||
do{
|
do{
|
||||||
if (!strcmp(#parametr, "href="))
|
if (isattr("href="))
|
||||||
{
|
{
|
||||||
if (stroka - 1 > list.visible) || (stroka < -2) return;
|
if (stroka - 1 > list.visible) || (stroka < -2) return;
|
||||||
|
|
||||||
@ -351,11 +358,11 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
|
|||||||
|
|
||||||
link = 1;
|
link = 1;
|
||||||
text_colors[text_color_index] = link_color_inactive;
|
text_colors[text_color_index] = link_color_inactive;
|
||||||
PageLinks.AddLink(#options, DrawBuf.zoom * stolbec * list.font_w + left1, top1-DrawBuf.zoom);
|
PageLinks.AddLink(#val, DrawBuf.zoom * stolbec * list.font_w + left1, top1-DrawBuf.zoom);
|
||||||
}
|
}
|
||||||
if (anchor) && (!strcmp(#parametr, "name="))
|
if (anchor) && (isattr("name="))
|
||||||
{
|
{
|
||||||
if (!strcmp(#anchor, #options))
|
if (!strcmp(#anchor, #val))
|
||||||
{
|
{
|
||||||
anchor_line_num=list.first+stroka;
|
anchor_line_num=list.first+stroka;
|
||||||
}
|
}
|
||||||
@ -369,7 +376,7 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTag("font"))
|
if (istag("font"))
|
||||||
{
|
{
|
||||||
if (opened)
|
if (opened)
|
||||||
{
|
{
|
||||||
@ -377,9 +384,9 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
|
|||||||
text_colors[text_color_index] = text_colors[text_color_index-1];
|
text_colors[text_color_index] = text_colors[text_color_index-1];
|
||||||
|
|
||||||
do{
|
do{
|
||||||
if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
|
if (strcmp(#attr, "color=") == 0) //&& (attr[1] == '#')
|
||||||
{
|
{
|
||||||
text_colors[text_color_index] = GetColor(#options);
|
text_colors[text_color_index] = GetColor(#val);
|
||||||
}
|
}
|
||||||
} while(GetNextParam());
|
} while(GetNextParam());
|
||||||
}
|
}
|
||||||
@ -387,43 +394,43 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
|
|||||||
if (text_color_index > 0) text_color_index--;
|
if (text_color_index > 0) text_color_index--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isTag("br")) {
|
if (istag("br")) {
|
||||||
NewLine();
|
NewLine();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isTag("div")) || (isTag("header")) || (isTag("article")) || (isTag("footer")) {
|
if (istag("div")) || (istag("header")) || (istag("article")) || (istag("footer")) {
|
||||||
IF(oldtag[0] <>'h') NewLine();
|
IF(oldtag[0] <>'h') NewLine();
|
||||||
if (!strcmp(#parametr, "bgcolor="))
|
if (isattr("bgcolor="))
|
||||||
{
|
{
|
||||||
bg_color=GetColor(#options);
|
bg_color=GetColor(#val);
|
||||||
DrawBuf.Fill(bg_color);
|
DrawBuf.Fill(bg_color);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isTag("p")) {
|
if (istag("p")) {
|
||||||
IF(oldtag[0] == 'h') return;
|
IF(oldtag[0] == 'h') return;
|
||||||
NewLine();
|
NewLine();
|
||||||
IF(opened) NewLine();
|
IF(opened) NewLine();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isTag("table")) {
|
if(istag("table")) {
|
||||||
table.active = opened;
|
table.active = opened;
|
||||||
NewLine();
|
NewLine();
|
||||||
if (opened) table.NewTable();
|
if (opened) table.NewTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isTag("td")) {
|
if(istag("td")) {
|
||||||
if (opened)
|
if (opened)
|
||||||
{
|
{
|
||||||
table.cur_col++;
|
table.cur_col++;
|
||||||
table.row_h = 0;
|
table.row_h = 0;
|
||||||
do {
|
do {
|
||||||
if (!strcmp(#parametr, "width="))
|
if (isattr("width="))
|
||||||
{
|
{
|
||||||
table.col_w[table.cur_col] = atoi(#options);
|
table.col_w[table.cur_col] = atoi(#val);
|
||||||
// NewLine();
|
// NewLine();
|
||||||
// strcpy(#line, #options);
|
// strcpy(#line, #val);
|
||||||
// NewLine();
|
// NewLine();
|
||||||
}
|
}
|
||||||
} while(GetNextParam());
|
} while(GetNextParam());
|
||||||
@ -434,7 +441,7 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isTag("tr")) {
|
if(istag("tr")) {
|
||||||
if (opened)
|
if (opened)
|
||||||
{
|
{
|
||||||
table.cur_col = 0;
|
table.cur_col = 0;
|
||||||
@ -451,121 +458,121 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (isTag("center"))
|
if (istag("center"))
|
||||||
{
|
{
|
||||||
if (opened) text_align = ALIGN_CENTER;
|
if (opened) style.align = ALIGN_CENTER;
|
||||||
if (!opened)
|
if (!opened)
|
||||||
{
|
{
|
||||||
NewLine();
|
NewLine();
|
||||||
text_align = ALIGN_LEFT;
|
style.align = ALIGN_LEFT;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isTag("right"))
|
if (istag("right"))
|
||||||
{
|
{
|
||||||
if (opened) text_align = ALIGN_RIGHT;
|
if (opened) style.align = ALIGN_RIGHT;
|
||||||
if (!opened)
|
if (!opened)
|
||||||
{
|
{
|
||||||
NewLine();
|
NewLine();
|
||||||
text_align = ALIGN_LEFT;
|
style.align = ALIGN_LEFT;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (isTag("h1")) || (isTag("h2")) || (isTag("h3")) || (isTag("h4")) {
|
if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) {
|
||||||
NewLine();
|
NewLine();
|
||||||
if (opened) && (stroka>1) NewLine();
|
if (opened) && (stroka>1) NewLine();
|
||||||
strcpy(#oldtag, #tag);
|
strcpy(#oldtag, #tag);
|
||||||
if (opened)
|
if (opened)
|
||||||
{
|
{
|
||||||
if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"center")) text_align = ALIGN_CENTER;
|
if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER;
|
||||||
if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"right")) text_align = ALIGN_RIGHT;
|
if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT;
|
||||||
b_text = 1;
|
style.b = 1;
|
||||||
}
|
}
|
||||||
if (!opened)
|
if (!opened)
|
||||||
{
|
{
|
||||||
text_align = ALIGN_LEFT;
|
style.align = ALIGN_LEFT;
|
||||||
b_text = 0;
|
style.b = 0;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
oldtag=NULL;
|
oldtag=NULL;
|
||||||
|
|
||||||
if (isTag("b")) || (isTag("strong")) || (isTag("big")) {
|
if (istag("b")) || (istag("strong")) || (istag("big")) {
|
||||||
b_text = opened;
|
style.b = opened;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(isTag("i")) || (isTag("em")) || (isTag("subtitle")) {
|
if(istag("i")) || (istag("em")) || (istag("subtitle")) {
|
||||||
i_text = opened;
|
style.i = opened;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isTag("dt"))
|
if (istag("dt"))
|
||||||
{
|
{
|
||||||
li_text = opened;
|
style.li = opened;
|
||||||
IF(opened == 0) return;
|
IF(opened == 0) return;
|
||||||
NewLine();
|
NewLine();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isTag("condition"))
|
if (istag("condition"))
|
||||||
{
|
{
|
||||||
condition_text_active = opened;
|
condition_text_active = opened;
|
||||||
if (opened) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options);
|
if (opened) && (isattr("show_if=")) condition_text_val = atoi(#val);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isTag("li")) || (isTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
|
if (istag("li")) || (istag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
|
||||||
{
|
{
|
||||||
li_text = opened;
|
style.li = opened;
|
||||||
if (opened)
|
if (opened)
|
||||||
{
|
{
|
||||||
NewLine();
|
NewLine();
|
||||||
if (stroka > -1) && (stroka - 2 < list.visible)
|
if (stroka > -1) && (stroka - 2 < list.visible)
|
||||||
DrawBuf.DrawBar(li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, list.line_h / 2 - DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x555555);
|
DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, list.line_h / 2 - DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x555555);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isTag("u")) || (isTag("ins")) u_text = opened;
|
if (istag("u")) || (istag("ins")) style.u = opened;
|
||||||
if (isTag("s")) || (isTag("strike")) || (isTag("del")) s_text = opened;
|
if (istag("s")) || (istag("strike")) || (istag("del")) style.s = opened;
|
||||||
if (isTag("ul")) || (isTag("ol")) IF(!opened)
|
if (istag("ul")) || (istag("ol")) IF(!opened)
|
||||||
{
|
{
|
||||||
li_text = opened;
|
style.li = opened;
|
||||||
li_tab--;
|
style.li_tab--;
|
||||||
NewLine();
|
NewLine();
|
||||||
} ELSE li_tab++;
|
} ELSE style.li_tab++;
|
||||||
if (isTag("dd")) stolbec += 5;
|
if (istag("dd")) stolbec += 5;
|
||||||
if (isTag("blockquote")) blq_text = opened;
|
if (istag("blockquote")) style.blq = opened;
|
||||||
if (isTag("pre")) || (isTag("code")) pre_text = opened;
|
if (istag("pre")) || (istag("code")) style.pre = opened;
|
||||||
if (isTag("hr"))
|
if (istag("hr"))
|
||||||
{
|
{
|
||||||
if (anchor) || (stroka < -1)
|
if (anchor) || (stroka < -1)
|
||||||
{
|
{
|
||||||
stroka+=2;
|
stroka+=2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999;
|
if (strcmp(#attr, "color=") == 0) hr_color = GetColor(#val); else hr_color = 0x999999;
|
||||||
NewLine();
|
NewLine();
|
||||||
DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
|
DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
|
||||||
NewLine();
|
NewLine();
|
||||||
}
|
}
|
||||||
if (isTag("img"))
|
if (istag("img"))
|
||||||
{
|
{
|
||||||
ImgCache.Images( left1, top1, WB1.list.w);
|
ImgCache.Images( left1, top1, WB1.list.w);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isTag("meta")) || (isTag("?xml"))
|
if (istag("meta")) || (istag("?xml"))
|
||||||
{
|
{
|
||||||
do{
|
do{
|
||||||
if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
|
if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding="))
|
||||||
{
|
{
|
||||||
strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
|
strcpy(#val, #val[strrchr(#val, '=')]); //ïîèñê â content=
|
||||||
strlwr(#options);
|
strlwr(#val);
|
||||||
meta_encoding = CH_NULL;
|
meta_encoding = CH_NULL;
|
||||||
if (!strcmp(#options, "utf-8")) || (!strcmp(#options,"utf8")) meta_encoding = CH_UTF8;
|
if (isval("utf-8")) || (isval("utf8")) meta_encoding = CH_UTF8;
|
||||||
else if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) meta_encoding = CH_KOI8;
|
else if (isval("koi8-r")) || (isval("koi8-u")) meta_encoding = CH_KOI8;
|
||||||
else if (!strcmp(#options, "windows-1251")) || (!strcmp(#options, "windows1251")) meta_encoding = CH_CP1251;
|
else if (isval("windows-1251")) || (isval("windows1251")) meta_encoding = CH_CP1251;
|
||||||
else if (!strcmp(#options, "windows-1252")) || (!strcmp(#options, "windows1252")) meta_encoding = CH_CP1252;
|
else if (isval("windows-1252")) || (isval("windows1252")) meta_encoding = CH_CP1252;
|
||||||
else if (!strcmp(#options, "iso-8859-5")) || (!strcmp(#options, "iso8859-5")) meta_encoding = CH_ISO8859_5;
|
else if (isval("iso-8859-5")) || (isval("iso8859-5")) meta_encoding = CH_ISO8859_5;
|
||||||
else if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) meta_encoding = CH_CP866;
|
else if (isval("dos")) || (isval("cp-866")) meta_encoding = CH_CP866;
|
||||||
if (cur_encoding==CH_NULL) BufEncode(meta_encoding);
|
if (cur_encoding==CH_NULL) BufEncode(meta_encoding);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -621,21 +628,20 @@ void TWebBrowser::NewLine()
|
|||||||
if (t_html) && (!t_body) return;
|
if (t_html) && (!t_body) return;
|
||||||
if (stroka * list.line_h + 5 >= 0) && ( stroka + 1 * list.line_h + 5 < list.h) && (!anchor)
|
if (stroka * list.line_h + 5 >= 0) && ( stroka + 1 * list.line_h + 5 < list.h) && (!anchor)
|
||||||
{
|
{
|
||||||
if (text_align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.line_h,stolbec * list.font_w);
|
if (style.align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.line_h,stolbec * list.font_w);
|
||||||
if (text_align == ALIGN_RIGHT) && (DrawBuf.zoom==1) DrawBuf.AlignRight(onleft,ontop,list.w,list.line_h,stolbec * list.font_w);
|
if (style.align == ALIGN_RIGHT) && (DrawBuf.zoom==1) DrawBuf.AlignRight(onleft,ontop,list.w,list.line_h,stolbec * list.font_w);
|
||||||
DrawBuf.bufy = ontop;
|
DrawBuf.bufy = ontop;
|
||||||
DrawBuf.Show();
|
DrawBuf.Show();
|
||||||
DrawBuf.Fill(bg_color);
|
DrawBuf.Fill(bg_color);
|
||||||
}
|
}
|
||||||
stroka++;
|
stroka++;
|
||||||
if (blq_text) stolbec = 6; else stolbec = 0;
|
if (style.blq) stolbec = 6; else stolbec = 0;
|
||||||
if (li_text) stolbec = li_tab * 5;
|
if (style.li) stolbec = style.li_tab * 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int isTag(dword text)
|
int istag(dword text) { if (!strcmp(#tag,text)) return 1; else return 0; }
|
||||||
{
|
int isattr(dword text) { if (!strcmp(#attr,text)) return 1; else return 0; }
|
||||||
if (!strcmp(#tag,text)) return 1; else return 0;
|
int isval(dword text) { if (!strcmp(#val,text)) return 1; else return 0; }
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -37,26 +37,20 @@ int ImageCache::GetImage(dword i_path)
|
|||||||
void ImageCache::Images(int left1, top1, width1)
|
void ImageCache::Images(int left1, top1, width1)
|
||||||
{
|
{
|
||||||
dword image;
|
dword image;
|
||||||
char img_path[4096], alt[4096];
|
char img_path[4096], alt[4096]=0;
|
||||||
int imgw=0, imgh=0, img_lines_first=0, cur_pic=0;
|
int imgw=0, imgh=0, img_lines_first=0, cur_pic=0;
|
||||||
|
|
||||||
do{
|
do{
|
||||||
if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl()
|
if (isattr("src="))
|
||||||
{
|
{
|
||||||
if (http_transfer!=0)
|
strcpy(#img_path, #val);
|
||||||
strcpy(#img_path, #history_list[BrowserHistory.current-1].Item);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//if (strcmp(#options))
|
|
||||||
strcpy(#img_path, #options);
|
|
||||||
}
|
|
||||||
PageLinks.GetAbsoluteURL(#img_path);
|
PageLinks.GetAbsoluteURL(#img_path);
|
||||||
cur_pic = GetImage(#img_path);
|
cur_pic = GetImage(#img_path);
|
||||||
}
|
}
|
||||||
if (!strcmp(#parametr,"alt="))
|
if (isattr("alt="))
|
||||||
{
|
{
|
||||||
strcpy(#alt, "[");
|
strcpy(#alt, "[");
|
||||||
strcat(#alt, #options);
|
strcat(#alt, #val);
|
||||||
strcat(#alt, "]");
|
strcat(#alt, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,6 +59,7 @@ void ImageCache::Images(int left1, top1, width1)
|
|||||||
if (!pics[cur_pic].image)
|
if (!pics[cur_pic].image)
|
||||||
{
|
{
|
||||||
if (alt) && (link) strcat(#line, #alt);
|
if (alt) && (link) strcat(#line, #alt);
|
||||||
|
//cur_pic = GetImage("/sys/network/noimg.png");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,14 @@ void LinksArray::GetAbsoluteURL(dword in_URL)
|
|||||||
if (UrlAbsolute(in_URL)) return;
|
if (UrlAbsolute(in_URL)) return;
|
||||||
|
|
||||||
IF (!strcmpn(in_URL,"./", 2)) in_URL+=2;
|
IF (!strcmpn(in_URL,"./", 2)) in_URL+=2;
|
||||||
|
if (!http_transfer)
|
||||||
|
{
|
||||||
strcpy(#newurl, BrowserHistory.CurrentUrl());
|
strcpy(#newurl, BrowserHistory.CurrentUrl());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy(#newurl, #history_list[BrowserHistory.current-1].Item);
|
||||||
|
}
|
||||||
|
|
||||||
if (ESBYTE[in_URL] == '/') //remove everything after site domain name
|
if (ESBYTE[in_URL] == '/') //remove everything after site domain name
|
||||||
{
|
{
|
||||||
|
@ -15,15 +15,15 @@ unsigned int GetNextParam()
|
|||||||
if (kavichki)
|
if (kavichki)
|
||||||
{
|
{
|
||||||
i=strrchr(#tagparam, kavichki);
|
i=strrchr(#tagparam, kavichki);
|
||||||
strlcpy(#options, #tagparam + i, sizeof(options));
|
strlcpy(#val, #tagparam + i, sizeof(val));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WHILE((i > 0) && (tagparam[i] <>'=')) i--; //i=strrchr(#tagparam, '=')+1;
|
WHILE((i > 0) && (tagparam[i] <>'=')) i--; //i=strrchr(#tagparam, '=')+1;
|
||||||
i++;
|
i++;
|
||||||
strlcpy(#options, #tagparam + i, sizeof(options));
|
strlcpy(#val, #tagparam + i, sizeof(val));
|
||||||
|
|
||||||
WHILE (options[0] == ' ') strcpy(#options, #options+1);
|
WHILE (val[0] == ' ') strcpy(#val, #val+1);
|
||||||
}
|
}
|
||||||
tagparam[i] = 0x00;
|
tagparam[i] = 0x00;
|
||||||
|
|
||||||
@ -32,8 +32,8 @@ unsigned int GetNextParam()
|
|||||||
IF (tagparam[i] == '=') //äåğçêàÿ çàãëóøêà
|
IF (tagparam[i] == '=') //äåğçêàÿ çàãëóøêà
|
||||||
tagparam[i + 1] = 0x00;
|
tagparam[i + 1] = 0x00;
|
||||||
}
|
}
|
||||||
strlcpy(#parametr, #tagparam + i + 1, sizeof(parametr));
|
strlcpy(#attr, #tagparam + i + 1, sizeof(attr));
|
||||||
tagparam[i] = 0x00;
|
tagparam[i] = 0x00;
|
||||||
strlwr(#parametr);
|
strlwr(#attr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
@ -30,14 +30,14 @@
|
|||||||
char homepage[] = FROM "html\\homepage.htm";
|
char homepage[] = FROM "html\\homepage.htm";
|
||||||
|
|
||||||
#ifdef LANG_RUS
|
#ifdef LANG_RUS
|
||||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 1.21";
|
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 1.22";
|
||||||
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
||||||
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
||||||
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
||||||
char page_not_found[] = FROM "html\page_not_found_ru.htm";
|
char page_not_found[] = FROM "html\page_not_found_ru.htm";
|
||||||
char accept_language[]= "Accept-Language: ru\n";
|
char accept_language[]= "Accept-Language: ru\n";
|
||||||
#else
|
#else
|
||||||
char version[]=" Text-based Browser 1.21";
|
char version[]=" Text-based Browser 1.22";
|
||||||
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
||||||
?define T_LAST_SLIDE "This slide is the last"
|
?define T_LAST_SLIDE "This slide is the last"
|
||||||
char loading[] = "Loading...<br>";
|
char loading[] = "Loading...<br>";
|
||||||
@ -571,7 +571,6 @@ void StopLoading()
|
|||||||
void SetPageDefaults()
|
void SetPageDefaults()
|
||||||
{
|
{
|
||||||
strcpy(#header, #version);
|
strcpy(#header, #version);
|
||||||
pre_text = 0;
|
|
||||||
WB1.list.count = WB1.list.first = 0;
|
WB1.list.count = WB1.list.first = 0;
|
||||||
stroka = 0;
|
stroka = 0;
|
||||||
cur_encoding = CH_NULL;
|
cur_encoding = CH_NULL;
|
||||||
@ -589,7 +588,7 @@ void OpenPage()
|
|||||||
if (!strncmp(#URL,"WebView:",8))
|
if (!strncmp(#URL,"WebView:",8))
|
||||||
{
|
{
|
||||||
SetPageDefaults();
|
SetPageDefaults();
|
||||||
if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.Prepare(#homepage, sizeof(homepage));
|
if (!strcmp(#URL, URL_SERVICE_HOME)) LoadInternalPage(#homepage, sizeof(homepage));
|
||||||
else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
|
else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -639,10 +638,10 @@ void ShowPage()
|
|||||||
PageLinks.Clear();
|
PageLinks.Clear();
|
||||||
if (http_transfer)
|
if (http_transfer)
|
||||||
{
|
{
|
||||||
WB1.Prepare(#loading, sizeof(loading));
|
LoadInternalPage(#loading, sizeof(loading));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
WB1.Prepare(#page_not_found, sizeof(page_not_found));
|
LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
WB1.Parse();
|
WB1.Parse();
|
||||||
@ -657,6 +656,13 @@ byte UrlExtIs(dword ext)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LoadInternalPage(dword bufpos, in_filesize){
|
||||||
|
bufsize = in_filesize;
|
||||||
|
bufpointer = bufpos;
|
||||||
|
WB1.Parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char downloader_stak[4096];
|
char downloader_stak[4096];
|
||||||
stop:
|
stop:
|
@ -27,5 +27,5 @@ ShowHistory()
|
|||||||
strcat(history_pointer, #pics[i].path);
|
strcat(history_pointer, #pics[i].path);
|
||||||
}
|
}
|
||||||
strcat(history_pointer, "</body></html>");
|
strcat(history_pointer, "</body></html>");
|
||||||
WB1.Prepare(history_pointer, strlen(history_pointer));
|
LoadInternalPage(history_pointer, strlen(history_pointer));
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user