forked from KolibriOS/kolibrios
WebView: use /lib/patterts/history.h instead own realization
git-svn-id: svn://kolibrios.org@5978 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
35b817fff3
commit
c455cae71e
@ -62,7 +62,6 @@ char attr[1200];
|
|||||||
char val[4096];
|
char val[4096];
|
||||||
char anchor[256]=0;
|
char anchor[256]=0;
|
||||||
|
|
||||||
#include "..\TWB\history.h"
|
|
||||||
#include "..\TWB\links.h"
|
#include "..\TWB\links.h"
|
||||||
#include "..\TWB\colors.h"
|
#include "..\TWB\colors.h"
|
||||||
#include "..\TWB\unicode_tags.h"
|
#include "..\TWB\unicode_tags.h"
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
struct path_string {
|
|
||||||
char Item[sizeof(URL)];
|
|
||||||
int was_first;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MAX_HISTORY_NUM 40
|
|
||||||
path_string history_list[MAX_HISTORY_NUM];
|
|
||||||
|
|
||||||
struct UrlsHistory {
|
|
||||||
int links_count;
|
|
||||||
int cur_y;
|
|
||||||
dword CurrentUrl();
|
|
||||||
dword GetUrl();
|
|
||||||
dword GetFirstLine();
|
|
||||||
void AddUrl();
|
|
||||||
byte GoBack();
|
|
||||||
byte GoForward();
|
|
||||||
} BrowserHistory;
|
|
||||||
|
|
||||||
dword UrlsHistory::CurrentUrl() {
|
|
||||||
return #history_list[cur_y].Item;
|
|
||||||
}
|
|
||||||
|
|
||||||
dword UrlsHistory::GetUrl(int id) {
|
|
||||||
return #history_list[id].Item;
|
|
||||||
}
|
|
||||||
|
|
||||||
dword UrlsHistory::GetFirstLine(int id) {
|
|
||||||
return history_list[id].was_first;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UrlsHistory::AddUrl() {
|
|
||||||
int i;
|
|
||||||
if (links_count>0) && (!strcmp(#URL,#history_list[cur_y].Item)) return;
|
|
||||||
|
|
||||||
if (cur_y>=MAX_HISTORY_NUM-1)
|
|
||||||
{
|
|
||||||
cur_y/=2;
|
|
||||||
for (i=0; i<cur_y; i++;)
|
|
||||||
{
|
|
||||||
strlcpy(#history_list[i].Item, #history_list[MAX_HISTORY_NUM-i].Item, sizeof(URL));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cur_y++;
|
|
||||||
// history_list[i].was_first = WB1.list.first;
|
|
||||||
strlcpy(#history_list[cur_y].Item, #URL, sizeof(URL));
|
|
||||||
links_count=cur_y;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
byte UrlsHistory::GoBack() {
|
|
||||||
if (cur_y<=1) return 0;
|
|
||||||
cur_y--;
|
|
||||||
strlcpy(#URL, #history_list[cur_y].Item, sizeof(URL));
|
|
||||||
// stroka = history_list[cur_y].was_first;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
byte UrlsHistory::GoForward() {
|
|
||||||
if (cur_y==links_count) return 0;
|
|
||||||
cur_y++;
|
|
||||||
strlcpy(#URL, #history_list[cur_y].Item, sizeof(URL));
|
|
||||||
return 1;
|
|
||||||
}
|
|
@ -129,11 +129,11 @@ void LinksArray::GetAbsoluteURL(dword in_URL)
|
|||||||
IF (!strcmpn(in_URL,"./", 2)) in_URL+=2;
|
IF (!strcmpn(in_URL,"./", 2)) in_URL+=2;
|
||||||
if (!http_transfer)
|
if (!http_transfer)
|
||||||
{
|
{
|
||||||
strcpy(#newurl, BrowserHistory.CurrentUrl());
|
strcpy(#newurl, History.current());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(#newurl, #history_list[BrowserHistory.cur_y-1].Item);
|
strcpy(#newurl, History.items.get(History.active-2));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ESBYTE[in_URL] == '/') //remove everything after site domain name
|
if (ESBYTE[in_URL] == '/') //remove everything after site domain name
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "..\lib\draw_buf.h"
|
#include "..\lib\draw_buf.h"
|
||||||
#include "..\lib\list_box.h"
|
#include "..\lib\list_box.h"
|
||||||
#include "..\lib\cursor.h"
|
#include "..\lib\cursor.h"
|
||||||
|
#include "..\lib\collection.h"
|
||||||
//*.obj libraries
|
//*.obj libraries
|
||||||
#include "..\lib\obj\box_lib.h"
|
#include "..\lib\obj\box_lib.h"
|
||||||
#include "..\lib\obj\libio_lib.h"
|
#include "..\lib\obj\libio_lib.h"
|
||||||
@ -21,6 +22,7 @@
|
|||||||
#include "..\lib\obj\iconv.h"
|
#include "..\lib\obj\iconv.h"
|
||||||
//useful patterns
|
//useful patterns
|
||||||
#include "..\lib\patterns\libimg_load_skin.h"
|
#include "..\lib\patterns\libimg_load_skin.h"
|
||||||
|
#include "..\lib\patterns\history.h"
|
||||||
|
|
||||||
char homepage[] = FROM "html\\homepage.htm";
|
char homepage[] = FROM "html\\homepage.htm";
|
||||||
|
|
||||||
@ -214,14 +216,14 @@ void main()
|
|||||||
http_free stdcall (http_transfer);
|
http_free stdcall (http_transfer);
|
||||||
http_transfer=0;
|
http_transfer=0;
|
||||||
PageLinks.GetAbsoluteURL(#URL);
|
PageLinks.GetAbsoluteURL(#URL);
|
||||||
BrowserHistory.cur_y--;
|
History.back();
|
||||||
strcpy(#editURL, #URL);
|
strcpy(#editURL, #URL);
|
||||||
DrawEditBox();
|
DrawEditBox();
|
||||||
OpenPage();
|
OpenPage();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BrowserHistory.AddUrl();
|
History.add(#URL);
|
||||||
ESI = http_transfer;
|
ESI = http_transfer;
|
||||||
bufpointer = ESI.http_msg.content_ptr;
|
bufpointer = ESI.http_msg.content_ptr;
|
||||||
bufsize = ESI.http_msg.content_received;
|
bufsize = ESI.http_msg.content_received;
|
||||||
@ -277,12 +279,16 @@ void Scan(dword id__)
|
|||||||
{
|
{
|
||||||
case SCAN_CODE_BS:
|
case SCAN_CODE_BS:
|
||||||
case BACK_BUTTON:
|
case BACK_BUTTON:
|
||||||
if (!BrowserHistory.GoBack()) return;
|
if (History.back()) {
|
||||||
|
strcpy(#URL, History.current());
|
||||||
OpenPage();
|
OpenPage();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case FORWARD_BUTTON:
|
case FORWARD_BUTTON:
|
||||||
if (!BrowserHistory.GoForward()) return;
|
if (History.forward()) {
|
||||||
|
strcpy(#URL, History.current());
|
||||||
OpenPage();
|
OpenPage();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case GOTOURL_BUTTON:
|
case GOTOURL_BUTTON:
|
||||||
case SCAN_CODE_ENTER:
|
case SCAN_CODE_ENTER:
|
||||||
@ -387,7 +393,7 @@ void OpenPage()
|
|||||||
StopLoading();
|
StopLoading();
|
||||||
souce_mode = false;
|
souce_mode = false;
|
||||||
strcpy(#editURL, #URL);
|
strcpy(#editURL, #URL);
|
||||||
BrowserHistory.AddUrl();
|
History.add(#URL);
|
||||||
if (!strncmp(#URL,"WebView:",8))
|
if (!strncmp(#URL,"WebView:",8))
|
||||||
{
|
{
|
||||||
SetPageDefaults();
|
SetPageDefaults();
|
||||||
@ -448,7 +454,6 @@ void ShowPage()
|
|||||||
{
|
{
|
||||||
WB1.Prepare();
|
WB1.Prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (!header) strcpy(#header, #version);
|
//if (!header) strcpy(#header, #version);
|
||||||
if (!strcmp(#version, #header)) DrawTitle(#header);
|
if (!strcmp(#version, #header)) DrawTitle(#header);
|
||||||
}
|
}
|
||||||
@ -486,7 +491,7 @@ void ClickLink()
|
|||||||
if (http_transfer > 0)
|
if (http_transfer > 0)
|
||||||
{
|
{
|
||||||
StopLoading();
|
StopLoading();
|
||||||
BrowserHistory.cur_y--;
|
History.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(#URL, PageLinks.GetURL(PageLinks.active));
|
strcpy(#URL, PageLinks.GetURL(PageLinks.active));
|
||||||
@ -494,7 +499,7 @@ void ClickLink()
|
|||||||
if (URL[0] == '#')
|
if (URL[0] == '#')
|
||||||
{
|
{
|
||||||
strcpy(#anchor, #URL+strrchr(#URL, '#'));
|
strcpy(#anchor, #URL+strrchr(#URL, '#'));
|
||||||
strcpy(#URL, BrowserHistory.CurrentUrl());
|
strcpy(#URL, History.current());
|
||||||
WB1.list.first=WB1.list.count-WB1.list.visible;
|
WB1.list.first=WB1.list.count-WB1.list.visible;
|
||||||
ShowPage();
|
ShowPage();
|
||||||
return;
|
return;
|
||||||
@ -518,15 +523,15 @@ void ClickLink()
|
|||||||
CreateThread(#Downloader,#downloader_stak+4092);
|
CreateThread(#Downloader,#downloader_stak+4092);
|
||||||
}
|
}
|
||||||
else RunProgram("@open", #URL);
|
else RunProgram("@open", #URL);
|
||||||
strcpy(#editURL, BrowserHistory.CurrentUrl());
|
strcpy(#editURL, History.current());
|
||||||
strcpy(#URL, BrowserHistory.CurrentUrl());
|
strcpy(#URL, History.current());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!strncmp(#URL,"mailto:", 7))
|
if (!strncmp(#URL,"mailto:", 7))
|
||||||
{
|
{
|
||||||
notify(#URL);
|
notify(#URL);
|
||||||
strcpy(#editURL, BrowserHistory.CurrentUrl());
|
strcpy(#editURL, History.current());
|
||||||
strcpy(#URL, BrowserHistory.CurrentUrl());
|
strcpy(#URL, History.current());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
OpenPage();
|
OpenPage();
|
||||||
|
@ -5,17 +5,15 @@ ShowHistory()
|
|||||||
int t;
|
int t;
|
||||||
|
|
||||||
free(history_pointer);
|
free(history_pointer);
|
||||||
history_pointer = malloc(64000);
|
history_pointer = malloc(History.items.data_size+256);
|
||||||
strcat(history_pointer, "<html><head><title>History</title></head><body><h1>History</h1>");
|
strcat(history_pointer, "<html><head><title>History</title></head><body><h1>History</h1>");
|
||||||
strcat(history_pointer, "<h2>Visited pages</h2><blockquote><br>");
|
strcat(history_pointer, "<h2>Visited pages</h2><blockquote><br>");
|
||||||
for (i=1; i<BrowserHistory.links_count; i++)
|
for (i=1; i<History.items.count; i++)
|
||||||
{
|
{
|
||||||
// t = BrowserHistory.GetFirstLine(i);
|
|
||||||
// strcat(history_pointer, itoa(t));
|
|
||||||
strcat(history_pointer, " <a href='");
|
strcat(history_pointer, " <a href='");
|
||||||
strcat(history_pointer, BrowserHistory.GetUrl(i));
|
strcat(history_pointer, History.items.get(i));
|
||||||
strcat(history_pointer, "'>");
|
strcat(history_pointer, "'>");
|
||||||
strcat(history_pointer, BrowserHistory.GetUrl(i));
|
strcat(history_pointer, History.items.get(i));
|
||||||
strcat(history_pointer, "</a><br>");
|
strcat(history_pointer, "</a><br>");
|
||||||
}
|
}
|
||||||
strcat(history_pointer, "</blockquote><h2>Cached images</h2>");
|
strcat(history_pointer, "</blockquote><h2>Cached images</h2>");
|
||||||
|
Loading…
Reference in New Issue
Block a user