forked from KolibriOS/kolibrios
Liza: integration TWB part #2
git-svn-id: svn://kolibrios.org@4534 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
72b2ccfd17
commit
af8dd86a4a
@ -1,19 +1,16 @@
|
||||
#include "..\TWB\links.h"
|
||||
|
||||
int downloader_id;
|
||||
|
||||
dword buf;
|
||||
dword filesize;
|
||||
|
||||
#define URL param
|
||||
|
||||
int mouse_twb;
|
||||
edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
|
||||
scroll_bar scroll_wv = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
|
||||
|
||||
char editURL[sizeof(URL)];
|
||||
char header[2048];
|
||||
|
||||
int downloader_id;
|
||||
|
||||
char download_path[]="/rd/1/.download";
|
||||
|
||||
@ -105,9 +102,9 @@ void TWebBrowser::DrawPage()
|
||||
|
||||
|
||||
char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", 0};
|
||||
//dword TWebBrowser::GetNewUrl(dword CUR_URL, NEW_URL){
|
||||
void TWebBrowser::GetNewUrl(){
|
||||
int i, len;
|
||||
char newurl[4096];
|
||||
|
||||
for (i=0; ABSOLUTE_LINKS[i]; i++)
|
||||
{
|
||||
@ -115,34 +112,34 @@ void TWebBrowser::GetNewUrl(){
|
||||
if (!strcmpn(#URL, ABSOLUTE_LINKS[i], len)) return;
|
||||
}
|
||||
|
||||
IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); //èãíîðèì :)
|
||||
strcpy(#editURL, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
|
||||
IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2);
|
||||
strcpy(#newurl, BrowserHistory.CurrentUrl());
|
||||
|
||||
if (URL[0] == '/')
|
||||
{
|
||||
i = strchr(#editURL+8, '/');
|
||||
editURL[i+7]=0;
|
||||
i = strchr(#newurl+8, '/');
|
||||
newurl[i+7]=0;
|
||||
strcpy(#URL, #URL+1);
|
||||
}
|
||||
|
||||
_CUT_ST_LEVEL_MARK:
|
||||
|
||||
if (editURL[strrchr(#editURL, '/')-2]<>'/') // åñëè íå http://
|
||||
if (newurl[strrchr(#newurl, '/')-2]<>'/')
|
||||
{
|
||||
editURL[strrchr(#editURL, '/')] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
|
||||
newurl[strrchr(#newurl, '/')] = 0x00;
|
||||
}
|
||||
|
||||
IF (!strncmp(#URL,"../",3)) //íà óðîâåíü ââåðõ
|
||||
IF (!strncmp(#URL,"../",3))
|
||||
{
|
||||
strcpy(#URL,#URL+3);
|
||||
editURL[strrchr(#editURL, '/')-1] = 0x00; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
|
||||
newurl[strrchr(#newurl, '/')-1] = 0x00;
|
||||
goto _CUT_ST_LEVEL_MARK;
|
||||
}
|
||||
|
||||
if (editURL[strlen(#editURL)-1]<>'/') strcat(#editURL, "/");
|
||||
if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/");
|
||||
|
||||
strcat(#editURL, #URL); //êëåèì íîâûé àäðåñ
|
||||
strcpy(#URL, #editURL);
|
||||
strcat(#newurl, #URL);
|
||||
strcpy(#URL, #newurl);
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,13 +29,19 @@
|
||||
#include "img\URLgoto.txt";
|
||||
|
||||
#ifdef LANG_RUS
|
||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 0.99.64";
|
||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 0.99.65";
|
||||
?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>ˆ«¨ ¥â ¤®áâ㯠¢ ˆâ¥à¥âë.";
|
||||
#else
|
||||
char version[]=" Text-based Browser 0.99.64";
|
||||
char version[]=" Text-based Browser 0.99.65";
|
||||
?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.";
|
||||
#endif
|
||||
|
||||
proc_info Form;
|
||||
@ -48,9 +54,15 @@ char stak[4096];
|
||||
mouse m;
|
||||
int action_buf;
|
||||
|
||||
|
||||
#include "..\TWB\TWB.c"
|
||||
#include "menu_rmb.h"
|
||||
|
||||
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};
|
||||
|
||||
|
||||
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN };
|
||||
|
||||
|
||||
@ -421,12 +433,23 @@ void ShowPage()
|
||||
if (!filesize)
|
||||
{
|
||||
PageLinks.Clear();
|
||||
DrawBar(WB1.list.x, WB1.list.y, WB1.list.w+scroll_wv.size_x+1, WB1.list.h, 0xFFFFFF); //fill all
|
||||
if (GetProcessSlot(downloader_id)<>0) WriteText(WB1.list.x + 10, WB1.list.y + 18, 0x80, 0, "Loading...");
|
||||
if (GetProcessSlot(downloader_id)<>0)
|
||||
{
|
||||
filesize = sizeof(loading);
|
||||
WB1.ParseHTML(#loading);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteText(WB1.list.x + 10, WB1.list.y + 18, 0x80, 0, "Page not found. May be, URL contains some errors.");
|
||||
if (!strncmp(#URL,"http:",5)) WriteText(WB1.list.x + 10, WB1.list.y + 32, 0x80, 0, "Or Internet unavilable for your configuration.");
|
||||
if (strncmp(#URL,"http:",5)==0)
|
||||
{
|
||||
filesize = sizeof(page_not_found_no_internet);
|
||||
WB1.ParseHTML(#page_not_found_no_internet);
|
||||
}
|
||||
else
|
||||
{
|
||||
filesize = sizeof(page_not_found);
|
||||
WB1.ParseHTML(#page_not_found);
|
||||
}
|
||||
}
|
||||
//return;
|
||||
}
|
||||
|
@ -349,15 +349,14 @@ void InitTWB() {
|
||||
WB1.list.visible = WB1.list.h / WB1.list.line_h;
|
||||
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h, WB1.list.line_h);
|
||||
|
||||
strcpy(#URL, "/sys/yavu.htm");
|
||||
strcpy(#header, #version);
|
||||
pre_text = 0;
|
||||
WB1.list.first = WB1.list.count = 0;
|
||||
WB1.ReadHtml(_WIN);
|
||||
}
|
||||
|
||||
void DrawLetter() {
|
||||
WB1.ParseHTML(buf);
|
||||
filesize = strlen(mdata);
|
||||
if (filesize) WB1.ParseHTML(mdata);
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,16 +43,6 @@ void ParseMail()
|
||||
mdata = strstr(mailstart, "\x0a\x0d") + 3;
|
||||
debug("ConvertToDOS");
|
||||
ConvertToDOS(mdata, mailstart);
|
||||
debug("FromHTMLtoTXT");
|
||||
FromHTMLtoTXT();
|
||||
letter_view.first = letter_view.count = 0;
|
||||
|
||||
line_off = mdata;
|
||||
while (line_off>1)
|
||||
{
|
||||
line_off = GetNextLine(line_off);
|
||||
letter_view.count++;
|
||||
}
|
||||
debug("SetAtrFromCurr");
|
||||
atr.SetAtrFromCurr(mail_list.current+1);
|
||||
DrawMailBox();
|
||||
@ -85,50 +75,6 @@ void ConvertToDOS(dword inbuf, searchin)
|
||||
}
|
||||
|
||||
|
||||
void FromHTMLtoTXT()
|
||||
{
|
||||
dword cur_chr, txt_buf_srt, txt_buf_end, is_tag=0;
|
||||
int i;
|
||||
if (strstri(mdata, "<html>")==0) && (strstri(mailstart, "text/html")==0) {debug("no html tags found"); return;}
|
||||
debug ("Mail got <html> code");
|
||||
cur_chr = mdata;
|
||||
txt_buf_srt = malloc(mailend - mailstart);
|
||||
txt_buf_end = txt_buf_srt;
|
||||
|
||||
while (cur_chr < mailend)
|
||||
{
|
||||
if (DSBYTE[cur_chr]=='<') is_tag = 1;
|
||||
if (!is_tag)
|
||||
{
|
||||
DSBYTE[txt_buf_end] = DSBYTE[cur_chr];
|
||||
txt_buf_end++;
|
||||
_END:
|
||||
}
|
||||
if (DSBYTE[cur_chr]=='>') is_tag = NULL;
|
||||
cur_chr++;
|
||||
}
|
||||
DSBYTE[txt_buf_end] = '\0';
|
||||
strcpy(mdata, txt_buf_srt);
|
||||
mailend = strlen(mailstart) + mailstart;
|
||||
free(txt_buf_srt);
|
||||
}
|
||||
|
||||
|
||||
dword GetNextLine(dword start_offset)
|
||||
{
|
||||
dword off_n = strstr(start_offset, "\n") + 1, //разрыв строки
|
||||
off_w = letter_view.w / 6 - 2 + start_offset, //max длинна скроки
|
||||
off_m;
|
||||
off_m = off_w;
|
||||
if (off_n < off_w) return off_n;
|
||||
while (off_m > start_offset) //перенос по словам
|
||||
{
|
||||
if (DSBYTE[off_m]==' ') || (DSBYTE[off_m]=='\9') || (DSBYTE[off_m]=='-') return off_m;
|
||||
off_m--;
|
||||
}
|
||||
return off_w;
|
||||
}
|
||||
|
||||
dword CopyBetweenOffsets(dword start, end) //do not forget to free(line) after use
|
||||
{
|
||||
dword line, new_line;
|
||||
|
Loading…
Reference in New Issue
Block a user