forked from KolibriOS/kolibrios
WebView: refactoring
git-svn-id: svn://kolibrios.org@8439 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
9220a9a313
commit
64a81df7e7
@ -11,10 +11,10 @@ dword link_color_active;
|
||||
#define BODY_MARGIN 6
|
||||
#define BASIC_LINE_H 18
|
||||
|
||||
DrawBufer DrawBuf;
|
||||
CANVAS canvas;
|
||||
char line[500];
|
||||
|
||||
struct _style {
|
||||
struct STYLE {
|
||||
bool
|
||||
b, u, s, h,
|
||||
font,
|
||||
@ -24,12 +24,20 @@ struct _style {
|
||||
image;
|
||||
dword bg_color;
|
||||
LIST tag_list;
|
||||
dword tag_title;
|
||||
dword title;
|
||||
void reset();
|
||||
};
|
||||
|
||||
void STYLE::reset()
|
||||
{
|
||||
b = u = s = h = blq = pre = title = false;
|
||||
font = false;
|
||||
tag_list.reset();
|
||||
}
|
||||
|
||||
struct TWebBrowser {
|
||||
llist list;
|
||||
_style style;
|
||||
STYLE style;
|
||||
dword draw_y, stolbec;
|
||||
int zoom;
|
||||
dword o_bufpointer;
|
||||
@ -39,6 +47,8 @@ struct TWebBrowser {
|
||||
dword bufsize;
|
||||
dword is_html;
|
||||
collection img_url;
|
||||
char header[150];
|
||||
char redirect[URL_SIZE];
|
||||
|
||||
void Paint();
|
||||
void SetPageDefaults();
|
||||
@ -47,14 +57,27 @@ struct TWebBrowser {
|
||||
void SetStyle();
|
||||
bool CheckForLineBreak();
|
||||
void NewLine();
|
||||
void DrawScroller();
|
||||
void ChangeEncoding();
|
||||
void DrawPage();
|
||||
char header[150];
|
||||
char redirect[URL_SIZE];
|
||||
|
||||
void tag_a();
|
||||
void tag_p();
|
||||
void tag_img();
|
||||
void tag_div();
|
||||
void tag_h1234_caption();
|
||||
void tag_ol_ul_dt();
|
||||
void tag_li();
|
||||
void tag_q();
|
||||
void tag_hr();
|
||||
void tag_code();
|
||||
void tag_meta_xml();
|
||||
void tag_body();
|
||||
void tag_iframe();
|
||||
void tag_title();
|
||||
void tag_font();
|
||||
};
|
||||
|
||||
scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee};
|
||||
#include "TWB\set_style.h"
|
||||
|
||||
//============================================================================================
|
||||
void TWebBrowser::Paint()
|
||||
@ -62,7 +85,7 @@ void TWebBrowser::Paint()
|
||||
dword start_x, line_length, stolbec_len;
|
||||
dword text_color__;
|
||||
|
||||
if (style.tag_title)
|
||||
if (style.title)
|
||||
{
|
||||
strncpy(#header, #line, sizeof(TWebBrowser.header)-1);
|
||||
strncat(#header, " - ", sizeof(TWebBrowser.header)-1);
|
||||
@ -81,51 +104,46 @@ void TWebBrowser::Paint()
|
||||
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);
|
||||
canvas.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);
|
||||
canvas.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);
|
||||
canvas.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc);
|
||||
canvas.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__);
|
||||
canvas.WriteText(start_x, draw_y, list.font_type, text_color__, #line, NULL);
|
||||
if (style.b) canvas.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line, NULL);
|
||||
if (style.s) canvas.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_color__);
|
||||
if (style.u) canvas.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);
|
||||
canvas.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);
|
||||
if (debug_mode) debugln(#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();
|
||||
t_html = t_body = link = false;
|
||||
style.reset();
|
||||
link_color_default = 0x0000FF;
|
||||
link_color_active = 0xFF0000;
|
||||
page_bg = 0xffEBE8E9; //E0E3E3 EBE8E9
|
||||
style.bg_color = page_bg;
|
||||
DrawBuf.Fill(0, page_bg);
|
||||
canvas.Fill(0, page_bg);
|
||||
links.clear();
|
||||
anchors.clear();
|
||||
img_url.drop();
|
||||
@ -164,14 +182,12 @@ void TWebBrowser::AddCharToTheLine(unsigned char _char)
|
||||
}
|
||||
//============================================================================================
|
||||
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);
|
||||
@ -224,77 +240,27 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
|
||||
if (!is_html) goto _DEFAULT;
|
||||
bufpos++;
|
||||
switch (ESBYTE[bufpos]) {
|
||||
case '!':
|
||||
case '/':
|
||||
case '?':
|
||||
case 'a'...'z':
|
||||
case 'A'...'Z':
|
||||
case '!': 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) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
|
||||
//&& (!chrnum(#tag.params,'\"') % 2) //<a title="<small>ATI</small><br>9800xt" href="vgamuseum.ru/9800xt">
|
||||
{
|
||||
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) {
|
||||
if (tag.parse_tag(#bufpos, bufpointer + bufsize)) {
|
||||
CheckForLineBreak();
|
||||
Paint();
|
||||
if (tag.name) {
|
||||
EAX = cur_encoding;
|
||||
$push eax
|
||||
$push cur_encoding
|
||||
SetStyle();
|
||||
$pop eax
|
||||
// The thing is that UTF if longer than other encodings.
|
||||
// So if encoding was changed to UTF than $bufpos position is wrong now,
|
||||
// So if encoding was changed from UTF to DOS than $bufpos position got wrong,
|
||||
// and we have to start parse from the very beginning
|
||||
if (EAX != cur_encoding) && (cur_encoding == CH_UTF8) {
|
||||
ParseHtml(bufpointer, bufsize);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_DEFAULT:
|
||||
@ -305,9 +271,8 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
|
||||
NewLine();
|
||||
list.count = draw_y;
|
||||
|
||||
DrawBuf.bufh = math.max(list.visible, draw_y);
|
||||
debugval("DrawBuf.bufh", DrawBuf.bufh);
|
||||
buf_data = realloc(buf_data, DrawBuf.bufh * DrawBuf.bufw * 4 + 8);
|
||||
canvas.bufh = math.max(list.visible, draw_y);
|
||||
buf_data = realloc(buf_data, canvas.bufh * canvas.bufw * 4 + 8);
|
||||
|
||||
list.CheckDoesValuesOkey();
|
||||
anchors.current = NULL;
|
||||
@ -346,330 +311,6 @@ bool TWebBrowser::CheckForLineBreak()
|
||||
return true;
|
||||
}
|
||||
//============================================================================================
|
||||
void TWebBrowser::SetStyle() {
|
||||
char img_path[4096]=0;
|
||||
dword imgbuf[44];
|
||||
dword cur_img;
|
||||
int img_x, img_y, img_w, img_h;
|
||||
|
||||
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 (!value) goto NOIMG;
|
||||
|
||||
if (!strcmp(value + strrchr(value, '.'), "svg")) goto NOIMG;
|
||||
|
||||
if (streqrp(value, "data:")) {
|
||||
if (!strstr(value, "base64,")) goto NOIMG;
|
||||
value = EAX+7;
|
||||
if (ESBYTE[value]==' ') value++;
|
||||
cur_img = malloc(strlen(value));
|
||||
base64_decode stdcall (value, cur_img, strlen(value));
|
||||
img_decode stdcall (cur_img, EAX, 0);
|
||||
$push eax
|
||||
free(cur_img);
|
||||
$pop eax
|
||||
if (EAX) goto IMGOK; else goto NOIMG;
|
||||
}
|
||||
|
||||
strlcpy(#img_path, value, sizeof(img_path)-1);
|
||||
get_absolute_url(#img_path, history.current());
|
||||
|
||||
if (check_is_the_adress_local(#img_path)) {
|
||||
img_from_file stdcall(#img_path);
|
||||
if (EAX) goto IMGOK; else goto NOIMG;
|
||||
}
|
||||
|
||||
if (cache.has(#img_path)) && (cache.current_size)
|
||||
{
|
||||
img_decode stdcall (cache.current_buf, cache.current_size, 0);
|
||||
if (!EAX) goto NOIMG;
|
||||
IMGOK:
|
||||
|
||||
cur_img = EAX;
|
||||
img_h = ESDWORD[cur_img+8];
|
||||
img_w = ESDWORD[cur_img+4];
|
||||
|
||||
if (img_w / 6 + stolbec > list.column_max) {
|
||||
NewLine();
|
||||
}
|
||||
img_x = stolbec*list.font_w+3;
|
||||
img_y = draw_y;
|
||||
|
||||
img_w = math.min(img_w, DrawBuf.bufw - img_x);
|
||||
|
||||
stolbec += img_w / 6;
|
||||
if (stolbec > list.column_max) NewLine();
|
||||
|
||||
if (img_h > list.item_h + 5) {
|
||||
draw_y += img_h - list.item_h;
|
||||
NewLine();
|
||||
}
|
||||
|
||||
if (link) links.add_text(img_x + list.x, img_y + list.y, img_w, img_h, 0);
|
||||
|
||||
if (img_y + img_h >= DrawBuf.bufh) DrawBuf.IncreaseBufSize();
|
||||
|
||||
if (ESDWORD[cur_img+20] != IMAGE_BPP32) {
|
||||
img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0);
|
||||
$push eax
|
||||
img_destroy stdcall(cur_img);
|
||||
$pop eax
|
||||
cur_img = EAX;
|
||||
if (!EAX) goto NOIMG;
|
||||
}
|
||||
imgbuf[04] = DrawBuf.bufw;
|
||||
imgbuf[08] = DrawBuf.bufh;
|
||||
imgbuf[20] = IMAGE_BPP32;
|
||||
imgbuf[24] = buf_data+8;
|
||||
img_blend stdcall(#imgbuf, cur_img, img_x, img_y, 0, 0, img_w, img_h);
|
||||
img_destroy stdcall(cur_img);
|
||||
return;
|
||||
} else {
|
||||
img_url.add(#img_path);
|
||||
}
|
||||
NOIMG:
|
||||
|
||||
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));
|
||||
img_path[sizeof(line)-3] = '\0'; //prevent overflow in sprintf
|
||||
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);
|
||||
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;
|
||||
@ -683,7 +324,6 @@ void TWebBrowser::ChangeEncoding(int _new_encoding)
|
||||
//============================================================================================
|
||||
void TWebBrowser::NewLine()
|
||||
{
|
||||
dword onleft, ontop;
|
||||
static int empty_line=0;
|
||||
|
||||
if (!stolbec) && (draw_y==BODY_MARGIN) return;
|
||||
@ -698,17 +338,26 @@ void TWebBrowser::NewLine()
|
||||
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);
|
||||
}
|
||||
//============================================================================================
|
||||
scroll_bar scroll_wv =
|
||||
{ 15,NULL,NULL,NULL,0,2,NULL,
|
||||
0,0,0xeeeeee,0xBBBbbb,0xeeeeee};
|
||||
|
||||
void TWebBrowser::DrawPage()
|
||||
{
|
||||
DrawBuf.Show(list.first, list.h);
|
||||
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);
|
||||
|
||||
canvas.Show(list.first, list.h);
|
||||
}
|
@ -1,195 +1,78 @@
|
||||
//Íàäî áóäåò ïåðåäåëàòü íà "äåðåâî ïîèñêà" èëè, ÷òî-òî ïîäîáíîå
|
||||
//áóäåò íå÷èòàáåëüíî, çàòî ìåíüøå è áûñòåå
|
||||
collection_int text_colors;
|
||||
|
||||
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);
|
||||
}
|
||||
"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, "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 GetColor(char* color_str)
|
||||
{
|
||||
int ii;
|
||||
dword textlen=0;
|
||||
dword color=0;
|
||||
|
||||
strlwr(color_str);
|
||||
if (ESBYTE[color_str] == '#')
|
||||
return StrToCol(color_str);
|
||||
{
|
||||
textlen = strlen(color_str);
|
||||
if (textlen==7) || (textlen==4)
|
||||
{
|
||||
FOR (ii=1; ii<textlen; ii++)
|
||||
{
|
||||
BL = ESBYTE[color_str+ii];
|
||||
IF ((BL>='0') && (BL<='9')) BL -= '0';
|
||||
//IF ((BL>='A') && (BL<='F')) BL -= 'A'-10;
|
||||
IF ((BL>='a') && (BL<='f')) BL -= 'a'-10;
|
||||
color = color*0x10 + BL;
|
||||
if (textlen==4) color = color*0x10 + BL; //#abc ->> #aabbcc
|
||||
}
|
||||
return color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ii=0; color_specs[ii].name!=0; ii++)
|
||||
{
|
||||
if (!strcmpi(color_str, color_specs[ii].name)) return color_specs[ii].rgb;
|
||||
if (streq(color_str, color_specs[ii].name))
|
||||
return color_specs[ii].rgb;
|
||||
}
|
||||
}
|
||||
|
||||
return text_colors.get(0);
|
||||
}
|
||||
|
@ -7,51 +7,108 @@ struct _tag
|
||||
bool opened;
|
||||
collection attributes;
|
||||
collection values;
|
||||
dword value;
|
||||
bool is();
|
||||
bool reset();
|
||||
bool parse_params();
|
||||
bool parse_tag();
|
||||
void debug_tag();
|
||||
bool get_next_param();
|
||||
dword get_value_of();
|
||||
} tag=0;
|
||||
|
||||
bool _tag::is(dword _text)
|
||||
{
|
||||
if ( !strcmp(#tag.name, _text) ) {
|
||||
if ( !strcmp(#name, _text) ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool _tag::reset()
|
||||
bool _tag::parse_tag(dword _bufpos, bufend)
|
||||
{
|
||||
if (!name) return false;
|
||||
strcpy(#prior, #name);
|
||||
name = NULL;
|
||||
opened = true;
|
||||
bool retok = true;
|
||||
dword bufpos = ESDWORD[_bufpos];
|
||||
|
||||
dword closepos;
|
||||
dword whitepos;
|
||||
|
||||
if (name) strcpy(#prior, #name); else prior = '\0';
|
||||
name = '\0';
|
||||
params = '\0';
|
||||
attributes.drop();
|
||||
values.drop();
|
||||
return true;
|
||||
|
||||
if (!strncmp(bufpos,"!--",3))
|
||||
{
|
||||
bufpos+=3;
|
||||
//STRSTR
|
||||
while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufend)
|
||||
{
|
||||
bufpos++;
|
||||
}
|
||||
bufpos+=2;
|
||||
goto _RET;
|
||||
}
|
||||
|
||||
if (ESBYTE[bufpos] == '/') {
|
||||
opened = false;
|
||||
bufpos++;
|
||||
} else {
|
||||
opened = true;
|
||||
}
|
||||
|
||||
closepos = strchr(bufpos, '>');
|
||||
whitepos = strchrw(bufpos, bufend-bufpos);
|
||||
if (whitepos > closepos) {
|
||||
//no param
|
||||
strncpy(#name, bufpos, math.min(closepos - bufpos, sizeof(tag.name)));
|
||||
debug_tag();
|
||||
params = '\0';
|
||||
bufpos = closepos;
|
||||
} else {
|
||||
//we have param
|
||||
strncpy(#name, bufpos, math.min(whitepos - bufpos, sizeof(tag.name)));
|
||||
strncpy(#params, whitepos, math.min(closepos - whitepos, sizeof(tag.params)));
|
||||
debug_tag();
|
||||
bufpos = closepos;
|
||||
while (get_next_param());
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
retok = false;
|
||||
goto _RET;
|
||||
}
|
||||
|
||||
strlwr(#name);
|
||||
|
||||
// ignore text inside the next tags
|
||||
if (is("script")) || (is("style")) || (is("binary")) || (is("select")) {
|
||||
strcpy(#prior, #name);
|
||||
sprintf(#name, "</%s>", #prior);
|
||||
if (strstri(bufpos, #name)) bufpos = EAX-1;
|
||||
retok = false;
|
||||
goto _RET;
|
||||
}
|
||||
|
||||
if (name[strlen(#name)-1]=='/') name[strlen(#name)-1]=NULL; //for <br/>
|
||||
|
||||
_RET:
|
||||
ESDWORD[_bufpos] = bufpos;
|
||||
return retok;
|
||||
}
|
||||
|
||||
bool _tag::parse_params()
|
||||
void _tag::debug_tag()
|
||||
{
|
||||
bool result = false;
|
||||
if (!name) return false;
|
||||
if (debug_mode) {
|
||||
debug("\n\ntag: "); debugln(#name);
|
||||
debug("params: "); debugln(#params);
|
||||
debugln(" ");
|
||||
debugch('<');
|
||||
if (!opened) debugch('/');
|
||||
debug(#name);
|
||||
debugln(">");
|
||||
if (params) {
|
||||
debug("params: ");
|
||||
debugln(#params+1);
|
||||
}
|
||||
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()
|
||||
@ -111,6 +168,12 @@ bool _tag::get_next_param()
|
||||
attributes.add(#attr);
|
||||
values.add(#val);
|
||||
|
||||
if (debug_mode) {
|
||||
debug("atr: "); debugln(#attr);
|
||||
debug("val: "); debugln(#val);
|
||||
debugch('\n');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -118,8 +181,9 @@ dword _tag::get_value_of(dword _attr_name)
|
||||
{
|
||||
int pos = attributes.get_pos_by_name(_attr_name);
|
||||
if (pos == -1) {
|
||||
return 0;
|
||||
value = 0;
|
||||
} else {
|
||||
return values.get(pos);
|
||||
value = values.get(pos);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
353
programs/cmm/browser/TWB/set_style.h
Normal file
353
programs/cmm/browser/TWB/set_style.h
Normal file
@ -0,0 +1,353 @@
|
||||
void TWebBrowser::SetStyle()
|
||||
{
|
||||
if (tag.get_value_of("name=")) || (tag.get_value_of("id=")) {
|
||||
anchors.add(tag.value, draw_y);
|
||||
if (anchors.current) && (streq(tag.value, #anchors.current+1)) {
|
||||
list.first = draw_y;
|
||||
anchors.current = NULL;
|
||||
}
|
||||
}
|
||||
if (tag.is("a")) { tag_a(); return; }
|
||||
if (tag.is("p")) { tag_p(); return; }
|
||||
if (tag.is("img")) { tag_img(); return; }
|
||||
if (tag.is("div")) { tag_div(); return; }
|
||||
if (tag.is("br")) { NewLine(); return; }
|
||||
if (tag.is("header")) { NewLine(); return; }
|
||||
if (tag.is("article")) { NewLine(); return; }
|
||||
if (tag.is("footer")) { NewLine(); return; }
|
||||
if (tag.is("figure")) { NewLine(); return; }
|
||||
if (tag.is("w:p")) { NewLine(); return; }
|
||||
if (tag.is("b")) { style.b = tag.opened; return; }
|
||||
if (tag.is("strong")) { style.b = tag.opened; return; }
|
||||
if (tag.is("big")) { style.b = tag.opened; return; }
|
||||
if (tag.is("w:b")) { style.b = tag.opened; return; }
|
||||
if (tag.is("u")) { style.u = tag.opened; return; }
|
||||
if (tag.is("ins")) { style.u = tag.opened; return; }
|
||||
if (tag.is("s")) { style.s = tag.opened; return; }
|
||||
if (tag.is("strike")) { style.s = tag.opened; return; }
|
||||
if (tag.is("del")) { style.s = tag.opened; return; }
|
||||
if (tag.is("pre")) { style.pre = tag.opened; return; }
|
||||
if (tag.is("blockquote")) { style.blq = tag.opened; return; }
|
||||
if (tag.is("dl")) { if (tag.opened) NewLine(); return; }
|
||||
if (tag.is("tr")) { if (tag.opened) NewLine(); return; }
|
||||
if (tag.is("td")) { if (tag.opened) AddCharToTheLine(' '); return; }
|
||||
if (tag.is("button")) { style.button = tag.opened; stolbec++; return; }
|
||||
if (tag.is("w:r")) { if (!tag.opened) style.b = false; return; }
|
||||
if (tag.is("h1")) { tag_h1234_caption(); return; }
|
||||
if (tag.is("h2")) { tag_h1234_caption(); return; }
|
||||
if (tag.is("h3")) { tag_h1234_caption(); return; }
|
||||
if (tag.is("h4")) { tag_h1234_caption(); return; }
|
||||
if (tag.is("font")) { tag_font(); return; }
|
||||
if (tag.is("dt")) { tag_ol_ul_dt(); return; }
|
||||
if (tag.is("ul")) { tag_ol_ul_dt(); return; }
|
||||
if (tag.is("ol")) { tag_ol_ul_dt(); return; }
|
||||
if (tag.is("li")) { tag_li(); return; }
|
||||
if (tag.is("q")) { tag_q(); return; }
|
||||
if (tag.is("hr")) { tag_hr(); return; }
|
||||
if (tag.is("meta")) { tag_meta_xml(); return; }
|
||||
if (tag.is("?xml")) { tag_meta_xml(); return; }
|
||||
if (tag.is("code")) { tag_code(); return; }
|
||||
if (tag.is("iframe")) { tag_iframe(); return; }
|
||||
if (tag.is("caption")) { tag_h1234_caption(); return; }
|
||||
if (tag.is("title")) { tag_title(); return; }
|
||||
if (tag.is("body")) { tag_body(); return; }
|
||||
if (tag.is("html")) { t_html = tag.opened; return; }
|
||||
if (tag.is("dd")) {
|
||||
//NewLine();
|
||||
//if (tag.opened) stolbec += 5; //stolbec overflow!
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_p()
|
||||
{
|
||||
IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) || (streq(#tag.prior,"p")) return;
|
||||
NewLine();
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_title()
|
||||
{
|
||||
style.title = tag.opened;
|
||||
if (!tag.opened) DrawTitle(#header);
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_font()
|
||||
{
|
||||
style.font = tag.opened;
|
||||
style.bg_color = page_bg;
|
||||
if (tag.opened)
|
||||
{
|
||||
if (tag.get_value_of("bg=")) style.bg_color = GetColor(tag.value);
|
||||
if (tag.get_value_of("color=")) {
|
||||
text_colors.add(GetColor(tag.value));
|
||||
} else {
|
||||
text_colors.add(text_colors.get_last());
|
||||
}
|
||||
}
|
||||
else text_colors.pop();
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_div()
|
||||
{
|
||||
if (streq(#tag.prior,"div")) && (tag.opened) return;
|
||||
if (!tag.opened) && (style.font) text_colors.pop();
|
||||
NewLine();
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_iframe()
|
||||
{
|
||||
if (tag.get_value_of("src=")) {
|
||||
NewLine();
|
||||
strcpy(#line, "IFRAME: ");
|
||||
Paint();
|
||||
link=true;
|
||||
links.add_link(tag.value);
|
||||
strncpy(#line, tag.value, sizeof(line)-1);
|
||||
while (CheckForLineBreak()) {};
|
||||
Paint();
|
||||
link=false;
|
||||
NewLine();
|
||||
}
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_a()
|
||||
{
|
||||
if (tag.opened)
|
||||
{
|
||||
if (tag.get_value_of("href=")) && (!strstr(tag.value,"javascript:"))
|
||||
{
|
||||
link = true;
|
||||
links.add_link(tag.value);
|
||||
}
|
||||
} else {
|
||||
link = false;
|
||||
style.bg_color = page_bg;
|
||||
}
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_meta_xml()
|
||||
{
|
||||
if (custom_encoding == -1) if (tag.get_value_of("charset="))
|
||||
|| (tag.get_value_of("content=")) || (tag.get_value_of("encoding="))
|
||||
{
|
||||
EDX = strrchr(tag.value, '=') + tag.value; //search in content=
|
||||
if (ESBYTE[EDX] == '"') EDX++;
|
||||
strlwr(EDX);
|
||||
if (streqrp(EDX,"utf-8")) || (streqrp(EDX,"utf8")) ChangeEncoding(CH_UTF8);
|
||||
else if (streqrp(EDX,"windows-1251")) || (streqrp(EDX,"windows1251")) ChangeEncoding(CH_CP1251);
|
||||
else if (streqrp(EDX,"dos")) || (streqrp(EDX,"cp-866")) ChangeEncoding(CH_CP866);
|
||||
else if (streqrp(EDX,"iso-8859-5")) || (streqrp(EDX,"iso8859-5")) ChangeEncoding(CH_ISO8859_5);
|
||||
else if (streqrp(EDX,"koi8-r")) || (streqrp(EDX,"koi8-u")) ChangeEncoding(CH_KOI8);
|
||||
}
|
||||
if (streq(tag.get_value_of("http-equiv="), "refresh")) && (tag.get_value_of("content=")) {
|
||||
if (tag.value = strstri(tag.value, "url=")) strcpy(#redirect, tag.value);
|
||||
}
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_code()
|
||||
{
|
||||
if (style.pre = tag.opened) {
|
||||
style.bg_color = 0xe4ffcb;
|
||||
} else {
|
||||
style.bg_color = page_bg;
|
||||
}
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_ol_ul_dt()
|
||||
{
|
||||
char type = ESBYTE[#tag.name];
|
||||
style.tag_list.upd_level(tag.opened, type);
|
||||
switch(type)
|
||||
{
|
||||
case 'd':
|
||||
if (tag.opened) NewLine();
|
||||
break;
|
||||
case 'u':
|
||||
case 'o':
|
||||
if (!tag.opened) && (!style.pre) NewLine();
|
||||
}
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_li()
|
||||
{
|
||||
if (tag.opened) {
|
||||
if (!style.tag_list.level) style.tag_list.upd_level(1, 'u');
|
||||
if (!style.pre) NewLine();
|
||||
if (style.tag_list.order_type() == 'u') {
|
||||
strcpy(#line, "\31 ");
|
||||
stolbec = style.tag_list.level * 5 - 2;
|
||||
}
|
||||
if (style.tag_list.order_type() == 'o') {
|
||||
sprintf(#line, "%i. ", style.tag_list.inc_counter());
|
||||
stolbec = style.tag_list.level * 5 - strlen(#line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_hr()
|
||||
{
|
||||
EAX = 0x999999;
|
||||
if (tag.get_value_of("color=")) GetColor(tag.value);
|
||||
$push eax;
|
||||
NewLine();
|
||||
$pop edi;
|
||||
draw_y += 10;
|
||||
canvas.DrawBar(5, draw_y - 1, list.w-10, 1, EDI);
|
||||
NewLine();
|
||||
draw_y += 10;
|
||||
return;
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_body()
|
||||
{
|
||||
t_body = tag.opened;
|
||||
if (tag.get_value_of("link=")) link_color_default = GetColor(tag.value);
|
||||
if (tag.get_value_of("alink=")) link_color_active = GetColor(tag.value);
|
||||
if (tag.get_value_of("text=")) text_colors.set(0, GetColor(tag.value));
|
||||
if (tag.get_value_of("bgcolor=")) {
|
||||
style.bg_color = page_bg = GetColor(tag.value);
|
||||
canvas.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);
|
||||
}
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_q()
|
||||
{
|
||||
if (tag.opened) {
|
||||
AddCharToTheLine(' ');
|
||||
AddCharToTheLine('\"');
|
||||
} else {
|
||||
AddCharToTheLine('\"');
|
||||
AddCharToTheLine(' ');
|
||||
}
|
||||
}
|
||||
|
||||
void TWebBrowser::tag_h1234_caption()
|
||||
{
|
||||
if (ESBYTE[#tag.name+1]=='4') {
|
||||
NewLine();
|
||||
NewLine();
|
||||
style.h = tag.opened;
|
||||
style.b = tag.opened;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TWebBrowser::tag_img()
|
||||
{
|
||||
char img_path[4096]=0;
|
||||
dword imgbuf[44];
|
||||
dword cur_img;
|
||||
int img_x, img_y, img_w, img_h;
|
||||
|
||||
if (!tag.get_value_of("src=")) goto NOIMG;
|
||||
|
||||
if (streqrp(tag.value, "data:")) {
|
||||
if (!strstr(tag.value, "base64,")) goto NOIMG;
|
||||
EDX = EAX+7;
|
||||
if (ESBYTE[EDX]==' ') EDX++;
|
||||
cur_img = malloc(strlen(EDX));
|
||||
base64_decode stdcall (EDX, cur_img, strlen(EDX));
|
||||
img_decode stdcall (cur_img, EAX, 0);
|
||||
$push eax
|
||||
free(cur_img);
|
||||
$pop eax
|
||||
if (EAX) goto IMGOK; else goto NOIMG;
|
||||
}
|
||||
|
||||
if (!strcmp(tag.value + strrchr(tag.value, '.'), "svg")) goto NOIMG;
|
||||
strlcpy(#img_path, tag.value, sizeof(img_path)-1);
|
||||
get_absolute_url(#img_path, history.current());
|
||||
|
||||
if (check_is_the_adress_local(#img_path)) {
|
||||
img_from_file stdcall(#img_path);
|
||||
if (EAX) goto IMGOK; else goto NOIMG;
|
||||
}
|
||||
|
||||
if (cache.has(#img_path)) {
|
||||
img_decode stdcall (cache.current_buf, cache.current_size, 0);
|
||||
if (EAX) goto IMGOK; else goto NOIMG;
|
||||
} else {
|
||||
img_url.add(#img_path);
|
||||
goto NOIMG;
|
||||
}
|
||||
|
||||
IMGOK:
|
||||
cur_img = EAX;
|
||||
img_h = ESDWORD[cur_img+8];
|
||||
img_w = ESDWORD[cur_img+4];
|
||||
|
||||
if (img_w / 6 + stolbec > list.column_max) {
|
||||
NewLine();
|
||||
}
|
||||
img_x = stolbec*list.font_w+3;
|
||||
img_y = draw_y;
|
||||
|
||||
img_w = math.min(img_w, canvas.bufw - img_x);
|
||||
|
||||
stolbec += img_w / 6;
|
||||
if (stolbec > list.column_max) NewLine();
|
||||
|
||||
if (img_h > list.item_h + 5) {
|
||||
draw_y += img_h - list.item_h;
|
||||
NewLine();
|
||||
}
|
||||
|
||||
if (link) links.add_text(img_x + list.x, img_y + list.y, img_w, img_h, 0);
|
||||
|
||||
if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize();
|
||||
|
||||
if (ESDWORD[cur_img+20] != IMAGE_BPP32) {
|
||||
img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0);
|
||||
$push eax
|
||||
img_destroy stdcall(cur_img);
|
||||
$pop eax
|
||||
cur_img = EAX;
|
||||
if (!EAX) goto NOIMG;
|
||||
}
|
||||
imgbuf[04] = canvas.bufw;
|
||||
imgbuf[08] = canvas.bufh;
|
||||
imgbuf[20] = IMAGE_BPP32;
|
||||
imgbuf[24] = buf_data+8;
|
||||
img_blend stdcall(#imgbuf, cur_img, img_x, img_y, 0, 0, img_w, img_h);
|
||||
img_destroy stdcall(cur_img);
|
||||
return;
|
||||
|
||||
NOIMG:
|
||||
if (tag.get_value_of("title=")) || (tag.get_value_of("alt=")) {
|
||||
strncpy(#img_path, tag.value, sizeof(line)-3);
|
||||
sprintf(#line, "[%s]", #img_path);
|
||||
} else {
|
||||
if (streqrp(#img_path, "data:")) img_path=0;
|
||||
replace_char(#img_path, '?', NULL, strlen(#img_path));
|
||||
img_path[sizeof(line)-3] = '\0'; //prevent overflow in sprintf
|
||||
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();
|
||||
}
|
@ -6,7 +6,7 @@ char *unicode_symbols[]={
|
||||
"#183","\31", "middot", "\31",
|
||||
"#149","-",
|
||||
"#151","-",
|
||||
"#160"," ", "nbsp", " ",
|
||||
"#160"," ", "nbsp", " ", "emsp", " ",
|
||||
"#169","(c)", "copy", "(c)",
|
||||
"#171","<<", "laquo","<<",
|
||||
"#174","(r)", "reg", "(r)",
|
||||
@ -44,6 +44,8 @@ char *unicode_symbols[]={
|
||||
"#9642", "-", //square in the middle of the line
|
||||
"#9658", ">",
|
||||
"#9660", "v",
|
||||
"#10094", "<",
|
||||
"#10095", ">",
|
||||
"#65122", "+",
|
||||
|
||||
"#8594", "->",
|
||||
|
@ -1,13 +1,12 @@
|
||||
enum {DT=1, OL, UL};
|
||||
struct LIST
|
||||
{
|
||||
int level;
|
||||
int ordered[5];
|
||||
char ordered[5];
|
||||
int counter[5];
|
||||
void reset();
|
||||
void upd_level();
|
||||
int inc_counter();
|
||||
int get_order_type();
|
||||
char order_type();
|
||||
};
|
||||
|
||||
void LIST::reset()
|
||||
@ -15,12 +14,12 @@ void LIST::reset()
|
||||
level = 0;
|
||||
}
|
||||
|
||||
void LIST::upd_level(int direction, type)
|
||||
void LIST::upd_level(int direction, char type)
|
||||
{
|
||||
if (direction == 1) && (level<5) {
|
||||
level++;
|
||||
counter[level]=0;
|
||||
ordered[level]=type;
|
||||
counter[level] = 0;
|
||||
ordered[level] = type;
|
||||
}
|
||||
if (direction == 0) && (level>0) {
|
||||
level--;
|
||||
@ -33,7 +32,7 @@ int LIST::inc_counter()
|
||||
return counter[level];
|
||||
}
|
||||
|
||||
int LIST::get_order_type()
|
||||
char LIST::order_type()
|
||||
{
|
||||
return ordered[level];
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
// DATA //
|
||||
// //
|
||||
//===================================================//
|
||||
char version[]="WebView 3.06";
|
||||
char version[]="WebView 3.1";
|
||||
|
||||
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
|
||||
|
||||
@ -372,8 +372,8 @@ void draw_window()
|
||||
bool BrowserWidthChanged()
|
||||
{
|
||||
dword source_mode_holder;
|
||||
if (WB1.list.w!=DrawBuf.bufw) {
|
||||
DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
|
||||
if (WB1.list.w!=canvas.bufw) {
|
||||
canvas.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
|
||||
if (!strncmp(history.current(),"http",4)) {
|
||||
//nihuya ne izyashnoe reshenie, no pust' poka butet tak
|
||||
source_mode_holder = source_mode;
|
||||
|
@ -9,7 +9,7 @@
|
||||
dword buf_data=0;
|
||||
|
||||
|
||||
struct DrawBufer {
|
||||
struct CANVAS {
|
||||
dword bufx, bufy, bufw, bufh;
|
||||
dword fill_color;
|
||||
|
||||
@ -25,10 +25,10 @@ struct DrawBufer {
|
||||
};
|
||||
|
||||
char draw_buf_not_enaught_ram[] =
|
||||
"'DrawBufer requested %i MB more memory than the system has.
|
||||
"'CANVAS requested %i MB more memory than the system has.
|
||||
Application could be unstable.' -E";
|
||||
|
||||
bool DrawBufer::Init(dword i_bufx, i_bufy, i_bufw, i_bufh)
|
||||
bool CANVAS::Init(dword i_bufx, i_bufy, i_bufw, i_bufh)
|
||||
{
|
||||
bufx = i_bufx;
|
||||
bufy = i_bufy;
|
||||
@ -42,14 +42,14 @@ bool DrawBufer::Init(dword i_bufx, i_bufy, i_bufw, i_bufh)
|
||||
return true;
|
||||
}
|
||||
|
||||
void DrawBufer::Fill(dword start_pointer, i_fill_color)
|
||||
void CANVAS::Fill(dword start_pointer, i_fill_color)
|
||||
{
|
||||
dword max_i = bufw * bufh * 4 - start_pointer/4;
|
||||
fill_color = i_fill_color;
|
||||
@MEMSETD(buf_data+start_pointer+8, max_i, fill_color);
|
||||
}
|
||||
|
||||
void DrawBufer::DrawBar(dword x, y, w, h, color)
|
||||
void CANVAS::DrawBar(dword x, y, w, h, color)
|
||||
{
|
||||
dword i, j;
|
||||
if (y + h >= bufh) IncreaseBufSize();
|
||||
@ -60,7 +60,7 @@ void DrawBufer::DrawBar(dword x, y, w, h, color)
|
||||
}
|
||||
}
|
||||
|
||||
void DrawBufer::WriteText(dword x, y, byte fontType, dword color, str_offset, strlen)
|
||||
void CANVAS::WriteText(dword x, y, byte fontType, dword color, str_offset, strlen)
|
||||
{
|
||||
#define BUGFIX_32000 32000
|
||||
dword ydiv=0;
|
||||
@ -89,13 +89,13 @@ void DrawBufer::WriteText(dword x, y, byte fontType, dword color, str_offset, st
|
||||
}
|
||||
}
|
||||
|
||||
void DrawBufer::PutPixel(dword x, y, color)
|
||||
void CANVAS::PutPixel(dword x, y, color)
|
||||
{
|
||||
dword pos = y*bufw+x*4+8+buf_data;
|
||||
ESDWORD[pos] = color;
|
||||
}
|
||||
|
||||
void DrawBufer::AlignRight(dword x,y,w,h, content_width)
|
||||
void CANVAS::AlignRight(dword x,y,w,h, content_width)
|
||||
{
|
||||
dword i, j, l;
|
||||
dword content_left = w - content_width / 2;
|
||||
@ -108,7 +108,7 @@ void DrawBufer::AlignRight(dword x,y,w,h, content_width)
|
||||
}
|
||||
}
|
||||
|
||||
void DrawBufer::AlignCenter(dword x,y,w,h, content_width)
|
||||
void CANVAS::AlignCenter(dword x,y,w,h, content_width)
|
||||
{
|
||||
dword i, j, l;
|
||||
dword content_left = w - content_width / 2;
|
||||
@ -121,12 +121,12 @@ void DrawBufer::AlignCenter(dword x,y,w,h, content_width)
|
||||
}
|
||||
}
|
||||
|
||||
void DrawBufer::Show(dword _y_offset, _h)
|
||||
void CANVAS::Show(dword _y_offset, _h)
|
||||
{
|
||||
PutPaletteImage(_y_offset * bufw * 4 + buf_data+8, bufw, _h, bufx, bufy, 32, 0);
|
||||
}
|
||||
|
||||
void DrawBufer::IncreaseBufSize()
|
||||
void CANVAS::IncreaseBufSize()
|
||||
{
|
||||
static dword bufh_initial;
|
||||
dword alloc_size;
|
||||
|
@ -407,6 +407,39 @@ inline fastcall void strcat( EDI, ESI)
|
||||
ESBYTE[dst] = 0;
|
||||
}
|
||||
|
||||
inline fastcall void chrcat(ESI, DI)
|
||||
{
|
||||
while (ESBYTE[ESI]) ESI++;
|
||||
ESBYTE[ESI] = DI;
|
||||
ESI++;
|
||||
ESBYTE[ESI] = 0;
|
||||
}
|
||||
|
||||
inline fastcall void chrncat(EDI, AL, EDX)
|
||||
{
|
||||
while (ESBYTE[EDI]) && (EDX) {
|
||||
EDI++;
|
||||
EDX--;
|
||||
}
|
||||
ESBYTE[EDI] = AL;
|
||||
EDI++;
|
||||
ESBYTE[EDI] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
inline dword strchr(ESI, BL)
|
||||
{
|
||||
loop()
|
||||
{
|
||||
AL = DSBYTE[ESI];
|
||||
if(!AL)return 0;
|
||||
if(AL==BL)return ESI;
|
||||
ESI++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
:void chrncat(dword dst, unsigned char s, dword len)
|
||||
{
|
||||
while (ESBYTE[dst]) && (len) {
|
||||
@ -418,14 +451,7 @@ inline fastcall void strcat( EDI, ESI)
|
||||
ESBYTE[dst+1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline fastcall void chrcat(ESI, DI)
|
||||
{
|
||||
while (ESBYTE[ESI]) ESI++;
|
||||
ESBYTE[ESI] = DI;
|
||||
ESI++;
|
||||
ESBYTE[ESI] = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
inline dword strchr(dword shb;char s)
|
||||
{
|
||||
@ -439,6 +465,18 @@ inline dword strchr(dword shb;char s)
|
||||
}
|
||||
}
|
||||
|
||||
inline dword strchrw(dword str, len)
|
||||
{
|
||||
len += str;
|
||||
loop()
|
||||
{
|
||||
if(!DSBYTE[str])return 0;
|
||||
if (__isWhite(DSBYTE[str])) return str;
|
||||
str++;
|
||||
if (str >= len) return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline fastcall signed int strrchr( ESI,BL)
|
||||
{
|
||||
int jj=0, last=0;
|
||||
|
@ -106,7 +106,7 @@ struct THEME
|
||||
char default_dir[] = "/rd/1";
|
||||
od_filter filter2 = { 33, "TXT\0ASM\0HTM\0HTML\0C\0H\0C--\0H--\0CPP\0\0" };
|
||||
|
||||
DrawBufer DrawBuf;
|
||||
CANVAS canvas;
|
||||
|
||||
dword cursor_pos=0;
|
||||
|
||||
|
@ -7,7 +7,7 @@ void ParseAndPaint()
|
||||
Parse();
|
||||
|
||||
list.visible = list.h / list.item_h;
|
||||
DrawBuf.Init(list.x, list.y, list.w, list.visible+1*list.item_h);
|
||||
canvas.Init(list.x, list.y, list.w, list.visible+1*list.item_h);
|
||||
DrawPage();
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ void PaintVisible()
|
||||
line_bg = theme.bg;
|
||||
|
||||
if (selection.start_y < absolute_y) && (selection.end_y > absolute_y) line_bg = selection.color;
|
||||
DrawBuf.DrawBar(0, ydraw, list.w, list.item_h, line_bg);
|
||||
canvas.DrawBar(0, ydraw, list.w, list.item_h, line_bg);
|
||||
|
||||
selection.draw(absolute_y);
|
||||
|
||||
@ -75,17 +75,17 @@ void PaintVisible()
|
||||
if (s2 > 0) break;
|
||||
|
||||
if (s1 > 0) && (s2 < 0) {
|
||||
DrawBuf.DrawBar(search.found.get(ff) - lines.get(absolute_y) * list.font_w + 3,
|
||||
canvas.DrawBar(search.found.get(ff) - lines.get(absolute_y) * list.font_w + 3,
|
||||
ydraw, strlen(#found_text) * list.font_w, list.item_h, theme.found);
|
||||
search_next = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (absolute_y<list.count) DrawBuf.WriteText(3, ydraw+3, list.font_type, theme.text,
|
||||
if (absolute_y<list.count) canvas.WriteText(3, ydraw+3, list.font_type, theme.text,
|
||||
lines.get(absolute_y), lines.len(absolute_y));
|
||||
}
|
||||
|
||||
PutPaletteImage(buf_data+8, DrawBuf.bufw, list.h, list.x, list.y, 32, 0);
|
||||
PutPaletteImage(buf_data+8, canvas.bufw, list.h, list.x, list.y, 32, 0);
|
||||
|
||||
if (swapped_selection) selection.swap_start_end();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ bool SELECTION::is_active()
|
||||
|
||||
void SELECTION::draw_line(dword x,y,w)
|
||||
{
|
||||
DrawBuf.DrawBar(x, y - list.first * list.item_h, w, list.item_h, color);
|
||||
canvas.DrawBar(x, y - list.first * list.item_h, w, list.item_h, color);
|
||||
}
|
||||
|
||||
void SELECTION::draw(int i)
|
||||
@ -35,12 +35,12 @@ void SELECTION::draw(int i)
|
||||
else if (start_y == i) draw_line(start_x * list.font_w+2, start_y, list.w -2- calc(start_x * list.font_w));
|
||||
else if (end_y == i) draw_line(0, end_y, end_x * list.font_w+2);
|
||||
//only for debug:
|
||||
//DrawBuf.DrawBar(start_x * list.font_w + 2, start_y * list.item_h, 2, list.item_h, 0x00FF00);
|
||||
//DrawBuf.DrawBar(end_x * list.font_w + 0, end_y * list.item_h, 2, list.item_h, 0xFF00FF);
|
||||
//canvas.DrawBar(start_x * list.font_w + 2, start_y * list.item_h, 2, list.item_h, 0x00FF00);
|
||||
//canvas.DrawBar(end_x * list.font_w + 0, end_y * list.item_h, 2, list.item_h, 0xFF00FF);
|
||||
}
|
||||
//DrawCursor
|
||||
if (list.cur_y >= list.first) && (list.cur_y <= list.first+list.visible) {
|
||||
DrawBuf.DrawBar(list.cur_x * list.font_w + 2, list.cur_y - list.first * list.item_h, 2, list.item_h, theme.cursor);
|
||||
canvas.DrawBar(list.cur_x * list.font_w + 2, list.cur_y - list.first * list.item_h, 2, list.item_h, theme.cursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user