Subversion Repositories Kolibri OS

Rev

Rev 7437 | Rev 7450 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3067 leency 1
//HTML Viewer in C--
7422 leency 2
//Copyright 2007-2018 by Veliant & Leency
6978 leency 3
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
3067 leency 4
 
4085 leency 5
#ifndef AUTOBUILD
6
	#include "lang.h--"
7
#endif
8
 
3107 leency 9
//libraries
6738 leency 10
#define MEMSIZE 4096 * 200
5499 leency 11
#include "..\lib\gui.h"
4508 leency 12
#include "..\lib\draw_buf.h"
13
#include "..\lib\list_box.h"
14
#include "..\lib\cursor.h"
5978 leency 15
#include "..\lib\collection.h"
6795 leency 16
#include "..\lib\random.h"
7037 leency 17
#include "..\lib\clipboard.h"
5981 leency 18
 
7437 leency 19
// *.obj libraries
5499 leency 20
#include "..\lib\obj\box_lib.h"
7049 leency 21
#include "..\lib\obj\libio.h"
22
#include "..\lib\obj\libimg.h"
5499 leency 23
#include "..\lib\obj\http.h"
5690 leency 24
#include "..\lib\obj\iconv.h"
5408 leency 25
//useful patterns
5978 leency 26
#include "..\lib\patterns\history.h"
6058 leency 27
#include "..\lib\patterns\http_downloader.h"
5408 leency 28
 
7281 leency 29
_http http = {0, 0, 0, 0, 0, 0, 0};
30
 
6698 leency 31
char homepage[] = FROM "html\\homepage.htm""\0";
4677 leency 32
 
4026 leency 33
#ifdef LANG_RUS
7428 leency 34
char version[]="Текстовый браузер 1.8c";
6045 leency 35
?define IMAGES_CACHE_CLEARED "Кэш картинок очищен"
36
?define T_LAST_SLIDE "Это последний слайд"
37
char loading[] = "Загрузка страницы...
";
6698 leency 38
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
6045 leency 39
char accept_language[]= "Accept-Language: ru\n";
40
char rmb_menu[] =
41
"Посмотреть исходник
42
Редактировать исходник
43
История
44
Менеджер загрузок";
7037 leency 45
char link_menu[] =
7208 leency 46
"Копировать ссылку
47
Скачать содержимое ссылки";
4026 leency 48
#else
7428 leency 49
char version[]="Text-based Browser 1.8c";
6045 leency 50
?define IMAGES_CACHE_CLEARED "Images cache cleared"
51
?define T_LAST_SLIDE "This slide is the last"
52
char loading[] = "Loading...
";
6698 leency 53
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
6045 leency 54
char accept_language[]= "Accept-Language: en\n";
55
char rmb_menu[] =
56
"View source
57
Edit source
58
History
59
Download Manager";
7037 leency 60
char link_menu[] =
7208 leency 61
"Copy link
62
Download link contents";
4026 leency 63
#endif
64
 
6795 leency 65
 
5773 leency 66
#define URL_SERVICE_HISTORY "WebView://history"
67
#define URL_SERVICE_HOME "WebView://home"
68
#define URL_SERVICE_SOURCE "WebView://source:"
5631 pavelyakov 69
 
3067 leency 70
proc_info Form;
71
 
5772 leency 72
//char search_path[]="http://nigma.ru/index.php?s=";
4558 hidnplayr 73
int redirected = 0;
3067 leency 74
 
4074 leency 75
char stak[4096];
5640 pavelyakov 76
 
4026 leency 77
int action_buf;
78
 
6731 leency 79
dword TOOLBAR_H = 40;
5519 leency 80
dword STATUSBAR_H = 15;
4677 leency 81
 
7425 leency 82
dword col_bg = 0xE3E2E2;
83
dword panel_color  = 0xE3E2E2;
84
dword border_color = 0x8C8C8C;
85
 
7282 leency 86
bool debug_mode = false;
87
bool old_tag_parser_mode = false;
88
 
5718 leency 89
progress_bar wv_progress_bar;
6931 leency 90
bool souce_mode = false;
91
bool open_in_a_new_window = false;
4677 leency 92
 
5718 leency 93
enum {
94
	BACK_BUTTON=1000,
95
	FORWARD_BUTTON,
96
	REFRESH_BUTTON,
97
	GOTOURL_BUTTON,
6795 leency 98
	SANDWICH_BUTTON,
5768 leency 99
	VIEW_SOURCE=1100,
5718 leency 100
	EDIT_SOURCE,
101
	VIEW_HISTORY,
7037 leency 102
	//FREE_IMG_CACHE,
6795 leency 103
	DOWNLOAD_MANAGER,
7282 leency 104
	COPY_LINK_URL=1200,
7208 leency 105
	DOWNLOAD_LINK_CONTENTS,
5718 leency 106
};
107
 
4411 leency 108
#include "..\TWB\TWB.c"
4636 leency 109
#include "history.h"
4718 leency 110
#include "show_src.h"
6001 leency 111
#include "download_manager.h"
3067 leency 112
 
4534 leency 113
char editURL[sizeof(URL)];
114
int	mouse_twb;
6731 leency 115
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(URL),#editURL,#mouse_twb,2,19,19};
4534 leency 116
 
7428 leency 117
#define SKIN_Y 24
4534 leency 118
 
3067 leency 119
void main()
120
{
7422 leency 121
	int i;
5626 leency 122
	load_dll(boxlib, #box_lib_init,0);
123
	load_dll(libio, #libio_init,1);
124
	load_dll(libimg, #libimg_init,1);
125
	load_dll(libHTTP, #http_lib_init,1);
5690 leency 126
	load_dll(iconv_lib, #iconv_open,0);
7428 leency 127
	Libimg_LoadImage(#skin, "/sys/toolbar.png");
7437 leency 128
	skin.h = 26;
7425 leency 129
	wv_progress_bar.progress_color = 0x72B7EB;
5772 leency 130
	CreateDir("/tmp0/1/downloads");
131
	if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME);
6045 leency 132
	WB1.list.SetFont(8, 14, 10011000b);
5779 leency 133
	WB1.list.no_selection = true;
6978 leency 134
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
135
	loop() switch(WaitEvent())
136
	{
137
		case evMouse:
138
			edit_box_mouse stdcall (#address_box);
139
			mouse.get();
7282 leency 140
			if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y))
141
			&& (bufsize) && (mouse.pkm) && (mouse.up) {
142
				if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y);
143
				break;
6978 leency 144
			}
7282 leency 145
			if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
6978 leency 146
			scrollbar_v_mouse (#scroll_wv);
147
			if (WB1.list.first != scroll_wv.position)
148
			{
149
				WB1.list.first = scroll_wv.position;
150
				WB1.DrawPage();
3067 leency 151
				break;
6978 leency 152
			}
153
			break;
5711 leency 154
 
6978 leency 155
		case evButton:
156
			ProcessEvent(GetButtonID());
157
			break;
5711 leency 158
 
6978 leency 159
		case evKey:
160
			GetKeys();
161
			if (address_box.flags & 0b10)
162
			{
163
				if (key_ascii == ASCII_KEY_ENTER) ProcessEvent(key_scancode); else {
164
					EAX = key_editbox;
165
					edit_box_key stdcall(#address_box);
5530 leency 166
				}
6978 leency 167
			}
168
			else
169
			{
7422 leency 170
				#define KEY_SCROLL_N 11
171
				if (SCAN_CODE_UP   == key_scancode) for (i=0;i
172
				if (SCAN_CODE_DOWN == key_scancode) for (i=0;i
6978 leency 173
				if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage();
174
				else ProcessEvent(key_scancode);
175
			}
176
			break;
177
 
178
		case evReDraw:
179
			if (menu.list.cur_y) {
180
				ProcessEvent(menu.list.cur_y);
181
				menu.list.cur_y = 0;
182
			}
183
			DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,col_bg,0,0);
184
			GetProcessInfo(#Form, SelfInfo);
185
			if (Form.status_window>2) { DrawTitle(#header); break; }
186
			if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
187
			if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
188
			Draw_Window();
189
			break;
190