/programs/cmm/browser/TWB/TWB.c |
---|
0,0 → 1,654 |
#include "TWB\colors.h" |
#include "TWB\anchors.h" |
#include "TWB\parse_tag.h" |
#include "TWB\special.h" |
#include "TWB\img.h" |
#include "TWB\tag_list.h" |
dword page_bg; |
dword link_color_default; |
dword link_color_active; |
#include "TWB\links.h" |
#define BODY_MARGIN 6 |
#define BASIC_LINE_H 18 |
DrawBufer DrawBuf; |
char line[500]; |
struct _style { |
bool |
b, u, s, h, |
font, |
pre, |
blq, |
button, |
image; |
dword bg_color; |
LIST tag_list; |
dword tag_title; |
}; |
struct TWebBrowser { |
llist list; |
_style style; |
_img page_img; |
dword draw_y, stolbec; |
int zoom; |
dword o_bufpointer; |
int cur_encoding, custom_encoding; |
bool link, t_html, t_body; |
dword bufpointer; |
dword bufsize; |
dword is_html; |
void Paint(); |
void SetPageDefaults(); |
void AddCharToTheLine(); |
void ParseHtml(); |
void SetStyle(); |
bool CheckForLineBreak(); |
void NewLine(); |
void DrawScroller(); |
void ChangeEncoding(); |
void DrawPage(); |
char header[150]; |
char redirect[URL_SIZE]; |
}; |
scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; |
//============================================================================================ |
void TWebBrowser::Paint() |
{ |
dword start_x, line_length, stolbec_len; |
dword text_color__; |
if (style.tag_title) |
{ |
strncpy(#header, #line, sizeof(TWebBrowser.header)-1); |
strncat(#header, " - ", sizeof(TWebBrowser.header)-1); |
strncat(#header, #version, sizeof(TWebBrowser.header)-1); |
line = 0; |
return; |
} |
if (t_html) && (!t_body) { |
line = 0; |
return; |
} |
if (line) |
{ |
start_x = stolbec * list.font_w + BODY_MARGIN + list.x; |
stolbec_len = strlen(#line) * zoom; |
line_length = stolbec_len * list.font_w; |
if (debug_mode) { |
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, 0xDDDddd); |
} |
if (style.bg_color!=page_bg) { |
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, style.bg_color); |
} |
if (style.image) { |
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xF9DBCB); |
} |
if (style.button) { |
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc); |
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999); |
} |
text_color__ = text_colors.get_last(); |
if (link) && (text_color__ == text_colors.get(0)) text_color__ = link_color_default; |
DrawBuf.WriteText(start_x, draw_y, list.font_type, text_color__, #line, NULL); |
if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line, NULL); |
if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_color__); |
if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_color__); |
if (link) { |
if (line[0]==' ') && (line[1]==NULL) {} else { |
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2)-1, line_length, zoom, link_color_default); |
links.add_text(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2)-1, zoom); |
} |
} |
stolbec += stolbec_len; |
if (debug_mode) debug(#line); |
line = NULL; |
} |
} |
//============================================================================================ |
void TWebBrowser::SetPageDefaults() |
{ |
style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre = |
link = style.tag_title = style.font = false; |
style.tag_list.reset(); |
link_color_default = 0x0000FF; |
link_color_active = 0xFF0000; |
page_bg = 0xFFFFFF; |
style.bg_color = page_bg; |
DrawBuf.Fill(0, page_bg); |
links.clear(); |
anchors.clear(); |
page_img.clear(); |
text_colors.drop(); |
text_colors.add(0); |
header = NULL; |
cur_encoding = CH_CP866; |
draw_y = BODY_MARGIN; |
stolbec = 0; |
line = 0; |
zoom = 1; |
redirect = '\0'; |
//hold original buffer |
if (o_bufpointer) o_bufpointer=free(o_bufpointer); |
o_bufpointer = malloc(bufsize); |
memmov(o_bufpointer, bufpointer, bufsize); |
if (custom_encoding != -1) { |
cur_encoding = custom_encoding; |
bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer); |
} |
} |
//============================================================================================ |
void TWebBrowser::AddCharToTheLine(unsigned char _char) |
{ |
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(dword _bufpointer, _bufsize){ |
word bukva[2]; |
char unicode_symbol[10]; |
dword unicode_symbol_result; |
dword j; |
bool ignor_param=false; |
int tab_len; |
dword bufpos; |
bufsize = _bufsize; |
if (bufpointer != _bufpointer) { |
bufpointer = malloc(bufsize); |
memmov(bufpointer, _bufpointer, bufsize); |
} else { |
custom_encoding = CH_CP866; |
} |
SetPageDefaults(); |
is_html = true; |
if (!strstri(bufpointer, "<body")) { |
t_body = true; |
if (!strstri(bufpointer, "<html")) && (!strstr(bufpointer, "<?xml")) && (!strstr(bufpointer, "<xml")) { |
style.pre = true; //show linebreaks for a plaint text |
is_html = false; |
} |
} |
for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;) |
{ |
//bukva = ESBYTE[bufpos]; |
switch (ESBYTE[bufpos]) |
{ |
case 0x0a: |
if (style.pre) { |
Paint(); |
NewLine(); |
} else { |
AddCharToTheLine(0x0a); |
} |
break; |
case 0x09: |
if (style.pre) { |
tab_len = strlen(#line) + stolbec % 4; |
if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len; |
for (j=0; j<tab_len; j++;) chrcat(#line,' '); |
} else { |
AddCharToTheLine(0x09); |
} |
break; |
case '&': // and so on |
for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (!__isWhite(ESBYTE[bufpos+j])) && (j<8); j++) |
{ |
bukva = ESBYTE[bufpos+j]; |
chrcat(#unicode_symbol, bukva); |
} |
if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) { |
bufpos += j; |
CheckForLineBreak(); |
} else { |
AddCharToTheLine('&'); |
} |
break; |
case '<': |
if (!is_html) goto _DEFAULT; |
bufpos++; |
switch (ESBYTE[bufpos]) { |
case '!': |
case '/': |
case 'a'...'z': |
case 'A'...'Z': |
goto _TAG; |
default: |
goto _DEFAULT; |
} |
_TAG: |
if (!strncmp(bufpos,"!--",3)) |
{ |
bufpos+=3; |
//STRSTR |
while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufpointer + bufsize) |
{ |
bufpos++; |
} |
bufpos+=2; |
break; |
} |
tag.reset(); |
if (ESBYTE[bufpos] == '/') { |
tag.opened = false; |
bufpos++; |
} |
ignor_param=false; |
while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû |
{ |
bukva = ESBYTE[bufpos]; |
if (__isWhite(bukva)) bukva = ' '; |
if (!ignor_param) && (bukva <>' ') { |
if (strlen(#tag.name)+1<sizeof(tag.name)) chrcat(#tag.name, bukva); |
} else { |
ignor_param = true; |
if (strlen(#tag.params)+1<sizeof(tag.params)) strcat(#tag.params, #bukva); |
//chrncat(#tag.params, bukva, sizeof(tag.params)-1); |
} |
bufpos++; |
} |
strlwr(#tag.name); |
// ignore text inside the next tags |
if (tag.is("script")) || (tag.is("style")) || (tag.is("binary")) || (tag.is("select")) { |
sprintf(#tag.params, "</%s>", #tag.name); |
if (j = strstri(bufpos, #tag.params)) bufpos = j-1; |
break; |
} |
if (tag.name[strlen(#tag.name)-1]=='/') tag.name[strlen(#tag.name)-1]=NULL; //for br/ !!!!!!!! |
if (tag.params) tag.parse_params(); |
if (tag.name) { |
CheckForLineBreak(); |
Paint(); |
if (tag.name) SetStyle(); |
} |
break; |
default: |
_DEFAULT: |
AddCharToTheLine(ESBYTE[bufpos]); |
} |
} |
Paint(); |
NewLine(); |
list.count = draw_y; |
list.CheckDoesValuesOkey(); |
anchors.current = NULL; |
custom_encoding = -1; |
if (!header) { |
strncpy(#header, #version, sizeof(TWebBrowser.header)-1); |
DrawTitle(#header); |
} |
} |
//============================================================================================ |
bool TWebBrowser::CheckForLineBreak() |
{ |
int line_break_pos; |
char new_line_text[4096]; |
//Do we need a line break? |
if (strlen(#line)*zoom + stolbec < list.column_max) return false; |
//Yes, we do. Lets calculate where... |
line_break_pos = strrchr(#line, ' '); |
//Is a new line fits in the current line? |
if (line_break_pos*zoom + stolbec > list.column_max) { |
line_break_pos = list.column_max/zoom - stolbec; |
while(line_break_pos) && (line[line_break_pos]!=' ') line_break_pos--; |
} |
//Maybe a new line is too big for the whole new line? Then we have to split it |
if (!line_break_pos) && (style.tag_list.level*5 + strlen(#line) * zoom >= list.column_max) { |
line_break_pos = list.column_max/zoom - stolbec; |
} |
strcpy(#new_line_text, #line + line_break_pos); |
line[line_break_pos] = 0x00; |
Paint(); |
strcpy(#line, #new_line_text); |
NewLine(); |
//while (CheckForLineBreak()==true) {}; |
return true; |
} |
//============================================================================================ |
void TWebBrowser::SetStyle() { |
char img_path[4096]=0; |
dword value; |
if (value = tag.get_value_of("name=")) || (value = tag.get_value_of("id=")) { |
anchors.add(value, draw_y); |
if (anchors.current) && (streq(value, #anchors.current+1)) { |
list.first = draw_y; |
anchors.current = NULL; |
} |
} |
if (tag.is("html")) { |
t_html = tag.opened; |
return; |
} |
if (tag.is("title")) { |
style.tag_title = tag.opened; |
if (!tag.opened) DrawTitle(#header); |
return; |
} |
if (tag.is("body")) { |
t_body = tag.opened; |
if (value = tag.get_value_of("link=")) link_color_default = GetColor(value); |
if (value = tag.get_value_of("alink=")) link_color_active = GetColor(value); |
if (value = tag.get_value_of("text=")) text_colors.set(0, GetColor(value)); |
if (value = tag.get_value_of("bgcolor=")) { |
style.bg_color = page_bg = GetColor(value); |
DrawBuf.Fill(0, page_bg); |
} |
// Autodetecting encoding if no encoding was set |
if (tag.opened) && (custom_encoding==-1) && (cur_encoding == CH_CP866) { |
if (strstr(bufpointer, "\208\190")) ChangeEncoding(CH_UTF8); |
else if (chrnum(bufpointer, '\246')>5) ChangeEncoding(CH_CP1251); |
} |
return; |
} |
if (tag.is("br")) { NewLine(); return; } |
if (tag.is("b")) || (tag.is("strong")) || (tag.is("big")) || (tag.is("w:b")) { |
style.b = tag.opened; |
return; |
} |
if (tag.is("w:r")) && (!tag.opened) { style.b = false; return; } |
if (tag.is("a")) { |
if (tag.opened) |
{ |
if (value = tag.get_value_of("href=")) && (!strstr(value,"javascript:")) |
{ |
link = true; |
links.add_link(value); |
} |
} else { |
link = false; |
style.bg_color = page_bg; |
} |
return; |
} |
if (tag.is("iframe")) && (value = tag.get_value_of("src=")) { |
NewLine(); |
strcpy(#line, "IFRAME: "); |
Paint(); |
link=true; |
links.add_link(value); |
strncpy(#line, value, sizeof(line)-1); |
while (CheckForLineBreak()) {}; |
Paint(); |
link=false; |
NewLine(); |
} |
if (tag.is("font")) { |
style.font = tag.opened; |
style.bg_color = page_bg; |
if (tag.opened) |
{ |
if (value = tag.get_value_of("bg=")) style.bg_color = GetColor(value); |
if (value = tag.get_value_of("color=")) { |
text_colors.add(GetColor(value)); |
} else { |
text_colors.add(text_colors.get_last()); |
} |
} |
else text_colors.pop(); |
return; |
} |
if (tag.is("div")) { |
if (streq(#tag.prior,"div")) && (tag.opened) return; |
if (!tag.opened) && (style.font) text_colors.pop(); |
NewLine(); |
return; |
} |
if (tag.is("header")) || (tag.is("article")) || (tag.is("footer")) || (tag.is("figure")) { |
NewLine(); |
return; |
} |
if (tag.is("p")) || (tag.is("w:p")) { |
IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) || (streq(#tag.prior,"p")) return; |
NewLine(); |
return; |
} |
if (tag.is("pre")) { style.pre = tag.opened; return; } |
if (tag.is("td")) { if (tag.opened) AddCharToTheLine(' '); return; } |
if (tag.is("tr")) { if (tag.opened) NewLine(); return; } |
if (tag.is("button")) { style.button = tag.opened; stolbec++; return; } |
if (tag.is("u")) || (tag.is("ins")) { style.u=tag.opened; return;} |
if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; } |
if (tag.is("dl")) { |
if (tag.opened) NewLine(); |
return; |
} |
if (tag.is("dd")) { |
//NewLine(); |
//if (tag.opened) stolbec += 5; //stolbec overflow! |
return; |
} |
if (tag.is("blockquote")) { style.blq = tag.opened; return; } |
if (tag.is("code")) { |
if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg; |
style.pre = tag.opened; return; |
} |
if (tag.is("img")) { |
value = tag.get_value_of("src="); |
/* |
if (streqrp(value, "data:")) { |
EAX = strstr(value, "base64,"); |
if (value == EAX) return; |
value = EAX; |
//cache.add(history.current(), http.content_pointer, http.content_received, PAGE); |
base64_decode stdcall (#pass_b64, value, strlen(value)); |
} else |
*/ |
strlcpy(#img_path, value, sizeof(img_path)-1); |
if (!img_path) { line=0; return; } |
value = page_img.add_pos(#img_path, stolbec+1*list.font_w+3, draw_y); |
if (cache.has(value)) { |
if (page_img.set_size(page_img.url.count-1, cache.current_buf, cache.current_size)) { |
if (link) links.add_text( |
stolbec * list.font_w + BODY_MARGIN + list.x, |
draw_y + list.y, |
page_img.xywh.get(page_img.url.count-1*4+2), |
page_img.xywh.get(page_img.url.count-1*4+3), |
0); |
stolbec += page_img.xywh.get(page_img.url.count-1*4+2) / 6 + 1; |
//if (stolbec > list.column_max) NewLine(); |
value = page_img.xywh.get(page_img.url.count-1*4+3); |
if (value > list.item_h) {draw_y += value - list.item_h; NewLine();} |
return; |
} |
} |
if (value = tag.get_value_of("title=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value); |
if (value = tag.get_value_of("alt=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value); |
if (!line) { |
if (!strncmp(#img_path, "data:", 5)) img_path=0; |
replace_char(#img_path, '?', NULL, strlen(#img_path)); |
sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/')); |
line[50]= NULL; |
} |
while (CheckForLineBreak()) {}; |
text_colors.add(0x9A6F29); |
style.image = true; |
Paint(); |
style.image = false; |
text_colors.pop(); |
return; |
} |
if (tag.is("h4")) { |
NewLine(); |
NewLine(); |
style.h = tag.opened; |
style.b = tag.opened; |
} |
if (tag.is("h1")) || (tag.is("h2")) || (tag.is("h3")) || (tag.is("caption")) { |
style.h = tag.opened; |
if (tag.opened) { |
if (!style.pre) NewLine(); |
draw_y += 10; |
zoom=2; |
list.font_type |= 10011001b; |
list.item_h = BASIC_LINE_H * 2 - 2; |
if (tag.is("h1")) style.b = true; |
} else { |
if (tag.is("h1")) style.b = false; |
NewLine(); |
zoom=1; |
list.font_type = 10011000b; |
list.item_h = BASIC_LINE_H; |
} |
return; |
} |
if (tag.is("dt")) { |
style.tag_list.upd_level(tag.opened, DT); |
if (tag.opened) NewLine(); |
return; |
} |
if (tag.is("ul")) { |
style.tag_list.upd_level(tag.opened, UL); |
if (!tag.opened) && (!style.pre) NewLine(); |
return; |
} |
if (tag.is("ol")) { |
style.tag_list.upd_level(tag.opened, OL); |
if (!tag.opened) && (!style.pre) NewLine(); |
return; |
} |
if (tag.is("li")) && (tag.opened) |
{ |
if (!style.tag_list.level) style.tag_list.upd_level(1, UL); |
if (!style.pre) NewLine(); |
if (style.tag_list.get_order_type() == UL) { |
strcpy(#line, "\31 "); |
stolbec = style.tag_list.level * 5 - 2; |
} |
if (style.tag_list.get_order_type() == OL) { |
sprintf(#line, "%i. ", style.tag_list.inc_counter()); |
stolbec = style.tag_list.level * 5 - strlen(#line); |
} |
return; |
} |
if (tag.is("q")) |
{ |
if (tag.opened) { |
EAX = strlen(#line); |
if (line[EAX-1] != ' ') chrcat(#line, ' '); |
chrcat(#line, '\"'); |
} |
if (!tag.opened) strcat(#line, "\" "); |
return; |
} |
if (tag.is("hr")) { |
if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999; |
$push edi; |
NewLine(); |
$pop edi; |
draw_y += 10; |
DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI); |
NewLine(); |
draw_y += 10; |
return; |
} |
if (tag.is("meta")) { |
if (streq(tag.get_value_of("http-equiv="), "refresh")) && (value = tag.get_value_of("content=")) { |
if (value = strstri(value, "url=")) strcpy(#redirect, value); |
} |
} |
if (custom_encoding == -1) && (tag.is("meta")) || (tag.is("?xml")) { |
if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding=")) |
{ |
value += strrchr(value, '='); //search in content= |
if (ESBYTE[value] == '"') value++; |
strlwr(value); |
if (streqrp(value,"utf-8")) || (streqrp(value,"utf8")) { ChangeEncoding(CH_UTF8); debugln("UTF"); } |
else if (streqrp(value,"windows-1251")) || (streqrp(value,"windows1251")) ChangeEncoding(CH_CP1251); |
else if (streqrp(value,"dos")) || (streqrp(value,"cp-866")) ChangeEncoding(CH_CP866); |
else if (streqrp(value,"iso-8859-5")) || (streqrp(value,"iso8859-5")) ChangeEncoding(CH_ISO8859_5); |
else if (streqrp(value,"koi8-r")) || (streqrp(value,"koi8-u")) ChangeEncoding(CH_KOI8); |
} |
return; |
} |
} |
//============================================================================================ |
void TWebBrowser::DrawScroller() |
{ |
scroll_wv.max_area = list.count; |
scroll_wv.cur_area = list.visible; |
scroll_wv.position = list.first; |
scroll_wv.all_redraw = 0; |
scroll_wv.start_x = list.x + list.w; |
scroll_wv.start_y = list.y; |
scroll_wv.size_y = list.h; |
scrollbar_v_draw(#scroll_wv); |
} |
//============================================================================================ |
void TWebBrowser::ChangeEncoding(int _new_encoding) |
{ |
if (cur_encoding == _new_encoding) return; |
cur_encoding = _new_encoding; |
bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer); |
if (header) { |
ChangeCharset(cur_encoding, "CP866", #header); |
DrawTitle(#header); |
} |
} |
//============================================================================================ |
void TWebBrowser::NewLine() |
{ |
dword onleft, ontop; |
static int empty_line=0; |
if (!stolbec) && (draw_y==BODY_MARGIN) return; |
if (style.tag_list.level) && (stolbec == style.tag_list.level * 5) { |
if (empty_line<1) empty_line++; |
else return; |
} else if (!stolbec) { |
if (empty_line<1) empty_line++; |
else return; |
} else { |
empty_line=0; |
} |
onleft = list.x + BODY_MARGIN; |
ontop = draw_y + list.y; |
if (t_html) && (!t_body) return; |
draw_y += list.item_h; |
if (style.blq) stolbec = 6; else stolbec = 0; |
stolbec += style.tag_list.level * 5; |
if (debug_mode) debugln(NULL); |
} |
//============================================================================================ |
void TWebBrowser::DrawPage() |
{ |
PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0); |
page_img.draw_all(list.x, list.y, list.w, list.h, list.first); |
DrawScroller(); |
} |
/programs/cmm/browser/TWB/img.h |
---|
0,0 → 1,98 |
struct _img |
{ |
collection url; |
collection_int xywh; |
int getid; |
void clear(); |
dword add_pos(); |
bool set_size(); |
dword current_url(); |
bool next_url(); |
void draw_all(); |
bool draw(); |
}; |
void _img::clear() |
{ |
url.drop(); |
xywh.drop(); |
getid = 0; |
} |
dword _img::add_pos(dword _path, _x, _y) |
{ |
char full_path[URL_SIZE]; |
strncpy(#full_path, _path, URL_SIZE); |
get_absolute_url(#full_path, history.current()); |
url.add(#full_path); |
xywh.add(_x); |
xywh.add(_y); |
xywh.add(NULL); |
xywh.add(NULL); |
return #full_path; |
} |
bool _img::set_size(dword _id, _buf, _size) |
{ |
img_decode stdcall (_buf, _size, 0); |
if (EAX) { |
EDI = EAX; |
xywh.set(_id*4+2, ESDWORD[EDI+4]); |
xywh.set(_id*4+3, ESDWORD[EDI+8]); |
free(EDI); |
return true; |
} |
return false; |
} |
//DELTE!!!!!11111111111111111111111111111111111111 |
dword _img::current_url() |
{ |
return url.get(getid); |
} |
//DELTE!!!!!11111111111111111111111111111111111111 |
bool _img::next_url() |
{ |
if (getid < url.count-1) { |
getid++; |
return 1; |
} |
return 0; |
} |
void _img::draw_all(int _x, _y, _w, _h, _start) |
{ |
int i, img_y; |
for (i=0; i<url.count; i++) |
{ |
img_y = xywh.get(i*4 + 1); |
if (img_y > _start) && (img_y < _start + _h) |
&& (cache.has(url.get(i))) draw(_x, _y, _w, _h, _start, i); |
} |
} |
bool _img::draw(int _x, _y, _w, _h, _start, i) |
{ |
int img_x, img_y, img_w, img_h; |
img_decode stdcall (cache.current_buf, cache.current_size, 0); |
if (EAX) { |
EDI = EAX; |
img_x = xywh.get(i*4+0); |
img_y = xywh.get(i*4+1); |
img_w = math.min(xywh.set(getid*4+2, ESDWORD[EDI+4]), _w - img_x); |
img_h = math.min(xywh.set(getid*4+3, ESDWORD[EDI+8]), _h + _start - img_y); |
img_draw stdcall(EDI, img_x + _x, img_y - _start + _y, img_w, img_h, 0, 0); |
free(EDI); |
} |
} |
/programs/cmm/browser/TWB/links.h |
---|
0,0 → 1,112 |
CustomCursor CursorPointer; |
dword CursorFile = FROM "TWB/pointer.cur"; |
#include "..\lib\collection.h" |
struct PAGE_LINKS { |
collection_int link; |
collection_int x; |
collection_int y; |
collection_int w; |
collection_int h; |
collection_int id; |
collection_int underline_h; |
collection page_links; |
signed int active; |
dword active_url; |
bool hover(); |
void add_link(); |
void add_text(); |
void clear(); |
void draw_underline(); |
} links; |
void PAGE_LINKS::add_link(dword lpath) |
{ |
page_links.add(lpath); |
} |
void PAGE_LINKS::add_text(dword _x, _y, _w, _h, _underline_h) |
{ |
x.add(_x); |
y.add(_y); |
w.add(_w); |
h.add(_h); |
underline_h.add(_underline_h); |
link.add(page_links.get_last()); |
id.add(page_links.count); |
} |
void PAGE_LINKS::clear() |
{ |
x.drop(); |
y.drop(); |
w.drop(); |
h.drop(); |
underline_h.drop(); |
link.drop(); |
id.drop(); |
page_links.drop(); |
page_links.realloc_size = 4096 * 32; |
active = -1; |
active_url = 0; |
CursorPointer.Restore(); |
} |
void PAGE_LINKS::draw_underline(signed _id, dword list_first, list_y, color) |
{ |
int i; |
if (_id == -1) return; |
for (i=0; i<id.count; i++) |
{ |
if (id.get(i) - id.get(_id) == 0) |
&& (y.get(i) + h.get(i) - list_first > list_y) { |
DrawBar(x.get(i), y.get(i) + h.get(i) - list_first, |
w.get(i), underline_h.get(i), color); |
} |
} |
} |
bool PAGE_LINKS::hover(dword list_y, list_first) |
{ |
int i; |
int mx = mouse.x; |
int my = mouse.y + list_first; |
if (!id.count) return false; |
//Here we check is any link hovered |
for (i=0; i<id.count; i++) |
{ |
if (mx>x.get(i)) && (my>y.get(i)) |
&& (mx<x.get(i)+w.get(i)) && (my<y.get(i)+h.get(i)) |
&& (my>list_y+list_first) |
{ |
if (active!=i) { |
CursorPointer.Load(#CursorFile); |
CursorPointer.Set(); |
draw_underline(active, list_first, list_y, link_color_default); |
draw_underline(i, list_first, list_y, page_bg); |
active_url = link.get(i); |
active = i; |
DrawStatusBar(); |
} |
if (mouse.lkm) && (mouse.down) { |
DrawRectangle(x.get(active), -list_first + y.get(active), |
w.get(active), h.get(active), 0); |
} |
return true; |
} |
} |
if (active_url) { |
CursorPointer.Restore(); |
draw_underline(active, list_first, list_y, link_color_default); |
active_url = 0; |
active = -1; |
DrawStatusBar(); |
} |
return false; |
} |
/programs/cmm/browser/TWB/colors.h |
---|
0,0 → 1,195 |
//Íàäî áóäåò ïåðåäåëàòü íà "äåðåâî ïîèñêà" èëè, ÷òî-òî ïîäîáíîå |
//áóäåò íå÷èòàáåëüíî, çàòî ìåíüøå è áûñòåå |
struct color_spec { |
char *name; |
int rgb; |
}; |
collection_int text_colors; |
struct color_spec color_specs[] = { |
"aliceblue", 0xF0F8FF, |
"antiquewhite", 0xFAEBD7, |
"aqua", 0x00FFFF, |
"aquamarine", 0x7FFFD4, |
"azure", 0xF0FFFF, |
"beige", 0xF5F5DC, |
"bisque", 0xFFE4C4, |
"black", 0x000000, |
"blanchedalmond", 0xFFEBCD, |
"blue", 0x0000FF, |
"blueviolet", 0x8A2BE2, |
"brown", 0xA52A2A, |
"burlywood", 0xDEB887, |
"cadetblue", 0x5F9EA0, |
"chartreuse", 0x7FFF00, |
"chocolate", 0xD2691E, |
"coral", 0xFF7F50, |
"cornflowerblue", 0x6495ED, |
"cornsilk", 0xFFF8DC, |
"crimson", 0xDC143C, |
"cyan", 0x00FFFF, |
"darkblue", 0x00008B, |
"darkcyan", 0x008B8B, |
"darkgoldenrod", 0xB8860B, |
"darkgray", 0xA9A9A9, |
"darkgreen", 0x006400, |
"darkkhaki", 0xBDB76B, |
"darkmagenta", 0x8B008B, |
"darkolivegreen", 0x556B2F, |
"darkorange", 0xFF8C00, |
"darkorchid", 0x9932CC, |
"darkred", 0x8B0000, |
"darksalmon", 0xE9967A, |
"darkseagreen", 0x8FBC8F, |
"darkslateblue", 0x483D8B, |
"darkslategray", 0x2F4F4F, |
"darkturquoise", 0x00CED1, |
"darkviolet", 0x9400D3, |
"deeppink", 0xFF1493, |
"deepskyblue", 0x00BFFF, |
"dimgray", 0x696969, |
"dodgerblue", 0x1E90FF, |
"firebrick", 0xB22222, |
"floralwhite", 0xFFFAF0, |
"forestgreen", 0x228B22, |
"fuchsia", 0xFF00FF, |
"gainsboro", 0xDCDCDC, |
"ghostwhite", 0xF8F8FF, |
"gold", 0xFFD700, |
"goldenrod", 0xDAA520, |
"gray", 0x808080, |
"green", 0x008000, |
"greenyellow", 0xADFF2F, |
"honeydew", 0xF0FFF0, |
"hotpink", 0xFF69B4, |
"indianred", 0xCD5C5C, |
"indigo", 0x4B0082, |
"ivory", 0xFFFFF0, |
"khaki", 0xF0E68C, |
"lavender", 0xE6E6FA, |
"lavenderblush", 0xFFF0F5, |
"lawngreen", 0x7CFC00, |
"lemonchiffon", 0xFFFACD, |
"lightblue", 0xADD8E6, |
"lightcoral", 0xF08080, |
"lightcyan", 0xE0FFFF, |
"lightgoldenrodyellow", 0xFAFAD2, |
"lightgreen", 0x90EE90, |
"lightgrey", 0xD3D3D3, |
"lightpink", 0xFFB6C1, |
"lightsalmon", 0xFFA07A, |
"lightseagreen", 0x20B2AA, |
"lightskyblue", 0x87CEFA, |
"lightslategray", 0x778899, |
"lightsteelblue", 0xB0C4DE, |
"lightyellow", 0xFFFFE0, |
"lime", 0x00FF00, |
"limegreen", 0x32CD32, |
"linen", 0xFAF0E6, |
"magenta", 0xFF00FF, |
"maroon", 0x800000, |
"mediumaquamarine", 0x66CDAA, |
"mediumblue", 0x0000CD, |
"mediumorchid", 0xBA55D3, |
"mediumpurple", 0x9370DB, |
"mediumseagreen", 0x3CB371, |
"mediumslateblue", 0x7B68EE, |
"mediumspringgreen",0x00FA9A, |
"mediumturquoise",0x48D1CC, |
"mediumvioletred",0xC71585, |
"midnightblue", 0x191970, |
"mintcream", 0xF5FFFA, |
"mistyrose", 0xFFE4E1, |
"moccasin", 0xFFE4B5, |
"navajowhite", 0xFFDEAD, |
"navy", 0x000080, |
"oldlace", 0xFDF5E6, |
"olive", 0x808000, |
"olivedrab", 0x6B8E23, |
"orange", 0xFFA500, |
"orangered", 0xFF4500, |
"orchid", 0xDA70D6, |
"palegoldenrod", 0xEEE8AA, |
"palegreen", 0x98FB98, |
"paleturquoise", 0xAFEEEE, |
"palevioletred", 0xDB7093, |
"papayawhip", 0xFFEFD5, |
"peachpuff", 0xFFDAB9, |
"peru", 0xCD853F, |
"pink", 0xFFC0CB, |
"plum", 0xDDA0DD, |
"powderblue", 0xB0E0E6, |
"purple", 0x800080, |
"red", 0xFF0000, |
"rosybrown", 0xBC8F8F, |
"royalblue", 0x4169E1, |
"saddlebrown", 0x8B4513, |
"salmon", 0xFA8072, |
"sandybrown", 0xF4A460, |
"seagreen", 0x2E8B57, |
"seashell", 0xFFF5EE, |
"sienna", 0xA0522D, |
"silver", 0xC0C0C0, |
"skyblue", 0x87CEEB, |
"slateblue", 0x6A5ACD, |
"slategray", 0x708090, |
"snow", 0xFFFAFA, |
"springgreen", 0x00FF7F, |
"steelblue", 0x4682B4, |
"tan", 0xD2B48C, |
"teal", 0x008080, |
"thistle", 0xD8BFD8, |
"tomato", 0xFF6347, |
"turquoise", 0x40E0D0, |
"violet", 0xEE82EE, |
"wheat", 0xF5DEB3, |
"white", 0xFFFFFF, |
"whitesmoke", 0xF5F5F5, |
"yellow", 0xFFFF00, |
"yellowgreen", 0x9ACD32, |
0}; |
dword StrToCol(char* htmlcolor) |
{ |
dword j=1, |
color=0, |
textlen=0; |
char ch=0x00; |
if (ESBYTE[htmlcolor]<>'#') return text_colors.get(0); |
textlen = strlen(htmlcolor); |
if (textlen==7) || (textlen==4) |
{ |
FOR (; j<textlen; j++) |
{ |
ch=ESBYTE[htmlcolor+j]; |
IF ((ch>='0') && (ch<='9')) ch -= '0'; |
IF ((ch>='A') && (ch<='F')) ch -= 'A'-10; |
IF ((ch>='a') && (ch<='f')) ch -= 'a'-10; |
color = color*0x10 + ch; |
if (textlen==4) color = color*0x10 + ch; //#abc ->> #aabbcc (ñëàâà âèêèïåäèè!!1) |
} |
return color; |
} |
return text_colors.get(0); |
} |
dword GetColor(char* color_str) |
{ |
int ii; |
if (ESBYTE[color_str] == '#') |
return StrToCol(color_str); |
else |
for (ii=0; color_specs[ii].name!=0; ii++) |
{ |
if (!strcmpi(color_str, color_specs[ii].name)) return color_specs[ii].rgb; |
} |
return text_colors.get(0); |
} |
/programs/cmm/browser/TWB/parse_tag.h |
---|
0,0 → 1,125 |
struct _tag |
{ |
char name[32]; |
char prior[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=0; |
bool _tag::is(dword _text) |
{ |
if ( !strcmp(#tag.name, _text) ) { |
return true; |
} else { |
return false; |
} |
} |
bool _tag::reset() |
{ |
if (!name) return false; |
strcpy(#prior, #name); |
name = NULL; |
opened = true; |
attributes.drop(); |
values.drop(); |
return true; |
} |
bool _tag::parse_params() |
{ |
bool result = false; |
if (!name) return false; |
if (debug_mode) { |
debug("\n\ntag: "); 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; |
int i; |
unsigned char val[4000]; |
unsigned char attr[4000]; |
if (!params) return false; |
i = strlen(#params) - 1; |
if (params[i] == '/') i--; |
while (i>0) && (__isWhite(params[i])) i--; |
if (params[i] == '"') || (params[i] == '\'') |
{ |
//remove quotes |
quotes = params[i]; |
params[i] = '\0'; |
i--; |
//find VAL start and copy |
i = strrchr(#params, quotes); |
strlcpy(#val, #params + i, sizeof(val)-1); |
params[i] = '\0'; |
i--; |
//find ATTR end |
while (i > 0) && (params[i] != '=') i--; |
params[i+1] = '\0'; |
} |
else |
{ |
//find VAL start and copy |
while (i > 0) && (params[i] != '=') i--; |
i++; |
strlcpy(#val, #params + i, sizeof(val)-1); |
//already have ATTR end |
} |
//find ATTR start and copy |
while (i>0) && (!__isWhite(params[i])) i--; |
strlcpy(#attr, #params + i + 1, sizeof(attr)-1); |
params[i] = '\0'; |
//fix case: src=./images/KolibriOS_logo2.jpg?sid=e8ece8b38b |
i = strchr(#attr,'='); |
if (!quotes) && (i) { |
strlcpy(#val, i+1, sizeof(val)-1); |
ESBYTE[i+1] = '\0'; |
} |
strlwr(#attr); |
strrtrim(#val); |
attributes.add(#attr); |
values.add(#val); |
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); |
} |
} |
/programs/cmm/browser/TWB/anchors.h |
---|
0,0 → 1,43 |
struct _anchors { |
char current[256]; |
collection anchor_name; |
collection anchor_position; |
void add(); |
int get_pos_by_name(); |
void clear(); |
void take_anchor_from(); |
} anchors=0; |
void _anchors::add(dword _name, _pos) |
{ |
anchor_name.add(_name); |
anchor_position.add(itoa(_pos)); |
} |
int _anchors::get_pos_by_name(dword _get_name) |
{ |
dword pos_name = anchor_name.get_pos_by_name(_get_name); |
if (ESBYTE[_get_name]==NULL) return 0; |
if (pos_name==-1) { |
return -1; |
} else { |
return atoi(anchor_position.get(pos_name)); |
} |
} |
void _anchors::clear() |
{ |
anchor_name.drop(); |
anchor_position.drop(); |
} |
void _anchors::take_anchor_from(dword _URL) |
{ |
int anchor_pos; |
if (!current) && (_URL) && (anchor_pos = strrchr(_URL, '#')) { |
strncpy(#current, _URL+anchor_pos-1, sizeof(_anchors.current)-1); |
ESBYTE[_URL+anchor_pos-1] = '\0'; |
} |
} |
/programs/cmm/browser/TWB/tag_list.h |
---|
0,0 → 1,39 |
enum {DT=1, OL, UL}; |
struct LIST |
{ |
int level; |
int ordered[5]; |
int counter[5]; |
void reset(); |
void upd_level(); |
int inc_counter(); |
int get_order_type(); |
}; |
void LIST::reset() |
{ |
level = 0; |
} |
void LIST::upd_level(int direction, type) |
{ |
if (direction == 1) && (level<5) { |
level++; |
counter[level]=0; |
ordered[level]=type; |
} |
if (direction == 0) && (level>0) { |
level--; |
} |
} |
int LIST::inc_counter() |
{ |
counter[level]++; |
return counter[level]; |
} |
int LIST::get_order_type() |
{ |
return ordered[level]; |
} |
/programs/cmm/browser/TWB/special.h |
---|
0,0 → 1,94 |
char *unicode_symbols[]={ |
"quot","\"", |
"amp", "&", |
"lt", "<", |
"gt", ">", |
"#183","\31", "middot", "\31", |
"#149","-", |
"#151","-", |
"#160"," ", "nbsp", " ", |
"#169","(c)", "copy", "(c)", |
"#171","<<", "laquo","<<", |
"#174","(r)", "reg", "(r)", |
"#187",">>", "raquo",">>", |
"trade", "[TM]", |
"bdquo", ",,", |
"minus", "-", |
"ndash", "-", |
"mdash", "-", //-- |
"rsquo", "'", |
"sect", "#", |
"ensp", " ", |
"emsp13", " ", |
"emsp14", " ", |
"numsp", " ", |
"puncsp", " ", |
"thinsp", " ", |
"#1028", "\242", |
"#1030", "I", |
"#1031", "\244", |
"#8211", "-", |
"#8217", "'", |
"#8220", "\"", |
"#8222", "\"", "ldquo", "\"", |
"#8221", "\"", "rdquo", "\"", |
"#8470", "N", |
"#8722", "-", |
"#9642", "-", //square in the middle of the line |
"#9658", ">", |
"#9660", "v", |
"#65122", "+", |
"uarr", "\24", |
"darr", "\25", |
"rarr", "\26", |
"larr", "\27", |
"bull", "\31", |
"percnt","%", |
"#xfeff", "", |
"times", "x", |
"lowast","*", |
0}; |
unsigned char unicode_chars[] = " ¡¢£¤¥¦§¨©ª«¬®¯àáâãäåæçèéêëìíîïðñh£\243i\105\244\0"; |
bool GetUnicodeSymbol(dword _line, in_tag, size) |
{ |
int j; |
int code; |
for (j=0; unicode_symbols[j]!=0; j+=2;) |
{ |
if (!strcmp(in_tag, unicode_symbols[j])) |
{ |
strncat(_line, unicode_symbols[j+1], size); |
return true; |
} |
} |
if (ESBYTE[in_tag]=='#') |
{ |
code = atoi(in_tag + 1); |
if (code>=0) && (code<=255) { |
chrncat(_line, code, size); //NOT ALL ASCII CODES IN KOLIBRI ARE COMPATABLE WITH STANDARDS |
return true; |
} |
if (code>=1040) && (code<=1040+72) { |
chrncat(_line, unicode_chars[code-1040], size); |
return true; |
} |
} |
return false; |
} |
/programs/cmm/browser/TWB/acid_0.1.htm |
---|
0,0 → 1,88 |
<!--doctype html public "-//w3c//dtd html 4.0 transitional//ru"--> |
<html> |
<head> |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
<title>Тест Acid 0.1</title> |
</head> |
<body bgcolor="#000000" link="#0066FF" text="#FFFFFF"> |
<h1 align=center>Это тестовая страница для проверки WebViewer</h1> |
<br /> |
<p>WebViewer является текстовым браузером и поддерживает все популярные кодировки (cp1251, koi-8, cp866, unicode) |
и некоторые теги. Поддержка таблииц (<table>), CSS, Javascript'a и Контактика пока не реализована :) |
</p> |
<br /> |
<b> |
<font color="#FF0000">K</font> |
<font color="#FFC005">o</font> |
<font color="#F6F574">l</font> |
<font color="#9EFC36">i</font> |
<font color="#29FDFD">b</font> |
<font color="#36A8FC">r</font> |
<font color="blueviolet">i</font> |
<font color="#C911FF">O</font> |
<font color="#C911FF">S</font> |
|
<font color="#C911FF">F</font> |
<font color="#36A8FC">o</font> |
<font color="#29FDFD">r</font> |
<font color="#9EFC36">e</font> |
<font color="#FFC005">v</font> |
<font color="#FF0000">e</font> |
<font color="#FFC005">r</font> |
</b> |
<br> |
<p> |
<bg bgcolor=#333> |
Небольшой список:<ol> |
<li><q>Этот текст в кавычках</q></li> |
<li><u>Это подчеркнутый текст</u></li> |
<li><s>Это перечеркнутый текст</s></li> |
<li><i>Это наклонный текст</i></li> |
<li><strong>Это текст с усиленным выделением</strong></li> |
<li><b><u><s><font color="#777444">Много тегов</font></s></u></b></ol> |
</bg> |
</p> |
<br> |
<pre> |
"Осень уже пришла!"- |
Шепнул мне на ухо ветер, |
Подкравшись к подушке моей. |
Басе |
</pre> |
<!-- комментарий: этого текста здесь <нет> --> |
<br> |
<a href="http://kolibrios.org/i/logo.png"><img id="2.1.4" src="http://kolibrios.org/i/logo.png" alt="logo"><br>Открыть</a><br> |
<br> |
<br> |
<a href='./index.htm'>./index.htm</a><br> |
<a href='/sys/index.htm'>Незакрытый тег а - index.htm<br> |
<a href="/sys/calc">/sys/calc</a><br> |
<a href="#2.1.4">#2.1.4</a><br> |
<a href="http://bash.im">http://bash.im</a><br> |
<a href="mailto:leency@mail.ru">Mail to Leency</a><br> |
<br> |
<br> |
В этом тексте есть переход на следующую строку, но браузер |
его должен проигнорировать. Еще много пробелов. А тут есть |
табы. Кое-какие символы: " & < > • |
© ® „ “ — Їжачок іншого боку р. Євфрат з'їв ґрунт та єврейський ґербалайф. |
<p>61055, г. |
Харьков, ул. Краснознаменная, 16</SPAN>, радиофизический |
корпус на территории НТУ «ХПИ» |
</p> |
<hr color="#758999"> |
<center>Zhitomyr 2008-2015</center> |
</body> |
</html> |
/programs/cmm/browser/TWB/pointer.cur |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/programs/cmm/browser/TWB |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/cmm/browser/WebView.c |
---|
22,6 → 22,7 |
#include "..\lib\obj\http.h" |
#include "..\lib\obj\iconv.h" |
#include "..\lib\obj\proc_lib.h" |
#include "..\lib\obj\netcode.h" |
//useful patterns |
#include "..\lib\patterns\history.h" |
31,7 → 32,7 |
char editbox_icons[] = FROM "res/editbox_icons.raw"; |
char version[]="WebView 2.7e"; |
char version[]="WebView 2.8 ALPHA PREVIEW"; |
#include "texts.h" |
#include "cache.h" |
38,6 → 39,7 |
#include "show_src.h" |
bool debug_mode = false; |
bool show_images = false; |
enum { |
NEW_TAB=600, |
68,7 → 70,7 |
enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB }; |
#include "..\TWB\TWB.c" //HTML Parser, a core component |
#include "TWB\TWB.c" //HTML Parser, a core component |
TWebBrowser WB1; |
84,7 → 86,7 |
bool source_mode = false; |
progress_bar wv_progress_bar; |
progress_bar prbar; |
char stak[4096]; |
proc_info Form; |
110,6 → 112,7 |
load_dll(libimg, #libimg_init,1); |
load_dll(libHTTP, #http_lib_init,1); |
load_dll(iconv_lib, #iconv_open,0); |
load_dll(netcode_lib, #base64_encode,0); |
load_dll(Proc_lib, #OpenDialog_init,0); |
OpenDialog_init stdcall (#o_dialog); |
} |
156,7 → 159,7 |
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
scrollbar_v_mouse (#scroll_wv); |
if (scroll_wv.delta) { |
if (scroll_wv.delta2) { |
WB1.list.first = scroll_wv.position; |
WB1.DrawPage(); |
break; |
164,7 → 167,7 |
if (links.hover(WB1.list.y, WB1.list.first)) |
{ |
if (mouse.mkm) { |
if (mouse.key&MOUSE_MIDDLE) && (mouse.up) { |
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) { |
EventClickLink(TARGET_NEW_WINDOW); |
} else { |
171,17 → 174,17 |
EventClickLink(TARGET_NEW_TAB); |
} |
} |
if (mouse.lkm) { |
if (mouse.key&MOUSE_LEFT) && (mouse.up) { |
CursorPointer.Restore(); |
EventClickLink(TARGET_SAME_TAB); |
} |
if (mouse.pkm) { |
if (mouse.key&MOUSE_RIGHT) && (mouse.up) { |
CursorPointer.Restore(); |
EventShowLinkMenu(); |
} |
} else { |
CursorPointer.Restore(); |
if (mouse.pkm) && (WB1.list.MouseOver(mouse.x, mouse.y)) { |
if (mouse.key&MOUSE_RIGHT) && (mouse.up) && (WB1.list.MouseOver(mouse.x, mouse.y)) { |
EventShowPageMenu(); |
} |
} |
259,7 → 262,7 |
} |
else if (http_get_type==IMG) { |
cache.add(WB1.page_img.current_url(), http.content_pointer, http.content_received, IMG); |
WB1.page_img.set_size(http.content_pointer, http.content_received); |
WB1.page_img.set_size(WB1.page_img.getid, http.content_pointer, http.content_received); |
GetImg(); |
} |
} |
397,6 → 400,7 |
case DOWNLOAD_LINK_CT: EventOpenDownloader( GetAbsoluteActiveURL() ); return; |
case OPEN_FILE: EventOpenDialog(); return; |
case SCAN_CODE_F12: EventToggleDebugMode(); return; |
case SCAN_CODE_F11: show_images^=1; return; |
} |
} |
420,10 → 424,10 |
void EventEditSource() |
{ |
if (check_is_the_adress_local(history.current())) { |
RunProgram("/rd/1/tinypad", history.current()); |
RunProgram("/rd/1/quark", history.current()); |
} else { |
CreateFile(WB1.bufsize, WB1.bufpointer, "/tmp0/1/WebView_tmp.htm"); |
if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
if (!EAX) RunProgram("/rd/1/quark", "/tmp0/1/WebView_tmp.htm"); |
} |
} |
443,7 → 447,7 |
void StopLoading() |
{ |
if (http.stop()) pause(10); |
wv_progress_bar.value = 0; |
prbar.value = 0; |
DrawOmnibox(); |
} |
494,10 → 498,22 |
return true; |
} |
void GetUrl(dword _http_url) |
{ |
char new_url_full[URL_SIZE+1]; |
if (!strncmp(_http_url,"http:",5)) { |
http.get(_http_url); |
} else if (!strncmp(_http_url,"https://",8)) { |
strcpy(#new_url_full, "http://gate.aspero.pro/?site="); |
strncat(#new_url_full, _http_url, URL_SIZE); |
http.get(#new_url_full); |
} |
} |
void OpenPage(dword _open_URL) |
{ |
char new_url[URL_SIZE+1]; |
char new_url_full[URL_SIZE+1]; |
int unz_id; |
StopLoading(); |
542,13 → 558,7 |
} |
http_get_type = PAGE; |
if (!strncmp(#new_url,"http:",5)) { |
http.get(#new_url); |
} else if (!strncmp(#new_url,"https://",8)) { |
strcpy(#new_url_full, "http://gate.aspero.pro/?site="); |
strncat(#new_url_full, #new_url, URL_SIZE); |
http.get(#new_url_full); |
} |
GetUrl(#new_url); |
DrawOmnibox(); |
703,7 → 713,7 |
} else { |
WB1.DrawPage(); |
} |
//GetImg(); |
GetImg(); |
} |
} |
715,15 → 725,12 |
void DrawProgress() |
{ |
dword persent; |
if (http.transfer == 0) return; |
if (wv_progress_bar.max) { |
persent = wv_progress_bar.value*100/wv_progress_bar.max; |
} else { |
persent = 10; |
dword pct; |
if (!http.transfer) return; |
if (http_get_type==PAGE) && (prbar.max) pct = prbar.value*30/prbar.max; else pct = 10; |
if (http_get_type==IMG) pct = WB1.page_img.getid * 70 / WB1.page_img.url.count + 30; |
DrawBar(address_box.left-1, address_box.top+20, pct*address_box.width+16/100, 2, 0x72B7EB); |
} |
DrawBar(address_box.left-1, address_box.top+20, persent*address_box.width+16/100, 2, 0x72B7EB); |
} |
void EventShowPageMenu() |
{ |
766,10 → 773,10 |
void EventUpdateProgressBar() |
{ |
wv_progress_bar.max = http.content_length; |
if (wv_progress_bar.value != http.content_received) |
prbar.max = http.content_length; |
if (prbar.value != http.content_received) |
{ |
wv_progress_bar.value = http.content_received; |
prbar.value = http.content_received; |
DrawProgress(); |
} |
} |
925,21 → 932,24 |
char redirect_url[URL_SIZE]; |
http.header_field("location", #redirect_url, URL_SIZE); |
get_absolute_url(#redirect_url, history.current()); |
history.back(); |
if (http_get_type==PAGE) history.back(); |
http.hfree(); |
if (http_get_type==PAGE) OpenPage(#redirect_url); |
else if (http_get_type==IMG) http.get(#redirect_url); |
else if (http_get_type==IMG) GetUrl(#redirect_url); |
} |
dword GetImg() |
{ |
if (!show_images) return; |
while (WB1.page_img.next_url()) { |
DrawProgress(); |
if (cache.has(WB1.page_img.current_url())) continue; |
http_get_type = IMG; |
http.get(WB1.page_img.current_url()); |
GetUrl(WB1.page_img.current_url()); |
return; |
} |
DrawOmnibox(); |
WB1.ParseHtml(WB1.o_bufpointer, WB1.bufsize); |
WB1.DrawPage(); |
} |
/programs/cmm/browser/history.h |
---|
42,16 → 42,10 |
strcat(history_pointer, "<br><b>Cached images</b><br>"); |
for (i=1; i<cache.url.count; i++) if (cache.type.get(i) == IMG) |
{ |
strcat(history_pointer, "<a href='"); |
strcat(history_pointer, cache.url.get(i)); |
strcat(history_pointer, "'>"); |
strcat(history_pointer, "<img src='"); |
strcat(history_pointer, cache.url.get(i)); |
strcat(history_pointer, "</a><br>"); |
// strcat(history_pointer, "<img src='"); |
// strcat(history_pointer, #pics[i].path); |
// strcat(history_pointer, "'><br>"); |
// strcat(history_pointer, #pics[i].path); |
strcat(history_pointer, "'><br>"); |
} |
strcat(history_pointer, "</body></html>"); |