Subversion Repositories Kolibri OS

Rev

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

Rev 4415 Rev 4416
Line 24... Line 24...
24
//images
24
//images
25
#include "img\toolbar_icons.c"
25
#include "img\toolbar_icons.c"
26
#include "img\URLgoto.txt";
26
#include "img\URLgoto.txt";
Line 27... Line 27...
27
 
27
 
28
#ifdef LANG_RUS
28
#ifdef LANG_RUS
29
	char version[]=" ’ҐЄбв®ўл© Ўа г§Ґа 0.99.3";
29
	char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.31";
30
	?define IMAGES_CACHE_CLEARED "Љни Є авЁ­®Є ®зЁйҐ­"
30
	?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
31
#else
31
#else
32
	char version[]=" Text-based Browser 0.99.3";
32
	char version[]=" Text-based Browser 0.99.31";
33
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
33
	?define IMAGES_CACHE_CLEARED "Images cache cleared"
Line 34... Line -...
34
#endif
-
 
35
 
-
 
36
 
-
 
37
#define URL param
-
 
38
char fontlol[64];
-
 
39
 
-
 
40
char editURL[sizeof(URL)],
-
 
41
	page_links[12000],
-
 
42
	header[2048];
-
 
43
 
-
 
44
 
-
 
45
int	mouse_dd;
-
 
46
edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(editURL),#editURL,#mouse_dd,2,19,19};
-
 
47
scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
-
 
48
 
34
#endif
49
 
35
 
50
proc_info Form;
36
proc_info Form;
Line -... Line 37...
-
 
37
#define WIN_W 640
Line 51... Line 38...
51
#define WIN_W 640
38
#define WIN_H 480
52
#define WIN_H 480
39
 
53
 
-
 
54
 
40
char search_path[]="http://nigma.ru/index.php?s=";
Line 55... Line -...
55
char stak[4096];
-
 
-
 
41
 
-
 
42
char stak[4096];
56
mouse m;
43
mouse m;
57
 
44
int action_buf;
Line 58... Line 45...
58
int action_buf;
45
 
Line 77... Line 64...
77
	strcpy(#editURL, #URL);
64
	strcpy(#editURL, #URL);
Line 78... Line 65...
78
	
65
	
79
	Form.width=WIN_W;
66
	Form.width=WIN_W;
80
	Form.height=WIN_H;
67
	Form.height=WIN_H;
81
	SetElementSizes();
68
	SetElementSizes();
Line 82... Line 69...
82
	WB1.OpenPage();
69
	OpenPage();
83
 
70
 
84
	SetEventMask(0x27);
71
	SetEventMask(0x27);
85
	loop()
72
	loop()
86
	{
73
	{
87
		WaitEventTimeout(2);
74
		WaitEventTimeout(2);
88
		switch(EAX & 0xFF)
75
		switch(EAX & 0xFF)
89
		{
76
		{
90
			CASE evMouse:
77
			CASE evMouse:
91
				/*
78
				/*
92
				//not work well, so we are use custom way of processing scroll
79
				//not work well, so we are use custom way of processing scroll
93
				scrollbar_v_mouse (#scroll1);
80
				scrollbar_v_mouse (#scroll_wv);
94
				if (WB1.list.first <> scroll1.position)
81
				if (WB1.list.first <> scroll_wv.position)
95
				{
82
				{
96
					WB1.list.first = scroll1.position;
83
					WB1.list.first = scroll_wv.position;
97
					WB1.ParseHTML(buf, filesize);
84
					WB1.ParseHTML(buf, filesize);
Line 98... Line 85...
98
				};
85
				};
Line 123... Line 110...
123
				{
110
				{
124
					if (WB1.list.MouseScroll(m.vert)) WB1.ParseHTML(buf);
111
					if (WB1.list.MouseScroll(m.vert)) WB1.ParseHTML(buf);
125
				}
112
				}
Line 126... Line 113...
126
				
113
				
127
				if (!m.lkm) scroll_used=0;
114
				if (!m.lkm) scroll_used=0;
128
				if (m.x>=scroll1.start_x) && (m.x<=scroll1.start_x+scroll1.size_x) 
115
				if (m.x>=scroll_wv.start_x) && (m.x<=scroll_wv.start_x+scroll_wv.size_x) 
129
				&& (m.y>=scroll1.start_y+scroll1.btn_height) && (-scroll1.btn_height+scroll1.start_y+scroll1.size_y>m.y)
116
				&& (m.y>=scroll_wv.start_y+scroll_wv.btn_height) && (-scroll_wv.btn_height+scroll_wv.start_y+scroll_wv.size_y>m.y)
130
				&& (WB1.list.count>WB1.list.visible) && (m.lkm)
117
				&& (WB1.list.count>WB1.list.visible) && (m.lkm)
131
				{
118
				{
132
					scroll_used=1;
119
					scroll_used=1;
Line 133... Line 120...
133
				}
120
				}
134
				
121
				
135
				if (scroll_used)
122
				if (scroll_used)
136
				{
123
				{
137
					half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2;
124
					half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2;
138
					if (half_scroll_size+WB1.list.y>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.list.y; //åñëè êóðñîð íàä îêíîì
125
					if (half_scroll_size+WB1.list.y>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.list.y;
139
					btn=WB1.list.first; //ñîõðàíÿåì ñòàðîå êîëè÷åñòâî
126
					btn=WB1.list.first;
140
					WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
127
					WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
141
					if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
128
					if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
Line 142... Line 129...
142
					if (btn<>WB1.list.first) WB1.ParseHTML(buf); //÷òîá ëèøíèé ðàç íå ïåðåðèñîâûâàòü
129
					if (btn<>WB1.list.first) WB1.ParseHTML(buf);
143
				}
130
				}
144
 
131
 
Line 156... Line 143...
156
				}
143
				}
157
				break;
144
				break;
158
			case evKey:
145
			case evKey:
159
				key = GetKey();
146
				key = GetKey();
Line 160... Line 147...
160
				
147
				
161
				if (address_box.flags & 0b10) SWITCH(key) //åñëè àêòèâíà ñòðîêà àäðåñà èãíîðèðóåì íåêîòîðûå êíîïêè
148
				if (address_box.flags & 0b10) SWITCH(key)
Line 162... Line 149...
162
					{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; } 
149
					{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; } 
Line 163... Line 150...
163
 
150
 
164
				Scan(key);
151
				Scan(key);
165
				
152
				
166
				_EDIT_MARK:
153
				_EDIT_MARK:
167
				if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);} //àäðåñíàÿ ñòðîêà
154
				if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
168
				break;
155
				break;
169
			case evReDraw:
156
			case evReDraw:
Line 184... Line 171...
184
}
171
}
Line 185... Line 172...
185
 
172
 
186
void SetElementSizes()
173
void SetElementSizes()
187
{
174
{
188
	address_box.width = Form.width-266;
175
	address_box.width = Form.width - 266;
189
	WB1.list.SetSizes(0, 44, Form.width - 10 - scroll1.size_x, Form.cheight - 44, 0, 10);
176
	WB1.list.SetSizes(0, 44, Form.width - 10 - scroll_wv.size_x, Form.cheight - 44, 0, 10);
190
	WB1.list.column_max = WB1.list.w - 30 / 6;
177
	WB1.list.column_max = WB1.list.w - 30 / 6;
191
	WB1.list.visible = WB1.list.h - 3 / WB1.list.line_h - 2;
178
	WB1.list.visible = WB1.list.h - 3 / WB1.list.line_h - 2;
192
	DrawBufInit();
179
	DrawBufInit();
Line 221... Line 208...
221
	DrawRectangle(206,15,Form.cwidth-205-50,16,0xE4ECF3);
208
	DrawRectangle(206,15,Form.cwidth-205-50,16,0xE4ECF3);
Line 222... Line 209...
222
 
209
 
223
	SetElementSizes();
210
	SetElementSizes();
Line 224... Line 211...
224
	WB1.ShowPage();
211
	WB1.ShowPage();
225
 
212
 
226
	DefineButton(scroll1.start_x+1, scroll1.start_y+1, 16, 16, BTN_UP+BT_HIDE, 0xE4DFE1);
213
	DefineButton(scroll_wv.start_x+1, scroll_wv.start_y+1, 16, 16, BTN_UP+BT_HIDE, 0xE4DFE1);
Line 227... Line 214...
227
	DefineButton(scroll1.start_x+1, scroll1.start_y+scroll1.size_y-18, 16, 16, BTN_DOWN+BT_HIDE, 0xE4DFE1);
214
	DefineButton(scroll_wv.start_x+1, scroll_wv.start_y+scroll_wv.size_y-18, 16, 16, BTN_DOWN+BT_HIDE, 0xE4DFE1);
228
}
215
}
Line 249... Line 236...
249
			WB1.ParseHTML(buf);
236
			WB1.ParseHTML(buf);
250
			return;
237
			return;
Line 251... Line 238...
251
 
238
 
252
		case 002: //free img cache
239
		case 002: //free img cache
-
 
240
			FreeImgCache();
253
			FreeImgCache();
241
			notify(IMAGES_CACHE_CLEARED);
254
			WB1.ParseHTML(buf);
242
			WB1.ParseHTML(buf);
Line 255... Line 243...
255
			return;
243
			return;
256
 
244
 
257
		case BACK:
245
		case BACK:
258
			if (!BrowserHistory.GoBack()) return;
246
			if (!BrowserHistory.GoBack()) return;
259
			WB1.OpenPage();
247
			OpenPage();
260
			return;
248
			return;
261
		case FORWARD:
249
		case FORWARD:
262
			if (!BrowserHistory.GoForward()) return;
250
			if (!BrowserHistory.GoForward()) return;
263
			WB1.OpenPage();
251
			OpenPage();
264
			return;
252
			return;
265
		case 052:  //F3
253
		case 052:  //F3
266
			if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL);
254
			if (strcmp(get_URL_part(5),"http:")<>0) RunProgram("/rd/1/tinypad", #URL);
Line 278... Line 266...
278
				Draw_Window();
266
				Draw_Window();
279
				return;
267
				return;
280
			}
268
			}
281
			anchor_line_num=WB1.list.first;
269
			anchor_line_num=WB1.list.first;
282
			anchor[0]='|';
270
			anchor[0]='|';
283
			WB1.OpenPage();
271
			OpenPage();
284
			return;
272
			return;
285
		case 014:
273
		case 014:
286
		case 020:
274
		case 020:
287
		case NEWTAB:
275
		case NEWTAB:
288
			MoveSize(190,80,OLD,OLD);
276
			MoveSize(190,80,OLD,OLD);
Line 293... Line 281...
293
			strcpy(#editURL, "http://kolibrios.org/en/index.htm");
281
			strcpy(#editURL, "http://kolibrios.org/en/index.htm");
294
		case GOTOURL:
282
		case GOTOURL:
295
		case 0x0D: //enter
283
		case 0x0D: //enter
296
			if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0;
284
			if ((strstr(#editURL,"ttp://")==0) && (editURL[0]!='/')) strcpy(#URL,"http://"); else URL[0] = 0;
297
			strcat(#URL, #editURL);
285
			strcat(#URL, #editURL);
298
			WB1.OpenPage();
286
			OpenPage();
299
			return;
287
			return;
300
		case SEARCHWEB:
288
		case SEARCHWEB:
301
			strcpy(#URL, #search_path);
289
			strcpy(#URL, #search_path);
302
			strcat(#URL, #editURL);
290
			strcat(#URL, #editURL);
303
			WB1.OpenPage();
291
			OpenPage();
304
			return;
292
			return;
Line 305... Line 293...
305
 
293
 
306
		case 183: //PgDown
294
		case 183: //PgDown
307
			if (WB1.list.count < WB1.list.visible) return;
295
			if (WB1.list.count < WB1.list.visible) return;
Line 318... Line 306...
318
			IF(WB1.list.first < 0) WB1.list.first = 0;
306
			IF(WB1.list.first < 0) WB1.list.first = 0;
319
			WB1.ParseHTML(buf);
307
			WB1.ParseHTML(buf);
320
			return;
308
			return;
Line 321... Line 309...
321
 
309
 
322
		case 178:
310
		case 178:
323
		case BTN_UP: //мотаем вверх
311
		case BTN_UP: //ìîòàåì ââåðõ
324
			IF(WB1.list.first <= 0) return;
312
			if (WB1.list.first <= 0) return;
325
			WB1.list.first--;
313
			WB1.list.first--;
326
			WB1.ParseHTML(buf);
314
			WB1.ParseHTML(buf);
Line 327... Line 315...
327
			return;
315
			return;
328
 
316
 
329
		case 177: 
317
		case 177: 
330
		case BTN_DOWN: //мотаем вниз
318
		case BTN_DOWN: //ìîòàåì âíèç
331
			IF(WB1.list.visible + WB1.list.first >= WB1.list.count) return;
319
			if (WB1.list.visible + WB1.list.first >= WB1.list.count) return;
332
			WB1.list.first++;
320
			WB1.list.first++;
Line 333... Line 321...
333
			WB1.ParseHTML(buf);
321
			WB1.ParseHTML(buf);
Line 363... Line 351...
363
	}
351
	}
364
	//liner.ru#1
352
	//liner.ru#1
365
	if (strrchr(#URL, '#')<>-1)
353
	if (strrchr(#URL, '#')<>-1)
366
	{
354
	{
367
		strcpy(#anchor, #URL+strrchr(#URL, '#'));
355
		strcpy(#anchor, #URL+strrchr(#URL, '#'));
368
		URL[strrchr(#URL, '#')-1] = 0x00; //çàãëóøêà
356
		URL[strrchr(#URL, '#')-1] = 0x00;
369
	}
357
	}
Line 370... Line 358...
370
	
358
	
Line 371... Line 359...
371
	WB1.GetNewUrl();
359
	WB1.GetNewUrl();
Line 384... Line 372...
384
		strcpy(#editURL, BrowserHistory.CurrentUrl());
372
		strcpy(#editURL, BrowserHistory.CurrentUrl());
385
		strcpy(#URL, BrowserHistory.CurrentUrl());
373
		strcpy(#URL, BrowserHistory.CurrentUrl());
386
		return;
374
		return;
387
	}
375
	}
Line 388... Line 376...
388
 
376
 
389
	WB1.OpenPage();
377
	OpenPage();
390
	return;
378
	return;
Line -... Line 379...
-
 
379
}
391
}
380
 
-
 
381
void OpenPage()
-
 
382
{
-
 
383
	if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
-
 
384
	KillProcess(downloader_id);
-
 
385
	strcpy(#editURL, #URL);
-
 
386
	BrowserHistory.AddUrl();
-
 
387
	strcpy(#header, #version);
-
 
388
	pre_text =0;
-
 
389
	if (!strcmp(get_URL_part(5),"http:")))
-
 
390
	{
-
 
391
		KillProcess(downloader_id);
-
 
392
		DeleteFile(#download_path);
-
 
393
		IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=NULL;
-
 
394
		downloader_id = RunProgram("/sys/network/downloader", #URL);
-
 
395
		IF (downloader_id<0) notify("Error running Downloader. Internet unavilable.");
-
 
396
		Draw_Window();
-
 
397
		return;
-
 
398
	}
-
 
399
	WB1.list.first = WB1.list.count =0;
-
 
400
	WB1.ReadHtml(_WIN);
Line 392... Line 401...
392
 
401
	WB1.ShowPage();