Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4490 → Rev 4491

/programs/cmm/TWB/TWB.c
1,7 → 1,7
#include "..\lib\draw_buf.h"
#include "..\lib\list_box.h"
#include "..\TWB\links.h"
 
 
int downloader_id;
 
dword buf;
35,7 → 35,7
 
TWebBrowser WB1;
 
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab,
byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab,
link, ignor_text, cur_encoding, text_align;
byte condition_text_active, condition_text_val, condition_href, condition_max;
 
45,7 → 45,8
 
dword text_colors[300];
dword text_color_index;
dword link_color;
dword link_color_inactive;
dword link_color_active;
dword bg_color;
 
int stroka;
65,7 → 66,6
#include "..\TWB\unicode_tags.h"
#include "..\TWB\img_cache.h"
#include "..\TWB\parce_tag.h"
#include "..\TWB\links.h"
 
 
 
212,7 → 212,8
condition_text_val = condition_text_active = 0; //îáíóëÿåì òåãè
condition_max = 255;
text_align = ALIGN_LEFT;
link_color = 0x0000FF;
link_color_inactive = 0x0000FF;
link_color_active = 0xFF0000;
bg_color = 0xFFFFFF;
DrawBuf.Fill(bg_color);
PageLinks.Clear();
331,9 → 332,9
TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
}
DrawPage();
line=NULL;
 
if (tag) WhatTextStyle(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //îáðàáîòêà òåãîâ
line=NULL;
 
tag = parametr = tagparam = ignor_param = NULL;
break;
384,26 → 385,27
char oldtag[100];
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
dword hr_color;
byte opened;
 
//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
if (tag[0] == '/')
{
rez = 0;
opened = 0;
strcpy(#tag, #tag+1);
}
else rez = 1;
else opened = 1;
if (isTag("html"))
{
IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0;
IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (opened==0) ignor_text = 1; ELSE ignor_text = 0;
return;
}
 
if (isTag("script")) || (isTag("style")) || (isTag("binary")) ignor_text = rez;
if (isTag("script")) || (isTag("style")) || (isTag("binary")) ignor_text = opened;
 
if(isTag("title"))
{
if (rez) header=NULL;
if (opened) header=NULL;
else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó
return;
}
410,10 → 412,20
 
if (ignor_text) return;
 
IF(isTag("q"))
{
if (opened)
{
TextGoDown(left1, top1, width1);
strcat(#line, ' \"');
}
if (!opened)
{
chrcat(#line, '\"');
TextGoDown(left1, top1, width1);
}
}
 
IF(isTag("q")) chrcat(#line, '\"');
 
if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
{
if (!strcmp(#anchor, #options)) anchor_line_num=list.first+stroka;
422,8 → 434,9
if (isTag("body"))
{
do{
if (!strcmp(#parametr, "condition_max=")) { condition_max = atoi(#options); debugi(condition_max); }
if (!strcmp(#parametr, "link=")) link_color = GetColor(#options);
if (!strcmp(#parametr, "condition_max=")) condition_max = atoi(#options);
if (!strcmp(#parametr, "link=")) link_color_inactive = GetColor(#options);
if (!strcmp(#parametr, "alink=")) link_color_active = GetColor(#options);
if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options);
if (!strcmp(#parametr, "bgcolor="))
{
436,7 → 449,7
 
if (isTag("a"))
{
if (rez)
if (opened)
{
if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
 
450,8 → 463,8
link = 1;
blink++;
text_colors[text_color_index] = link_color;
PageLinks.Add(#options);
text_colors[text_color_index] = link_color_inactive;
PageLinks.AddLink(#options, stolbec*6+left1, top1);
}
if (anchor) && (!strcmp(#parametr, "name="))
{
464,6 → 477,7
}
else {
link = 0;
PageLinks.AddText(#line, strlen(#line)*6, list.line_h);
IF(text_color_index > 0) text_color_index--;
}
return;
471,7 → 485,7
 
if (isTag("font"))
{
if (rez)
if (opened)
{
text_color_index++;
text_colors[text_color_index] = text_colors[text_color_index-1];
498,14 → 512,14
if (isTag("p")) {
IF(oldtag[0] == 'h') return;
TextGoDown(left1, top1, width1);
IF(rez) TextGoDown(left1, top1 + 10, width1);
IF(opened) TextGoDown(left1, top1 + 10, width1);
return;
}
/*
if (isTag("center"))
{
if (rez) text_align = ALIGN_CENTER;
if (!rez)
if (opened) text_align = ALIGN_CENTER;
if (!opened)
{
TextGoDown(left1, top1, width1);
text_align = ALIGN_LEFT;
514,8 → 528,8
}
if (isTag("right"))
{
if (rez) text_align = ALIGN_RIGHT;
if (!rez)
if (opened) text_align = ALIGN_RIGHT;
if (!opened)
{
TextGoDown(left1, top1, width1);
text_align = ALIGN_LEFT;
525,15 → 539,15
*/
if (isTag("h1")) || (isTag("h2")) || (isTag("h3")) || (isTag("h4")) {
TextGoDown(left1, top1, width1);
if (rez) && (stroka>1) TextGoDown(left1, top1 + 10, width1);
if (opened) && (stroka>1) TextGoDown(left1, top1 + 10, width1);
strcpy(#oldtag, #tag);
if (rez)
if (opened)
{
if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"center")) text_align = ALIGN_CENTER;
if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"right")) text_align = ALIGN_RIGHT;
b_text = 1;
}
if (!rez)
if (!opened)
{
text_align = ALIGN_LEFT;
b_text = 0;
544,30 → 558,30
oldtag=NULL;
if (isTag("b")) || (isTag("strong")) || (isTag("big")) {
b_text = rez;
b_text = opened;
return;
}
if(isTag("i")) || (isTag("em")) || (isTag("subtitle")) {
i_text = rez;
i_text = opened;
return;
}
if (isTag("dt"))
{
li_text = rez;
IF(rez == 0) return;
li_text = opened;
IF(opened == 0) return;
TextGoDown(left1, top1, width1);
return;
}
if (isTag("condition"))
{
condition_text_active = rez;
if (rez) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options);
condition_text_active = opened;
if (opened) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options);
return;
}
if (isTag("li")) || (isTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
{
li_text = rez;
if (rez)
li_text = opened;
if (opened)
{
TextGoDown(left1, top1, width1);
if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555);
574,17 → 588,17
}
return;
}
if (isTag("u")) || (isTag("ins")) u_text = rez;
if (isTag("s")) || (isTag("strike")) || (isTag("del")) s_text = rez;
if (isTag("ul")) || (isTag("ol")) IF(!rez)
if (isTag("u")) || (isTag("ins")) u_text = opened;
if (isTag("s")) || (isTag("strike")) || (isTag("del")) s_text = opened;
if (isTag("ul")) || (isTag("ol")) IF(!opened)
{
li_text = rez;
li_text = opened;
li_tab--;
TextGoDown(left1, top1, width1);
} ELSE li_tab++;
if (isTag("dd")) stolbec += 5;
if (isTag("blockquote")) blq_text = rez;
if (isTag("pre")) pre_text = rez;
if (isTag("blockquote")) blq_text = opened;
if (isTag("pre")) pre_text = opened;
if (isTag("hr"))
{
if (anchor) || (stroka < -1)
599,7 → 613,7
}
if (isTag("img"))
{
ImgCache1.Images( left1, top1, width1);
ImgCache.Images( left1, top1, width1);
return;
}
if (isTag("meta")) || (isTag("?xml"))
617,6 → 631,16
}
}
 
/*
char *encodings = {
"utf-8", _UTF,
"utf8", _UTF,
"koi8-r", _KOI,
"koi8-u", _KOI,
"dos", _DOS,
"cp-866", _DOS
};
*/
 
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
{
/programs/cmm/TWB/img_cache.h
6,14 → 6,14
 
s_image pics[100]; //pics = mem_Alloc( 100*sizeof(s_image) );
 
struct ImgCache {
struct ImageCache {
int pics_count;
void Free();
int GetImage();
void Images();
} ImgCache1;
};
 
void ImgCache::Free()
void ImageCache::Free()
{
for ( ; pics_count>0; pics_count--)
{
22,7 → 22,7
}
}
 
int ImgCache::GetImage(dword i_path)
int ImageCache::GetImage(dword i_path)
{
int i;
for (i=0; i<pics_count; i++) if (!strcmp(#pics[i].path, i_path)) return i; //image exists
34,7 → 34,7
}
 
 
void ImgCache::Images(int left1, top1, width1)
void ImageCache::Images(int left1, top1, width1)
{
dword image;
char img_path[4096], alt[4096];
97,4 → 97,6
img_draw stdcall (pics[cur_pic].image, left1-5, top1, w, h,0,img_lines_first);
DrawBar(left1+w - 5, top1, WB1.list.w-w, h, bg_color);
IF (link) UnsafeDefineButton(left1 - 5, top1, w, h-1, blink + BT_HIDE, 0xB5BFC9);
}
}
 
ImageCache ImgCache;
/programs/cmm/TWB/links.h
1,36 → 1,76
struct array_link {
dword link, text;
int x,y,w,h;
};
 
struct LinksArray
{
array_link links[100];
char page_links[12000];
void Add();
dword buflen;
int count, active;
 
void Hover();
void AddLink();
void AddText();
dword GetURL();
void Clear();
} PageLinks;
};
 
void LinksArray::Add(dword new_link)
void LinksArray::AddLink(dword new_link, int link_x, link_y)
{
strcat(#page_links, new_link);
strcat(#page_links, "|");
links[count].x = link_x;
links[count].y = link_y;
 
links[count].link = buflen;
strcpy(buflen, new_link);
buflen += strlen(new_link)+1;
count++;
}
 
void LinksArray::AddText(dword new_text, int link_w, link_h)
{
if (count<1) return;
links[count-1].w = link_w;
links[count-1].h = link_h;
 
links[count-1].text = buflen;
strcpy(buflen, new_text);
buflen += strlen(new_text)+1;
}
 
dword LinksArray::GetURL(int id)
{
int i, j = 0;
for (i = 0; i <= id - 401; i++)
return links[id].link;
}
 
void LinksArray::Clear()
{
do
buflen = #page_links;
count = 0;
active = -1;
}
 
void LinksArray::Hover(dword mx, my, link_col_in, link_col_a)
{
j++;
if (j>=strlen(#page_links)) return;
int i;
if (active>=0)
{
WriteText(links[active].x,links[active].y, 0x80, link_col_in, links[active].text);
DrawBar(links[active].x,links[active].y+8,links[active].w,1, link_col_in);
active = -1;
}
while (page_links[j] <>'|');
for (i=0; i<count; i++)
{
if (mx>links[i].x) && (my>links[i].y) && (mx<links[i].x+links[i].w) && (my<links[i].y+links[i].h)
{
WriteText(links[i].x,links[i].y, 0x80, link_col_a, links[i].text);
DrawBar(links[i].x,links[i].y+8,links[i].w,1, link_col_a);
active = i;
return;
}
page_links[j] = 0x00;
strcpy(#URL, #page_links+strrchr(#page_links, '|'));
return #URL;
}
}
 
void LinksArray::Clear()
{
strcpy(#page_links,"|");
}
 
LinksArray PageLinks;
/programs/cmm/browser/HTMLv.c
25,11 → 25,11
#include "img\URLgoto.txt";
 
#ifdef LANG_RUS
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.61";
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.63";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "â® ¯®á«¥¤­¨© á« ©¤"
#else
char version[]=" Text-based Browser 0.99.61";
char version[]=" Text-based Browser 0.99.63";
?define IMAGES_CACHE_CLEARED "Images cache cleared"
?define T_LAST_SLIDE "This slide is the last"
#endif
91,6 → 91,7
edit_box_mouse stdcall (#address_box);
 
m.get();
PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active);
if (m.y>WB1.list.y) && (m.y<Form.height) && (filesize)
{
238,7 → 239,7
return;
 
case 002: //free img cache
ImgCache1.Free();
ImgCache.Free();
notify(IMAGES_CACHE_CLEARED);
WB1.ParseHTML(buf);
return;
337,7 → 338,7
 
void ProcessLinks(int id)
{
strcpy(#URL, PageLinks.GetURL(id));
strcpy(#URL, PageLinks.GetURL(id-401));
//$1 - Condition Script
if (URL[0] == '$')