Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7756 → Rev 7757

/programs/cmm/TWB/TWB.c
2,8 → 2,12
#include "..\TWB\anchors.h"
#include "..\TWB\parce_tag.h"
#include "..\TWB\absolute_url.h"
char line[500];
#include "..\TWB\unicode_tags.h"
#include "..\TWB\img_cache.h"
dword page_bg;
dword link_color_inactive;
dword link_color_active;
#include "..\TWB\links.h"
 
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
 
39,15 → 43,10
void BufEncode();
} WB1;
 
dword page_bg;
#include "..\TWB\img_cache.h"
char line[500];
 
dword link_color_inactive;
dword link_color_active;
 
bool link, cur_encoding, t_html, t_body;
 
#include "..\TWB\links.h"
 
dword bufpointer=0;
dword bufsize=0;
57,7 → 56,7
int body_magrin=6;
int basic_line_h=22;
 
scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,15,0,0xeeeeee,0xBBBbbb,0xeeeeee};
scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee};
 
//============================================================================================
void TWebBrowser::DrawStyle()
128,8 → 127,10
stolbec = 0;
line = 0;
zoom = 1;
if (o_bufpointer) free(o_bufpointer);
o_bufpointer = 0;
//hold original buffer
if (o_bufpointer) o_bufpointer=free(o_bufpointer);
o_bufpointer = malloc(bufsize);
memmov(o_bufpointer, bufpointer, bufsize);
}
//============================================================================================
void TWebBrowser::AddCharToTheLine(unsigned char _char)
187,7 → 188,7
bukva = ESBYTE[bufpos+j];
chrcat(#unicode_symbol, bukva);
}
if (bukva = GetUnicodeSymbol(#unicode_symbol)) {
if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) {
bufpos += j;
CheckForLineBreak();
} else {
242,7 → 243,7
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) && (!tag.is("i")) && (!tag.is("svg")) {
if (tag.name) {
CheckForLineBreak();
DrawStyle();
if (tag.name) SetStyle();
305,7 → 306,7
return;
}
IF(tag.is("q"))
if (tag.is("q"))
{
if (tag.opened) {
meta_encoding = strlen(#line);
384,6 → 385,7
return;
}
if (tag.is("br")) { NewLine(); return; }
if (tag.is("td")) { if (tag.opened) AddCharToTheLine(' '); return; }
if (tag.is("tr")) { if (tag.opened) NewLine(); return; }
if (tag.is("b")) || (tag.is("strong")) || (tag.is("big")) { style.b = tag.opened; return; }
if (tag.is("button")) { style.button = tag.opened; stolbec++; return; }
459,7 → 461,7
if (tag.is("ul")) || (tag.is("ol")) {
if (!tag.opened)
{
style.li = tag.opened;
style.li = false;
style.li_tab--;
NewLine();
}
495,18 → 497,11
//============================================================================================
void TWebBrowser::BufEncode(dword set_new_encoding)
{
if (cur_encoding == set_new_encoding) return;
if (o_bufpointer==0) {
o_bufpointer = malloc(bufsize);
strcpy(o_bufpointer, bufpointer);
} else {
strcpy(bufpointer, o_bufpointer);
}
//debugval("cur_encoding ", cur_encoding);
//debugval("set_new_encoding", set_new_encoding);
if (cur_encoding != set_new_encoding) {
cur_encoding = set_new_encoding;
bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer);
}
}
//============================================================================================
void TWebBrowser::DrawScroller()
{
/programs/cmm/TWB/absolute_url.h
1,40 → 1,33
 
dword GetAbsoluteURL(dword in_URL)
:dword GetAbsoluteURL(dword new_URL, base_URL)
{
int i;
dword orig_URL = in_URL;
dword orig_URL = new_URL;
char newurl[URL_SIZE+1];
strcpy(#newurl, base_URL);
 
while (i=strstr(in_URL, "&"))
while (i=strstr(new_URL, "&"))
{
strcpy(i+1, i+5);
}
 
if (check_is_the_url_absolute(in_URL)) return orig_URL;
if (check_is_the_url_absolute(new_URL)) return orig_URL;
 
IF (!strncmp(in_URL,"//", 2))
IF (!strncmp(new_URL,"//", 2))
{
strcpy(#newurl, "http:");
strcat(#newurl, in_URL);
strcat(#newurl, new_URL);
strcpy(orig_URL, #newurl);
return orig_URL;
}
IF (!strncmp(in_URL,"./", 2)) in_URL+=2;
if (!http.transfer)
{
strcpy(#newurl, history.current());
}
else
{
strcpy(#newurl, history.items.get(history.active-2));
}
IF (!strncmp(new_URL,"./", 2)) new_URL+=2;
 
if (ESBYTE[in_URL] == '/') //remove everything after site domain name
if (ESBYTE[new_URL] == '/') //remove everything after site domain name
{
i = strchr(#newurl+8, '/');
if (i) ESBYTE[i]=0;
in_URL+=1;
new_URL+=1;
}
_CUT_ST_LEVEL_MARK:
44,9 → 37,9
newurl[strrchr(#newurl, '/')] = 0x00;
}
IF (!strncmp(in_URL,"../",3))
IF (!strncmp(new_URL,"../",3))
{
in_URL+=3;
new_URL+=3;
newurl[strrchr(#newurl, '/')-1] = 0x00;
goto _CUT_ST_LEVEL_MARK;
}
53,7 → 46,7
if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/");
strcat(#newurl, in_URL);
strcat(#newurl, new_URL);
strcpy(orig_URL, #newurl);
return orig_URL;
}
/programs/cmm/TWB/img_cache.h
52,7 → 52,9
imgh = DSWORD[pics[cur_pic].image+8];
if (imgw > width1) imgw = width1;
//draw_y += imgh + 5; TEMPORARY TURN OFF!!!
/*
draw_y += imgh + 5; TEMPORARY TURN OFF!!!
if (top1+imgh<WB1.list.y) || (top1>WB1.list.y+WB1.list.h-10) return; //if all image is out of visible area
if (top1<WB1.list.y) //if image partly visible (at the top)
{
69,7 → 71,6
img_draw stdcall (pics[cur_pic].image, left1-5, top1, imgw, imgh,0,img_lines_first);
DrawBar(left1+imgw - 5, top1, WB1.list.w-imgw, imgh, page_bg);
DrawBar(WB1.list.x, top1+imgh, WB1.list.w, -imgh % WB1.list.item_h + WB1.list.item_h, page_bg);
/*
if (link)
{
UnsafeDefineButton(left1 - 5, top1, imgw, imgh-1, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
/programs/cmm/TWB/links.h
9,7 → 9,8
 
struct array_link {
dword link;
int x,y,w,h;
unsigned int x,y,w,h;
unsigned int unic_id;
int underline, underline_h;
};
 
16,13 → 17,15
struct LinksArray {
array_link links[MAXLINKS];
collection page_links;
int count;
int active;
unsigned int count;
unsigned int unic_count;
unsigned int active;
bool HoverAndProceed();
void AddLink();
void AddText();
dword GetURL();
void Clear();
void DrawUnderline();
} PageLinks;
 
void LinksArray::AddLink(dword lpath)
29,6 → 32,7
{
if (count>= MAXLINKS) return;
page_links.add(lpath);
unic_count++;
}
 
void LinksArray::AddText(dword _x, _y, _w, _h, _link_underline, _underline_h)
41,6 → 45,7
links[count].underline = _link_underline;
links[count].underline_h = _underline_h;
links[count].link = page_links.get(page_links.count-1);
links[count].unic_id = unic_count;
count++;
}
 
55,12 → 60,24
page_links.realloc_size = 4096 * 32;
count = 0;
active = -1;
unic_count = 0;
CursorPointer.Restore();
}
 
void LinksArray::DrawUnderline(dword und_id, list_first, list_y, color)
{
int i;
for (i=0; i<count; i++)
{
if (links[i].unic_id==links[und_id].unic_id) && (links[i].y + links[i].h - list_first > list_y) {
DrawBar(links[i].x, links[i].y + links[i].h - list_first, links[i].w, links[i].underline_h, color);
}
}
}
 
PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, NULL, 0};
 
bool LinksArray::HoverAndProceed(dword mx, my)
bool LinksArray::HoverAndProceed(dword mx, my, list_y, list_first)
{
int i;
if (!count) return true;
68,10 → 85,10
{
if (mx>links[i].x) && (my>links[i].y)
&& (mx<links[i].x+links[i].w) && (my<links[i].y+links[i].h)
&& (my>WB1.list.y+WB1.list.first)
&& (my>list_y+list_first)
{
if (mouse.lkm) && (mouse.down) {
DrawRectangle(links[active].x, -WB1.list.first + links[active].y,
DrawRectangle(links[active].x, -list_first + links[active].y,
links[active].w, links[active].h, 0);
return false;
}
91,10 → 108,15
if (active==i) return false;
CursorPointer.Load(#CursorFile);
CursorPointer.Set();
if (links[active].underline) DrawUnderline(links[active].x, -WB1.list.first + links[active].y
+ links[active].h, links[active].w, links[active].underline_h, link_color_inactive);
if (links[i].underline) DrawUnderline(links[i].x, -WB1.list.first + links[i].y
+ links[i].h, links[i].w, links[i].underline_h, page_bg);
 
if (links[active].underline) {
DrawUnderline(active, list_first, list_y, link_color_inactive);
}
 
if (links[i].underline) {
DrawUnderline(i, list_first, list_y, page_bg);
}
 
active = i;
DrawStatusBar(links[active].link);
return true;
104,15 → 126,10
{
CursorPointer.Restore();
if (links[active].underline) {
DrawUnderline(links[active].x, -WB1.list.first + links[active].y + links[active].h,links[active].w,
links[active].underline_h, link_color_inactive);
DrawUnderline(active, list_first, list_y, link_color_inactive);
}
DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
DrawStatusBar(NULL);
active = -1;
}
}
 
void DrawUnderline(dword x,y,w,h,color)
{
if (y>WB1.list.y) DrawBar(x,y,w,h,color);
}
/programs/cmm/TWB/unicode_tags.h
1,14 → 1,9
char *unicode_symbols[]={
"#32", " ",
"#34", "\"", "quot","\"",
"#38", "&", "amp", "&",
"#39", "'",
"#039","'",
"#60", "<", "lt", "<",
"#62", ">", "gt", ">",
"#91", "[",
"#93", "]",
"#96", "'",
"quot","\"",
"amp", "&",
"lt", "<",
"gt", ">",
"#183","\31", "middot", "\31",
"#149","-",
"#151","-",
"#160"," ", "nbsp", " ",
32,11 → 27,13
 
"#8211", "-",
"#8217", "'",
"#8220", "\"",
"#8222", "\"", "ldquo", "\"",
"#8221", "\"", "rdquo", "\"",
"#8470", "N",
"#8722", "-",
"#9642", "-", //square in the middle of the line
"#65122", "+",
 
"uarr", "\24",
"darr", "\25",
53,34 → 50,32
 
unsigned char unicode_chars[] = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯àáâãäåæçèéêëìíîïðñh£\243i\105\244\0";
 
bool GetUnicodeSymbol(dword in_tag)
bool GetUnicodeSymbol(dword _line, in_tag, size)
{
int j, specia1040;
int j;
int code;
for (j=0; unicode_symbols[j]!=0; j+=2;)
{
if (!strcmp(in_tag, unicode_symbols[j]))
{
strcat(#line, unicode_symbols[j+1]);
strncat(_line, unicode_symbols[j+1], size);
return true;
}
}
 
specia1040 = atoi(in_tag + 1) - 1040;
if (ESBYTE[in_tag+1] == '1') && (specia1040>=0)
&& (specia1040<=72) && (strlen(in_tag) == 5)
if (ESBYTE[in_tag]=='#')
{
if (strlen(#line)<sizeof(line)-2) {
/*
j = strlen(#line);
line[j] = unicode_chars[specia1040];
line[j+1] = EOS;
*/
chrcat(#line, unicode_chars[specia1040]);
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;
}