forked from KolibriOS/kolibrios
WebView 2.6: rewrite links, fix crashes
git-svn-id: svn://kolibrios.org@7970 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
ed82b4c1bb
commit
d9aa711ac9
@ -35,7 +35,6 @@ struct TWebBrowser {
|
|||||||
dword o_bufpointer;
|
dword o_bufpointer;
|
||||||
int cur_encoding, custom_encoding;
|
int cur_encoding, custom_encoding;
|
||||||
bool link, t_html, t_body;
|
bool link, t_html, t_body;
|
||||||
dword link_bg;
|
|
||||||
dword bufpointer;
|
dword bufpointer;
|
||||||
dword bufsize;
|
dword bufsize;
|
||||||
dword is_html;
|
dword is_html;
|
||||||
@ -106,7 +105,7 @@ void TWebBrowser::Paint()
|
|||||||
if (link) {
|
if (link) {
|
||||||
if (line[0]==' ') && (line[1]==NULL) {} else {
|
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);
|
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2)-1, line_length, zoom, link_color_default);
|
||||||
PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2)-1, UNDERLINE, zoom);
|
links.add_text(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2)-1, zoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stolbec += stolbec_len;
|
stolbec += stolbec_len;
|
||||||
@ -123,10 +122,9 @@ void TWebBrowser::SetPageDefaults()
|
|||||||
link_color_default = 0x0000FF;
|
link_color_default = 0x0000FF;
|
||||||
link_color_active = 0xFF0000;
|
link_color_active = 0xFF0000;
|
||||||
page_bg = 0xFFFFFF;
|
page_bg = 0xFFFFFF;
|
||||||
link_bg = 0xFFFFFF;
|
|
||||||
style.bg_color = page_bg;
|
style.bg_color = page_bg;
|
||||||
DrawBuf.Fill(0, page_bg);
|
DrawBuf.Fill(0, page_bg);
|
||||||
PageLinks.Clear();
|
links.clear();
|
||||||
anchors.clear();
|
anchors.clear();
|
||||||
header = NULL;
|
header = NULL;
|
||||||
cur_encoding = CH_CP866;
|
cur_encoding = CH_CP866;
|
||||||
@ -341,10 +339,9 @@ void TWebBrowser::SetStyle() {
|
|||||||
t_body = tag.opened;
|
t_body = tag.opened;
|
||||||
if (value = tag.get_value_of("link=")) link_color_default = GetColor(value);
|
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("alink=")) link_color_active = GetColor(value);
|
||||||
if (value = tag.get_value_of("bglink=")) link_bg=GetColor(value);
|
|
||||||
if (value = tag.get_value_of("text=")) text_colors[0]=GetColor(value);
|
if (value = tag.get_value_of("text=")) text_colors[0]=GetColor(value);
|
||||||
if (value = tag.get_value_of("bgcolor=")) {
|
if (value = tag.get_value_of("bgcolor=")) {
|
||||||
style.bg_color = page_bg = link_bg = GetColor(value);
|
style.bg_color = page_bg = GetColor(value);
|
||||||
DrawBuf.Fill(0, page_bg);
|
DrawBuf.Fill(0, page_bg);
|
||||||
}
|
}
|
||||||
// Autodetecting encoding if no encoding was set
|
// Autodetecting encoding if no encoding was set
|
||||||
@ -366,8 +363,7 @@ void TWebBrowser::SetStyle() {
|
|||||||
if (value = tag.get_value_of("href=")) && (!strstr(value,"javascript:"))
|
if (value = tag.get_value_of("href=")) && (!strstr(value,"javascript:"))
|
||||||
{
|
{
|
||||||
link = true;
|
link = true;
|
||||||
PageLinks.AddLink(value);
|
links.add_link(value);
|
||||||
style.bg_color = link_bg;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
link = false;
|
link = false;
|
||||||
@ -380,7 +376,7 @@ void TWebBrowser::SetStyle() {
|
|||||||
strcpy(#line, "IFRAME: ");
|
strcpy(#line, "IFRAME: ");
|
||||||
Paint();
|
Paint();
|
||||||
link=true;
|
link=true;
|
||||||
PageLinks.AddLink(value);
|
links.add_link(value);
|
||||||
strncpy(#line, value, sizeof(line)-1);
|
strncpy(#line, value, sizeof(line)-1);
|
||||||
while (CheckForLineBreak()) {};
|
while (CheckForLineBreak()) {};
|
||||||
Paint();
|
Paint();
|
||||||
|
@ -37,7 +37,7 @@ void _anchors::take_anchor_from(dword _URL)
|
|||||||
int anchor_pos;
|
int anchor_pos;
|
||||||
if (!current) && (_URL) && (anchor_pos = strrchr(_URL, '#')) {
|
if (!current) && (_URL) && (anchor_pos = strrchr(_URL, '#')) {
|
||||||
strncpy(#current, _URL+anchor_pos-1, sizeof(_anchors.current)-1);
|
strncpy(#current, _URL+anchor_pos-1, sizeof(_anchors.current)-1);
|
||||||
ESBYTE[_URL+anchor_pos-1] = EOS;
|
ESBYTE[_URL+anchor_pos-1] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ void ImageCache::Images(dword left1, top1, width1)
|
|||||||
DrawBar(WB1.list.x, top1+imgh, WB1.list.w, -imgh % WB1.list.item_h + WB1.list.item_h, page_bg);
|
DrawBar(WB1.list.x, top1+imgh, WB1.list.w, -imgh % WB1.list.item_h + WB1.list.item_h, page_bg);
|
||||||
if (link)
|
if (link)
|
||||||
{
|
{
|
||||||
UnsafeDefineButton(left1 - 5, top1, imgw, imgh-1, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
|
UnsafeDefineButton(left1 - 5, top1, imgw, imgh-1, links.count + 400 + BT_HIDE, 0xB5BFC9);
|
||||||
PageLinks.AddText(0, imgw, imgh-1, NOLINE, 1);
|
links.AddText(0, imgw, imgh-1, NOLINE, 1);
|
||||||
WB1.DrawPage();
|
WB1.DrawPage();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@ -2,153 +2,111 @@ CustomCursor CursorPointer;
|
|||||||
dword CursorFile = FROM "../TWB/pointer.cur";
|
dword CursorFile = FROM "../TWB/pointer.cur";
|
||||||
#include "..\lib\collection.h"
|
#include "..\lib\collection.h"
|
||||||
|
|
||||||
#define NOLINE 0
|
struct PAGE_LINKS {
|
||||||
#define UNDERLINE 1
|
collection_int link;
|
||||||
|
collection_int x;
|
||||||
|
collection_int y;
|
||||||
|
collection_int w;
|
||||||
|
collection_int h;
|
||||||
|
collection_int id;
|
||||||
|
collection_int underline_h;
|
||||||
|
|
||||||
#define MAXLINKS 2000
|
|
||||||
|
|
||||||
bool open_new_window=false;
|
|
||||||
bool open_new_tab=false;
|
|
||||||
|
|
||||||
struct array_link {
|
|
||||||
dword link;
|
|
||||||
unsigned int x,y,w,h;
|
|
||||||
unsigned int unic_id;
|
|
||||||
int underline, underline_h;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LinksArray {
|
|
||||||
array_link links[MAXLINKS];
|
|
||||||
collection page_links;
|
collection page_links;
|
||||||
unsigned int count;
|
signed int active;
|
||||||
unsigned int unic_count;
|
dword active_url;
|
||||||
unsigned int active;
|
bool hover();
|
||||||
bool HoverAndProceed();
|
void add_link();
|
||||||
bool Click();
|
void add_text();
|
||||||
void AddLink();
|
void clear();
|
||||||
void AddText();
|
void draw_underline();
|
||||||
dword GetURL();
|
} links;
|
||||||
void Clear();
|
|
||||||
void DrawUnderline();
|
|
||||||
} PageLinks;
|
|
||||||
|
|
||||||
void LinksArray::AddLink(dword lpath)
|
void PAGE_LINKS::add_link(dword lpath)
|
||||||
{
|
{
|
||||||
if (count>= MAXLINKS) return;
|
|
||||||
page_links.add(lpath);
|
page_links.add(lpath);
|
||||||
unic_count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinksArray::AddText(dword _x, _y, _w, _h, _link_underline, _underline_h)
|
void PAGE_LINKS::add_text(dword _x, _y, _w, _h, _underline_h)
|
||||||
{
|
{
|
||||||
if (count>= MAXLINKS) return;
|
x.add(_x);
|
||||||
links[count].x = _x;
|
y.add(_y);
|
||||||
links[count].y = _y;
|
w.add(_w);
|
||||||
links[count].w = _w;
|
h.add(_h);
|
||||||
links[count].h = _h;
|
underline_h.add(_underline_h);
|
||||||
links[count].underline = _link_underline;
|
link.add(page_links.get_last());
|
||||||
links[count].underline_h = _underline_h;
|
id.add(page_links.count);
|
||||||
links[count].link = page_links.get(page_links.count-1);
|
|
||||||
links[count].unic_id = unic_count;
|
|
||||||
count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dword LinksArray::GetURL(int id)
|
void PAGE_LINKS::clear()
|
||||||
{
|
{
|
||||||
return links[id].link;
|
x.drop();
|
||||||
}
|
y.drop();
|
||||||
|
w.drop();
|
||||||
|
h.drop();
|
||||||
|
underline_h.drop();
|
||||||
|
link.drop();
|
||||||
|
id.drop();
|
||||||
|
|
||||||
void LinksArray::Clear()
|
|
||||||
{
|
|
||||||
page_links.drop();
|
page_links.drop();
|
||||||
page_links.realloc_size = 4096 * 32;
|
page_links.realloc_size = 4096 * 32;
|
||||||
count = 0;
|
|
||||||
active = -1;
|
active = -1;
|
||||||
unic_count = 0;
|
active_url = 0;
|
||||||
CursorPointer.Restore();
|
CursorPointer.Restore();
|
||||||
open_new_window = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinksArray::DrawUnderline(dword und_id, list_first, list_y, color)
|
void PAGE_LINKS::draw_underline(signed _id, dword list_first, list_y, color)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<count; i++)
|
if (_id == -1) return;
|
||||||
|
for (i=0; i<id.count; i++)
|
||||||
{
|
{
|
||||||
if (links[i].unic_id==links[und_id].unic_id) && (links[i].y + links[i].h - list_first > list_y) {
|
if (id.get(i) - id.get(_id) == 0)
|
||||||
DrawBar(links[i].x, links[i].y + links[i].h - list_first, links[i].w, links[i].underline_h, color);
|
&& (y.get(i) + h.get(i) - list_first > list_y) {
|
||||||
|
DrawBar(x.get(i), y.get(i) + h.get(i) - list_first,
|
||||||
|
w.get(i), underline_h.get(i), color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PathShow_data status_text = {0, 17,250, 6, 250};
|
bool PAGE_LINKS::hover(dword list_y, list_first)
|
||||||
|
|
||||||
bool LinksArray::Click(dword list_first)
|
|
||||||
{
|
|
||||||
if (mouse.lkm) && (mouse.down) {
|
|
||||||
DrawRectangle(links[active].x, -list_first + links[active].y,
|
|
||||||
links[active].w, links[active].h, 0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (mouse.mkm) && (mouse.up) {
|
|
||||||
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
|
|
||||||
open_new_window = true;
|
|
||||||
EventClickLink(PageLinks.GetURL(PageLinks.active));
|
|
||||||
open_new_window = false;
|
|
||||||
} else {
|
|
||||||
open_new_tab = true;
|
|
||||||
EventClickLink(PageLinks.GetURL(PageLinks.active));
|
|
||||||
open_new_tab = false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (mouse.lkm) && (mouse.up) {
|
|
||||||
CursorPointer.Restore();
|
|
||||||
EventClickLink(PageLinks.GetURL(PageLinks.active));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (mouse.pkm) && (mouse.up) {
|
|
||||||
EventShowLinkMenu();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LinksArray::HoverAndProceed(dword mx, my, list_y, list_first)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (!count) return true;
|
int mx = mouse.x;
|
||||||
for (i=0; i<count; i++)
|
int my = mouse.y + list_first;
|
||||||
|
if (!id.count) return false;
|
||||||
|
|
||||||
|
//Here we check is any link hovered
|
||||||
|
for (i=0; i<id.count; i++)
|
||||||
{
|
{
|
||||||
if (mx>links[i].x) && (my>links[i].y)
|
if (mx>x.get(i)) && (my>y.get(i))
|
||||||
&& (mx<links[i].x+links[i].w) && (my<links[i].y+links[i].h)
|
&& (mx<x.get(i)+w.get(i)) && (my<y.get(i)+h.get(i))
|
||||||
&& (my>list_y+list_first)
|
&& (my>list_y+list_first)
|
||||||
{
|
{
|
||||||
if (active!=i) {
|
if (active!=i) {
|
||||||
CursorPointer.Load(#CursorFile);
|
CursorPointer.Load(#CursorFile);
|
||||||
CursorPointer.Set();
|
CursorPointer.Set();
|
||||||
|
|
||||||
if (links[active].underline) {
|
draw_underline(active, list_first, list_y, link_color_default);
|
||||||
DrawUnderline(active, list_first, list_y, link_color_default);
|
draw_underline(i, list_first, list_y, page_bg);
|
||||||
}
|
|
||||||
|
|
||||||
if (links[i].underline) {
|
|
||||||
DrawUnderline(i, list_first, list_y, page_bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
active_url = link.get(i);
|
||||||
active = i;
|
active = i;
|
||||||
DrawStatusBar(links[active].link);
|
DrawStatusBar();
|
||||||
|
}
|
||||||
|
if (mouse.lkm) && (mouse.down) {
|
||||||
|
DrawRectangle(x.get(active), -list_first + y.get(active),
|
||||||
|
w.get(active), h.get(active), 0);
|
||||||
}
|
}
|
||||||
Click(list_first);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (active!=-1)
|
if (active_url) {
|
||||||
{
|
|
||||||
CursorPointer.Restore();
|
CursorPointer.Restore();
|
||||||
if (links[active].underline) {
|
draw_underline(active, list_first, list_y, link_color_default);
|
||||||
DrawUnderline(active, list_first, list_y, link_color_default);
|
active_url = 0;
|
||||||
}
|
|
||||||
DrawStatusBar(NULL);
|
|
||||||
active = -1;
|
active = -1;
|
||||||
|
DrawStatusBar();
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,18 +71,18 @@ bool _tag::get_next_param()
|
|||||||
{
|
{
|
||||||
//remove quotes
|
//remove quotes
|
||||||
quotes = params[i];
|
quotes = params[i];
|
||||||
params[i] = EOS;
|
params[i] = '\0';
|
||||||
i--;
|
i--;
|
||||||
|
|
||||||
//find VAL start and copy
|
//find VAL start and copy
|
||||||
i = strrchr(#params, quotes);
|
i = strrchr(#params, quotes);
|
||||||
strlcpy(#val, #params + i, sizeof(val)-1);
|
strlcpy(#val, #params + i, sizeof(val)-1);
|
||||||
params[i] = EOS;
|
params[i] = '\0';
|
||||||
i--;
|
i--;
|
||||||
|
|
||||||
//find ATTR end
|
//find ATTR end
|
||||||
while (i > 0) && (params[i] != '=') i--;
|
while (i > 0) && (params[i] != '=') i--;
|
||||||
params[i+1] = EOS;
|
params[i+1] = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -64,6 +64,8 @@ enum {
|
|||||||
TAB_CLOSE_ID = 900
|
TAB_CLOSE_ID = 900
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB };
|
||||||
|
|
||||||
#include "..\TWB\TWB.c" //HTML Parser, a core component
|
#include "..\TWB\TWB.c" //HTML Parser, a core component
|
||||||
|
|
||||||
TWebBrowser WB1;
|
TWebBrowser WB1;
|
||||||
@ -125,7 +127,6 @@ void HandleParam()
|
|||||||
ExitProcess();
|
ExitProcess();
|
||||||
} else if (!strncmp(#param, "-download ", 10)) {
|
} else if (!strncmp(#param, "-download ", 10)) {
|
||||||
strcpy(#downloader_edit, #param+10);
|
strcpy(#downloader_edit, #param+10);
|
||||||
//CreateThread(#Downloader,#downloader_stak+4092);
|
|
||||||
Downloader();
|
Downloader();
|
||||||
ExitProcess();
|
ExitProcess();
|
||||||
} else if (!strncmp(#param, "-source ", 8)) {
|
} else if (!strncmp(#param, "-source ", 8)) {
|
||||||
@ -151,7 +152,7 @@ void HandleParam()
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
int i, btn, redirect_count=0;
|
int i, redirect_count=0;
|
||||||
LoadLibraries();
|
LoadLibraries();
|
||||||
CreateDir("/tmp0/1/Downloads");
|
CreateDir("/tmp0/1/Downloads");
|
||||||
//CreateDir("/tmp0/1/WebView_Cache");
|
//CreateDir("/tmp0/1/WebView_Cache");
|
||||||
@ -165,33 +166,47 @@ void main()
|
|||||||
case evMouse:
|
case evMouse:
|
||||||
edit_box_mouse stdcall (#address_box);
|
edit_box_mouse stdcall (#address_box);
|
||||||
mouse.get();
|
mouse.get();
|
||||||
PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y, WB1.list.y, WB1.list.first);
|
|
||||||
if (PageLinks.active == -1) && (mouse.pkm) && (mouse.up) {
|
|
||||||
if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
|
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
|
||||||
|
|
||||||
scrollbar_v_mouse (#scroll_wv);
|
scrollbar_v_mouse (#scroll_wv);
|
||||||
if (WB1.list.first != scroll_wv.position)
|
if (scroll_wv.delta) {
|
||||||
{
|
|
||||||
WB1.list.first = scroll_wv.position;
|
WB1.list.first = scroll_wv.position;
|
||||||
WB1.DrawPage();
|
WB1.DrawPage();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (mouse.up) && (! address_box.flags & ed_focus) && (address_box.flags & ed_shift_bac)
|
|
||||||
|
if (links.hover(WB1.list.y, WB1.list.first))
|
||||||
{
|
{
|
||||||
DrawOmnibox(); //reset text selection
|
if (mouse.mkm) {
|
||||||
|
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
|
||||||
|
EventClickLink(TARGET_NEW_WINDOW);
|
||||||
|
} else {
|
||||||
|
EventClickLink(TARGET_NEW_TAB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mouse.lkm) {
|
||||||
|
CursorPointer.Restore();
|
||||||
|
EventClickLink(TARGET_SAME_TAB);
|
||||||
|
}
|
||||||
|
if (mouse.pkm) {
|
||||||
|
CursorPointer.Restore();
|
||||||
|
EventShowLinkMenu();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CursorPointer.Restore();
|
||||||
|
if (mouse.pkm) && (WB1.list.MouseOver(mouse.x, mouse.y)) {
|
||||||
|
EventShowPageMenu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case evButton:
|
case evButton:
|
||||||
btn = GetButtonID();
|
ProcessEvent( GetButtonID() );
|
||||||
if (1==btn) ExitProcess(); else ProcessEvent(btn);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case evKey:
|
case evKey:
|
||||||
GetKeys();
|
GetKeys();
|
||||||
//if (key_scancode == SCAN_CODE_F1) {DebugTabs();break;}
|
|
||||||
|
|
||||||
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
|
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
|
||||||
if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();break;}
|
if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();break;}
|
||||||
@ -352,7 +367,7 @@ void draw_window()
|
|||||||
DrawOmnibox();
|
DrawOmnibox();
|
||||||
}
|
}
|
||||||
DrawProgress();
|
DrawProgress();
|
||||||
DrawStatusBar(NULL);
|
DrawStatusBar();
|
||||||
DrawTabsBar();
|
DrawTabsBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,9 +403,11 @@ void EventChangeEncodingAndLoadPage(int _new_encoding)
|
|||||||
|
|
||||||
void ProcessEvent(dword id__)
|
void ProcessEvent(dword id__)
|
||||||
{
|
{
|
||||||
char new_clip_url[URL_SIZE+1];
|
|
||||||
switch (id__)
|
switch (id__)
|
||||||
{
|
{
|
||||||
|
case 1:
|
||||||
|
ExitProcess();
|
||||||
|
break;
|
||||||
case ENCODINGS...ENCODINGS+6:
|
case ENCODINGS...ENCODINGS+6:
|
||||||
EventChangeEncodingAndLoadPage(id__-ENCODINGS);
|
EventChangeEncodingAndLoadPage(id__-ENCODINGS);
|
||||||
return;
|
return;
|
||||||
@ -450,25 +467,18 @@ void ProcessEvent(dword id__)
|
|||||||
EventRefreshPage();
|
EventRefreshPage();
|
||||||
return;
|
return;
|
||||||
case IN_NEW_TAB:
|
case IN_NEW_TAB:
|
||||||
open_new_tab = true;
|
EventClickLink(TARGET_NEW_TAB);
|
||||||
EventClickLink(PageLinks.GetURL(PageLinks.active));
|
|
||||||
open_new_tab = false;
|
|
||||||
return;
|
return;
|
||||||
case IN_NEW_WINDOW:
|
case IN_NEW_WINDOW:
|
||||||
open_new_window = true;
|
EventClickLink(TARGET_NEW_WINDOW);
|
||||||
EventClickLink(PageLinks.GetURL(PageLinks.active));
|
|
||||||
open_new_window = false;
|
|
||||||
return;
|
return;
|
||||||
case COPY_LINK_URL:
|
case COPY_LINK_URL:
|
||||||
strncpy(#new_clip_url, PageLinks.GetURL(PageLinks.active), URL_SIZE);
|
Clipboard__CopyText(GetAbsoluteActiveURL());
|
||||||
GetAbsoluteURL(#new_clip_url, history.current());
|
|
||||||
Clipboard__CopyText(#new_clip_url);
|
|
||||||
notify("'URL copied to clipboard'O");
|
notify("'URL copied to clipboard'O");
|
||||||
return;
|
return;
|
||||||
case DOWNLOAD_LINK_CONTENTS:
|
case DOWNLOAD_LINK_CONTENTS:
|
||||||
if (!downloader_opened) {
|
if (!downloader_opened) {
|
||||||
strcpy(#downloader_edit, PageLinks.GetURL(PageLinks.active));
|
strcpy(#downloader_edit, GetAbsoluteActiveURL());
|
||||||
GetAbsoluteURL(#downloader_edit, history.current());
|
|
||||||
CreateThread(#Downloader,#downloader_stak+4092);
|
CreateThread(#Downloader,#downloader_stak+4092);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -565,23 +575,20 @@ bool GetLocalFileData(dword _path)
|
|||||||
void OpenPage(dword _open_URL)
|
void OpenPage(dword _open_URL)
|
||||||
{
|
{
|
||||||
char new_url[URL_SIZE+1];
|
char new_url[URL_SIZE+1];
|
||||||
|
char new_url_full[URL_SIZE+1];
|
||||||
int unz_id;
|
int unz_id;
|
||||||
|
|
||||||
StopLoading();
|
StopLoading();
|
||||||
|
|
||||||
if (open_new_tab) {
|
|
||||||
open_new_tab = false;
|
|
||||||
EventOpenNewTab(_open_URL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetOmniboxText(_open_URL);
|
SetOmniboxText(_open_URL);
|
||||||
|
|
||||||
strncpy(#new_url, _open_URL, URL_SIZE);
|
strncpy(#new_url, _open_URL, URL_SIZE);
|
||||||
|
|
||||||
//Exclude # from the URL to the load page
|
//Exclude # from the URL to the load page
|
||||||
//We will bring it back when we get the buffer
|
//We will bring it back when we get the buffer
|
||||||
if (strrchr(#new_url, '#')) anchors.take_anchor_from(#new_url);
|
if (strrchr(#new_url, '#')) {
|
||||||
|
anchors.take_anchor_from(#new_url);
|
||||||
|
}
|
||||||
|
|
||||||
history.add(#new_url);
|
history.add(#new_url);
|
||||||
|
|
||||||
@ -605,9 +612,9 @@ void OpenPage(dword _open_URL)
|
|||||||
if (!strncmp(#new_url,"http:",5)) {
|
if (!strncmp(#new_url,"http:",5)) {
|
||||||
http.get(#new_url);
|
http.get(#new_url);
|
||||||
} else if (!strncmp(#new_url,"https://",8)) {
|
} else if (!strncmp(#new_url,"https://",8)) {
|
||||||
strcpy(#new_url, "http://gate.aspero.pro/?site=");
|
strcpy(#new_url_full, "http://gate.aspero.pro/?site=");
|
||||||
strncat(#new_url, _open_URL, URL_SIZE);
|
strncat(#new_url_full, #new_url, URL_SIZE);
|
||||||
http.get(#new_url);
|
http.get(#new_url_full);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawOmnibox();
|
DrawOmnibox();
|
||||||
@ -631,34 +638,56 @@ void OpenPage(dword _open_URL)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventClickLink(dword _click_URL)
|
|
||||||
|
bool EventClickAnchor()
|
||||||
|
{
|
||||||
|
dword aURL = links.active_url;
|
||||||
|
|
||||||
|
if (anchors.get_pos_by_name(aURL+1)!=-1) {
|
||||||
|
WB1.list.first = anchors.get_pos_by_name(aURL+1);
|
||||||
|
//WB1.list.CheckDoesValuesOkey();
|
||||||
|
strcpy(#editURL, history.current());
|
||||||
|
strcat(#editURL, aURL);
|
||||||
|
DrawOmnibox();
|
||||||
|
WB1.DrawPage();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventClickLink(dword _target)
|
||||||
{
|
{
|
||||||
char new_url[URL_SIZE+1];
|
char new_url[URL_SIZE+1];
|
||||||
char new_url_full[URL_SIZE+1];
|
char new_url_full[URL_SIZE+1];
|
||||||
|
dword aURL = GetAbsoluteActiveURL();
|
||||||
|
if (!aURL) return;
|
||||||
|
|
||||||
if (open_new_window) {
|
strcpy(#new_url, aURL);
|
||||||
strncpy(#new_url, _click_URL, sizeof(new_url));
|
|
||||||
GetAbsoluteURL(#new_url, history.current());
|
if (ESBYTE[aURL]=='#') {
|
||||||
|
if (_target == TARGET_SAME_TAB) {
|
||||||
|
EventClickAnchor();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
strcpy(#new_url, history.current());
|
||||||
|
strcat(#new_url, aURL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_target == TARGET_NEW_TAB) {
|
||||||
|
EventOpenNewTab(#new_url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_target == TARGET_NEW_WINDOW) {
|
||||||
strcpy(#new_url_full, "-new ");
|
strcpy(#new_url_full, "-new ");
|
||||||
strncat(#new_url_full, #new_url, sizeof(new_url_full));
|
strncat(#new_url_full, #new_url, URL_SIZE);
|
||||||
RunProgram(#program_path, #new_url_full);
|
RunProgram(#program_path, #new_url_full);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ESBYTE[_click_URL]=='#') {
|
if (!strncmp(#new_url,"mailto:", 7)) || (!strncmp(#new_url,"tel:", 4)) {
|
||||||
if (anchors.get_pos_by_name(_click_URL+1)!=-1) {
|
notify(#new_url);
|
||||||
WB1.list.first = anchors.get_pos_by_name(_click_URL+1);
|
|
||||||
WB1.list.CheckDoesValuesOkey();
|
|
||||||
}
|
|
||||||
strcpy(#editURL, history.current());
|
|
||||||
strcat(#editURL, _click_URL);
|
|
||||||
DrawOmnibox();
|
|
||||||
WB1.DrawPage();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncmp(_click_URL,"mailto:", 7)) || (!strncmp(_click_URL,"tel:", 4)) {
|
|
||||||
notify(_click_URL);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,9 +696,6 @@ void EventClickLink(dword _click_URL)
|
|||||||
history.back();
|
history.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(#new_url, _click_URL);
|
|
||||||
GetAbsoluteURL(#new_url, history.current());
|
|
||||||
|
|
||||||
if (strrchr(#new_url, '#')!=0) {
|
if (strrchr(#new_url, '#')!=0) {
|
||||||
anchors.take_anchor_from(#new_url);
|
anchors.take_anchor_from(#new_url);
|
||||||
OpenPage(#new_url);
|
OpenPage(#new_url);
|
||||||
@ -717,7 +743,7 @@ void EventSubmitOmnibox()
|
|||||||
OpenPage(#editURL);
|
OpenPage(#editURL);
|
||||||
} else {
|
} else {
|
||||||
strcpy(#new_url, "http://");
|
strcpy(#new_url, "http://");
|
||||||
strncat(#new_url, #editURL, sizeof(new_url)-1);
|
strncat(#new_url, #editURL, URL_SIZE-1);
|
||||||
OpenPage(#new_url);
|
OpenPage(#new_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -733,7 +759,7 @@ void LoadInternalPage(dword _bufdata, _in_bufsize){
|
|||||||
DrawOmnibox();
|
DrawOmnibox();
|
||||||
}
|
}
|
||||||
WB1.ParseHtml(_bufdata, _in_bufsize);
|
WB1.ParseHtml(_bufdata, _in_bufsize);
|
||||||
DrawStatusBar(NULL);
|
DrawStatusBar();
|
||||||
DrawActiveTab();
|
DrawActiveTab();
|
||||||
if (source_mode) {
|
if (source_mode) {
|
||||||
source_mode = false;
|
source_mode = false;
|
||||||
@ -784,7 +810,7 @@ void EventShowMainMenu()
|
|||||||
|
|
||||||
void EventShowEncodingsList()
|
void EventShowEncodingsList()
|
||||||
{
|
{
|
||||||
open_lmenu(Form.left + Form.cwidth, Form.top + skin_height + status_text.start_y + 8,
|
open_lmenu(Form.left + Form.cwidth, Form.top + skin_height + Form.cheight - STATUSBAR_H + 12,
|
||||||
MENU_ALIGN_BOT_RIGHT, WB1.cur_encoding + 1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
|
MENU_ALIGN_BOT_RIGHT, WB1.cur_encoding + 1, "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
|
||||||
menu_id = ENCODINGS;
|
menu_id = ENCODINGS;
|
||||||
}
|
}
|
||||||
@ -895,23 +921,17 @@ void EventUpdateBrowser()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawStatusBar(dword _status_text)
|
void DrawStatusBar()
|
||||||
{
|
{
|
||||||
status_text.font_color = sc.work_text;
|
dword status_y = Form.cheight - STATUSBAR_H + 4;
|
||||||
status_text.start_x = 10;
|
dword status_w = Form.cwidth - 90;
|
||||||
status_text.start_y = Form.cheight - STATUSBAR_H + 4;
|
|
||||||
status_text.area_size_x = Form.cwidth - status_text.start_x -3 - 70;
|
|
||||||
//DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, sc.work);
|
|
||||||
DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
|
DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
|
||||||
if (_status_text) {
|
if (links.active_url) {
|
||||||
status_text.text_pointer = _status_text;
|
ESI = math.min(status_w/6, strlen(links.active_url));
|
||||||
PathShow_prepare stdcall(#status_text);
|
WriteText(10, status_y, 0, sc.work_text, links.active_url);
|
||||||
PathShow_draw stdcall(#status_text);
|
|
||||||
}
|
}
|
||||||
DefineHiddenButton(status_text.start_x+status_text.area_size_x+10, status_text.start_y-3,
|
DefineHiddenButton(status_w+20, status_y-3, 60, 12, CHANGE_ENCODING);
|
||||||
60, 12, CHANGE_ENCODING);
|
WriteTextCenter(status_w+20, status_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets);
|
||||||
WriteTextCenter(status_text.start_x+status_text.area_size_x+10,
|
|
||||||
status_text.start_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawOmnibox()
|
void DrawOmnibox()
|
||||||
@ -941,5 +961,15 @@ void SetOmniboxText(dword _text)
|
|||||||
DrawOmnibox();
|
DrawOmnibox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dword GetAbsoluteActiveURL()
|
||||||
|
{
|
||||||
|
char abs_url[URL_SIZE];
|
||||||
|
if (links.active_url) {
|
||||||
|
strncpy(#abs_url, links.active_url, URL_SIZE);
|
||||||
|
GetAbsoluteURL(#abs_url, history.current());
|
||||||
|
return #abs_url;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
stop:
|
stop:
|
@ -1,4 +1,4 @@
|
|||||||
char version[]="WebView 2.5e";
|
char version[]="WebView 2.6";
|
||||||
|
|
||||||
#ifdef LANG_RUS
|
#ifdef LANG_RUS
|
||||||
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
|
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
|
||||||
|
@ -27,7 +27,7 @@ void draw_ascii()
|
|||||||
{
|
{
|
||||||
char s[2];
|
char s[2];
|
||||||
int i, x, y;
|
int i, x, y;
|
||||||
s[1]=EOS;
|
s[1] = '\0';
|
||||||
for (i=0; i<256; i++) {
|
for (i=0; i<256; i++) {
|
||||||
y = i / 20;
|
y = i / 20;
|
||||||
x = i % 20;
|
x = i % 20;
|
||||||
|
@ -28,7 +28,6 @@ char program_path[4096];
|
|||||||
#define bool int
|
#define bool int
|
||||||
|
|
||||||
#define NULL 0
|
#define NULL 0
|
||||||
#define EOS 0
|
|
||||||
#define OLD -1
|
#define OLD -1
|
||||||
#define true 1
|
#define true 1
|
||||||
#define false 0
|
#define false 0
|
||||||
|
@ -64,7 +64,7 @@ struct PathShow_data
|
|||||||
dword type;
|
dword type;
|
||||||
word start_y,
|
word start_y,
|
||||||
start_x,
|
start_x,
|
||||||
font_size_x, // 6 - for font 0, 8 - for font 1
|
font_w, // 6 - for font 0, 8 - for font 1
|
||||||
area_size_x;
|
area_size_x;
|
||||||
dword font_number, // 0 - monospace, 1 - variable
|
dword font_number, // 0 - monospace, 1 - variable
|
||||||
background_flag,
|
background_flag,
|
||||||
|
@ -176,7 +176,7 @@ void MailBoxLoop() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PageLinks.HoverAndProceed(mouse.x, mouse.y);
|
links.hover(mouse.x, mouse.y);
|
||||||
|
|
||||||
if (!mail_list.count) break;
|
if (!mail_list.count) break;
|
||||||
if (!panels_drag) { scrollbar_v_mouse (#scroll1); scrollbar_v_mouse (#scroll_wv); }
|
if (!panels_drag) { scrollbar_v_mouse (#scroll1); scrollbar_v_mouse (#scroll_wv); }
|
||||||
@ -419,5 +419,5 @@ int GetLetterSize_(int number) {
|
|||||||
|
|
||||||
|
|
||||||
void EventClickLink() {
|
void EventClickLink() {
|
||||||
RunProgram("/sys/network/WebView", PageLinks.GetURL(PageLinks.active));
|
RunProgram("/sys/network/WebView", links.active_url);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user