2012-11-26 19:26:15 +04:00
|
|
|
|
//HTML Viewer in C--
|
2020-03-20 04:28:59 +03:00
|
|
|
|
//Copyright 2007-2020 by Veliant & Leency
|
2017-09-17 04:32:09 +03:00
|
|
|
|
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
|
2012-11-26 19:26:15 +04:00
|
|
|
|
|
2013-10-25 01:45:17 +04:00
|
|
|
|
#ifndef AUTOBUILD
|
|
|
|
|
#include "lang.h--"
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-12-15 04:16:06 +04:00
|
|
|
|
//libraries
|
2020-03-27 13:38:54 +03:00
|
|
|
|
#define MEMSIZE 1024 * 850
|
2015-03-05 23:55:28 +03:00
|
|
|
|
#include "..\lib\gui.h"
|
2014-01-22 04:08:47 +04:00
|
|
|
|
#include "..\lib\draw_buf.h"
|
|
|
|
|
#include "..\lib\list_box.h"
|
|
|
|
|
#include "..\lib\cursor.h"
|
2015-12-17 01:44:42 +03:00
|
|
|
|
#include "..\lib\collection.h"
|
2016-12-14 01:08:14 +03:00
|
|
|
|
#include "..\lib\random.h"
|
2017-10-01 14:57:00 +03:00
|
|
|
|
#include "..\lib\clipboard.h"
|
2015-12-17 22:15:49 +03:00
|
|
|
|
|
2018-10-06 01:10:27 +03:00
|
|
|
|
// *.obj libraries
|
2015-03-05 23:55:28 +03:00
|
|
|
|
#include "..\lib\obj\box_lib.h"
|
2017-10-05 01:59:57 +03:00
|
|
|
|
#include "..\lib\obj\libio.h"
|
|
|
|
|
#include "..\lib\obj\libimg.h"
|
2015-03-05 23:55:28 +03:00
|
|
|
|
#include "..\lib\obj\http.h"
|
2015-08-07 01:37:34 +03:00
|
|
|
|
#include "..\lib\obj\iconv.h"
|
2020-03-23 04:11:31 +03:00
|
|
|
|
#include "..\lib\obj\proc_lib.h"
|
2020-03-29 13:57:14 +03:00
|
|
|
|
|
2015-02-15 13:18:26 +03:00
|
|
|
|
//useful patterns
|
2015-12-17 01:44:42 +03:00
|
|
|
|
#include "..\lib\patterns\history.h"
|
2016-01-15 02:05:51 +03:00
|
|
|
|
#include "..\lib\patterns\http_downloader.h"
|
2020-03-23 04:11:31 +03:00
|
|
|
|
#include "..\lib\patterns\simple_open_dialog.h"
|
2015-02-15 13:18:26 +03:00
|
|
|
|
|
2020-03-29 13:57:14 +03:00
|
|
|
|
#include "show_src.h"
|
|
|
|
|
#include "download_manager.h"
|
|
|
|
|
_history history;
|
|
|
|
|
#include "history.h"
|
|
|
|
|
bool debug_mode = false;
|
|
|
|
|
#include "..\TWB\TWB.c"
|
|
|
|
|
|
2020-03-31 00:29:52 +03:00
|
|
|
|
char version[]="WebView 2.0 Gold";
|
|
|
|
|
|
2013-10-15 02:41:27 +04:00
|
|
|
|
#ifdef LANG_RUS
|
2016-11-10 20:48:36 +03:00
|
|
|
|
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
|
2020-03-21 21:49:45 +03:00
|
|
|
|
char homepage[] = FROM "html\\homepage_ru.htm""\0";
|
|
|
|
|
char help[] = FROM "html\\help_ru.htm""\0";
|
2016-01-08 05:19:41 +03:00
|
|
|
|
char accept_language[]= "Accept-Language: ru\n";
|
|
|
|
|
char rmb_menu[] =
|
|
|
|
|
"<EFBFBD><EFBFBD>ᬮ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>室<EFBFBD><E5AEA4><EFBFBD>
|
2020-03-31 00:29:52 +03:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>室<EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
char main_menu[] =
|
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 䠩<>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2016-01-08 05:19:41 +03:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>㧮<EFBFBD>";
|
2017-10-01 14:57:00 +03:00
|
|
|
|
char link_menu[] =
|
2018-03-23 18:04:20 +03:00
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>뫪<EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᮤ<EFBFBD>ন<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>뫪<EFBFBD>";
|
2020-03-31 00:29:52 +03:00
|
|
|
|
char loading_text[] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>㧪<EFBFBD>...";
|
2013-10-15 02:41:27 +04:00
|
|
|
|
#else
|
2016-11-10 20:48:36 +03:00
|
|
|
|
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
|
2020-03-21 21:49:45 +03:00
|
|
|
|
char homepage[] = FROM "html\\homepage_en.htm""\0";
|
|
|
|
|
char help[] = FROM "html\\help_en.htm""\0";
|
2016-01-08 05:19:41 +03:00
|
|
|
|
char accept_language[]= "Accept-Language: en\n";
|
|
|
|
|
char rmb_menu[] =
|
|
|
|
|
"View source
|
2020-03-31 00:29:52 +03:00
|
|
|
|
Edit source";
|
|
|
|
|
char main_menu[] =
|
|
|
|
|
"Open local file
|
|
|
|
|
New window
|
2016-01-08 05:19:41 +03:00
|
|
|
|
History
|
|
|
|
|
Download Manager";
|
2017-10-01 14:57:00 +03:00
|
|
|
|
char link_menu[] =
|
2018-03-23 18:04:20 +03:00
|
|
|
|
"Copy link
|
|
|
|
|
Download link contents";
|
2020-03-31 00:29:52 +03:00
|
|
|
|
char loading_text[] = "Loading...";
|
2013-10-15 02:41:27 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
2020-03-27 23:18:44 +03:00
|
|
|
|
#define URL_SIZE 4000
|
2020-03-26 03:12:32 +03:00
|
|
|
|
|
2020-03-25 03:18:19 +03:00
|
|
|
|
#define URL_SERVICE_HISTORY "WebView:history"
|
|
|
|
|
#define URL_SERVICE_HOMEPAGE "WebView:home"
|
|
|
|
|
#define URL_SERVICE_HELP "WebView:help"
|
2013-10-15 02:41:27 +04:00
|
|
|
|
|
2020-03-31 00:29:52 +03:00
|
|
|
|
#define PADDING 9
|
|
|
|
|
#define SKIN_Y 24
|
|
|
|
|
#define TSZE 25
|
|
|
|
|
dword TOOLBAR_H = PADDING+TSZE+PADDING+2;
|
2015-03-16 17:20:32 +03:00
|
|
|
|
dword STATUSBAR_H = 15;
|
2018-10-02 17:01:29 +03:00
|
|
|
|
|
2020-03-25 03:18:19 +03:00
|
|
|
|
int action_buf;
|
2014-03-22 14:29:29 +04:00
|
|
|
|
|
2020-03-31 00:29:52 +03:00
|
|
|
|
_http http = {0, 0, 0, 0, 0, 0, 0};
|
|
|
|
|
|
2020-03-25 03:18:19 +03:00
|
|
|
|
bool source_mode = false;
|
2018-05-20 16:40:58 +03:00
|
|
|
|
|
2015-08-13 15:23:35 +03:00
|
|
|
|
progress_bar wv_progress_bar;
|
2020-03-25 03:18:19 +03:00
|
|
|
|
char stak[4096];
|
|
|
|
|
proc_info Form;
|
2014-03-22 14:29:29 +04:00
|
|
|
|
|
2015-08-13 15:23:35 +03:00
|
|
|
|
enum {
|
|
|
|
|
BACK_BUTTON=1000,
|
|
|
|
|
FORWARD_BUTTON,
|
|
|
|
|
REFRESH_BUTTON,
|
|
|
|
|
GOTOURL_BUTTON,
|
2016-12-14 01:08:14 +03:00
|
|
|
|
SANDWICH_BUTTON,
|
2020-03-25 03:18:19 +03:00
|
|
|
|
VIEW_SOURCE,
|
2015-08-13 15:23:35 +03:00
|
|
|
|
EDIT_SOURCE,
|
2020-03-31 00:29:52 +03:00
|
|
|
|
OPEN_FILE,
|
|
|
|
|
NEW_WINDOW,
|
2015-08-13 15:23:35 +03:00
|
|
|
|
VIEW_HISTORY,
|
2016-12-14 01:08:14 +03:00
|
|
|
|
DOWNLOAD_MANAGER,
|
2020-03-25 03:18:19 +03:00
|
|
|
|
COPY_LINK_URL,
|
2018-03-23 18:04:20 +03:00
|
|
|
|
DOWNLOAD_LINK_CONTENTS,
|
2015-08-13 15:23:35 +03:00
|
|
|
|
};
|
|
|
|
|
|
2020-03-23 04:11:31 +03:00
|
|
|
|
char default_dir[] = "/rd/1";
|
|
|
|
|
od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" };
|
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
char editURL[URL_SIZE+1];
|
2020-03-31 00:29:52 +03:00
|
|
|
|
edit_box address_box = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff,
|
|
|
|
|
0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19};
|
2014-01-27 06:16:25 +04:00
|
|
|
|
|
2014-03-30 15:57:13 +04:00
|
|
|
|
|
2020-03-23 04:11:31 +03:00
|
|
|
|
void LoadLibraries()
|
|
|
|
|
{
|
|
|
|
|
load_dll(boxlib, #box_lib_init,0);
|
|
|
|
|
load_dll(libio, #libio_init,1);
|
|
|
|
|
load_dll(libimg, #libimg_init,1);
|
|
|
|
|
load_dll(libHTTP, #http_lib_init,1);
|
|
|
|
|
load_dll(iconv_lib, #iconv_open,0);
|
|
|
|
|
load_dll(Proc_lib, #OpenDialog_init,0);
|
|
|
|
|
OpenDialog_init stdcall (#o_dialog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HandleParam()
|
|
|
|
|
{
|
|
|
|
|
if (param) {
|
2020-03-25 03:18:19 +03:00
|
|
|
|
if (!strncmp(#param, "-d ", 3)) {
|
2020-03-23 04:11:31 +03:00
|
|
|
|
strcpy(#downloader_edit, #param+3);
|
|
|
|
|
CreateThread(#Downloader,#downloader_stak+4092);
|
|
|
|
|
ExitProcess();
|
2020-03-25 03:18:19 +03:00
|
|
|
|
} else if (!strncmp(#param, "-s ", 3)) {
|
|
|
|
|
source_mode = true;
|
2020-03-27 13:38:54 +03:00
|
|
|
|
history.add(#param + 3);
|
2020-03-23 04:11:31 +03:00
|
|
|
|
} else {
|
2020-03-27 13:38:54 +03:00
|
|
|
|
history.add(#param);
|
2020-03-23 04:11:31 +03:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2020-03-27 13:38:54 +03:00
|
|
|
|
history.add(URL_SERVICE_HOMEPAGE);
|
2020-03-23 04:11:31 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-26 19:26:15 +04:00
|
|
|
|
void main()
|
|
|
|
|
{
|
2020-03-31 00:29:52 +03:00
|
|
|
|
int i, btn, redirect_count=0;
|
2020-03-23 04:11:31 +03:00
|
|
|
|
LoadLibraries();
|
|
|
|
|
CreateDir("/tmp0/1/downloads");
|
2018-10-02 23:13:25 +03:00
|
|
|
|
Libimg_LoadImage(#skin, "/sys/toolbar.png");
|
2020-03-23 04:11:31 +03:00
|
|
|
|
HandleParam();
|
2018-10-06 01:10:27 +03:00
|
|
|
|
skin.h = 26;
|
2016-01-08 05:19:41 +03:00
|
|
|
|
WB1.list.SetFont(8, 14, 10011000b);
|
2015-08-29 23:14:17 +03:00
|
|
|
|
WB1.list.no_selection = true;
|
2017-09-17 04:32:09 +03:00
|
|
|
|
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
|
|
|
|
|
loop() switch(WaitEvent())
|
|
|
|
|
{
|
|
|
|
|
case evMouse:
|
|
|
|
|
edit_box_mouse stdcall (#address_box);
|
|
|
|
|
mouse.get();
|
2020-03-29 13:57:14 +03:00
|
|
|
|
if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y, WB1.list.y, WB1.list.first))
|
2020-03-27 13:38:54 +03:00
|
|
|
|
&& (mouse.pkm) && (mouse.up) {
|
2018-05-20 16:40:58 +03:00
|
|
|
|
if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y);
|
|
|
|
|
break;
|
2017-09-17 04:32:09 +03:00
|
|
|
|
}
|
2018-05-20 16:40:58 +03:00
|
|
|
|
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
|
2017-09-17 04:32:09 +03:00
|
|
|
|
scrollbar_v_mouse (#scroll_wv);
|
|
|
|
|
if (WB1.list.first != scroll_wv.position)
|
|
|
|
|
{
|
|
|
|
|
WB1.list.first = scroll_wv.position;
|
|
|
|
|
WB1.DrawPage();
|
2012-11-26 19:26:15 +04:00
|
|
|
|
break;
|
2017-09-17 04:32:09 +03:00
|
|
|
|
}
|
2020-03-31 00:29:52 +03:00
|
|
|
|
if (mouse.up) && (! address_box.flags & ed_focus) && (address_box.flags & ed_shift_bac)
|
|
|
|
|
{
|
|
|
|
|
DrawOmnibox(); //reset text selection
|
|
|
|
|
}
|
2017-09-17 04:32:09 +03:00
|
|
|
|
break;
|
2015-08-10 18:08:16 +03:00
|
|
|
|
|
2017-09-17 04:32:09 +03:00
|
|
|
|
case evButton:
|
2020-03-31 00:29:52 +03:00
|
|
|
|
btn = GetButtonID();
|
|
|
|
|
if (1==btn) ExitProcess(); else ProcessEvent(btn);
|
2017-09-17 04:32:09 +03:00
|
|
|
|
break;
|
2015-08-10 18:08:16 +03:00
|
|
|
|
|
2017-09-17 04:32:09 +03:00
|
|
|
|
case evKey:
|
|
|
|
|
GetKeys();
|
2020-03-21 17:33:54 +03:00
|
|
|
|
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
|
2020-03-26 03:12:32 +03:00
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_H) {ProcessEvent(VIEW_HISTORY);break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_U) {EventViewSource();break;}
|
2020-03-21 17:33:54 +03:00
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_T)
|
2020-03-26 03:12:32 +03:00
|
|
|
|
|| (key_scancode == SCAN_CODE_KEY_N) {RunProgram(#program_path, NULL);break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_J) {ProcessEvent(DOWNLOAD_MANAGER);break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_R) {ProcessEvent(REFRESH_BUTTON);break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_ENTER) {EventSeachWeb();break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_LEFT) {ProcessEvent(BACK_BUTTON);break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_RIGHT) {ProcessEvent(FORWARD_BUTTON);break;}
|
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_W) {ExitProcess();break;}
|
2020-03-21 17:33:54 +03:00
|
|
|
|
}
|
2020-03-21 21:49:45 +03:00
|
|
|
|
|
|
|
|
|
if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON);
|
|
|
|
|
|
2018-10-29 14:39:31 +03:00
|
|
|
|
if (address_box.flags & ed_focus)
|
2017-09-17 04:32:09 +03:00
|
|
|
|
{
|
2020-03-21 17:33:54 +03:00
|
|
|
|
if (key_scancode == SCAN_CODE_ENTER) {
|
|
|
|
|
ProcessEvent(key_scancode);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2017-09-17 04:32:09 +03:00
|
|
|
|
EAX = key_editbox;
|
|
|
|
|
edit_box_key stdcall(#address_box);
|
2015-08-10 18:08:16 +03:00
|
|
|
|
}
|
2017-09-17 04:32:09 +03:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-10-01 19:41:14 +03:00
|
|
|
|
#define KEY_SCROLL_N 11
|
|
|
|
|
if (SCAN_CODE_UP == key_scancode) for (i=0;i<KEY_SCROLL_N;i++) WB1.list.KeyUp();
|
|
|
|
|
if (SCAN_CODE_DOWN == key_scancode) for (i=0;i<KEY_SCROLL_N;i++) WB1.list.KeyDown();
|
2020-03-21 21:49:45 +03:00
|
|
|
|
if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();}
|
2017-09-17 04:32:09 +03:00
|
|
|
|
if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
|
|
|
|
|
else ProcessEvent(key_scancode);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2015-03-18 22:40:42 +03:00
|
|
|
|
|
2017-09-17 04:32:09 +03:00
|
|
|
|
case evReDraw:
|
2018-10-11 17:32:24 +03:00
|
|
|
|
if (menu.cur_y) {
|
|
|
|
|
ProcessEvent(menu.cur_y);
|
|
|
|
|
menu.cur_y = 0;
|
2017-09-17 04:32:09 +03:00
|
|
|
|
}
|
2020-03-27 13:38:54 +03:00
|
|
|
|
DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),
|
|
|
|
|
GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
|
2017-09-17 04:32:09 +03:00
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2020-03-23 04:11:31 +03:00
|
|
|
|
system.color.get();
|
2017-09-17 04:32:09 +03:00
|
|
|
|
if (Form.status_window>2) { DrawTitle(#header); break; }
|
|
|
|
|
if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
|
|
|
|
|
if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
|
2020-03-23 04:11:31 +03:00
|
|
|
|
draw_window();
|
2017-09-17 04:32:09 +03:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evNetwork:
|
2020-03-31 00:29:52 +03:00
|
|
|
|
if (http.transfer <= 0) break;
|
|
|
|
|
http.receive();
|
|
|
|
|
EventUpdateProgressBar();
|
|
|
|
|
if (http.receive_result != 0) break;
|
|
|
|
|
if (http.status_code >= 300) && (http.status_code < 400)
|
|
|
|
|
{
|
|
|
|
|
// Handle redirects
|
|
|
|
|
if (redirect_count<=5) {
|
|
|
|
|
redirect_count++;
|
|
|
|
|
http.handle_redirect();
|
2018-05-20 16:40:58 +03:00
|
|
|
|
http.free();
|
2020-03-31 00:29:52 +03:00
|
|
|
|
GetAbsoluteURL(#http.redirect_url, history.current());
|
|
|
|
|
history.back();
|
|
|
|
|
OpenPage(#http.redirect_url);
|
|
|
|
|
} else {
|
|
|
|
|
notify("'Too many redirects.' -E");
|
|
|
|
|
StopLoading();
|
2014-01-27 23:34:00 +04:00
|
|
|
|
}
|
2020-03-31 00:29:52 +03:00
|
|
|
|
} else {
|
|
|
|
|
// Loading the page is complete, free resources
|
|
|
|
|
redirect_count = 0;
|
|
|
|
|
http.free();
|
|
|
|
|
LoadInternalPage(http.content_pointer, http.content_received);
|
2017-09-17 04:32:09 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-11-26 19:26:15 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetElementSizes()
|
|
|
|
|
{
|
2016-12-12 01:58:11 +03:00
|
|
|
|
basic_line_h = calc(WB1.list.font_h * 130) / 100;
|
2020-03-31 00:29:52 +03:00
|
|
|
|
address_box.width = Form.cwidth - address_box.left - 52 - 16;
|
2016-12-21 13:56:06 +03:00
|
|
|
|
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x,
|
2016-12-12 01:58:11 +03:00
|
|
|
|
Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h);
|
|
|
|
|
WB1.list.wheel_size = 7 * basic_line_h;
|
2020-03-22 22:50:16 +03:00
|
|
|
|
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1;
|
2016-12-12 01:58:11 +03:00
|
|
|
|
WB1.list.visible = WB1.list.h;
|
2012-11-26 19:26:15 +04:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-17 22:19:36 +03:00
|
|
|
|
|
2015-12-17 22:15:49 +03:00
|
|
|
|
|
2020-03-23 04:11:31 +03:00
|
|
|
|
void draw_window()
|
2012-11-26 19:26:15 +04:00
|
|
|
|
{
|
2020-03-31 00:29:52 +03:00
|
|
|
|
int i;
|
2012-11-26 19:26:15 +04:00
|
|
|
|
SetElementSizes();
|
2020-03-31 00:29:52 +03:00
|
|
|
|
|
|
|
|
|
DrawBar(0,0, Form.cwidth,PADDING, system.color.work);
|
|
|
|
|
DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, system.color.work);
|
|
|
|
|
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, system.color.work_dark);
|
|
|
|
|
DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, system.color.work_graph);
|
|
|
|
|
DrawBar(0, PADDING, address_box.left-2, TSZE+1, system.color.work);
|
|
|
|
|
DrawBar(address_box.left+address_box.width+18, PADDING, Form.cwidth-address_box.left-address_box.width-18, TSZE+1, system.color.work);
|
|
|
|
|
|
|
|
|
|
DrawTopPanelButton(BACK_BUTTON, PADDING-1, 30);
|
|
|
|
|
DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, 31);
|
|
|
|
|
DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, -1);
|
|
|
|
|
for (i=0; i<=2; i++) DrawBar(Form.cwidth-PADDING-TSZE+3, i*5+PADDING+7, 15, 3, system.color.work_graph);
|
|
|
|
|
|
|
|
|
|
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, system.color.work);
|
|
|
|
|
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, system.color.work_graph);
|
|
|
|
|
|
|
|
|
|
DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x,
|
|
|
|
|
WB1.list.h-1, scroll_wv.bckg_col);
|
|
|
|
|
|
|
|
|
|
if (WB1.list.w!=WB1.DrawBuf.bufw) {
|
|
|
|
|
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
|
|
|
|
|
if (!strncmp(history.current(),"http",4)) {
|
|
|
|
|
//nihuya ne izyachnoe reshenie, no pust' poka butet tak
|
|
|
|
|
i=source_mode;
|
|
|
|
|
debugval("source_mode", source_mode);
|
|
|
|
|
LoadInternalPage(#loading_text, sizeof(loading_text));
|
|
|
|
|
source_mode=i;
|
|
|
|
|
debugval("source_mode", source_mode);
|
|
|
|
|
}
|
|
|
|
|
OpenPage(history.current());
|
2020-03-29 13:57:14 +03:00
|
|
|
|
} else {
|
2018-05-20 16:40:58 +03:00
|
|
|
|
WB1.DrawPage();
|
2020-03-21 21:49:45 +03:00
|
|
|
|
DrawOmnibox();
|
2018-05-20 16:40:58 +03:00
|
|
|
|
}
|
2014-03-24 03:18:01 +04:00
|
|
|
|
DrawProgress();
|
2012-11-26 19:26:15 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-11-10 20:48:36 +03:00
|
|
|
|
void ProcessEvent(dword id__)
|
2013-12-27 04:33:12 +04:00
|
|
|
|
{
|
2016-11-10 20:48:36 +03:00
|
|
|
|
switch (id__)
|
2013-12-27 04:33:12 +04:00
|
|
|
|
{
|
2020-03-31 00:29:52 +03:00
|
|
|
|
case NEW_WINDOW:
|
|
|
|
|
RunProgram(#program_path, NULL);
|
2016-11-10 20:48:36 +03:00
|
|
|
|
return;
|
2015-08-10 18:08:16 +03:00
|
|
|
|
case SCAN_CODE_BS:
|
2015-08-13 15:23:35 +03:00
|
|
|
|
case BACK_BUTTON:
|
2016-01-01 19:51:53 +03:00
|
|
|
|
if (history.back()) {
|
2020-03-27 13:38:54 +03:00
|
|
|
|
OpenPage(history.current());
|
2015-12-17 01:44:42 +03:00
|
|
|
|
}
|
2015-08-10 18:08:16 +03:00
|
|
|
|
return;
|
2015-08-13 15:23:35 +03:00
|
|
|
|
case FORWARD_BUTTON:
|
2016-01-01 19:51:53 +03:00
|
|
|
|
if (history.forward()) {
|
2020-03-27 13:38:54 +03:00
|
|
|
|
OpenPage(history.current());
|
2015-12-17 01:44:42 +03:00
|
|
|
|
}
|
2015-08-10 18:08:16 +03:00
|
|
|
|
return;
|
2015-08-13 15:23:35 +03:00
|
|
|
|
case GOTOURL_BUTTON:
|
2015-08-26 22:22:20 +03:00
|
|
|
|
case SCAN_CODE_ENTER:
|
2020-03-21 17:33:54 +03:00
|
|
|
|
EventSubmitOmnibox();
|
2015-08-10 18:08:16 +03:00
|
|
|
|
return;
|
2015-08-13 15:23:35 +03:00
|
|
|
|
case REFRESH_BUTTON:
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (http.transfer > 0) {
|
2015-08-10 18:59:20 +03:00
|
|
|
|
StopLoading();
|
2020-03-23 04:11:31 +03:00
|
|
|
|
draw_window();
|
2020-03-27 13:38:54 +03:00
|
|
|
|
} else {
|
|
|
|
|
OpenPage(history.current());
|
2015-08-10 18:59:20 +03:00
|
|
|
|
}
|
|
|
|
|
return;
|
2015-08-13 15:23:35 +03:00
|
|
|
|
case SANDWICH_BUTTON:
|
2020-03-31 00:29:52 +03:00
|
|
|
|
EventShowMainMenu(Form.cwidth - 215, TOOLBAR_H-6);
|
2014-01-29 04:14:09 +04:00
|
|
|
|
return;
|
2015-08-13 15:23:35 +03:00
|
|
|
|
case VIEW_SOURCE:
|
2020-03-25 03:18:19 +03:00
|
|
|
|
EventViewSource();
|
2014-03-30 15:57:13 +04:00
|
|
|
|
break;
|
2015-08-13 15:23:35 +03:00
|
|
|
|
case EDIT_SOURCE:
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (check_is_the_adress_local(history.current())) {
|
|
|
|
|
RunProgram("/rd/1/tinypad", history.current());
|
2020-03-25 03:18:19 +03:00
|
|
|
|
} else {
|
2018-04-16 01:44:36 +03:00
|
|
|
|
CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
|
2015-07-30 18:49:09 +03:00
|
|
|
|
if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
|
2014-03-13 02:56:28 +04:00
|
|
|
|
}
|
2013-12-27 04:33:12 +04:00
|
|
|
|
return;
|
2015-08-13 15:23:35 +03:00
|
|
|
|
case VIEW_HISTORY:
|
2020-03-27 13:38:54 +03:00
|
|
|
|
OpenPage(URL_SERVICE_HISTORY);
|
2015-08-13 15:23:35 +03:00
|
|
|
|
return;
|
|
|
|
|
case DOWNLOAD_MANAGER:
|
|
|
|
|
if (!downloader_opened) {
|
2015-12-22 21:14:35 +03:00
|
|
|
|
downloader_edit = NULL;
|
2015-08-13 15:23:35 +03:00
|
|
|
|
CreateThread(#Downloader,#downloader_stak+4092);
|
|
|
|
|
}
|
2013-12-27 04:33:12 +04:00
|
|
|
|
return;
|
2018-05-20 16:40:58 +03:00
|
|
|
|
case COPY_LINK_URL:
|
2017-10-01 14:57:00 +03:00
|
|
|
|
Clipboard__CopyText(PageLinks.GetURL(PageLinks.active));
|
|
|
|
|
notify("'URL copied to clipboard'O");
|
|
|
|
|
return;
|
2018-03-23 18:04:20 +03:00
|
|
|
|
case DOWNLOAD_LINK_CONTENTS:
|
|
|
|
|
if (!downloader_opened) {
|
|
|
|
|
strcpy(#downloader_edit, PageLinks.GetURL(PageLinks.active));
|
|
|
|
|
CreateThread(#Downloader,#downloader_stak+4092);
|
|
|
|
|
}
|
|
|
|
|
return;
|
2020-03-31 00:29:52 +03:00
|
|
|
|
case OPEN_FILE:
|
|
|
|
|
EventOpenDialog();
|
|
|
|
|
return;
|
2018-05-20 16:40:58 +03:00
|
|
|
|
case SCAN_CODE_F12:
|
|
|
|
|
debug_mode ^= 1;
|
|
|
|
|
if (debug_mode) notify("'Debug mode ON'-I");
|
|
|
|
|
else notify("'Debug mode OFF'-I");
|
|
|
|
|
return;
|
2013-12-27 04:33:12 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-13 02:56:28 +04:00
|
|
|
|
void StopLoading()
|
|
|
|
|
{
|
2018-05-18 23:18:10 +03:00
|
|
|
|
if (http.transfer)
|
2014-03-15 14:34:28 +04:00
|
|
|
|
{
|
2018-05-18 23:18:10 +03:00
|
|
|
|
EAX = http.transfer;
|
2014-03-15 14:34:28 +04:00
|
|
|
|
EAX = EAX.http_msg.content_ptr; // get pointer to data
|
|
|
|
|
$push EAX // save it on the stack
|
2018-05-18 23:18:10 +03:00
|
|
|
|
http_free stdcall (http.transfer); // abort connection
|
2014-03-15 14:34:28 +04:00
|
|
|
|
$pop EAX
|
2015-07-30 18:49:09 +03:00
|
|
|
|
free(EAX); // free data
|
2018-05-18 23:18:10 +03:00
|
|
|
|
http.transfer=0;
|
2020-03-22 22:50:16 +03:00
|
|
|
|
pause(10);
|
2014-03-15 14:34:28 +04:00
|
|
|
|
}
|
2015-03-16 17:20:32 +03:00
|
|
|
|
wv_progress_bar.value = 0;
|
2020-03-21 21:49:45 +03:00
|
|
|
|
DrawOmnibox();
|
2014-03-14 23:06:48 +04:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 23:18:44 +03:00
|
|
|
|
//rewrite into
|
2020-03-29 13:57:14 +03:00
|
|
|
|
//bool strrpl(dword dst, from, into, dst_len);
|
|
|
|
|
bool ReplaceSpaceInUrl(dword url, size) {
|
2020-03-27 23:18:44 +03:00
|
|
|
|
unsigned int i, j;
|
2020-03-29 13:57:14 +03:00
|
|
|
|
bool was_changed=false;
|
|
|
|
|
for (i=url+size-3; i>url; i--)
|
2020-02-10 22:53:38 +03:00
|
|
|
|
{
|
2020-03-27 23:18:44 +03:00
|
|
|
|
if (ESBYTE[i]!=' ') continue;
|
2020-03-29 13:57:14 +03:00
|
|
|
|
for (j=url+size-3; j>=i; j--) {
|
|
|
|
|
ESBYTE[j+3]=ESBYTE[j+2];
|
2020-03-27 23:18:44 +03:00
|
|
|
|
ESBYTE[j+2]=ESBYTE[j+1];
|
|
|
|
|
ESBYTE[j+1]=ESBYTE[j];
|
|
|
|
|
}
|
|
|
|
|
ESBYTE[i] = '%';
|
|
|
|
|
ESBYTE[i+1] = '2';
|
|
|
|
|
ESBYTE[i+2] = '0';
|
2020-03-29 13:57:14 +03:00
|
|
|
|
was_changed = true;
|
2020-02-10 22:53:38 +03:00
|
|
|
|
}
|
2020-03-29 13:57:14 +03:00
|
|
|
|
return was_changed;
|
2020-02-10 22:53:38 +03:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
bool GetLocalFileData(dword _path)
|
2013-12-27 16:30:42 +04:00
|
|
|
|
{
|
2020-03-27 13:38:54 +03:00
|
|
|
|
dword data, size;
|
|
|
|
|
file_size stdcall (_path);
|
|
|
|
|
if (!EBX) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
size = EBX;
|
|
|
|
|
data = malloc(size);
|
|
|
|
|
ReadFile(0, size, data, _path);
|
|
|
|
|
LoadInternalPage(data, size);
|
|
|
|
|
free(data);
|
|
|
|
|
return true;
|
2014-03-24 02:49:49 +04:00
|
|
|
|
}
|
2020-03-27 13:38:54 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpenPage(dword _open_URL)
|
|
|
|
|
{
|
|
|
|
|
char new_url[URL_SIZE+1];
|
|
|
|
|
|
|
|
|
|
StopLoading();
|
|
|
|
|
|
|
|
|
|
strcpy(#editURL, _open_URL);
|
2020-03-31 00:29:52 +03:00
|
|
|
|
address_box.flags=0;
|
2020-03-27 13:38:54 +03:00
|
|
|
|
DrawOmnibox();
|
2020-03-26 03:12:32 +03:00
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
strncpy(#new_url, _open_URL, URL_SIZE);
|
|
|
|
|
|
|
|
|
|
//Exclude # from the URL to the load page
|
|
|
|
|
//We will bring it back when we get the buffer
|
|
|
|
|
if (strrchr(#new_url, '#')) anchors.take_anchor_from(#new_url);
|
|
|
|
|
|
|
|
|
|
history.add(#new_url);
|
|
|
|
|
|
|
|
|
|
if (!strncmp(#new_url,"WebView:",8)) {
|
|
|
|
|
//INTERNAL PAGE
|
|
|
|
|
if (!strcmp(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage));
|
|
|
|
|
else if (!strcmp(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help));
|
|
|
|
|
else if (!strcmp(#new_url, URL_SERVICE_HISTORY)) ShowHistory();
|
|
|
|
|
else LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
|
|
|
|
} else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) {
|
|
|
|
|
//WEB PAGE
|
2020-03-29 13:57:14 +03:00
|
|
|
|
if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {
|
|
|
|
|
strcpy(#editURL, #new_url);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (!strncmp(#new_url,"http:",5)) {
|
|
|
|
|
http.get(#new_url);
|
|
|
|
|
} else if (!strncmp(#new_url,"https://",8)) {
|
|
|
|
|
strcpy(#new_url, "http://gate.aspero.pro/?site=");
|
|
|
|
|
strncat(#new_url, _open_URL, URL_SIZE);
|
|
|
|
|
http.get(#new_url);
|
|
|
|
|
}
|
2020-03-31 00:29:52 +03:00
|
|
|
|
|
|
|
|
|
DrawOmnibox();
|
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (!http.transfer) {
|
2014-03-15 14:23:06 +04:00
|
|
|
|
StopLoading();
|
2020-03-27 13:38:54 +03:00
|
|
|
|
LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
2014-03-15 14:23:06 +04:00
|
|
|
|
}
|
2020-03-27 13:38:54 +03:00
|
|
|
|
} else {
|
|
|
|
|
//LOCAL PAGE
|
|
|
|
|
if (!GetLocalFileData(#new_url)) {
|
|
|
|
|
LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
2014-03-15 19:16:08 +04:00
|
|
|
|
}
|
2014-03-13 02:56:28 +04:00
|
|
|
|
}
|
2013-12-27 16:30:42 +04:00
|
|
|
|
}
|
2013-12-27 15:15:17 +04:00
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
void EventClickLink(dword _click_URL)
|
2014-01-22 04:08:47 +04:00
|
|
|
|
{
|
2020-03-27 23:18:44 +03:00
|
|
|
|
char new_url[URL_SIZE+1];
|
2020-03-21 17:33:54 +03:00
|
|
|
|
|
2020-03-31 00:29:52 +03:00
|
|
|
|
if (open_new_window) {
|
|
|
|
|
strcpy(#new_url, _click_URL);
|
|
|
|
|
GetAbsoluteURL(#new_url, history.current());
|
|
|
|
|
RunProgram(#program_path, #new_url);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (ESBYTE[_click_URL]=='#') {
|
|
|
|
|
if (anchors.get_pos_by_name(_click_URL+1)!=-1) {
|
|
|
|
|
WB1.list.first = anchors.get_pos_by_name(_click_URL+1);
|
|
|
|
|
WB1.list.CheckDoesValuesOkey();
|
|
|
|
|
}
|
|
|
|
|
strcpy(#editURL, history.current());
|
|
|
|
|
strcat(#editURL, _click_URL);
|
|
|
|
|
DrawOmnibox();
|
|
|
|
|
WB1.DrawPage();
|
|
|
|
|
return;
|
2020-03-21 17:33:54 +03:00
|
|
|
|
}
|
2015-03-02 00:36:17 +03:00
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (!strncmp(_click_URL,"mailto:", 7)) || (!strncmp(_click_URL,"tel:", 4)) {
|
|
|
|
|
notify(_click_URL);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-08-19 15:48:31 +03:00
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (http.transfer > 0) {
|
2015-08-27 02:55:33 +03:00
|
|
|
|
StopLoading();
|
2016-01-01 19:51:53 +03:00
|
|
|
|
history.back();
|
2015-08-27 02:55:33 +03:00
|
|
|
|
}
|
2016-11-20 14:10:10 +03:00
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
strcpy(#new_url, _click_URL);
|
2020-03-29 13:57:14 +03:00
|
|
|
|
GetAbsoluteURL(#new_url, history.current());
|
2020-03-27 13:38:54 +03:00
|
|
|
|
|
|
|
|
|
if (strrchr(#new_url, '#')!=0) {
|
|
|
|
|
anchors.take_anchor_from(#new_url);
|
|
|
|
|
OpenPage(#new_url);
|
2015-08-27 02:55:33 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
2016-11-20 14:10:10 +03:00
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (!strncmp(#new_url,"WebView:",8)) {
|
|
|
|
|
OpenPage(#new_url);
|
2020-03-21 17:33:54 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
2016-11-20 14:10:10 +03:00
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (strncmp(#new_url,"http://",7)!=0) && (strncmp(#new_url,"https://",8)!=0)
|
2016-11-20 14:10:10 +03:00
|
|
|
|
{
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (UrlExtIs(#new_url,".htm")!=true) && (UrlExtIs(#new_url,".html")!=true)
|
2016-11-20 14:10:10 +03:00
|
|
|
|
{
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (strchr(#new_url, '|')) {
|
|
|
|
|
ESBYTE[strchr(#new_url, '|')] = NULL;
|
|
|
|
|
RunProgram(#new_url, strlen(#new_url)+1+#new_url);
|
|
|
|
|
} else {
|
|
|
|
|
RunProgram("/sys/@open", #new_url);
|
2018-10-01 19:41:14 +03:00
|
|
|
|
}
|
2016-11-20 14:10:10 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
2020-03-27 13:38:54 +03:00
|
|
|
|
} else {
|
|
|
|
|
if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true)
|
|
|
|
|
|| (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true)
|
|
|
|
|
|| (UrlExtIs(#new_url,".7z")==true) {
|
2017-09-17 15:35:45 +03:00
|
|
|
|
if (!downloader_opened) {
|
2020-03-27 13:38:54 +03:00
|
|
|
|
strcpy(#downloader_edit, #new_url);
|
2017-09-17 15:35:45 +03:00
|
|
|
|
CreateThread(#Downloader,#downloader_stak+4092);
|
|
|
|
|
}
|
|
|
|
|
else notify("'WebView\nPlease, start a new download only when previous ended.'Et");
|
2016-11-20 14:10:10 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-27 13:38:54 +03:00
|
|
|
|
OpenPage(#new_url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventSubmitOmnibox()
|
|
|
|
|
{
|
|
|
|
|
char new_url[URL_SIZE+1];
|
|
|
|
|
if (!editURL[0]) return;
|
|
|
|
|
if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/')
|
|
|
|
|
|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) {
|
|
|
|
|
OpenPage(#editURL);
|
|
|
|
|
} else {
|
|
|
|
|
strcpy(#new_url, "http://");
|
|
|
|
|
strncat(#new_url, #editURL, sizeof(new_url)-1);
|
|
|
|
|
OpenPage(#new_url);
|
2017-07-05 13:33:54 +03:00
|
|
|
|
}
|
2015-08-27 02:55:33 +03:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
void LoadInternalPage(dword _bufdata, _in_bufsize){
|
|
|
|
|
if (!_bufdata) || (!_in_bufsize) {
|
2020-03-26 03:12:32 +03:00
|
|
|
|
LoadInternalPage(#page_not_found, sizeof(page_not_found));
|
2020-03-27 13:38:54 +03:00
|
|
|
|
} else {
|
|
|
|
|
bufsize = _in_bufsize;
|
|
|
|
|
if (bufpointer!=_bufdata) free(bufpointer);
|
|
|
|
|
bufpointer = malloc(bufsize);
|
|
|
|
|
memmov(bufpointer, _bufdata, bufsize);
|
|
|
|
|
WB1.list.first = 0; //scroll page to the top
|
|
|
|
|
DrawOmnibox();
|
|
|
|
|
if(!strrchr(#editURL, '#')) {
|
|
|
|
|
strcat(#editURL, #anchors.current);
|
|
|
|
|
DrawOmnibox();
|
|
|
|
|
}
|
2020-03-29 13:57:14 +03:00
|
|
|
|
WB1.ParseHtml();
|
2020-03-27 23:18:44 +03:00
|
|
|
|
if (source_mode) {
|
|
|
|
|
source_mode = false;
|
|
|
|
|
ShowSource(bufpointer, bufsize);
|
2020-03-29 13:57:14 +03:00
|
|
|
|
} else {
|
|
|
|
|
WB1.DrawPage();
|
2020-03-27 23:18:44 +03:00
|
|
|
|
}
|
2020-03-21 17:33:54 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
|
byte UrlExtIs(dword base, ext)
|
2020-03-21 17:33:54 +03:00
|
|
|
|
{
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true;
|
2020-03-21 17:33:54 +03:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawProgress()
|
|
|
|
|
{
|
|
|
|
|
dword persent;
|
|
|
|
|
if (http.transfer == 0) return;
|
2020-03-27 13:38:54 +03:00
|
|
|
|
if (wv_progress_bar.max) {
|
|
|
|
|
persent = wv_progress_bar.value*100/wv_progress_bar.max;
|
|
|
|
|
} else {
|
|
|
|
|
persent = 10;
|
|
|
|
|
}
|
2020-03-31 00:29:52 +03:00
|
|
|
|
DrawBar(address_box.left-1, address_box.top+20, persent*address_box.width+16/100, 2, 0x72B7EB);
|
2020-03-21 17:33:54 +03:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-14 01:08:14 +03:00
|
|
|
|
void EventShowPageMenu(dword _left, _top)
|
2016-12-04 19:50:34 +03:00
|
|
|
|
{
|
|
|
|
|
menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-31 00:29:52 +03:00
|
|
|
|
void EventShowMainMenu(dword _left, _top)
|
|
|
|
|
{
|
|
|
|
|
menu.show(Form.left+_left-6+77,Form.top+_top+skin_height-3, 140, #main_menu, OPEN_FILE);
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-14 01:08:14 +03:00
|
|
|
|
void EventShowLinkMenu(dword _left, _top)
|
|
|
|
|
{
|
2018-05-20 16:40:58 +03:00
|
|
|
|
menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK_URL);
|
2016-12-14 01:08:14 +03:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-18 23:18:10 +03:00
|
|
|
|
void EventUpdateProgressBar()
|
|
|
|
|
{
|
|
|
|
|
wv_progress_bar.max = http.content_length;
|
|
|
|
|
if (wv_progress_bar.value != http.content_received)
|
|
|
|
|
{
|
|
|
|
|
wv_progress_bar.value = http.content_received;
|
|
|
|
|
DrawProgress();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-21 21:49:45 +03:00
|
|
|
|
void EventSeachWeb()
|
|
|
|
|
{
|
2020-03-27 13:38:54 +03:00
|
|
|
|
char new_url[URL_SIZE+1];
|
|
|
|
|
replace_char(#editURL, ' ', '_', URL_SIZE);
|
|
|
|
|
strcpy(#new_url, "https://www.google.com/search?q=");
|
|
|
|
|
strncat(#new_url, #editURL, URL_SIZE);
|
|
|
|
|
OpenPage(#new_url);
|
2020-03-21 21:49:45 +03:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-23 04:11:31 +03:00
|
|
|
|
void EventOpenDialog()
|
|
|
|
|
{
|
|
|
|
|
OpenDialog_start stdcall (#o_dialog);
|
|
|
|
|
if (o_dialog.status) {
|
2020-03-27 13:38:54 +03:00
|
|
|
|
OpenPage(#openfile_path);
|
2020-03-23 04:11:31 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-25 03:18:19 +03:00
|
|
|
|
void EventViewSource()
|
|
|
|
|
{
|
2020-03-27 13:38:54 +03:00
|
|
|
|
char source_view_param[URL_SIZE+1];
|
2020-03-25 03:18:19 +03:00
|
|
|
|
strcpy(#source_view_param, "-s ");
|
2020-03-27 13:38:54 +03:00
|
|
|
|
strncat(#source_view_param, history.current(), URL_SIZE);
|
2020-03-25 03:18:19 +03:00
|
|
|
|
RunProgram(#program_path, #source_view_param);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-21 17:33:54 +03:00
|
|
|
|
void DrawStatusBar(dword _status_text)
|
2016-12-14 01:08:14 +03:00
|
|
|
|
{
|
2020-03-23 04:11:31 +03:00
|
|
|
|
status_text.start_x = 10;
|
2016-12-14 01:08:14 +03:00
|
|
|
|
status_text.start_y = Form.cheight - STATUSBAR_H + 3;
|
|
|
|
|
status_text.area_size_x = Form.cwidth - status_text.start_x -3;
|
2020-03-31 00:29:52 +03:00
|
|
|
|
DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, system.color.work);
|
2016-12-14 01:08:14 +03:00
|
|
|
|
status_text.text_pointer = _status_text;
|
|
|
|
|
PathShow_prepare stdcall(#status_text);
|
|
|
|
|
PathShow_draw stdcall(#status_text);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-31 00:29:52 +03:00
|
|
|
|
|
|
|
|
|
void DrawOvalBorder(dword x,y,w,h, light,dark,right,dots)
|
|
|
|
|
{
|
|
|
|
|
DrawBar(x+1, y, w, 1, light);
|
|
|
|
|
DrawBar(x+1, y+h+1, w, 1, dark);
|
|
|
|
|
DrawBar(x, y+1, 1, h-1, light);
|
|
|
|
|
DrawBar(x+w+1, y+2, 1, h-2, right);
|
|
|
|
|
|
|
|
|
|
PutPixel(x, y, dots);
|
|
|
|
|
PutPixel(x+w+1, y+h+1, dots);
|
|
|
|
|
PutPixel(x, y+h+1, dots);
|
|
|
|
|
PutPixel(x+w+1, y, dots);
|
|
|
|
|
|
|
|
|
|
PutPixel(x, y+h, dark);
|
|
|
|
|
PutPixel(x+w+1, y+1, light);
|
|
|
|
|
PutPixel(x+w+1, y+h, dark);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
libimg_image top_icons;
|
|
|
|
|
libimg_image left_icons;
|
|
|
|
|
|
|
|
|
|
void DrawTopPanelButton(dword _button_id, _x, signed int _icon_n)
|
|
|
|
|
{
|
|
|
|
|
static dword semi_white=0, bg_col, bg_col_light, bg_col_dark, bg_dark;
|
|
|
|
|
if (!semi_white) {
|
|
|
|
|
bg_col = system.color.work;
|
|
|
|
|
if (GrayScaleImage(#bg_col,1,1)<65) bg_dark=true; else bg_dark=false;
|
|
|
|
|
Libimg_LoadImage(#top_icons, "/sys/icons16.png");
|
|
|
|
|
Libimg_LoadImage(#left_icons, "/sys/icons16.png");
|
|
|
|
|
|
|
|
|
|
semi_white = MixColors(system.color.work, 0xFFFfff, bg_dark*90 + 96);
|
|
|
|
|
bg_col_dark = MixColors(system.color.work, system.color.work_graph, 90);
|
|
|
|
|
bg_col_light = MixColors(semi_white, 0xFFFfff, bg_dark*90 + 10);
|
|
|
|
|
|
|
|
|
|
Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffFFFfff, semi_white);
|
|
|
|
|
Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffCACBD6, MixColors(semi_white, 0, 220));
|
|
|
|
|
|
|
|
|
|
Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xffFFFfff, system.color.work);
|
|
|
|
|
Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xffCACBD6, MixColors(system.color.work, 0, 200));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawWideRectangle(_x+1, PADDING+1, TSZE, TSZE, 5, semi_white);
|
|
|
|
|
DrawOvalBorder(_x, PADDING, TSZE, TSZE, bg_col_light, bg_col_dark, semi_white, system.color.work);
|
|
|
|
|
|
|
|
|
|
DefineHiddenButton(_x, PADDING, TSZE+1, TSZE+1, _button_id);
|
|
|
|
|
if (_icon_n==-1) {
|
|
|
|
|
DrawBar(_x+6, PADDING+5, 16, 16, semi_white);
|
|
|
|
|
} else {
|
|
|
|
|
img_draw stdcall(top_icons.image, _x+6, PADDING+5, 16, 16, 0, _icon_n*16);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawOmnibox()
|
|
|
|
|
{
|
|
|
|
|
int skin_x_offset;
|
|
|
|
|
|
|
|
|
|
DrawOvalBorder(address_box.left-2, address_box.top-3, address_box.width+18, 24, system.color.work_graph, system.color.work_graph, system.color.work_graph, system.color.work_dark);
|
|
|
|
|
DrawBar(address_box.left-1, address_box.top-2, address_box.width+18, 1, 0xD8DCD8);
|
|
|
|
|
DrawBar(address_box.left-1, address_box.top-1, address_box.width+18, 1, address_box.color);
|
|
|
|
|
DrawBar(address_box.left-1, address_box.top, 1, 22, address_box.color);
|
|
|
|
|
|
|
|
|
|
if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0;
|
|
|
|
|
EditBox_UpdateText(#address_box, address_box.flags);
|
|
|
|
|
edit_box_draw stdcall(#address_box);
|
|
|
|
|
if (http.transfer > 0) skin_x_offset = 85; else skin_x_offset = 68;
|
|
|
|
|
img_draw stdcall(skin.image, address_box.left+address_box.width+1,
|
|
|
|
|
address_box.top-1, 16, skin.h-3, skin_x_offset, SKIN_Y+2);
|
|
|
|
|
DefineHiddenButton(address_box.left+address_box.width-1, address_box.top-2, 17, skin.h-3, REFRESH_BUTTON);
|
|
|
|
|
|
|
|
|
|
DrawProgress();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-07-30 18:49:09 +03:00
|
|
|
|
stop:
|