2012-11-26 16:26:15 +01:00
|
|
|
|
//HTML Viewer in C--
|
2013-10-08 19:27:18 +02:00
|
|
|
|
//Copyright 2007-2013 by Veliant & Leency
|
2012-12-15 01:16:06 +01:00
|
|
|
|
//Asper, lev, Lrz, Barsuk, Nable...
|
2012-11-26 16:26:15 +01:00
|
|
|
|
//home icon - rachel fu, GPL licence
|
|
|
|
|
|
2013-10-24 23:45:17 +02:00
|
|
|
|
#ifndef AUTOBUILD
|
|
|
|
|
#include "lang.h--"
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-12-15 01:16:06 +01:00
|
|
|
|
//libraries
|
2013-03-11 19:16:24 +01:00
|
|
|
|
#define MEMSIZE 0x100000
|
2012-11-26 16:26:15 +01:00
|
|
|
|
#include "..\lib\kolibri.h"
|
|
|
|
|
#include "..\lib\strings.h"
|
|
|
|
|
#include "..\lib\figures.h"
|
|
|
|
|
#include "..\lib\encoding.h"
|
|
|
|
|
#include "..\lib\file_system.h"
|
|
|
|
|
#include "..\lib\mem.h"
|
|
|
|
|
#include "..\lib\dll.h"
|
2014-01-22 01:08:47 +01:00
|
|
|
|
#include "..\lib\draw_buf.h"
|
|
|
|
|
#include "..\lib\list_box.h"
|
|
|
|
|
#include "..\lib\cursor.h"
|
|
|
|
|
|
2012-12-15 01:16:06 +01:00
|
|
|
|
//*.obj libraries
|
|
|
|
|
#include "..\lib\lib.obj\box_lib.h"
|
|
|
|
|
#include "..\lib\lib.obj\libio_lib.h"
|
|
|
|
|
#include "..\lib\lib.obj\libimg_lib.h"
|
2014-01-27 20:34:00 +01:00
|
|
|
|
#include "..\lib\lib.obj\http.h"
|
2012-12-15 01:16:06 +01:00
|
|
|
|
//images
|
2012-11-26 16:26:15 +01:00
|
|
|
|
#include "img\toolbar_icons.c"
|
|
|
|
|
#include "img\URLgoto.txt";
|
|
|
|
|
|
2013-10-15 00:41:27 +02:00
|
|
|
|
#ifdef LANG_RUS
|
2014-01-30 19:28:50 +01:00
|
|
|
|
char version[]=" <20><><EFBFBD><EFBFBD>⮢<EFBFBD><E2AEA2> <20><><EFBFBD>㧥<EFBFBD> 0.99.67";
|
2013-12-27 13:30:42 +01:00
|
|
|
|
?define IMAGES_CACHE_CLEARED "<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>⨭<EFBFBD><E2A8AD> <20><><EFBFBD>饭"
|
2013-12-29 13:48:06 +01:00
|
|
|
|
?define T_LAST_SLIDE "<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <><E1ABA0>"
|
2014-01-30 19:28:50 +01:00
|
|
|
|
char loading[] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>㧪<EFBFBD> <20><>࠭<EFBFBD><E0A0AD><EFBFBD>...<br>";
|
2014-01-29 01:14:09 +01:00
|
|
|
|
unsigned char page_not_found[] = FROM "html\page_not_found_ru.htm";
|
2013-10-15 00:41:27 +02:00
|
|
|
|
#else
|
2014-01-30 19:28:50 +01:00
|
|
|
|
char version[]=" Text-based Browser 0.99.67";
|
2013-10-15 00:41:27 +02:00
|
|
|
|
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
2013-12-29 13:48:06 +01:00
|
|
|
|
?define T_LAST_SLIDE "This slide is the last"
|
2014-01-30 19:28:50 +01:00
|
|
|
|
char loading[] = "Loading...<br>";
|
2014-01-29 01:14:09 +01:00
|
|
|
|
unsigned char page_not_found[] = FROM "html\page_not_found_en.htm";
|
2013-10-15 00:41:27 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
2012-11-26 16:26:15 +01:00
|
|
|
|
proc_info Form;
|
|
|
|
|
#define WIN_W 640
|
|
|
|
|
#define WIN_H 480
|
|
|
|
|
|
2013-12-27 13:30:42 +01:00
|
|
|
|
char search_path[]="http://nigma.ru/index.php?s=";
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2013-10-22 23:56:28 +02:00
|
|
|
|
char stak[4096];
|
2012-11-26 16:26:15 +01:00
|
|
|
|
mouse m;
|
2013-10-15 00:41:27 +02:00
|
|
|
|
int action_buf;
|
|
|
|
|
|
2014-01-27 20:35:41 +01:00
|
|
|
|
dword http_transfer = 0;
|
|
|
|
|
dword http_buffer;
|
2014-01-27 03:16:25 +01:00
|
|
|
|
|
2014-01-27 21:16:33 +01:00
|
|
|
|
int downloader_id;
|
|
|
|
|
|
2013-12-27 00:36:17 +01:00
|
|
|
|
#include "..\TWB\TWB.c"
|
|
|
|
|
#include "menu_rmb.h"
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2014-01-27 03:16:25 +01:00
|
|
|
|
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};
|
|
|
|
|
|
2014-01-29 01:14:09 +01:00
|
|
|
|
#define URL_HISTORY "WebView://history"
|
2014-01-27 03:16:25 +01:00
|
|
|
|
|
2014-01-19 21:06:42 +01:00
|
|
|
|
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN };
|
|
|
|
|
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
2013-10-24 20:26:04 +02:00
|
|
|
|
int key, btn;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
int half_scroll_size;
|
2013-10-15 00:41:27 +02:00
|
|
|
|
int scroll_used=0, show_menu;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
mem_Init();
|
2014-01-27 20:34:00 +01:00
|
|
|
|
CursorPointer.Load(#CursorFile);
|
2012-12-15 01:16:06 +01:00
|
|
|
|
if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
|
2014-01-27 20:34:00 +01:00
|
|
|
|
if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
|
|
|
|
|
if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
|
2014-01-27 21:16:33 +01:00
|
|
|
|
if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http");
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2014-01-27 20:34:00 +01:00
|
|
|
|
if (!URL) strcpy(#URL, "/sys/index.htm");
|
2012-11-26 16:26:15 +01:00
|
|
|
|
Form.width=WIN_W;
|
|
|
|
|
Form.height=WIN_H;
|
|
|
|
|
SetElementSizes();
|
2013-12-27 13:30:42 +01:00
|
|
|
|
OpenPage();
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2014-01-27 20:34:00 +01:00
|
|
|
|
SetEventMask(0xa7);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
WaitEventTimeout(2);
|
|
|
|
|
switch(EAX & 0xFF)
|
|
|
|
|
{
|
|
|
|
|
CASE evMouse:
|
2013-10-24 20:26:04 +02:00
|
|
|
|
if (!CheckActiveProcess(Form.ID)) break;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2013-04-12 02:11:49 +02:00
|
|
|
|
edit_box_mouse stdcall (#address_box);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
m.get();
|
2014-01-30 19:28:50 +01:00
|
|
|
|
if (m.y>WB1.list.y) PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2014-01-27 21:16:33 +01:00
|
|
|
|
if (m.y>WB1.list.y) && (m.y<Form.height) && (bufsize)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
2013-10-15 00:41:27 +02:00
|
|
|
|
if (m.pkm)
|
|
|
|
|
{
|
|
|
|
|
show_menu = 1;
|
|
|
|
|
}
|
|
|
|
|
if (!m.pkm) && (show_menu)
|
|
|
|
|
{
|
|
|
|
|
show_menu = 0;
|
|
|
|
|
SwitchToAnotherThread();
|
2013-10-22 23:56:28 +02:00
|
|
|
|
CreateThread(#menu_rmb,#stak+4092);
|
2013-10-15 00:41:27 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-27 12:15:17 +01:00
|
|
|
|
if (m.vert)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
2014-01-30 19:28:50 +01:00
|
|
|
|
if (WB1.list.MouseScroll(m.vert)) WB1.Parse(bufpointer, bufsize);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m.lkm) scroll_used=0;
|
2013-12-27 13:30:42 +01:00
|
|
|
|
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)
|
2013-12-27 12:15:17 +01:00
|
|
|
|
&& (WB1.list.count>WB1.list.visible) && (m.lkm)
|
2013-10-15 00:41:27 +02:00
|
|
|
|
{
|
|
|
|
|
scroll_used=1;
|
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
if (scroll_used)
|
|
|
|
|
{
|
2013-12-27 12:15:17 +01:00
|
|
|
|
half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2;
|
2013-12-27 13:30:42 +01:00
|
|
|
|
if (half_scroll_size+WB1.list.y>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.list.y;
|
|
|
|
|
btn=WB1.list.first;
|
2013-12-27 12:15:17 +01:00
|
|
|
|
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;
|
2014-01-30 19:28:50 +01:00
|
|
|
|
if (btn<>WB1.list.first) WB1.Parse(bufpointer, bufsize);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case evButton:
|
|
|
|
|
btn=GetButtonID();
|
2013-04-10 14:40:09 +02:00
|
|
|
|
if (btn==1)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
|
|
|
|
KillProcess(downloader_id);
|
|
|
|
|
ExitProcess();
|
|
|
|
|
}
|
|
|
|
|
ELSE
|
|
|
|
|
{
|
2013-12-27 01:33:12 +01:00
|
|
|
|
Scan(btn);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case evKey:
|
|
|
|
|
key = GetKey();
|
|
|
|
|
|
2013-12-27 13:30:42 +01:00
|
|
|
|
if (address_box.flags & 0b10) SWITCH(key)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; }
|
|
|
|
|
|
2013-12-27 01:33:12 +01:00
|
|
|
|
Scan(key);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
_EDIT_MARK:
|
2013-12-27 13:30:42 +01:00
|
|
|
|
if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
break;
|
|
|
|
|
case evReDraw:
|
2013-12-27 01:33:12 +01:00
|
|
|
|
if (action_buf) { Scan(action_buf); action_buf=0;}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
Draw_Window();
|
|
|
|
|
break;
|
2014-01-27 21:16:33 +01:00
|
|
|
|
|
2014-01-27 20:34:00 +01:00
|
|
|
|
case evNetwork:
|
|
|
|
|
return;
|
2014-01-27 21:16:33 +01:00
|
|
|
|
http_get stdcall (#search_path, 0);
|
2014-01-27 20:34:00 +01:00
|
|
|
|
http_transfer = EAX;
|
2014-01-27 21:16:33 +01:00
|
|
|
|
IF (http_transfer < 0) notify("Error from HTTP lib");
|
|
|
|
|
|
|
|
|
|
if (http_transfer > 0) {
|
2014-01-27 20:34:00 +01:00
|
|
|
|
http_process stdcall (http_transfer);
|
|
|
|
|
$push EAX
|
|
|
|
|
ESI = http_transfer;
|
2014-01-27 21:16:33 +01:00
|
|
|
|
bufpointer = ESI.http_msg.content_ptr;
|
|
|
|
|
debug(bufpointer);
|
|
|
|
|
//bufsize = ESI.http_msg.content_received;
|
|
|
|
|
bufsize = strlen(bufpointer)-2;
|
|
|
|
|
debugi(bufsize);
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(bufpointer, bufsize);
|
2014-01-27 20:34:00 +01:00
|
|
|
|
$pop EAX
|
|
|
|
|
if (EAX == 0) {
|
|
|
|
|
http_free stdcall (http_transfer);
|
|
|
|
|
http_transfer=0;
|
|
|
|
|
}
|
2014-01-27 21:16:33 +01:00
|
|
|
|
pause(10);
|
2014-01-27 20:34:00 +01:00
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
default:
|
|
|
|
|
if (downloader_id<>0)
|
|
|
|
|
{
|
|
|
|
|
if (GetProcessSlot(downloader_id)<>0) break;
|
|
|
|
|
downloader_id=0;
|
2013-12-27 12:15:17 +01:00
|
|
|
|
WB1.list.first = WB1.list.count = 0;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
WB1.ReadHtml(_WIN);
|
|
|
|
|
Draw_Window();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetElementSizes()
|
|
|
|
|
{
|
2013-12-27 13:30:42 +01:00
|
|
|
|
address_box.width = Form.width - 266;
|
|
|
|
|
WB1.list.SetSizes(0, 44, Form.width - 10 - scroll_wv.size_x, Form.cheight - 44, 0, 10);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
WB1.list.column_max = WB1.list.w - 30 / 6;
|
|
|
|
|
WB1.list.visible = WB1.list.h - 3 / WB1.list.line_h - 2;
|
2014-01-18 12:46:58 +01:00
|
|
|
|
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h, WB1.list.line_h);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Draw_Window()
|
|
|
|
|
{
|
|
|
|
|
int j;
|
2013-04-12 02:11:49 +02:00
|
|
|
|
DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0xE4DFE1,0,0);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2013-04-10 14:40:09 +02:00
|
|
|
|
if (Form.status_window>2)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
|
|
|
|
DrawTitle(#header);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
|
|
|
|
|
if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
|
|
|
|
|
|
|
|
|
|
PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
|
2013-03-11 19:16:24 +01:00
|
|
|
|
if (GetProcessSlot(downloader_id)<>0) _PutImage(88,10, 24,24, #stop_btn);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2013-04-10 14:40:09 +02:00
|
|
|
|
DrawBar(200,0,Form.cwidth-200,43,0xE4DFE1);
|
|
|
|
|
DrawBar(0,42,Form.cwidth,1,0xE2DBDC);
|
|
|
|
|
DrawBar(0,43,Form.cwidth,1,0xD2CED0);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
for (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0xE4DFE1);
|
2013-04-10 14:40:09 +02:00
|
|
|
|
_PutImage(Form.cwidth-48,14, 40,19, #URLgoto);
|
|
|
|
|
DefineButton(Form.cwidth-28,15, 18, 16, GOTOURL+BT_HIDE, 0xE4DFE1);
|
|
|
|
|
DefineButton(Form.cwidth-47,15, 17, 16, SEARCHWEB+BT_HIDE, 0xE4DFE1);
|
|
|
|
|
DrawRectangle(205,14,Form.cwidth-205-49,18,0x94AECE); //around adress bar
|
|
|
|
|
DrawRectangle(206,15,Form.cwidth-205-50,16,0xE4ECF3);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
|
|
|
|
SetElementSizes();
|
2014-01-22 01:08:47 +01:00
|
|
|
|
ShowPage();
|
2013-04-10 14:40:09 +02:00
|
|
|
|
|
2013-12-27 13:30:42 +01:00
|
|
|
|
DefineButton(scroll_wv.start_x+1, scroll_wv.start_y+1, 16, 16, BTN_UP+BT_HIDE, 0xE4DFE1);
|
|
|
|
|
DefineButton(scroll_wv.start_x+1, scroll_wv.start_y+scroll_wv.size_y-18, 16, 16, BTN_DOWN+BT_HIDE, 0xE4DFE1);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-12-27 01:33:12 +01:00
|
|
|
|
void Scan(int id)
|
|
|
|
|
{
|
2013-12-27 12:15:17 +01:00
|
|
|
|
if (id >= 400) ProcessLinks(id);
|
2013-12-27 01:33:12 +01:00
|
|
|
|
|
|
|
|
|
switch (id)
|
|
|
|
|
{
|
|
|
|
|
case 011: //Ctrk+K
|
|
|
|
|
WB1.ReadHtml(_KOI);
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(bufpointer, bufsize);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
2013-12-27 01:33:12 +01:00
|
|
|
|
case 021: //Ctrl+U
|
|
|
|
|
WB1.ReadHtml(_UTF);
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(bufpointer, bufsize);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
2013-12-27 01:33:12 +01:00
|
|
|
|
case 004: //Ctrl+D
|
|
|
|
|
WB1.ReadHtml(_DOS);
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(bufpointer, bufsize);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
2014-01-27 02:17:07 +01:00
|
|
|
|
case 005: //Win encoding
|
|
|
|
|
WB1.ReadHtml(_WIN);
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(bufpointer, bufsize);
|
2014-01-27 02:17:07 +01:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 009: //free img cache
|
2014-01-19 23:46:58 +01:00
|
|
|
|
ImgCache.Free();
|
2013-12-27 13:30:42 +01:00
|
|
|
|
notify(IMAGES_CACHE_CLEARED);
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(bufpointer, bufsize);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
2014-01-29 01:28:04 +01:00
|
|
|
|
case 003: //history
|
2014-01-29 01:14:09 +01:00
|
|
|
|
strcpy(#URL, URL_HISTORY);
|
|
|
|
|
OpenPage();
|
|
|
|
|
return;
|
|
|
|
|
|
2013-12-27 01:33:12 +01:00
|
|
|
|
case BACK:
|
|
|
|
|
if (!BrowserHistory.GoBack()) return;
|
2013-12-27 13:30:42 +01:00
|
|
|
|
OpenPage();
|
2013-12-27 01:33:12 +01:00
|
|
|
|
return;
|
|
|
|
|
case FORWARD:
|
|
|
|
|
if (!BrowserHistory.GoForward()) return;
|
2013-12-27 13:30:42 +01:00
|
|
|
|
OpenPage();
|
2013-12-27 01:33:12 +01:00
|
|
|
|
return;
|
|
|
|
|
case 052: //F3
|
2014-01-19 21:06:42 +01:00
|
|
|
|
if (strncmp(#URL,"http:",5)<>0) RunProgram("/rd/1/tinypad", #URL);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
else RunProgram("/rd/1/tinypad", #download_path);
|
2013-12-27 01:33:12 +01:00
|
|
|
|
return;
|
|
|
|
|
case 054: //F5
|
2014-01-30 19:28:50 +01:00
|
|
|
|
IF(address_box.flags & 0b10) WB1.Parse(bufpointer, bufsize);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
2013-12-27 01:33:12 +01:00
|
|
|
|
case REFRESH:
|
|
|
|
|
if (GetProcessSlot(downloader_id)<>0)
|
|
|
|
|
{
|
|
|
|
|
KillProcess(downloader_id);
|
|
|
|
|
pause(20);
|
|
|
|
|
Draw_Window();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-12-27 12:15:17 +01:00
|
|
|
|
anchor_line_num=WB1.list.first;
|
2013-12-27 01:33:12 +01:00
|
|
|
|
anchor[0]='|';
|
2013-12-27 13:30:42 +01:00
|
|
|
|
OpenPage();
|
2013-12-27 01:33:12 +01:00
|
|
|
|
return;
|
2013-12-27 12:15:17 +01:00
|
|
|
|
case 014:
|
|
|
|
|
case 020:
|
2013-12-27 01:33:12 +01:00
|
|
|
|
case NEWTAB:
|
|
|
|
|
MoveSize(190,80,OLD,OLD);
|
|
|
|
|
RunProgram(#program_path, #URL);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case HOME:
|
|
|
|
|
strcpy(#editURL, "http://kolibrios.org/en/index.htm");
|
|
|
|
|
case GOTOURL:
|
|
|
|
|
case 0x0D: //enter
|
|
|
|
|
if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0;
|
|
|
|
|
strcat(#URL, #editURL);
|
2013-12-27 13:30:42 +01:00
|
|
|
|
OpenPage();
|
2013-12-27 01:33:12 +01:00
|
|
|
|
return;
|
|
|
|
|
case SEARCHWEB:
|
|
|
|
|
strcpy(#URL, #search_path);
|
|
|
|
|
strcat(#URL, #editURL);
|
2013-12-27 13:30:42 +01:00
|
|
|
|
OpenPage();
|
2013-12-27 01:33:12 +01:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 183: //PgDown
|
2013-12-27 12:15:17 +01:00
|
|
|
|
if (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;
|
|
|
|
|
IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible;
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(bufpointer, bufsize);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
2013-12-27 01:33:12 +01:00
|
|
|
|
case 184: //PgUp
|
2013-12-27 12:15:17 +01:00
|
|
|
|
if (WB1.list.count < WB1.list.visible) return;
|
|
|
|
|
IF(WB1.list.first == 0) return;
|
|
|
|
|
WB1.list.first -= WB1.list.visible - 2;
|
|
|
|
|
IF(WB1.list.first < 0) WB1.list.first = 0;
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(bufpointer, bufsize);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 178:
|
2014-01-29 01:14:09 +01:00
|
|
|
|
case BTN_UP:
|
2013-12-27 13:30:42 +01:00
|
|
|
|
if (WB1.list.first <= 0) return;
|
2013-12-27 12:15:17 +01:00
|
|
|
|
WB1.list.first--;
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(bufpointer, bufsize);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 177:
|
2014-01-29 01:14:09 +01:00
|
|
|
|
case BTN_DOWN:
|
2013-12-27 13:30:42 +01:00
|
|
|
|
if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
|
2013-12-27 12:15:17 +01:00
|
|
|
|
WB1.list.first++;
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(bufpointer, bufsize);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
2013-12-27 01:33:12 +01:00
|
|
|
|
case 180: //home
|
2014-01-30 19:28:50 +01:00
|
|
|
|
if (WB1.list.KeyHome()) WB1.Parse(bufpointer, bufsize);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
return;
|
|
|
|
|
|
2013-12-27 01:33:12 +01:00
|
|
|
|
case 181: //end
|
2013-12-27 12:15:17 +01:00
|
|
|
|
if (WB1.list.count < WB1.list.visible) return;
|
2014-01-30 19:28:50 +01:00
|
|
|
|
if (WB1.list.KeyEnd()) WB1.Parse(bufpointer, bufsize);
|
2013-12-27 01:33:12 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-27 12:15:17 +01:00
|
|
|
|
void ProcessLinks(int id)
|
|
|
|
|
{
|
2014-01-29 01:14:09 +01:00
|
|
|
|
strcpy(#URL, PageLinks.GetURL(id-401));
|
2013-12-29 13:48:06 +01:00
|
|
|
|
//$1 - Condition Script
|
|
|
|
|
if (URL[0] == '$')
|
|
|
|
|
{
|
|
|
|
|
if (URL[1]=='-') && (condition_href) condition_href--;
|
|
|
|
|
if (URL[1]=='+')
|
|
|
|
|
{
|
|
|
|
|
if (condition_href<condition_max) condition_href++; else notify(T_LAST_SLIDE);
|
|
|
|
|
}
|
|
|
|
|
if (URL[1]!='-') && (URL[1]!='+') condition_href = atoi(#URL+1);
|
|
|
|
|
strcpy(#URL, BrowserHistory.CurrentUrl());
|
2014-01-22 01:08:47 +01:00
|
|
|
|
ShowPage();
|
2013-12-29 13:48:06 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2013-12-27 12:15:17 +01:00
|
|
|
|
//#1
|
|
|
|
|
if (URL[0] == '#')
|
|
|
|
|
{
|
2013-12-29 13:48:06 +01:00
|
|
|
|
strcpy(#anchor, #URL+strrchr(#URL, '#'));
|
2013-12-27 12:15:17 +01:00
|
|
|
|
strcpy(#URL, BrowserHistory.CurrentUrl());
|
|
|
|
|
WB1.list.first=WB1.list.count-WB1.list.visible;
|
2014-01-22 01:08:47 +01:00
|
|
|
|
ShowPage();
|
2013-12-27 12:15:17 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//liner.ru#1
|
2013-12-29 13:48:06 +01:00
|
|
|
|
if (strrchr(#URL, '#')!=-1)
|
2013-12-27 12:15:17 +01:00
|
|
|
|
{
|
|
|
|
|
strcpy(#anchor, #URL+strrchr(#URL, '#'));
|
2013-12-27 13:30:42 +01:00
|
|
|
|
URL[strrchr(#URL, '#')-1] = 0x00;
|
2013-12-27 12:15:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WB1.GetNewUrl();
|
|
|
|
|
|
|
|
|
|
if (!strcmp(#URL + strlen(#URL) - 4, ".gif")) || (!strcmp(#URL + strlen(#URL) - 4, ".png")) || (!strcmp(#URL + strlen(#URL) - 4, ".jpg"))
|
|
|
|
|
{
|
|
|
|
|
//if (strstr(#URL,"http:"))
|
|
|
|
|
RunProgram("/sys/media/kiv", #URL);
|
|
|
|
|
strcpy(#editURL, BrowserHistory.CurrentUrl());
|
|
|
|
|
strcpy(#URL, BrowserHistory.CurrentUrl());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!strcmpn(#URL,"mailto:", 7))
|
|
|
|
|
{
|
|
|
|
|
notify(#URL);
|
|
|
|
|
strcpy(#editURL, BrowserHistory.CurrentUrl());
|
|
|
|
|
strcpy(#URL, BrowserHistory.CurrentUrl());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-27 13:30:42 +01:00
|
|
|
|
OpenPage();
|
2013-12-27 12:15:17 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-27 13:30:42 +01:00
|
|
|
|
void OpenPage()
|
|
|
|
|
{
|
|
|
|
|
if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
|
|
|
|
|
KillProcess(downloader_id);
|
|
|
|
|
strcpy(#editURL, #URL);
|
|
|
|
|
BrowserHistory.AddUrl();
|
|
|
|
|
strcpy(#header, #version);
|
|
|
|
|
pre_text =0;
|
2014-01-19 21:06:42 +01:00
|
|
|
|
if (!strncmp(#URL,"http:",5))
|
2013-12-27 13:30:42 +01:00
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
WB1.list.first = WB1.list.count =0;
|
|
|
|
|
WB1.ReadHtml(_WIN);
|
2014-01-22 01:08:47 +01:00
|
|
|
|
ShowPage();
|
2013-12-27 13:30:42 +01:00
|
|
|
|
}
|
2013-12-27 12:15:17 +01:00
|
|
|
|
|
2014-01-22 01:08:47 +01:00
|
|
|
|
void ShowPage()
|
|
|
|
|
{
|
|
|
|
|
address_box.size = address_box.pos = strlen(#editURL);
|
|
|
|
|
address_box.offset=0;
|
|
|
|
|
edit_box_draw stdcall(#address_box);
|
|
|
|
|
|
2014-01-29 01:14:09 +01:00
|
|
|
|
if (strcmp(#URL, URL_HISTORY)==0) ShowHistory(); else
|
2014-01-27 21:16:33 +01:00
|
|
|
|
if (!bufsize)
|
2014-01-22 01:08:47 +01:00
|
|
|
|
{
|
|
|
|
|
PageLinks.Clear();
|
2014-01-30 19:28:50 +01:00
|
|
|
|
if (GetProcessSlot(downloader_id)<>0)
|
|
|
|
|
WB1.Parse(#loading, sizeof(loading));
|
2014-01-22 01:08:47 +01:00
|
|
|
|
else
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(#page_not_found, sizeof(page_not_found));
|
2014-01-22 01:08:47 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(bufpointer, bufsize);
|
2014-01-22 01:08:47 +01:00
|
|
|
|
|
|
|
|
|
if (!header) strcpy(#header, #version);
|
|
|
|
|
if (!strcmp(#version, #header)) DrawTitle(#header);
|
|
|
|
|
}
|
2013-12-27 12:15:17 +01:00
|
|
|
|
|
2014-01-29 01:14:09 +01:00
|
|
|
|
ShowHistory()
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
static int history_pointer;
|
|
|
|
|
|
|
|
|
|
free(history_pointer);
|
|
|
|
|
history_pointer = malloc(64000);
|
2014-01-30 19:28:50 +01:00
|
|
|
|
strcat(history_pointer, " <title>History</title><h1>History</h1>");
|
2014-01-29 01:14:09 +01:00
|
|
|
|
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>");
|
2014-01-30 19:28:50 +01:00
|
|
|
|
strcat(history_pointer, #pics[i].path);
|
2014-01-29 01:14:09 +01:00
|
|
|
|
}
|
|
|
|
|
bufpointer = history_pointer;
|
2014-01-30 19:28:50 +01:00
|
|
|
|
WB1.Parse(history_pointer, strlen(history_pointer));
|
2014-01-29 01:14:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-27 01:33:12 +01:00
|
|
|
|
|
2012-11-26 16:26:15 +01:00
|
|
|
|
stop:
|