forked from KolibriOS/kolibrios
HTMLv 0.99.69
git-svn-id: svn://kolibrios.org@4636 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
1964654d95
commit
5aa14a9e6a
@ -1,7 +1,7 @@
|
|||||||
#include "..\TWB\links.h"
|
#include "..\TWB\links.h"
|
||||||
|
|
||||||
|
|
||||||
dword bufpointer;
|
dword bufpointer;
|
||||||
|
dword o_bufpointer;
|
||||||
dword bufsize;
|
dword bufsize;
|
||||||
|
|
||||||
#define URL param
|
#define URL param
|
||||||
@ -16,7 +16,7 @@ struct TWebBrowser {
|
|||||||
llist list;
|
llist list;
|
||||||
DrawBufer DrawBuf;
|
DrawBufer DrawBuf;
|
||||||
void GetNewUrl();
|
void GetNewUrl();
|
||||||
void ReadHtml();
|
void Prepare();
|
||||||
void Parse();
|
void Parse();
|
||||||
void WhatTextStyle();
|
void WhatTextStyle();
|
||||||
void DrawPage();
|
void DrawPage();
|
||||||
@ -30,7 +30,7 @@ byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab,
|
|||||||
link, ignor_text, cur_encoding, text_align;
|
link, ignor_text, cur_encoding, text_align;
|
||||||
byte condition_text_active, condition_text_val, condition_href, condition_max;
|
byte condition_text_active, condition_text_val, condition_href, condition_max;
|
||||||
|
|
||||||
enum { _WIN, _DOS, _KOI, _UTF };
|
enum { _WIN, _DOS, _KOI, _UTF, _DEFAULT };
|
||||||
|
|
||||||
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
|
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
|
||||||
|
|
||||||
@ -57,6 +57,7 @@ char anchor[256];
|
|||||||
#include "..\TWB\unicode_tags.h"
|
#include "..\TWB\unicode_tags.h"
|
||||||
#include "..\TWB\img_cache.h"
|
#include "..\TWB\img_cache.h"
|
||||||
#include "..\TWB\parce_tag.h"
|
#include "..\TWB\parce_tag.h"
|
||||||
|
#include "..\TWB\table.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -140,70 +141,39 @@ void TWebBrowser::GetNewUrl(){
|
|||||||
strcpy(#URL, #newurl);
|
strcpy(#URL, #newurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BufEncode(int set_new_encoding)
|
||||||
void TWebBrowser::ReadHtml(byte encoding)
|
|
||||||
{
|
{
|
||||||
if (native_http)
|
cur_encoding = set_new_encoding;
|
||||||
|
if (o_bufpointer==0)
|
||||||
{
|
{
|
||||||
if (strncmp(#URL,"http:",5)) {
|
debugi(bufsize);
|
||||||
file_size stdcall (#URL);
|
bufsize = strlen(bufpointer);
|
||||||
bufsize = EBX;
|
debugi(bufsize);
|
||||||
}
|
o_bufpointer = malloc(bufsize);
|
||||||
|
strcpy(o_bufpointer, bufpointer);
|
||||||
if (!bufsize) return;
|
|
||||||
|
|
||||||
if (strncmp(#URL,"http:",5)) {
|
|
||||||
mem_Free(bufpointer);
|
|
||||||
bufpointer = mem_Alloc(bufsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strncmp(#URL,"http:",5)) ReadFile(0, bufsize, bufpointer, #URL);
|
|
||||||
|
|
||||||
cur_encoding = encoding;
|
|
||||||
if (encoding==_WIN) wintodos(bufpointer);
|
|
||||||
if (encoding==_UTF) utf8rutodos(bufpointer);
|
|
||||||
if (encoding==_KOI) koitodos(bufpointer);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!strncmp(#URL,"http:",5))
|
strcpy(bufpointer, o_bufpointer);
|
||||||
file_size stdcall (#download_path);
|
|
||||||
else
|
|
||||||
file_size stdcall (#URL);
|
|
||||||
|
|
||||||
bufsize = EBX;
|
|
||||||
if (!bufsize) return;
|
|
||||||
|
|
||||||
mem_Free(bufpointer);
|
|
||||||
bufpointer = mem_Alloc(bufsize);
|
|
||||||
if (!strncmp(#URL,"http:",5))
|
|
||||||
ReadFile(0, bufsize, bufpointer, #download_path);
|
|
||||||
else
|
|
||||||
ReadFile(0, bufsize, bufpointer, #URL);
|
|
||||||
|
|
||||||
cur_encoding = encoding;
|
|
||||||
if (encoding==_WIN) wintodos(bufpointer);
|
|
||||||
if (encoding==_UTF) utf8rutodos(bufpointer);
|
|
||||||
if (encoding==_KOI) koitodos(bufpointer);
|
|
||||||
}
|
}
|
||||||
|
if (set_new_encoding==_WIN) wintodos(bufpointer);
|
||||||
|
if (set_new_encoding==_UTF) utf8rutodos(bufpointer);
|
||||||
|
if (set_new_encoding==_KOI) koitodos(bufpointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void TWebBrowser::Prepare(dword bufpos, in_filesize){
|
||||||
void TWebBrowser::ReadHtml(byte encoding)
|
bufsize = in_filesize;
|
||||||
{
|
bufpointer = bufpos;
|
||||||
|
Parse();
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
void TWebBrowser::Parse(dword bufpos, in_filesize){
|
void TWebBrowser::Parse(){
|
||||||
word bukva[2];
|
word bukva[2];
|
||||||
int j, perenos_num;
|
int j, perenos_num;
|
||||||
byte ignor_param;
|
byte ignor_param;
|
||||||
char temp[768];
|
char temp[768];
|
||||||
bufsize = in_filesize;
|
dword bufpos = bufpointer;
|
||||||
bufpointer = bufpos;
|
|
||||||
|
|
||||||
b_text = i_text = u_text = s_text = blq_text =
|
b_text = i_text = u_text = s_text = blq_text =
|
||||||
li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab =
|
li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab =
|
||||||
@ -372,7 +342,7 @@ void TWebBrowser::Parse(dword bufpos, in_filesize){
|
|||||||
{
|
{
|
||||||
anchor=NULL;
|
anchor=NULL;
|
||||||
list.first=anchor_line_num;
|
list.first=anchor_line_num;
|
||||||
Parse(bufpointer, bufsize);
|
Parse();
|
||||||
}
|
}
|
||||||
DrawScroller();
|
DrawScroller();
|
||||||
}
|
}
|
||||||
@ -383,7 +353,7 @@ char oldtag[100];
|
|||||||
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
||||||
dword hr_color;
|
dword hr_color;
|
||||||
byte opened;
|
byte opened;
|
||||||
|
byte meta_encoding;
|
||||||
//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
|
//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
|
||||||
if (tag[0] == '/')
|
if (tag[0] == '/')
|
||||||
{
|
{
|
||||||
@ -496,7 +466,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
|||||||
if (text_color_index > 0) text_color_index--;
|
if (text_color_index > 0) text_color_index--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(isTag("tr")) || (isTag("br")) {
|
if (isTag("br")) {
|
||||||
TextGoDown(left1, top1, width1);
|
TextGoDown(left1, top1, width1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -510,6 +480,43 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
|||||||
IF(opened) TextGoDown(left1, top1 + 10, width1);
|
IF(opened) TextGoDown(left1, top1 + 10, width1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(isTag("table")) {
|
||||||
|
if (opened)
|
||||||
|
{
|
||||||
|
table.active = true;
|
||||||
|
TextGoDown(left1, top1, width1);
|
||||||
|
table.NewTable();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
table.active = false;
|
||||||
|
TextGoDown(left1, top1, width1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isTag("td")) {
|
||||||
|
if (opened)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isTag("tr")) {
|
||||||
|
if (opened)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TextGoDown(left1, top1, width1);
|
||||||
|
if (table.cur_row == 0) table.max_cols = table.cur_col;
|
||||||
|
table.cur_row++;
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
if (isTag("center"))
|
if (isTag("center"))
|
||||||
{
|
{
|
||||||
@ -617,26 +624,19 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
|
|||||||
if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
|
if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
|
||||||
{
|
{
|
||||||
strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
|
strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
|
||||||
if (!strcmp(#options, "utf-8")) || (!strcmp(#options,"utf8")) ReadHtml(_UTF);
|
strlwr(#options);
|
||||||
if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI);
|
if (!strcmp(#options, "utf-8")) || (!strcmp(#options,"utf8")) meta_encoding = _UTF;
|
||||||
if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) ReadHtml(_DOS);
|
if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) meta_encoding = _KOI;
|
||||||
|
if (!strcmp(#options, "windows-1251")) || (!strcmp(#options, "windows1251")) meta_encoding = _WIN;
|
||||||
|
//if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) meta_encoding = _DOS;
|
||||||
|
if ((cur_encoding==_DEFAULT) && (http_transfer==0)) BufEncode(meta_encoding);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} while(GetNextParam());
|
} while(GetNextParam());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
char *encodings = {
|
|
||||||
"utf-8", _UTF,
|
|
||||||
"utf8", _UTF,
|
|
||||||
"koi8-r", _KOI,
|
|
||||||
"koi8-u", _KOI,
|
|
||||||
"dos", _DOS,
|
|
||||||
"cp-866", _DOS
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
|
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
|
||||||
{
|
{
|
||||||
scroll_wv.max_area = list.count;
|
scroll_wv.max_area = list.count;
|
||||||
@ -673,3 +673,5 @@ int isTag(dword text)
|
|||||||
{
|
{
|
||||||
if (!strcmp(#tag,text)) return 1; else return 0;
|
if (!strcmp(#tag,text)) return 1; else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ void ImageCache::Images(int left1, top1, width1)
|
|||||||
do{
|
do{
|
||||||
if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl()
|
if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl()
|
||||||
{
|
{
|
||||||
if (downloader_id) strcpy(#img_path, #history_list[BrowserHistory.current-1].Item); else
|
if (http_transfer<>0) strcpy(#img_path, #history_list[BrowserHistory.current-1].Item); else
|
||||||
strcpy(#img_path, BrowserHistory.CurrentUrl());
|
strcpy(#img_path, BrowserHistory.CurrentUrl());
|
||||||
if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
|
if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
|
||||||
{
|
{
|
||||||
|
19
programs/cmm/TWB/table.h
Normal file
19
programs/cmm/TWB/table.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
struct Table
|
||||||
|
{
|
||||||
|
byte active;
|
||||||
|
byte max_cols;
|
||||||
|
byte max_rows;
|
||||||
|
byte cur_col;
|
||||||
|
byte cur_row;
|
||||||
|
int col_w[255];
|
||||||
|
int col_h[255];
|
||||||
|
void NewTable();
|
||||||
|
} table;
|
||||||
|
|
||||||
|
void Table::NewTable()
|
||||||
|
{
|
||||||
|
cur_row = 0;
|
||||||
|
cur_col = 0;
|
||||||
|
max_rows = 0;
|
||||||
|
max_cols = 0;
|
||||||
|
}
|
@ -30,14 +30,14 @@
|
|||||||
#include "img\URLgoto.txt";
|
#include "img\URLgoto.txt";
|
||||||
|
|
||||||
#ifdef LANG_RUS
|
#ifdef LANG_RUS
|
||||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 0.99.67";
|
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 0.99.69";
|
||||||
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
||||||
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
||||||
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
||||||
unsigned char page_not_found[] = FROM "html\page_not_found_ru.htm";
|
unsigned char page_not_found[] = FROM "html\page_not_found_ru.htm";
|
||||||
char accept_language[]= "Accept-Language: ru\n\0";
|
char accept_language[]= "Accept-Language: ru\n\0";
|
||||||
#else
|
#else
|
||||||
char version[]=" Text-based Browser 0.99.67";
|
char version[]=" Text-based Browser 0.99.69";
|
||||||
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
||||||
?define T_LAST_SLIDE "This slide is the last"
|
?define T_LAST_SLIDE "This slide is the last"
|
||||||
char loading[] = "Loading...<br>";
|
char loading[] = "Loading...<br>";
|
||||||
@ -45,8 +45,6 @@
|
|||||||
char accept_language[]= "Accept-Language: en\n\0";
|
char accept_language[]= "Accept-Language: en\n\0";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
byte native_http=1;
|
|
||||||
|
|
||||||
proc_info Form;
|
proc_info Form;
|
||||||
#define WIN_W 640
|
#define WIN_W 640
|
||||||
#define WIN_H 480
|
#define WIN_H 480
|
||||||
@ -62,10 +60,9 @@ int action_buf;
|
|||||||
dword http_transfer = 0;
|
dword http_transfer = 0;
|
||||||
dword http_buffer;
|
dword http_buffer;
|
||||||
|
|
||||||
int downloader_id;
|
|
||||||
|
|
||||||
#include "..\TWB\TWB.c"
|
#include "..\TWB\TWB.c"
|
||||||
#include "menu_rmb.h"
|
#include "menu_rmb.h"
|
||||||
|
#include "history.h"
|
||||||
|
|
||||||
char editURL[sizeof(URL)];
|
char editURL[sizeof(URL)];
|
||||||
int mouse_twb;
|
int mouse_twb;
|
||||||
@ -103,12 +100,12 @@ void main()
|
|||||||
{
|
{
|
||||||
CASE evMouse:
|
CASE evMouse:
|
||||||
if (!CheckActiveProcess(Form.ID)) break;
|
if (!CheckActiveProcess(Form.ID)) break;
|
||||||
|
//Edit URL
|
||||||
edit_box_mouse stdcall (#address_box);
|
edit_box_mouse stdcall (#address_box);
|
||||||
|
|
||||||
m.get();
|
m.get();
|
||||||
|
//Links hover
|
||||||
if (m.y>WB1.list.y) PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color);
|
if (m.y>WB1.list.y) PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color);
|
||||||
|
//Menu
|
||||||
if (m.y>WB1.list.y) && (m.y<Form.height) && (bufsize)
|
if (m.y>WB1.list.y) && (m.y<Form.height) && (bufsize)
|
||||||
{
|
{
|
||||||
if (m.pkm)
|
if (m.pkm)
|
||||||
@ -123,12 +120,12 @@ void main()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Mouse scroll
|
||||||
if (m.vert)
|
if (m.vert)
|
||||||
{
|
{
|
||||||
if (WB1.list.MouseScroll(m.vert)) WB1.Parse(bufpointer, bufsize);
|
if (WB1.list.MouseScroll(m.vert)) WB1.Parse();
|
||||||
}
|
}
|
||||||
|
//Drag scroller
|
||||||
if (!m.lkm) scroll_used=0;
|
if (!m.lkm) scroll_used=0;
|
||||||
if (m.x>=scroll_wv.start_x) && (m.x<=scroll_wv.start_x+scroll_wv.size_x)
|
if (m.x>=scroll_wv.start_x) && (m.x<=scroll_wv.start_x+scroll_wv.size_x)
|
||||||
&& (m.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>m.y)
|
&& (m.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>m.y)
|
||||||
@ -136,7 +133,6 @@ void main()
|
|||||||
{
|
{
|
||||||
scroll_used=1;
|
scroll_used=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scroll_used)
|
if (scroll_used)
|
||||||
{
|
{
|
||||||
half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2;
|
half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2;
|
||||||
@ -144,21 +140,13 @@ void main()
|
|||||||
btn=WB1.list.first;
|
btn=WB1.list.first;
|
||||||
WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
|
WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
|
||||||
if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
|
if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
|
||||||
if (btn<>WB1.list.first) WB1.Parse(bufpointer, bufsize);
|
if (btn<>WB1.list.first) WB1.Parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case evButton:
|
case evButton:
|
||||||
btn=GetButtonID();
|
btn=GetButtonID();
|
||||||
if (btn==1)
|
if (btn==1) ExitProcess();
|
||||||
{
|
Scan(btn);
|
||||||
KillProcess(downloader_id);
|
|
||||||
ExitProcess();
|
|
||||||
}
|
|
||||||
ELSE
|
|
||||||
{
|
|
||||||
Scan(btn);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case evKey:
|
case evKey:
|
||||||
key = GetKey();
|
key = GetKey();
|
||||||
@ -172,7 +160,7 @@ void main()
|
|||||||
if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
|
if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
|
||||||
break;
|
break;
|
||||||
case evReDraw:
|
case evReDraw:
|
||||||
if (action_buf) { Scan(action_buf); action_buf=0;}
|
if (action_buf) Scan(action_buf);
|
||||||
Draw_Window();
|
Draw_Window();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -181,9 +169,10 @@ void main()
|
|||||||
http_process stdcall (http_transfer);
|
http_process stdcall (http_transfer);
|
||||||
$push EAX
|
$push EAX
|
||||||
ESI = http_transfer;
|
ESI = http_transfer;
|
||||||
|
if (o_bufpointer) o_bufpointer = free(o_bufpointer);
|
||||||
bufpointer = ESI.http_msg.content_ptr;
|
bufpointer = ESI.http_msg.content_ptr;
|
||||||
bufsize = ESI.http_msg.content_received;
|
bufsize = ESI.http_msg.content_received;
|
||||||
WB1.Parse(bufpointer, bufsize);
|
WB1.Parse();
|
||||||
|
|
||||||
$pop EAX
|
$pop EAX
|
||||||
if (EAX == 0) {
|
if (EAX == 0) {
|
||||||
@ -230,15 +219,6 @@ void main()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
if (downloader_id<>0)
|
|
||||||
{
|
|
||||||
if (GetProcessSlot(downloader_id)<>0) break;
|
|
||||||
downloader_id=0;
|
|
||||||
WB1.list.first = WB1.list.count = 0;
|
|
||||||
WB1.ReadHtml(_WIN);
|
|
||||||
Draw_Window();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -268,7 +248,7 @@ void Draw_Window()
|
|||||||
if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
|
if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
|
||||||
|
|
||||||
PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
|
PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
|
||||||
if (GetProcessSlot(downloader_id)<>0) || (http_transfer > 0) _PutImage(88,10, 24,24, #stop_btn);
|
if (http_transfer > 0) _PutImage(88,10, 24,24, #stop_btn);
|
||||||
|
|
||||||
DrawBar(200,0,Form.cwidth-200,43,0xE4DFE1);
|
DrawBar(200,0,Form.cwidth-200,43,0xE4DFE1);
|
||||||
DrawBar(0,42,Form.cwidth,1,0xE2DBDC);
|
DrawBar(0,42,Form.cwidth,1,0xE2DBDC);
|
||||||
@ -288,36 +268,42 @@ void Draw_Window()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ChangeCharset(byte new_charset)
|
||||||
|
{
|
||||||
|
BufEncode(new_charset);
|
||||||
|
WB1.Parse();
|
||||||
|
}
|
||||||
|
|
||||||
void Scan(int id)
|
void Scan(int id)
|
||||||
{
|
{
|
||||||
if (id >= 400) ProcessLinks(id);
|
action_buf=0;
|
||||||
|
if (id >= 400)
|
||||||
|
{
|
||||||
|
ProcessLinks(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case 011: //Ctrk+K
|
case 011: //Ctrk+K
|
||||||
WB1.ReadHtml(_KOI);
|
ChangeCharset(_KOI);
|
||||||
WB1.Parse(bufpointer, bufsize);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 021: //Ctrl+U
|
case 021: //Ctrl+U
|
||||||
WB1.ReadHtml(_UTF);
|
ChangeCharset(_UTF);
|
||||||
WB1.Parse(bufpointer, bufsize);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 004: //Ctrl+D
|
case 004: //Ctrl+D
|
||||||
WB1.ReadHtml(_DOS);
|
ChangeCharset(_DOS);
|
||||||
WB1.Parse(bufpointer, bufsize);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 005: //Win encoding
|
case 005: //Win encoding
|
||||||
WB1.ReadHtml(_WIN);
|
ChangeCharset(_WIN);
|
||||||
WB1.Parse(bufpointer, bufsize);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 009: //free img cache
|
case 009: //free img cache
|
||||||
ImgCache.Free();
|
ImgCache.Free();
|
||||||
notify(IMAGES_CACHE_CLEARED);
|
notify(IMAGES_CACHE_CLEARED);
|
||||||
WB1.Parse(bufpointer, bufsize);
|
WB1.Parse();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 003: //history
|
case 003: //history
|
||||||
@ -334,35 +320,23 @@ void Scan(int id)
|
|||||||
OpenPage();
|
OpenPage();
|
||||||
return;
|
return;
|
||||||
case 052: //F3
|
case 052: //F3
|
||||||
if (strncmp(#URL,"http:",5)<>0) RunProgram("/rd/1/tinypad", #URL);
|
if (strncmp(#URL,"http:",5)==0)
|
||||||
else RunProgram("/rd/1/tinypad", #download_path);
|
{
|
||||||
|
WriteFile(bufsize, bufpointer, "/tmp0/1/webview.tmp");
|
||||||
|
if (EAX==0) RunProgram("/rd/1/tinypad", "/tmp0/1/webview.tmp");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RunProgram("/rd/1/tinypad", #URL);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case 054: //F5
|
case 054: //F5
|
||||||
IF(address_box.flags & 0b10) WB1.Parse(bufpointer, bufsize);
|
IF(address_box.flags & 0b10) WB1.Parse();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case REFRESH:
|
case REFRESH:
|
||||||
if (http_transfer<>0)
|
if (http_transfer > 0) StopLoading();
|
||||||
{
|
else OpenPage();
|
||||||
EAX = http_transfer;
|
|
||||||
EAX = EAX.http_msg.content_ptr; // get pointer to data
|
|
||||||
$push EAX // save it on the stack
|
|
||||||
http_free stdcall (http_transfer); // abort connection
|
|
||||||
$pop EAX
|
|
||||||
mem_Free(EAX); // free data
|
|
||||||
http_transfer=0;
|
|
||||||
bufsize = 0;
|
|
||||||
}
|
|
||||||
if (GetProcessSlot(downloader_id)<>0)
|
|
||||||
{
|
|
||||||
KillProcess(downloader_id);
|
|
||||||
pause(20);
|
|
||||||
Draw_Window();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
anchor_line_num=WB1.list.first;
|
|
||||||
anchor[0]='|';
|
|
||||||
OpenPage();
|
|
||||||
return;
|
return;
|
||||||
case 014:
|
case 014:
|
||||||
case 020:
|
case 020:
|
||||||
@ -390,7 +364,7 @@ void Scan(int id)
|
|||||||
IF(WB1.list.first == WB1.list.count - WB1.list.visible) return;
|
IF(WB1.list.first == WB1.list.count - WB1.list.visible) return;
|
||||||
WB1.list.first += WB1.list.visible + 2;
|
WB1.list.first += WB1.list.visible + 2;
|
||||||
IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible;
|
IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible;
|
||||||
WB1.Parse(bufpointer, bufsize);
|
WB1.Parse();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 184: //PgUp
|
case 184: //PgUp
|
||||||
@ -398,30 +372,30 @@ void Scan(int id)
|
|||||||
IF(WB1.list.first == 0) return;
|
IF(WB1.list.first == 0) return;
|
||||||
WB1.list.first -= WB1.list.visible - 2;
|
WB1.list.first -= WB1.list.visible - 2;
|
||||||
IF(WB1.list.first < 0) WB1.list.first = 0;
|
IF(WB1.list.first < 0) WB1.list.first = 0;
|
||||||
WB1.Parse(bufpointer, bufsize);
|
WB1.Parse();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 178:
|
case 178:
|
||||||
case BTN_UP:
|
case BTN_UP:
|
||||||
if (WB1.list.first <= 0) return;
|
if (WB1.list.first <= 0) return;
|
||||||
WB1.list.first--;
|
WB1.list.first--;
|
||||||
WB1.Parse(bufpointer, bufsize);
|
WB1.Parse();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 177:
|
case 177:
|
||||||
case BTN_DOWN:
|
case BTN_DOWN:
|
||||||
if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
|
if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
|
||||||
WB1.list.first++;
|
WB1.list.first++;
|
||||||
WB1.Parse(bufpointer, bufsize);
|
WB1.Parse();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 180: //home
|
case 180: //home
|
||||||
if (WB1.list.KeyHome()) WB1.Parse(bufpointer, bufsize);
|
if (WB1.list.KeyHome()) WB1.Parse();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 181: //end
|
case 181: //end
|
||||||
if (WB1.list.count < WB1.list.visible) return;
|
if (WB1.list.count < WB1.list.visible) return;
|
||||||
if (WB1.list.KeyEnd()) WB1.Parse(bufpointer, bufsize);
|
if (WB1.list.KeyEnd()) WB1.Parse();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -477,39 +451,56 @@ void ProcessLinks(int id)
|
|||||||
strcpy(#URL, BrowserHistory.CurrentUrl());
|
strcpy(#URL, BrowserHistory.CurrentUrl());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenPage();
|
OpenPage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StopLoading()
|
||||||
|
{
|
||||||
|
if (http_transfer<>0)
|
||||||
|
{
|
||||||
|
EAX = http_transfer;
|
||||||
|
EAX = EAX.http_msg.content_ptr; // get pointer to data
|
||||||
|
$push EAX // save it on the stack
|
||||||
|
http_free stdcall (http_transfer); // abort connection
|
||||||
|
$pop EAX
|
||||||
|
mem_Free(EAX); // free data
|
||||||
|
http_transfer=0;
|
||||||
|
bufsize = 0;
|
||||||
|
}
|
||||||
|
anchor_line_num=WB1.list.first;
|
||||||
|
anchor[0]='|';
|
||||||
|
}
|
||||||
|
|
||||||
void OpenPage()
|
void OpenPage()
|
||||||
{
|
{
|
||||||
if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
|
if (http_transfer<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
|
||||||
KillProcess(downloader_id);
|
StopLoading();
|
||||||
strcpy(#editURL, #URL);
|
strcpy(#editURL, #URL);
|
||||||
BrowserHistory.AddUrl();
|
BrowserHistory.AddUrl();
|
||||||
strcpy(#header, #version);
|
strcpy(#header, #version);
|
||||||
pre_text =0;
|
pre_text =0;
|
||||||
if (!strncmp(#URL,"http:",5))
|
WB1.list.ClearList();
|
||||||
|
if (strncmp(#URL,"http:",5)==0)
|
||||||
{
|
{
|
||||||
if (native_http)
|
http_get stdcall (#URL, #accept_language);
|
||||||
{
|
http_transfer = EAX;
|
||||||
http_get stdcall (#URL, #accept_language);
|
cur_encoding = _DEFAULT;
|
||||||
http_transfer = EAX;
|
IF (http_transfer < 0) notify("Error from HTTP lib");
|
||||||
IF (http_transfer < 0) notify("Error from HTTP lib");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
KillProcess(downloader_id);
|
|
||||||
DeleteFile(#download_path);
|
|
||||||
downloader_id = RunProgram("/sys/network/downloader", #URL);
|
|
||||||
IF (downloader_id<0) notify("Error running Downloader. Internet unavilable.");
|
|
||||||
}
|
|
||||||
Draw_Window();
|
Draw_Window();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WB1.list.first = WB1.list.count =0;
|
else
|
||||||
WB1.ReadHtml(_WIN);
|
{
|
||||||
|
file_size stdcall (#URL);
|
||||||
|
bufsize = EBX;
|
||||||
|
if (!bufsize) return;
|
||||||
|
mem_Free(bufpointer);
|
||||||
|
cur_encoding = _DEFAULT;
|
||||||
|
if (o_bufpointer) o_bufpointer = free(o_bufpointer);
|
||||||
|
bufpointer = mem_Alloc(bufsize);
|
||||||
|
ReadFile(0, bufsize, bufpointer, #URL);
|
||||||
|
}
|
||||||
ShowPage();
|
ShowPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,46 +514,21 @@ void ShowPage()
|
|||||||
if (!bufsize)
|
if (!bufsize)
|
||||||
{
|
{
|
||||||
PageLinks.Clear();
|
PageLinks.Clear();
|
||||||
if (GetProcessSlot(downloader_id)<>0)
|
if (http_transfer<>0)
|
||||||
WB1.Parse(#loading, sizeof(loading));
|
{
|
||||||
|
WB1.Prepare(#loading, sizeof(loading));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
WB1.Parse(#page_not_found, sizeof(page_not_found));
|
WB1.Prepare(#page_not_found, sizeof(page_not_found));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
WB1.Parse(bufpointer, bufsize);
|
WB1.Parse();
|
||||||
|
|
||||||
if (!header) strcpy(#header, #version);
|
if (!header) strcpy(#header, #version);
|
||||||
if (!strcmp(#version, #header)) DrawTitle(#header);
|
if (!strcmp(#version, #header)) DrawTitle(#header);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowHistory()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
static int history_pointer;
|
|
||||||
|
|
||||||
free(history_pointer);
|
|
||||||
history_pointer = malloc(64000);
|
|
||||||
strcat(history_pointer, " <title>History</title><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>");
|
|
||||||
strcat(history_pointer, #pics[i].path);
|
|
||||||
}
|
|
||||||
bufpointer = history_pointer;
|
|
||||||
WB1.Parse(history_pointer, strlen(history_pointer));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
|
27
programs/cmm/browser/history.h
Normal file
27
programs/cmm/browser/history.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
ShowHistory()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
static int history_pointer;
|
||||||
|
|
||||||
|
free(history_pointer);
|
||||||
|
history_pointer = malloc(64000);
|
||||||
|
strcat(history_pointer, " <title>History</title><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>");
|
||||||
|
strcat(history_pointer, #pics[i].path);
|
||||||
|
}
|
||||||
|
WB1.Prepare(history_pointer, strlen(history_pointer));
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user