HTMLv: History or URLs & cached images (available from menu), Page not found custom

git-svn-id: svn://kolibrios.org@4544 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2014-01-29 00:14:09 +00:00
parent a54c8a7ac9
commit 1db99aa26a
7 changed files with 103 additions and 66 deletions

View File

@ -632,7 +632,7 @@ void TWebBrowser::TextGoDown(int left1, top1, width1)
DrawBuf.Fill(bg_color);
}
stroka++;
if (blq_text) stolbec = 8; else stolbec = 0;
if (blq_text) stolbec = 6; else stolbec = 0;
if (li_text) stolbec = li_tab * 5;
}

View File

@ -1,59 +1,59 @@
struct UrlsHistory {
dword CurrentUrl();
void AddUrl();
byte GoBack();
byte GoForward();
};
UrlsHistory BrowserHistory;
struct path_string {
char Item[4096];
};
#define MAX_HISTORY_NUM 40
path_string history_list[MAX_HISTORY_NUM];
int history_num;
int history_current;
dword UrlsHistory::CurrentUrl()
{
return #history_list[history_current].Item;
struct UrlsHistory {
int links_count;
int current;
dword CurrentUrl();
dword GetUrl();
void AddUrl();
byte GoBack();
byte GoForward();
};
dword UrlsHistory::CurrentUrl() {
return #history_list[current].Item;
}
void UrlsHistory::AddUrl() //òóò íóæåí ââîäèìûé ýëåìåíò - äëÿ óíèâåðñàëüíîñòè
{
int i;
if (history_num>0) && (!strcmp(#URL,#history_list[history_current].Item)) return;
dword UrlsHistory::GetUrl(int id) {
return #history_list[id].Item;
}
if (history_current>=MAX_HISTORY_NUM-1)
void UrlsHistory::AddUrl() {
int i;
if (links_count>0) && (!strcmp(#URL,#history_list[current].Item)) return;
if (current>=MAX_HISTORY_NUM-1)
{
history_current/=2;
for (i=0; i<history_current; i++;)
current/=2;
for (i=0; i<current; i++;)
{
strlcpy(#history_list[i].Item, #history_list[MAX_HISTORY_NUM-i].Item, sizeof(history_list[0].Item));
}
}
history_current++;
strlcpy(#history_list[history_current].Item, #URL, sizeof(history_list[0].Item));
history_num=history_current;
current++;
strlcpy(#history_list[current].Item, #URL, sizeof(history_list[0].Item));
links_count=current;
}
byte UrlsHistory::GoBack()
{
if (history_current<=1) return 0;
history_current--;
strlcpy(#URL, #history_list[history_current].Item, sizeof(URL));
byte UrlsHistory::GoBack() {
if (current<=1) return 0;
current--;
strlcpy(#URL, #history_list[current].Item, sizeof(URL));
return 1;
}
byte UrlsHistory::GoForward()
{
if (history_current==history_num) return 0;
history_current++;
strlcpy(#URL, #history_list[history_current].Item, sizeof(URL));
byte UrlsHistory::GoForward() {
if (current==links_count) return 0;
current++;
strlcpy(#URL, #history_list[current].Item, sizeof(URL));
return 1;
}
UrlsHistory BrowserHistory;

View File

@ -9,7 +9,7 @@ s_image pics[100]; //pics = mem_Alloc( 100*sizeof(s_image) );
struct ImageCache {
int pics_count;
void Free();
int GetImage();
int GetImageNumber();
void Images();
};
@ -22,7 +22,7 @@ void ImageCache::Free()
}
}
int ImageCache::GetImage(dword i_path)
int ImageCache::GetImageNumber(dword i_path)
{
int i;
for (i=0; i<pics_count; i++) if (!strcmp(#pics[i].path, i_path)) return i; //image exists
@ -55,7 +55,7 @@ void ImageCache::Images(int left1, top1, width1)
img_path[strrchr(#img_path, '/')] = '\0';
strcat(#img_path, #options);
}
cur_pic = GetImage(#img_path);
cur_pic = GetImageNumber(#img_path);
}
}
if (!strcmp(#parametr,"alt="))

View File

@ -24,7 +24,7 @@
?define T_WALLPAPERS " Wallpappers"
#endif
unsigned char icons[sizeof(file "icons.raw")]= FROM "icons.raw";
unsigned char icons[]= FROM "icons.raw";
#define PANEL_H 30

View File

@ -30,19 +30,17 @@
#include "img\URLgoto.txt";
#ifdef LANG_RUS
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.65";
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.66";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤"
char loading[] = "Loading...";
char page_not_found[] = "‘âà ­¨æ  ­¥ ­ ©¤¥­ . ‚®¬®¦­®, URL ᮤ¥à¦¨â ®è¨¡ªã.";
char page_not_found_no_internet[] = "‘âà ­¨æ  ­¥ ­ ©¤¥­ . ‚®¬®¦­®, URL ᮤ¥à¦¨â ®è¨¡ªã.<br>ˆ«¨ ­¥â ¤®áâ㯠 ¢ ˆ­â¥à­¥âë.";
char loading[] = "‡ £à㧪  áâà ­¨æë...";
unsigned char page_not_found[] = FROM "html\page_not_found_ru.htm";
#else
char version[]=" Text-based Browser 0.99.65";
char version[]=" Text-based Browser 0.99.66";
?define IMAGES_CACHE_CLEARED "Images cache cleared"
?define T_LAST_SLIDE "This slide is the last"
char loading[] = "Loading...";
char page_not_found[] = "Page not found. Maybe, URL contains some errors.";
char page_not_found_no_internet[] = "Page not found. Maybe, URL contains some errors.<br>Or Internet unavailable for your configuration.";
unsigned char page_not_found[] = FROM "html\page_not_found_en.htm";
#endif
proc_info Form;
@ -67,6 +65,7 @@ char editURL[sizeof(URL)];
int mouse_twb;
edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
#define URL_HISTORY "WebView://history"
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN };
@ -284,6 +283,11 @@ void Scan(int id)
WB1.ParseHTML(bufpointer);
return;
case 008: //history
strcpy(#URL, URL_HISTORY);
OpenPage();
return;
case BACK:
if (!BrowserHistory.GoBack()) return;
OpenPage();
@ -350,14 +354,14 @@ void Scan(int id)
return;
case 178:
case BTN_UP: //ìîòàåì ââåðõ
case BTN_UP:
if (WB1.list.first <= 0) return;
WB1.list.first--;
WB1.ParseHTML(bufpointer);
return;
case 177:
case BTN_DOWN: //ìîòàåì âíèç
case BTN_DOWN:
if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
WB1.list.first++;
WB1.ParseHTML(bufpointer);
@ -379,7 +383,6 @@ void Scan(int id)
void ProcessLinks(int id)
{
strcpy(#URL, PageLinks.GetURL(id-401));
//$1 - Condition Script
if (URL[0] == '$')
{
@ -460,28 +463,21 @@ void ShowPage()
address_box.offset=0;
edit_box_draw stdcall(#address_box);
if (strcmp(#URL, URL_HISTORY)==0) ShowHistory(); else
if (!bufsize)
{
PageLinks.Clear();
if (GetProcessSlot(downloader_id)<>0)
{
bufsize = sizeof(loading);
WB1.ParseHTML(#loading);
bufsize = sizeof(loading);
WB1.ParseHTML(#loading);
}
else
{
if (strncmp(#URL,"http:",5)==0)
{
bufsize = sizeof(page_not_found_no_internet);
WB1.ParseHTML(#page_not_found_no_internet);
}
else
{
bufsize = sizeof(page_not_found);
WB1.ParseHTML(#page_not_found);
}
bufsize = sizeof(page_not_found);
WB1.ParseHTML(#page_not_found);
}
//return;
bufsize = 0;
}
else
WB1.ParseHTML(bufpointer);
@ -490,5 +486,34 @@ void ShowPage()
if (!strcmp(#version, #header)) DrawTitle(#header);
}
ShowHistory()
{
int i;
static int history_pointer;
free(history_pointer);
history_pointer = malloc(64000);
strcat(history_pointer, "<h1>History</h1>");
strcat(history_pointer, "<h2>Visited pages</h2><blockquote><br>");
for (i=1; i<BrowserHistory.links_count; i++)
{
strcat(history_pointer, "<a href='");
strcat(history_pointer, BrowserHistory.GetUrl(i));
strcat(history_pointer, "'>");
strcat(history_pointer, BrowserHistory.GetUrl(i));
strcat(history_pointer, "</a><br>");
}
strcat(history_pointer, "</blockquote><h2>Cached images</h2><br>");
for (i=1; i<ImgCache.pics_count; i++)
{
strcat(history_pointer, "<img src='");
strcat(history_pointer, #pics[i].path);
strcat(history_pointer, "' /><br>");
}
bufsize = strlen(history_pointer);
bufpointer = history_pointer;
WB1.ParseHTML(history_pointer);
}
stop:

View File

@ -1,4 +1,14 @@
15.10.13 - 0.99.08
20.11.2013 - 0.99.6
- переделаны ссылки, курсор превращается в руку при наведении
29.12.2013 - 0.99.5
- Condition Script
27.12.2013 - 0.99.4
- отделение TWB компонента от браузера
15.10.13 - 0.99.1
- поддержка тегов <center>, <right> и параметра align="center/right" для тегов h1..h4
- ףכףקרוםםמו לום‏
- לףכ<D7A3>עט<D7A2>ח<EFBFBD>קםמסע<D7A1>

View File

@ -8,9 +8,11 @@ char *ITEMS_LIST[]={
#ifdef LANG_RUS
"ˆá室­¨ª áâà ­¨æë F3",52,
"Žç¨áâ¨âì ªíè ª à⨭®ª" ,02,
"ˆáâ®à¨ï" ,08,
#else
"View source F3",52,
"Free image cache" ,09,
"History" ,08,
#endif
0};