Subversion Repositories Kolibri OS

Rev

Rev 7749 | Rev 7752 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7749 Rev 7750
Line 26... Line 26...
26
//useful patterns
26
//useful patterns
27
#include "..\lib\patterns\history.h"
27
#include "..\lib\patterns\history.h"
28
#include "..\lib\patterns\http_downloader.h"
28
#include "..\lib\patterns\http_downloader.h"
29
#include "..\lib\patterns\simple_open_dialog.h"
29
#include "..\lib\patterns\simple_open_dialog.h"
Line 30... Line -...
30
 
-
 
31
_http http = {0, 0, 0, 0, 0, 0, 0};
-
 
32
 
-
 
33
 
30
 
34
#ifdef LANG_RUS
31
#ifdef LANG_RUS
35
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.93";
32
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.94";
36
#define T_LOADING "‡ £à㧪  áâà ­¨æë..."
33
#define T_LOADING "‡ £à㧪  áâà ­¨æë..."
37
#define T_RENDERING "¥­¤¥à¨­£..."
34
#define T_RENDERING "¥­¤¥à¨­£..."
38
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
35
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
39
char homepage[] = FROM "html\\homepage_ru.htm""\0";
36
char homepage[] = FROM "html\\homepage_ru.htm""\0";
Line 46... Line 43...
46
Œ¥­¥¤¦¥à § £à㧮ª";
43
Œ¥­¥¤¦¥à § £à㧮ª";
47
char link_menu[] =
44
char link_menu[] =
48
"Š®¯¨à®¢ âì áá뫪ã
45
"Š®¯¨à®¢ âì áá뫪ã
49
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
46
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
50
#else
47
#else
51
char version[]="Text-based Browser 1.93";
48
char version[]="Text-based Browser 1.94";
52
#define T_LOADING "Loading..."
49
#define T_LOADING "Loading..."
53
#define T_RENDERING "Rendering..."
50
#define T_RENDERING "Rendering..."
54
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
51
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
55
char homepage[] = FROM "html\\homepage_en.htm""\0";
52
char homepage[] = FROM "html\\homepage_en.htm""\0";
56
char help[] = FROM "html\\help_en.htm""\0";
53
char help[] = FROM "html\\help_en.htm""\0";
Line 63... Line 60...
63
char link_menu[] =
60
char link_menu[] =
64
"Copy link
61
"Copy link
65
Download link contents";
62
Download link contents";
66
#endif
63
#endif
Line -... Line 64...
-
 
64
 
-
 
65
dword col_bg = 0xE3E2E2;
-
 
66
dword panel_color  = 0xE3E2E2;
Line 67... Line -...
67
 
-
 
68
 
-
 
69
#define URL_SERVICE_HISTORY "WebView://history"
67
dword border_color = 0x8C8C8C;
70
#define URL_SERVICE_HOMEPAGE "WebView://home"
68
 
Line 71... Line 69...
71
#define URL_SERVICE_HELP "WebView://help"
69
bool debug_mode = false;
Line -... Line 70...
-
 
70
bool open_in_a_new_window = false;
-
 
71
 
72
#define URL_SERVICE_SOURCE "WebView://source:"
72
_http http = {0, 0, 0, 0, 0, 0, 0};
-
 
73
 
Line -... Line 74...
-
 
74
#include "..\TWB\TWB.c"
-
 
75
#include "history.h"
73
 
76
#include "show_src.h"
Line 74... Line 77...
74
proc_info Form;
77
#include "download_manager.h"
75
 
78
 
Line 76... Line 79...
76
char stak[4096];
79
#define URL_SERVICE_HISTORY "WebView:history"
77
 
-
 
78
int action_buf;
-
 
Line 79... Line 80...
79
 
80
#define URL_SERVICE_HOMEPAGE "WebView:home"
Line 80... Line 81...
80
dword TOOLBAR_H = 40;
81
#define URL_SERVICE_HELP "WebView:help"
81
dword STATUSBAR_H = 15;
-
 
82
 
82
 
83
dword col_bg = 0xE3E2E2;
83
dword TOOLBAR_H = 40;
Line 84... Line 84...
84
dword panel_color  = 0xE3E2E2;
84
dword STATUSBAR_H = 15;
85
dword border_color = 0x8C8C8C;
85
 
86
 
86
int action_buf;
87
bool debug_mode = false;
87
 
88
 
88
bool source_mode = false;
89
progress_bar wv_progress_bar;
89
 
90
 
90
progress_bar wv_progress_bar;
91
bool souce_mode = false;
91
char stak[4096];
92
bool open_in_a_new_window = false;
92
proc_info Form;
93
 
93
 
94
enum { 
94
enum { 
95
	BACK_BUTTON=1000, 
95
	BACK_BUTTON=1000, 
96
	FORWARD_BUTTON, 
96
	FORWARD_BUTTON, 
Line 97... Line -...
97
	REFRESH_BUTTON, 
-
 
98
	GOTOURL_BUTTON, 
-
 
99
	SANDWICH_BUTTON,
-
 
100
	VIEW_SOURCE=1100,
-
 
101
	EDIT_SOURCE,
-
 
102
	VIEW_HISTORY,
97
	REFRESH_BUTTON, 
103
	DOWNLOAD_MANAGER,
98
	GOTOURL_BUTTON, 
Line 104... Line 99...
104
	COPY_LINK_URL=1200,
99
	SANDWICH_BUTTON,
105
	DOWNLOAD_LINK_CONTENTS,
100
	VIEW_SOURCE,
Line 130... Line 125...
130
}
125
}
Line 131... Line 126...
131
 
126
 
132
void HandleParam()
127
void HandleParam()
133
{
128
{
134
	if (param) {
129
	if (param) {
135
		if (param[0]=='-') && (param[1]=='d') {
130
		if (!strncmp(#param, "-d ", 3)) {
136
			strcpy(#downloader_edit, #param+3);
131
			strcpy(#downloader_edit, #param+3);
137
			CreateThread(#Downloader,#downloader_stak+4092);
132
			CreateThread(#Downloader,#downloader_stak+4092);
-
 
133
			ExitProcess();
-
 
134
		} else if (!strncmp(#param, "-s ", 3)) {
-
 
135
			source_mode = true;
138
			ExitProcess();
136
			strcpy(#URL, #param + 3);
139
		} else {
137
		} else {
140
			strcpy(#URL, #param); 
138
			strcpy(#URL, #param); 
141
		}
139
		}
142
	} else {
140
	} else {
Line 183... Line 181...
183
		case evKey:
181
		case evKey:
184
			GetKeys();
182
			GetKeys();
185
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
183
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
186
				if (key_scancode == SCAN_CODE_KEY_O) EventOpenDialog();
184
				if (key_scancode == SCAN_CODE_KEY_O) EventOpenDialog();
187
				if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY);
185
				if (key_scancode == SCAN_CODE_KEY_H) ProcessEvent(VIEW_HISTORY);
188
				if (key_scancode == SCAN_CODE_KEY_U) ProcessEvent(VIEW_SOURCE);
186
				if (key_scancode == SCAN_CODE_KEY_U) EventViewSource();
189
				if (key_scancode == SCAN_CODE_KEY_T) 
187
				if (key_scancode == SCAN_CODE_KEY_T) 
190
				|| (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL);
188
				|| (key_scancode == SCAN_CODE_KEY_N) RunProgram(#program_path, NULL);
191
				if (key_scancode == SCAN_CODE_KEY_W) ExitProcess();
189
				if (key_scancode == SCAN_CODE_KEY_W) ExitProcess();
192
				if (key_scancode == SCAN_CODE_KEY_J) ProcessEvent(DOWNLOAD_MANAGER);
190
				if (key_scancode == SCAN_CODE_KEY_J) ProcessEvent(DOWNLOAD_MANAGER);
193
				if (key_scancode == SCAN_CODE_KEY_R) ProcessEvent(REFRESH_BUTTON);
191
				if (key_scancode == SCAN_CODE_KEY_R) ProcessEvent(REFRESH_BUTTON);
Line 222... Line 220...
222
		case evReDraw:
220
		case evReDraw:
223
			if (menu.cur_y) {
221
			if (menu.cur_y) {
224
				ProcessEvent(menu.cur_y);
222
				ProcessEvent(menu.cur_y);
225
				menu.cur_y = 0;
223
				menu.cur_y = 0;
226
			}
224
			}
227
			DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,0,0,0);
225
			DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
228
			GetProcessInfo(#Form, SelfInfo);
226
			GetProcessInfo(#Form, SelfInfo);
229
			system.color.get();
227
			system.color.get();
230
			col_bg = system.color.work;
228
			col_bg = system.color.work;
231
			if (Form.status_window>2) { DrawTitle(#header); break; }
229
			if (Form.status_window>2) { DrawTitle(#header); break; }
232
			if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
230
			if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
Line 357... Line 355...
357
			return;
355
			return;
358
		case SANDWICH_BUTTON:
356
		case SANDWICH_BUTTON:
359
			EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6);
357
			EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6);
360
			return;
358
			return;
361
		case VIEW_SOURCE:
359
		case VIEW_SOURCE:
362
			WB1.list.first = 0;
-
 
363
			ShowSource();
360
			EventViewSource();
364
			WB1.LoadInternalPage(bufpointer, bufsize);
-
 
365
			break;
361
			break;
366
		case EDIT_SOURCE:
362
		case EDIT_SOURCE:
367
			if (!strncmp(#URL,"http",4)) 
363
			if (check_is_the_adress_local(#URL)) {
-
 
364
				RunProgram("/rd/1/tinypad", #URL);
368
			{
365
			} else {
369
				CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
366
				CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
370
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
367
				if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
371
			}
368
			}
372
			else RunProgram("/rd/1/tinypad", #URL);
-
 
373
			return;
369
			return;
374
		case VIEW_HISTORY:
370
		case VIEW_HISTORY:
375
			strcpy(#URL, URL_SERVICE_HISTORY);
371
			strcpy(#URL, URL_SERVICE_HISTORY);
376
			OpenPage();
372
			OpenPage();
377
			return;
373
			return;
Line 442... Line 438...
442
 
438
 
443
void OpenPage()
439
void OpenPage()
444
{
440
{
445
	char getUrl[sizeof(URL)];
441
	char getUrl[sizeof(URL)];
446
	StopLoading();
-
 
447
	souce_mode = false;
442
	StopLoading();
448
	strcpy(#editURL, #URL);
443
	strcpy(#editURL, #URL);
449
	history.add(#URL);
444
	history.add(#URL);
450
	if (!strncmp(#URL,"WebView:",8))
445
	if (!strncmp(#URL,"WebView:",8))
451
	{
446
	{
452
		SetPageDefaults();
447
		SetPageDefaults();
453
		if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) WB1.LoadInternalPage(#homepage, sizeof(homepage));
448
		if (!strcmp(#URL, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage)-1);
454
		else if (!strcmp(#URL, URL_SERVICE_HELP)) WB1.LoadInternalPage(#help, sizeof(help));
449
		else if (!strcmp(#URL, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help)-1);
455
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
450
		else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
456
		else {bufsize=0; ShowPage();} //page not found
451
		else {bufsize=0; ShowPage();} //page not found
457
		DrawOmnibox();
452
		DrawOmnibox();
458
		return;
453
		return;
Line 498... Line 493...
498
{
493
{
499
	char anchor[256];
494
	char anchor[256];
500
	int anchor_pos;
495
	int anchor_pos;
Line 501... Line 496...
501
	
496
	
502
	anchor_pos = strrchr(#URL, '#')-1;
497
	anchor_pos = strrchr(#URL, '#')-1;
503
	strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor));
498
	strlcpy(#anchor, #URL+anchor_pos, sizeof(anchor)-1);
Line 504... Line 499...
504
	URL[anchor_pos] = 0x00;
499
	URL[anchor_pos] = 0x00;
505
 
500
 
506
	//#1
501
	//#1
Line 624... Line 619...
624
void DrawOmnibox()
619
void DrawOmnibox()
625
{
620
{
626
	int skin_x_offset;
621
	int skin_x_offset;
627
	DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
622
	DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color);
628
	DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color);
623
	DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color);
629
	//address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
624
	if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0;
630
	//address_box.offset = 0;
-
 
631
	EditBox_UpdateText(#address_box, address_box.flags);
625
	EditBox_UpdateText(#address_box, address_box.flags);
632
	edit_box_draw stdcall(#address_box);
626
	edit_box_draw stdcall(#address_box);
633
	if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51;
627
	if (http.transfer > 0) skin_x_offset = 68; else skin_x_offset = 51;
634
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
628
	img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y);
635
}
629
}
Line -... Line 630...
-
 
630
 
-
 
631
void LoadInternalPage(dword bufpos, in_filesize){
-
 
632
	bufsize = in_filesize;
-
 
633
	bufpointer = bufpos;
-
 
634
	ShowPage();
Line 636... Line 635...
636
 
635
}
637
 
636
 
638
void ShowPage()
637
void ShowPage()
639
{
638
{
640
	DrawOmnibox();
-
 
641
	if (!bufsize)
639
	DrawOmnibox();
642
	{
640
	if (!bufsize) || (!bufpointer) {
643
		WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found));
-
 
644
	}
-
 
645
	else
641
		LoadInternalPage(#page_not_found, sizeof(page_not_found)-1);
-
 
642
	}
-
 
643
	WB1.Prepare();
-
 
644
	if (source_mode) {
-
 
645
		source_mode = false;
646
	{
646
		ShowSource();
647
		WB1.Prepare();
647
		LoadInternalPage(bufpointer, bufsize);
Line 648... Line 648...
648
	}
648
	}
649
}
649
}
Line 696... Line 696...
696
		strcpy(#URL, #openfile_path);
696
		strcpy(#URL, #openfile_path);
697
		OpenPage();
697
		OpenPage();
698
	}
698
	}
699
}
699
}
Line -... Line 700...
-
 
700
 
-
 
701
void EventViewSource()
-
 
702
{
-
 
703
	char source_view_param[sizeof(URL)+4];
-
 
704
	strcpy(#source_view_param, "-s ");
-
 
705
	strcat(#source_view_param, #URL);
-
 
706
	RunProgram(#program_path, #source_view_param);
-
 
707
}
700
 
708
 
701
void DrawStatusBar(dword _status_text)
709
void DrawStatusBar(dword _status_text)
702
{
710
{
703
	status_text.start_x = 10;
711
	status_text.start_x = 10;
704
	status_text.start_y = Form.cheight - STATUSBAR_H + 3;
712
	status_text.start_y = Form.cheight - STATUSBAR_H + 3;