forked from KolibriOS/kolibrios
WebView 1.38: readable big headers, fix <li> and <hr> tag, fix show source
git-svn-id: svn://kolibrios.org@5773 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
1b46e09ba6
commit
1936dd7a63
@ -101,8 +101,8 @@ void TWebBrowser::DrawStyle()
|
||||
if (style.s) DrawBuf.DrawBar(start_x, list.line_h / 2 - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
||||
if (style.u) DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
||||
if (link) {
|
||||
DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
||||
PageLinks.AddText(#line, line_length, list.line_h, UNDERLINE);
|
||||
DrawBuf.DrawBar(start_x, list.line_h*style.h + list.line_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
||||
PageLinks.AddText(#line, line_length, list.line_h*style.h + list.line_h, UNDERLINE);
|
||||
}
|
||||
stolbec += stolbec_len;
|
||||
}
|
||||
@ -118,10 +118,8 @@ void TWebBrowser::Prepare(){
|
||||
word bukva[2];
|
||||
int j;
|
||||
byte ignor_param;
|
||||
char temp[768];
|
||||
dword bufpos = bufpointer;
|
||||
dword bufpos;
|
||||
int line_len;
|
||||
|
||||
style.b = style.i = style.u = style.s = style.h = style.blq = t_html = t_body =
|
||||
style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0;
|
||||
style.align = ALIGN_LEFT;
|
||||
@ -134,30 +132,27 @@ void TWebBrowser::Prepare(){
|
||||
stroka = -list.first;
|
||||
stolbec = 0;
|
||||
line = 0;
|
||||
|
||||
//for plaint text use CP866 for other UTF
|
||||
if (strstri(bufpointer, "html"))
|
||||
{
|
||||
style.pre = 0;
|
||||
cur_encoding = CH_CP866;
|
||||
cur_encoding = CH_UTF8;
|
||||
}
|
||||
else
|
||||
{
|
||||
style.pre = 1;
|
||||
cur_encoding = CH_UTF8;
|
||||
cur_encoding = CH_CP866;
|
||||
}
|
||||
|
||||
for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;)
|
||||
for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
|
||||
{
|
||||
if (ignor_text) && (ESBYTE[bufpos]!='<') continue;
|
||||
bukva = ESBYTE[bufpos];
|
||||
if (ignor_text) && (bukva!='<') continue;
|
||||
switch (bukva)
|
||||
{
|
||||
case 0x0a:
|
||||
if (style.pre)
|
||||
{
|
||||
chrcat(#line, ' ');
|
||||
bukva = temp = NULL;
|
||||
Perenos();
|
||||
break;
|
||||
}
|
||||
@ -170,7 +165,6 @@ void TWebBrowser::Prepare(){
|
||||
break;
|
||||
}
|
||||
goto DEFAULT_MARK;
|
||||
|
||||
case '&': // and so on
|
||||
bufpos++;
|
||||
tag=0;
|
||||
@ -212,7 +206,7 @@ void TWebBrowser::Prepare(){
|
||||
Perenos();
|
||||
DrawStyle();
|
||||
line = NULL;
|
||||
if (tag) SetStyle(WB1.DrawBuf.zoom * 5 + list.x, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ
|
||||
if (tag) SetStyle(); //îáðàáîòêà òåãîâ
|
||||
strcpy(#oldtag, #tag);
|
||||
tag = attr = tagparam = ignor_param = NULL;
|
||||
break;
|
||||
@ -245,9 +239,9 @@ void TWebBrowser::Perenos()
|
||||
{
|
||||
int perenos_num;
|
||||
char new_line_text[4096];
|
||||
if (stolbec + utf8_strlen(#line) < list.column_max) return;
|
||||
if (utf8_strlen(#line)*DrawBuf.zoom + stolbec < list.column_max) return;
|
||||
perenos_num = strrchr(#line, ' ');
|
||||
if (!perenos_num) && (utf8_strlen(#line)>list.column_max) perenos_num=list.column_max;
|
||||
if (!perenos_num) && (utf8_strlen(#line)*DrawBuf.zoom>list.column_max) perenos_num=list.column_max/DrawBuf.zoom;
|
||||
strcpy(#new_line_text, #line + perenos_num);
|
||||
line[perenos_num] = 0x00;
|
||||
DrawStyle();
|
||||
@ -255,8 +249,9 @@ void TWebBrowser::Perenos()
|
||||
NewLine();
|
||||
}
|
||||
//============================================================================================
|
||||
void TWebBrowser::SetStyle(int left1, top1) {
|
||||
dword hr_color;
|
||||
void TWebBrowser::SetStyle() {
|
||||
int left1 = 5 + list.x;
|
||||
int top1 = stroka * list.line_h + list.y + 5;
|
||||
byte opened;
|
||||
byte meta_encoding;
|
||||
//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
|
||||
@ -266,7 +261,6 @@ void TWebBrowser::SetStyle(int left1, top1) {
|
||||
strcpy(#tag, #tag+1);
|
||||
}
|
||||
else opened = 1;
|
||||
|
||||
if (istag("html")) {
|
||||
t_html = opened;
|
||||
return;
|
||||
@ -394,15 +388,14 @@ void TWebBrowser::SetStyle(int left1, top1) {
|
||||
if (opened) NewLine();
|
||||
return;
|
||||
}
|
||||
if (istag("li")) || (istag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
|
||||
if (istag("li")) || (istag("dt"))
|
||||
{
|
||||
style.li = opened;
|
||||
if (opened)
|
||||
{
|
||||
NewLine();
|
||||
if (stroka > -1) && (stroka - 2 < list.visible)
|
||||
DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, list.line_h
|
||||
/ 2 - DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x555555);
|
||||
DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, stroka +1 * list.line_h - 3
|
||||
- DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x454545);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -416,15 +409,13 @@ void TWebBrowser::SetStyle(int left1, top1) {
|
||||
else style.li_tab++;
|
||||
}
|
||||
if (istag("hr")) {
|
||||
if (anchor) || (stroka < -1)
|
||||
{
|
||||
stroka+=2;
|
||||
return;
|
||||
}
|
||||
if (strcmp(#attr, "color=") == 0) hr_color = GetColor(#val); else hr_color = 0x999999;
|
||||
if (isattr("color=")) EDI = GetColor(#val); else EDI = 0x999999;
|
||||
$push edi;
|
||||
NewLine();
|
||||
DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
|
||||
$pop edi;
|
||||
DrawBuf.DrawBar(5, list.line_h*stroka+4, list.w-10, 1, EDI);
|
||||
NewLine();
|
||||
return;
|
||||
}
|
||||
if (istag("meta")) || (istag("?xml")) {
|
||||
do{
|
||||
|
@ -18,6 +18,7 @@ struct LinksArray {
|
||||
void Hover();
|
||||
void AddLink();
|
||||
void AddText();
|
||||
void ClickLink();
|
||||
dword GetURL();
|
||||
void Clear();
|
||||
void GetAbsoluteURL();
|
||||
@ -68,15 +69,17 @@ PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, #temp, 0
|
||||
void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
|
||||
{
|
||||
int i;
|
||||
signed int WBY = -WB1.list.first*WB1.list.line_h + WB1.list.line_h - WB1.DrawBuf.zoom;
|
||||
signed int WBY = -WB1.list.first*WB1.list.line_h - WB1.DrawBuf.zoom;
|
||||
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)
|
||||
{
|
||||
if (mouse.down) DrawRectangle(links[active].x, links[active].y, links[active].w, links[active].h, 0);
|
||||
if (mouse.up) ClickLink();
|
||||
if (active==i) return;
|
||||
CursorPointer.Set();
|
||||
if (links[active].underline) DrawBar(links[active].x, WBY + links[active].y,links[active].w, WB1.DrawBuf.zoom, link_col_in);
|
||||
if (links[i].underline) DrawBar(links[i].x, WBY + links[i].y,links[i].w, WB1.DrawBuf.zoom, bg_col);
|
||||
if (links[active].underline) DrawBar(links[active].x, WBY + links[active].y + links[active].h,links[active].w, WB1.DrawBuf.zoom, link_col_in);
|
||||
if (links[i].underline) DrawBar(links[i].x, WBY + links[i].y + links[i].h,links[i].w, WB1.DrawBuf.zoom, bg_col);
|
||||
active = i;
|
||||
status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
|
||||
status_text.start_y = Form.cheight - STATUSBAR_H + 3;
|
||||
@ -91,7 +94,7 @@ void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
|
||||
if (active!=-1)
|
||||
{
|
||||
CursorPointer.Restore();
|
||||
if (links[active].underline) DrawBar(links[active].x, WBY + links[active].y,links[active].w, WB1.DrawBuf.zoom, link_col_in);
|
||||
if (links[active].underline) DrawBar(links[active].x, WBY + links[active].y + links[active].h,links[active].w, WB1.DrawBuf.zoom, link_col_in);
|
||||
DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
|
||||
active = -1;
|
||||
}
|
||||
@ -161,3 +164,54 @@ void LinksArray::GetAbsoluteURL(dword in_URL)
|
||||
strcpy(orig_URL, #newurl);
|
||||
}
|
||||
|
||||
void LinksArray::ClickLink()
|
||||
{
|
||||
if (http_transfer > 0)
|
||||
{
|
||||
StopLoading();
|
||||
BrowserHistory.current--;
|
||||
}
|
||||
|
||||
strcpy(#URL, PageLinks.GetURL(PageLinks.active));
|
||||
//#1
|
||||
if (URL[0] == '#')
|
||||
{
|
||||
strcpy(#anchor, #URL+strrchr(#URL, '#'));
|
||||
strcpy(#URL, BrowserHistory.CurrentUrl());
|
||||
WB1.list.first=WB1.list.count-WB1.list.visible;
|
||||
ShowPage();
|
||||
return;
|
||||
}
|
||||
//liner.ru#1
|
||||
if (strrchr(#URL, '#')!=-1)
|
||||
{
|
||||
strcpy(#anchor, #URL+strrchr(#URL, '#'));
|
||||
URL[strrchr(#URL, '#')-1] = 0x00;
|
||||
}
|
||||
|
||||
PageLinks.GetAbsoluteURL(#URL);
|
||||
|
||||
if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1)
|
||||
|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1)
|
||||
{
|
||||
//notify(#URL);
|
||||
if (!strncmp(#URL,"http://", 7))
|
||||
{
|
||||
strcpy(#DL_URL, #URL);
|
||||
CreateThread(#Downloader,#downloader_stak+4092);
|
||||
}
|
||||
else RunProgram("@open", #URL);
|
||||
strcpy(#editURL, BrowserHistory.CurrentUrl());
|
||||
strcpy(#URL, BrowserHistory.CurrentUrl());
|
||||
return;
|
||||
}
|
||||
if (!strncmp(#URL,"mailto:", 7))
|
||||
{
|
||||
notify(#URL);
|
||||
strcpy(#editURL, BrowserHistory.CurrentUrl());
|
||||
strcpy(#URL, BrowserHistory.CurrentUrl());
|
||||
return;
|
||||
}
|
||||
OpenPage();
|
||||
return;
|
||||
}
|
||||
|
@ -13,28 +13,26 @@
|
||||
#include "..\lib\draw_buf.h"
|
||||
#include "..\lib\list_box.h"
|
||||
#include "..\lib\cursor.h"
|
||||
|
||||
//*.obj libraries
|
||||
#include "..\lib\obj\box_lib.h"
|
||||
#include "..\lib\obj\libio_lib.h"
|
||||
#include "..\lib\obj\libimg_lib.h"
|
||||
#include "..\lib\obj\http.h"
|
||||
#include "..\lib\obj\iconv.h"
|
||||
|
||||
//useful patterns
|
||||
#include "..\lib\patterns\libimg_load_skin.h"
|
||||
|
||||
char homepage[] = FROM "html\\homepage.htm";
|
||||
|
||||
#ifdef LANG_RUS
|
||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 1.35";
|
||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 1.38";
|
||||
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
||||
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
||||
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
||||
char page_not_found[] = FROM "html\page_not_found_ru.htm";
|
||||
char accept_language[]= "Accept-Language: ru\n";
|
||||
#else
|
||||
char version[]=" Text-based Browser 1.35";
|
||||
char version[]=" Text-based Browser 1.38";
|
||||
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
||||
?define T_LAST_SLIDE "This slide is the last"
|
||||
char loading[] = "Loading...<br>";
|
||||
@ -42,14 +40,14 @@ char homepage[] = FROM "html\\homepage.htm";
|
||||
char accept_language[]= "Accept-Language: en\n";
|
||||
#endif
|
||||
|
||||
#define URL_SERVICE_HISTORY "WebView://history"
|
||||
#define URL_SERVICE_HOME "WebView://home"
|
||||
#define URL_SERVICE_SOURCE "WebView://source:"
|
||||
|
||||
|
||||
proc_info Form;
|
||||
#define WIN_W 799
|
||||
#define WIN_H 559
|
||||
|
||||
//char search_path[]="http://nigma.ru/index.php?s=";
|
||||
char str_location[]="location\0";
|
||||
int redirected = 0;
|
||||
|
||||
char stak[4096];
|
||||
@ -95,12 +93,6 @@ char editURL[sizeof(URL)];
|
||||
int mouse_twb;
|
||||
edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
|
||||
|
||||
#define URL_SERVICE_HISTORY "WebView://history"
|
||||
#define URL_SERVICE_HOME "WebView://home"
|
||||
#define URL_SERVICE_SOURCE "WebView://source:"
|
||||
|
||||
libimg_image skin;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -134,12 +126,6 @@ void main()
|
||||
PageLinks.Hover(mouse.x, WB1.list.first*WB1.list.line_h + mouse.y, link_color_inactive, link_color_active, bg_color);
|
||||
if (bufsize) && (mouse.pkm) && (mouse.up) { CreateThread(#menu_rmb,#stak+4092); break; }
|
||||
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
|
||||
if (mouse.down) && (PageLinks.active>=0)
|
||||
{
|
||||
DrawRectangle(PageLinks.links[PageLinks.active].x, PageLinks.links[PageLinks.active].y,
|
||||
PageLinks.links[PageLinks.active].w, PageLinks.links[PageLinks.active].h, 0);
|
||||
ClickLink();
|
||||
}
|
||||
}
|
||||
//Drag scroller
|
||||
scroll_wv.all_redraw = 0;
|
||||
@ -180,7 +166,7 @@ void main()
|
||||
|
||||
case evReDraw:
|
||||
if (action_buf) Scan(action_buf);
|
||||
DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,col_bg,0,0);
|
||||
DefineAndDrawWindow(GetScreenWidth()-800/2,GetScreenHeight()-600/2,800,600,0x73,col_bg,0,0);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
if (Form.status_window>2) { DrawTitle(#header); break; }
|
||||
if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
|
||||
@ -208,7 +194,7 @@ void main()
|
||||
redirected++;
|
||||
if (redirected<=5)
|
||||
{
|
||||
http_find_header_field stdcall (http_transfer, #str_location);
|
||||
http_find_header_field stdcall (http_transfer, "location\0");
|
||||
if (EAX!=0) {
|
||||
ESI = EAX;
|
||||
EDI = #URL;
|
||||
@ -267,7 +253,7 @@ void SetElementSizes()
|
||||
WB1.list.wheel_size = 7;
|
||||
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w;
|
||||
WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h;
|
||||
if (WB1.list.w!=WB1.DrawBuf.bufw) WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h * 20);
|
||||
if (WB1.list.w!=WB1.DrawBuf.bufw) WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h * 30);
|
||||
}
|
||||
|
||||
void Draw_Window()
|
||||
@ -352,7 +338,7 @@ void Scan(dword id__)
|
||||
case VIEW_SOURCE:
|
||||
WB1.list.first = 0;
|
||||
ShowSource();
|
||||
WB1.DrawPage();
|
||||
WB1.LoadInternalPage(bufpointer, bufsize);
|
||||
break;
|
||||
case EDIT_SOURCE:
|
||||
if (!strncmp(#URL,"http:",5))
|
||||
@ -390,59 +376,6 @@ void Scan(dword id__)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ClickLink()
|
||||
{
|
||||
if (http_transfer > 0)
|
||||
{
|
||||
StopLoading();
|
||||
BrowserHistory.current--;
|
||||
}
|
||||
|
||||
strcpy(#URL, PageLinks.GetURL(PageLinks.active));
|
||||
//#1
|
||||
if (URL[0] == '#')
|
||||
{
|
||||
strcpy(#anchor, #URL+strrchr(#URL, '#'));
|
||||
strcpy(#URL, BrowserHistory.CurrentUrl());
|
||||
WB1.list.first=WB1.list.count-WB1.list.visible;
|
||||
ShowPage();
|
||||
return;
|
||||
}
|
||||
//liner.ru#1
|
||||
if (strrchr(#URL, '#')!=-1)
|
||||
{
|
||||
strcpy(#anchor, #URL+strrchr(#URL, '#'));
|
||||
URL[strrchr(#URL, '#')-1] = 0x00;
|
||||
}
|
||||
|
||||
PageLinks.GetAbsoluteURL(#URL);
|
||||
|
||||
if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1)
|
||||
|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1)
|
||||
{
|
||||
//notify(#URL);
|
||||
if (!strncmp(#URL,"http://", 7))
|
||||
{
|
||||
strcpy(#DL_URL, #URL);
|
||||
CreateThread(#Downloader,#downloader_stak+4092);
|
||||
}
|
||||
else RunProgram("@open", #URL);
|
||||
strcpy(#editURL, BrowserHistory.CurrentUrl());
|
||||
strcpy(#URL, BrowserHistory.CurrentUrl());
|
||||
return;
|
||||
}
|
||||
if (!strncmp(#URL,"mailto:", 7))
|
||||
{
|
||||
notify(#URL);
|
||||
strcpy(#editURL, BrowserHistory.CurrentUrl());
|
||||
strcpy(#URL, BrowserHistory.CurrentUrl());
|
||||
return;
|
||||
}
|
||||
OpenPage();
|
||||
return;
|
||||
}
|
||||
|
||||
void StopLoading()
|
||||
{
|
||||
if (http_transfer)
|
||||
@ -531,20 +464,15 @@ void ShowPage()
|
||||
DrawEditBox();
|
||||
if (!bufsize)
|
||||
{
|
||||
PageLinks.Clear();
|
||||
if (http_transfer)
|
||||
{
|
||||
WB1.LoadInternalPage(#loading, sizeof(loading));
|
||||
}
|
||||
else
|
||||
WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
||||
if (http_transfer) WB1.LoadInternalPage(#loading, sizeof(loading));
|
||||
else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
||||
}
|
||||
else
|
||||
{
|
||||
WB1.Prepare();
|
||||
}
|
||||
|
||||
if (!header) strcpy(#header, #version);
|
||||
//if (!header) strcpy(#header, #version);
|
||||
if (!strcmp(#version, #header)) DrawTitle(#header);
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,8 @@ dword ShowSource()
|
||||
souce_mode = true;
|
||||
new_buf = malloc(bufsize*5);
|
||||
new_buf_start = new_buf;
|
||||
if (strlen(#header)-strlen(#version)>0) header[strlen(#header)-strlen(#version)-2] = 0; else strcpy(#header, "Source");
|
||||
new_buf += sprintf(new_buf,"<html><head><title>%s</title><body><pre>",#header);
|
||||
header[strrchr(#header, '-')-2]=0;
|
||||
new_buf += sprintf(new_buf,"<html><head><title>Source: %s</title><body><pre>",#header);
|
||||
for (i=bufpointer; i<bufpointer+bufsize; i++)
|
||||
{
|
||||
ww = ESBYTE[i];
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.0 KiB |
@ -5,9 +5,9 @@
|
||||
#include "../lib/obj/libimg_lib.h"
|
||||
#endif
|
||||
|
||||
struct libimg_image {
|
||||
:struct libimg_image {
|
||||
dword image, w, h;
|
||||
};
|
||||
} skin;
|
||||
|
||||
:void Libimg_LoadImage(dword struct_pointer, file_path)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user