Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
5481 leency 1
//Leency, Veliant, Punk_Joker & KolibriOS Team 2008-2015
3363 leency 2
//GNU GPL licence.
3
 
4022 leency 4
#ifndef AUTOBUILD
5
#include "lang.h--"
6
#endif
7
 
3363 leency 8
//libraries
4049 leency 9
#define MEMSIZE 0xD0000
3363 leency 10
#include "..\lib\kolibri.h"
4427 punk_joker 11
#include "..\lib\clipboard.h"
3363 leency 12
#include "..\lib\strings.h"
13
#include "..\lib\mem.h"
14
#include "..\lib\dll.h"
15
#include "..\lib\file_system.h"
5499 leency 16
#include "..\lib\gui.h"
3434 leency 17
#include "..\lib\list_box.h"
18
#include "..\lib\copyf.h"
4863 leency 19
#include "..\lib\random.h"
5487 leency 20
//obj
5499 leency 21
#include "..\lib\obj\libini.h"
22
#include "..\lib\obj\box_lib.h"
3363 leency 23
//images
24
#include "imgs\toolbar.txt"
25
#include "imgs\left_p.txt"
4846 leency 26
#include "imgs\icons.txt"
3363 leency 27
 
3848 punk_joker 28
#ifdef LANG_RUS
29
	?define T_FILE "Файл"
30
	?define T_TYPE "Тип"
31
	?define T_SIZE "Размер"
32
	?define T_NEW_FOLDER "Новая папка"
33
	?define T_NEW_FILE "Новый файл"
34
	?define T_DELETE_FILE "Вы действительно хотите удалить"
35
	?define T_YES "Да"
36
	?define T_NO "Нет"
5555 punk_joker 37
	?define T_CANCEL "Отмена"
38
	?define T_CREATE "Создать"
3848 punk_joker 39
	?define T_DEL_ERROR_1 "Ошибка. Папка не пустая."
3997 leency 40
	?define WAIT_DELETING_FOLDER "Удаляется папка. Подожите..."
3848 punk_joker 41
	?define NOT_CREATE_FOLDER "Не удалось создать папку."
42
	?define NOT_CREATE_FILE "Не удалось создать файл."
5506 punk_joker 43
	?define ERROR_1 "Ошибка при загрузке библиотеки /rd/1/lib/box_lib.obj"
5514 leency 44
	?define T_PASTE_WINDOW_TITLE "Копирую..."
3883 leency 45
	?define T_PASTE_WINDOW_TEXT "Копируется файл:"
5514 leency 46
	?define T_PASTE_WINDOW_BUTTON "Прервать"
47
	?define INFO_AFTER_COPY "Копирование завершено"
4022 leency 48
	?define T_CANCEL_PASTE "Копирование прекращено. Папка скопирована не полностью."
4049 leency 49
	?define T_SELECT_APP_TO_OPEN_WITH "Выберите программу для открытия файла"
5514 leency 50
	?define DEL_MORE_FILES_1 "выбранные элементы ("
5512 punk_joker 51
	?define DEL_MORE_FILES_2 " шт.)?"
3933 kaitz 52
#elif LANG_EST
53
	?define T_FILE "Fail"
54
	?define T_TYPE "T№№p"
55
	?define T_SIZE "Suurus"
56
	?define T_NEW_FOLDER "Uus kataloog"
57
	?define T_NEW_FILE "Uus fail"
58
	?define T_DELETE_FILE "Kas sa tahad tїesti kustutada"
59
	?define T_YES "Jah"
60
	?define T_NO "Ei"
61
	?define T_DEL_ERROR_1 "Viga. Kataloog ei ole t№hi."
3997 leency 62
	?define WAIT_DELETING_FOLDER "Deleting folder. Please, wait..."
3933 kaitz 63
	?define NOT_CREATE_FOLDER "Kataloogi ei saa luua."
64
	?define NOT_CREATE_FILE "Faili ei saa luua."
5506 punk_joker 65
	?define ERROR_1 "Viga teegi laadimisel /rd/1/lib/box_lib.obj"
5514 leency 66
	?define T_PASTE_WINDOW_TITLE "Kopeerin..."
3933 kaitz 67
	?define T_PASTE_WINDOW_TEXT "Kopeerin faili:"
5514 leency 68
	?define T_PASTE_WINDOW_BUTTON "Abort"
69
	?define INFO_AFTER_COPY "Copy finished"
4022 leency 70
	?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
4049 leency 71
	?define T_SELECT_APP_TO_OPEN_WITH "Select application to open file"
5514 leency 72
	?define DEL_MORE_FILES_1 "selected items("
73
	?define DEL_MORE_FILES_2 " pcs.)?"
3848 punk_joker 74
#else
75
	?define T_FILE "File"
76
	?define T_TYPE "Type"
77
	?define T_SIZE "Size"
78
	?define T_NEW_FOLDER "New folder"
79
	?define T_NEW_FILE "New file"
80
	?define T_DELETE_FILE "Do you really want to delete"
81
	?define T_YES "Yes"
82
	?define T_NO "No"
83
	?define T_DEL_ERROR_1 "Error. Folder isn't empty."
3997 leency 84
	?define WAIT_DELETING_FOLDER "Deleting folder. Please, wait..."
3848 punk_joker 85
	?define NOT_CREATE_FOLDER "Folder can not be created."
86
	?define NOT_CREATE_FILE "File can not be created."
5506 punk_joker 87
	?define ERROR_1 "Error while loading library /rd/1/lib/box_lib.obj"
5514 leency 88
	?define T_PASTE_WINDOW_TITLE "Copying..."
3883 leency 89
	?define T_PASTE_WINDOW_TEXT "Copying file:"
5514 leency 90
	?define T_PASTE_WINDOW_BUTTON "Abort"
91
	?define INFO_AFTER_COPY "Copy finished"
4022 leency 92
	?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
4049 leency 93
	?define T_SELECT_APP_TO_OPEN_WITH "Select application to open file"
5514 leency 94
	?define DEL_MORE_FILES_1 "selected items("
95
	?define DEL_MORE_FILES_2 " pcs.)?"
3848 punk_joker 96
#endif
97
 
3444 leency 98
enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir
99
 
5555 punk_joker 100
#define TITLE "Eolite File Manager v2.77"
101
#define ABOUT_TITLE "Eolite v2.77"
4076 leency 102
dword col_padding, col_selec, col_lpanel;
3363 leency 103
 
3434 leency 104
int toolbar_buttons_x[7]={9,46,85,134,167,203};
105
struct path_string { char Item[4096]; };
3363 leency 106
 
4136 punk_joker 107
byte active_about=0;
4070 punk_joker 108
word about_window;
5416 punk_joker 109
byte active_settings=0;
110
word settings_window;
4040 punk_joker 111
 
4136 punk_joker 112
byte menu_call_mouse=0;
113
 
3434 leency 114
llist files;
115
 
116
byte
3363 leency 117
	path[4096],
118
	file_path[4096],
3404 leency 119
	file_name[256],
5555 punk_joker 120
	new_element_name[256],
3434 leency 121
	temp[4096];
122
byte
3439 leency 123
	rename_active=0,
124
	del_active=0,
5555 punk_joker 125
	new_element_active=0,
4399 punk_joker 126
	show_dev_name=1,
4225 punk_joker 127
	real_files_names_case=0,
5532 leency 128
	use_big_fonts=0,
129
	font_type,
5459 punk_joker 130
	info_after_copy=0,
3434 leency 131
	sort_num=2,
3441 leency 132
	itdir;
3363 leency 133
 
5441 leency 134
dword eolite_ini_path;
135
 
3363 leency 136
proc_info Form;
4076 leency 137
system_colors sc;
3363 leency 138
mouse m;
5532 leency 139
int mouse_dd, scroll_used, sc_slider_h, sorting_arrow_x, kolibrios_drive;
4897 leency 140
dword buf;
3434 leency 141
dword file_mas[6898];
142
int j, i;
4028 leency 143
int action_buf;
4863 leency 144
int rand_n;
5513 punk_joker 145
int selected_count;
3363 leency 146
 
5549 punk_joker 147
mouse gestures;
148
signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
149
byte stats;
150
 
4028 leency 151
edit_box edit2 = {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xffffff,0,248,#file_name,#mouse_dd,64,6,6};
5555 punk_joker 152
edit_box new_file_ed = {150,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xffffff,0,248,#new_element_name,#mouse_dd,64,6,6};
3434 leency 153
PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0};
3363 leency 154
PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
155
 
4042 leency 156
#include "include\copy.h"
5435 leency 157
#include "include\gui.h"
3363 leency 158
#include "include\sorting.h"
4042 leency 159
#include "include\icons.h"
3363 leency 160
#include "include\left_panel.h"
161
#include "include\history.h"
4042 leency 162
#include "include\menu.h"
163
#include "include\about.h"
5416 punk_joker 164
#include "include\settings.h"
5447 punk_joker 165
#include "include\properties.h"
3363 leency 166
 
167
void main()
168
{
3444 leency 169
	word key, id, can_show, can_select, m_selected;
4897 leency 170
	dword selected_offset;
4863 leency 171
	rand_n = random(40);
5549 punk_joker 172
	gestures.get();
3363 leency 173
	mem_Init();
3848 punk_joker 174
	if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(ERROR_1);
5399 punk_joker 175
    if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini");
5441 leency 176
	eolite_ini_path = abspath("Eolite.ini");
177
	LoadIniSettings();
178
	GetSystemDiscs();
4076 leency 179
	SetAppColors();
5555 punk_joker 180
	strcpy(#new_element_name, T_NEW_FILE);
181
	new_file_ed.size = strlen(T_NEW_FILE);
3363 leency 182
	if (param)
183
	{
184
		strcpy(#path, #param);
3434 leency 185
		if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //add "/" to the end of the string
3363 leency 186
	}
187
	else
3695 leency 188
	{
3432 leency 189
		strcpy(#path, "/rd/1/");
3695 leency 190
	}
3363 leency 191
	Open_Dir(#path,ONLY_OPEN);
3432 leency 192
	SetEventMask(0x27);
3434 leency 193
	loop() switch(WaitEvent())
3363 leency 194
	{
195
		case evMouse:
4081 leency 196
			if (del_active) || (!CheckActiveProcess(Form.ID)) || (Form.status_window>2) break;
5555 punk_joker 197
			if (new_element_active) || (!CheckActiveProcess(Form.ID)) || (Form.status_window>2)
198
			{
199
				edit_box_mouse stdcall(#new_file_ed);
200
				break;
201
			}
4081 leency 202
			if (rename_active) { edit_box_mouse stdcall(#edit2); break; }
3363 leency 203
 
204
			m.get();
5549 punk_joker 205
 
206
 
207
			gestures.get();
5550 punk_joker 208
			if (!gestures.mkm) && (stats>0) stats = 0;
5549 punk_joker 209
			if (gestures.mkm) && (stats==0)
210
			{
211
				x_old = gestures.x;
212
				y_old = gestures.y;
213
				stats = 1;
214
			}
215
			if (gestures.mkm) && (stats==1)
216
			{
217
				dif_x = gestures.x-x_old;
218
				dif_y = gestures.y-y_old;
5550 punk_joker 219
				adif_x = fabs(dif_x);
220
				adif_y = fabs(dif_y);
5549 punk_joker 221
 
222
				if (adif_x>adif_y)
223
				{
224
					if (dif_x > 150)
225
					{
226
						if (HistoryPath(GO_FORWARD))
227
							{
5550 punk_joker 228
								files.first=files.current=NULL;
5549 punk_joker 229
								Open_Dir(#path,WITH_REDRAW);
230
							}
231
						stats = 0;
232
					}
233
					if (dif_x < -150)
234
					{
235
						GoBack();
236
						stats = 0;
237
					}
238
				}
239
				else
240
				{
5550 punk_joker 241
					if (dif_y < -100)
5549 punk_joker 242
					{
243
						Dir_Up();
244
						stats = 0;
245
					}
246
				}
247
			}
248
 
3363 leency 249
 
4078 leency 250
			if (files.MouseOver(m.x, m.y)) && (!can_select)
3363 leency 251
			{
4042 leency 252
				m_selected = m.y - files.y / files.line_h;
3434 leency 253
				if (m.lkm) can_select = 1;
254
				if (m.pkm)
255
				{
256
					can_show = 1;
4042 leency 257
					if (m.y - files.y / files.line_h != files.current) can_select = 1;
3434 leency 258
				}
259
			}
260
 
261
			//select/open file {
262
			if (!m.lkm) && (!m.pkm) && (can_select)
263
			{
264
				can_select = 0;
4042 leency 265
				if (m.y>=files.y)
3695 leency 266
				{
4042 leency 267
					id = m.y - files.y / files.line_h;
3695 leency 268
					if (id!=m_selected)
269
					{
270
						can_show=0;
271
						break;
272
					}
273
					if (files.current!=id)
3876 leency 274
					{
275
						if (id
276
					}
3695 leency 277
					else
5443 punk_joker 278
						Open(0);
3695 leency 279
				}
3434 leency 280
			};
281
			// } select/open file
282
 
283
			//file menu {
284
			if (!m.pkm) && (!m.lkm) && (can_show)
285
			{
286
				can_show = 0;
4136 punk_joker 287
				menu_call_mouse = 1;
4042 leency 288
				if (m.y>=files.y)
3695 leency 289
				{
290
					SwitchToAnotherThread();
4057 leency 291
					CreateThread(#FileMenu,#menu_stak+4092);
3695 leency 292
				}
3434 leency 293
				break;
294
			}
295
			// } file menu
3363 leency 296
 
3434 leency 297
			if (m.vert)
298
			{
4069 leency 299
				if (files.MouseScroll(m.vert)) List_ReDraw();
3434 leency 300
				break;
301
			}
302
 
4042 leency 303
			if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>40) && (m.y
3363 leency 304
			{
5441 leency 305
				IF (m.lkm==1) DrawRectangle3D(Form.cwidth - 17,41,14,14,0xC7C7C7,0xFFFFFF);
3434 leency 306
				WHILE (m.lkm==1) && (files.first>0)
3363 leency 307
				{
3434 leency 308
					pause(8);
309
					files.first--;
3363 leency 310
					List_ReDraw();
311
					m.get();
312
				}
5441 leency 313
				DrawRectangle3D(Form.cwidth - 17,41,14,14,0xFFFFFF,0xC7C7C7);
3363 leency 314
			}
315
 
316
			if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>onTop(22,0)+1) && (m.y
317
			{
5441 leency 318
				IF (m.lkm==1) DrawRectangle3D(Form.cwidth - 17,onTop(21,0),14,14,0xC7C7C7,0xFFFFFF);
3434 leency 319
				while (m.lkm==1) && (files.first
3363 leency 320
				{
3434 leency 321
					pause(8);
322
					files.first++;
3363 leency 323
					List_ReDraw();
324
					m.get();
325
				}
5441 leency 326
				DrawRectangle3D(Form.cwidth - 17,onTop(21,0),14,14,0xFFFFFF,0xC7C7C7);
3363 leency 327
			}
328
 
3434 leency 329
			//Scrooll
330
			if (!m.lkm) && (scroll_used) { scroll_used=NULL; Scroll(); }
331
			if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>56) && (m.y
3363 leency 332
 
333
			if (scroll_used)
334
			{
5532 leency 335
				IF (sc_slider_h/2+files.y>m.y) || (m.y<0) || (m.y>4000) m.y=sc_slider_h/2+files.y; //anee eo?ni? iaa ieiii
3434 leency 336
				id=files.first;
5532 leency 337
				j= sc_slider_h/2;
4042 leency 338
				files.first = m.y -j -files.y * files.count;
339
				files.first /= onTop(22,files.y);
3434 leency 340
				IF (files.visible+files.first>files.count) files.first=files.count-files.visible;
3444 leency 341
				IF (id!=files.first) List_ReDraw();
3363 leency 342
			}
343
			break;
344
//Button pressed-----------------------------------------------------------------------------
345
		case evButton:
346
			id=GetButtonID();
4070 punk_joker 347
			if (id==1)
348
			{
349
				KillProcess(about_window);
350
				ExitProcess();
351
			}
3439 leency 352
			if (rename_active) break;
353
			if (del_active)
3363 leency 354
			{
355
				IF (id==301) || (id==302) Del_File(302-id);
356
				break;
357
			}
5555 punk_joker 358
			if (new_element_active)
359
			{
360
				IF (id==301) || (id==302) NewElement(302-id);
361
				break;
362
			}
3439 leency 363
 
3363 leency 364
			switch(id)
365
			{
366
				case 21: //Back
367
						GoBack();
368
						break;
369
				case 22: //Forward
370
						if (HistoryPath(GO_FORWARD))
371
						{
3434 leency 372
							files.first=files.current=NULL; //aaa?o nienea
3363 leency 373
							Open_Dir(#path,WITH_REDRAW);
374
						}
375
						break;
376
				case 23: //up!
377
						Dir_Up();
378
						break;
379
				case 24: //cut
3846 punk_joker 380
						Copy(#file_path, CUT);
3444 leency 381
						break;
3363 leency 382
				case 25: //copy
3846 punk_joker 383
						Copy(#file_path, NOCUT);
3444 leency 384
						break;
3363 leency 385
				case 26: //paste
4057 leency 386
						CreateThread(#Paste,#copy_stak+4092);
3363 leency 387
						break;
388
				case 31...33: //sort
4022 leency 389
						IF(sort_num==1) DrawFilledBar(sorting_arrow_x,42,6,10);
390
						IF(sort_num==2) DrawFilledBar(sorting_arrow_x,42,6,10);
391
						IF(sort_num==3) DrawFilledBar(sorting_arrow_x,42,6,10);
3363 leency 392
						sort_num=id-30;
3434 leency 393
						Open_Dir(#path,WITH_REDRAW);
3363 leency 394
						break;
3434 leency 395
				case 50...60: //Actions
3444 leency 396
						FnProcess(id-50);
3363 leency 397
						break;
398
				case 100...120:
399
					DEVICE_MARK:
3444 leency 400
						DrawRectangle(17,id-100*16+74,159,16, 0); //auaaeaiea
3363 leency 401
						strcpy(#path, #disk_list[id-100].Item);
3434 leency 402
						files.first=files.current=0;
3444 leency 403
						Open_Dir(#path,WITH_REDRAW);
3363 leency 404
						pause(5);
3444 leency 405
						DrawRectangle(17,id-100*16+74,159,16, 0xFFFFFF);
3363 leency 406
						break;
407
			}
408
			break;
409
//Key pressed-----------------------------------------------------------------------------
410
		case evKey:
411
			key = GetKey();
412
			if (Form.status_window>2) break;
413
			IF (del_active)
414
			{
415
				IF (key==013) Del_File(true);
416
				IF (key==027) Del_File(false);
417
				break;
418
			}
5555 punk_joker 419
			IF (new_element_active)
420
			{
421
				IF (key==027) NewElement(0);
422
				EAX=key<<8;
423
				edit_box_key stdcall (#new_file_ed);
424
				break;
425
			}
3444 leency 426
			IF (edit2.flags!=64) && (key!=13) && (key!=27)
3363 leency 427
			{
428
				EAX=key<<8;
429
				edit_box_key stdcall (#edit2);
430
				break;
431
			}
432
			switch (key)
433
			{
434
					case 209...217:
435
							id=key-110;
436
							IF (id-100>=disc_num) break;
437
							GOTO DEVICE_MARK;
5511 leency 438
					case ASCII_KEY_BS:
3363 leency 439
							//GoBack();
440
							Dir_Up();
441
							break;
3434 leency 442
					case 004: //Ctrl+D set as bg
3363 leency 443
							strcpy(#temp, "\\S__");
444
							strcat(#temp, #file_path);
445
							RunProgram("/sys/media/kiv", #temp);
446
							break;
3434 leency 447
					case 014: //Ctrl+N new window
3363 leency 448
							IF (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD);
449
							RunProgram("/sys/File Managers/Eolite", #path);
450
							break;
451
					case 024: //Ctrl+X
3444 leency 452
							Copy(#file_path, CUT);
453
							break;
3363 leency 454
					case 003: //Ctrl+C
3444 leency 455
							Copy(#file_path, NOCUT);
3363 leency 456
							break;
457
					case 022: //Ctrl+V
4057 leency 458
							CreateThread(#Paste,#copy_stak+4092);
3363 leency 459
							break;
5512 punk_joker 460
					case 001: //Ctrl+A
461
							debugln("press Ctrl+A");
462
							for (i=0; i
463
							{
464
								selected_offset = file_mas[i]*304 + buf+32 + 7;
465
								ESBYTE[selected_offset] = 1;
5513 punk_joker 466
								selected_count++;
5512 punk_joker 467
							}
468
							List_ReDraw();
469
							break;
470
					case 021: //Ctrl+U
471
							debugln("press Ctrl+A");
472
							for (i=0; i
473
							{
474
								selected_offset = file_mas[i]*304 + buf+32 + 7;
475
								ESBYTE[selected_offset] = 0;
476
							}
5513 punk_joker 477
							selected_count = 0;
5512 punk_joker 478
							List_ReDraw();
479
							break;
5511 leency 480
					case ASCII_KEY_ESC:
3363 leency 481
							IF (rename_active==1) ReName(false);
482
							break;
5511 leency 483
					case ASCII_KEY_ENTER:
3363 leency 484
							IF (rename_active==1) {ReName(true); break;}
5443 punk_joker 485
							Open(0);
3363 leency 486
							break;
4136 punk_joker 487
					case 074: //menu
488
							menu_call_mouse=0;
489
							SwitchToAnotherThread();
490
							CreateThread(#FileMenu,#menu_stak+4092);
491
							break;
4070 punk_joker 492
					case 173: //Ctrl+Enter
4225 punk_joker 493
							if (!itdir) ShowOpenWithDialog();
5443 punk_joker 494
							else Open(1);
4070 punk_joker 495
							break;
5511 leency 496
					case ASCII_KEY_UP:
3444 leency 497
							List_Current(-1);
3363 leency 498
							break;
5511 leency 499
					case ASCII_KEY_DOWN:
3444 leency 500
							List_Current(1);
3363 leency 501
							break;
5511 leency 502
					case ASCII_KEY_HOME:
4069 leency 503
							if (files.KeyHome()) List_ReDraw();
3363 leency 504
							break;
5511 leency 505
					case ASCII_KEY_END:
4069 leency 506
							if (files.KeyEnd()) List_ReDraw();
3363 leency 507
							break;
5511 leency 508
					case ASCII_KEY_PGDN:
3444 leency 509
							List_Current(files.visible-1);
3363 leency 510
							break;
5511 leency 511
					case ASCII_KEY_PGUP:
3444 leency 512
							List_Current(-files.visible+1);
3363 leency 513
							break;
5511 leency 514
					case ASCII_KEY_DEL:
3434 leency 515
							Del_Form();
3363 leency 516
							break;
5511 leency 517
					case ASCII_KEY_INS:
4897 leency 518
							selected_offset = file_mas[files.current+files.first]*304 + buf+32 + 7;
5513 punk_joker 519
							if (ESBYTE[selected_offset])
520
							{
521
								ESBYTE[selected_offset]=0;
522
								selected_count--;
523
							}
524
							else
525
							{
526
								ESBYTE[selected_offset] = 1;
527
								selected_count++;
528
							}
4897 leency 529
							List_Current(1);
4698 punk_joker 530
							break;
5443 punk_joker 531
					case 048...059: //F1-F10
3444 leency 532
							FnProcess(key-49);
3363 leency 533
							break;
534
					default:
3434 leency 535
							for (i=files.current+files.first+1; i
3363 leency 536
							{
537
								strcpy(#temp, file_mas[i]*304+buf+72);
538
								IF (temp[0]==key) || (temp[0]==key-32)
539
								{
3444 leency 540
									List_Current(i-files.current-files.first);
3363 leency 541
									break;
542
								}
543
							}
544
			}
545
			break;
546
		case evReDraw:
4042 leency 547
			draw_window();
4028 leency 548
			if (action_buf) { menu_action(action_buf); action_buf=0;}
3363 leency 549
	}
550
}
551
 
4225 punk_joker 552
 
5435 leency 553
inline fastcall signed int _strrchr( ESI,BL)
554
{
555
	int jj=0, last=strlen(ESI);
556
	do{
557
		jj++;
558
		$lodsb
559
		IF(AL==BL) last=jj;
560
	} while(AL!=0);
561
	return last;
562
}
4225 punk_joker 563
 
5435 leency 564
 
4028 leency 565
void menu_action(dword id)
566
{
567
	if (id==COPY_PASTE_END)
568
	{
569
		FnProcess(5);
570
		SelectFile(#copy_to+strrchr(#copy_to,'/'));
571
	}
5443 punk_joker 572
	if (id==100) Open(0);
4225 punk_joker 573
	if (id==201) ShowOpenWithDialog();
4028 leency 574
	if (id==202) FnProcess(3); //F3
575
	if (id==203) FnProcess(4); //F4
576
	if (id==104) Copy(#file_path, NOCUT);
577
	if (id==105) Copy(#file_path, CUT);
4057 leency 578
	if (id==106) CreateThread(#Paste,#copy_stak+4092);
4034 leency 579
	if (id==207) FnProcess(2);
4028 leency 580
	if (id==108) Del_Form();
581
	if (id==109) FnProcess(5);
5447 punk_joker 582
	if (id==110) FnProcess(8);
5428 leency 583
	if (id==300) { FnProcess(5); List_ReDraw(); }
4028 leency 584
}
3363 leency 585
 
4028 leency 586
 
3444 leency 587
void draw_window()
588
{
4863 leency 589
	DefineAndDrawWindow(GetScreenWidth()-550/4+rand_n,rand_n+30,550,500,0x73,sc.work,TITLE,0);
3444 leency 590
	GetProcessInfo(#Form, SelfInfo);
591
	if (Form.status_window>2) return;
5441 leency 592
	files.SetSizes(192, 57, Form.cwidth - 210, onTop(57,6), disc_num*16+195,files.line_h);
3444 leency 593
	if (Form.height < files.min_h) MoveSize(OLD,OLD,OLD,files.min_h);
594
	if (Form.width<480) MoveSize(OLD,OLD,480,OLD);
595
	GetProcessInfo(#Form, SelfInfo); //if win_size changed
596
 
3363 leency 597
	PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal);
4076 leency 598
	DrawBar(127, 8, 1, 25, sc.work_graph);
599
	for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,sc.work);
600
	for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,sc.work);
5441 leency 601
	DrawBar(246,0,Form.cwidth - 297,12, sc.work); //upper editbox
602
	DrawBar(246,29,Form.cwidth - 297,5,sc.work);  //under editbox
603
	DrawRectangle(246,12,Form.cwidth - 303,16,sc.work_graph);
604
	DefineButton(Form.cwidth - 25,6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about
3363 leency 605
	PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal);
3434 leency 606
	//main rectangles
4076 leency 607
	DrawRectangle(1,40,Form.cwidth-3,onTop(46,0),sc.work_graph);
3444 leency 608
	DrawRectangle(0,39,Form.cwidth-1,onTop(44,0),col_palette[4]); //bg
3363 leency 609
	for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]);
610
	DrawLeftPanel();
3434 leency 611
	//ListBox
5444 leency 612
	DrawFlatButton(files.x,40,Form.cwidth - files.x - 159,16,31,sc.work,T_FILE);
613
	DrawFlatButton(Form.cwidth - 159,40,73,16,32,sc.work,T_TYPE);
614
	DrawFlatButton(Form.cwidth - 86,40,68,16,33,sc.work,T_SIZE);
4076 leency 615
	DrawBar(files.x+files.w,files.y,1,onTop(22,files.y),sc.work_graph); //line to the left from the scroll
616
	DrawFlatButton(files.x+files.w,40,16,16,0,sc.work,"\x18");
617
	DrawFlatButton(files.x+files.w,onTop(22,0),16,16,0,sc.work,"\x19");
3363 leency 618
	Open_Dir(#path,ONLY_SHOW);
619
	if (del_active) Del_Form();
5555 punk_joker 620
	if (new_element_active) NewElement_Form();
3444 leency 621
	if (rename_active) FnProcess(2);
3363 leency 622
}
623
 
624
 
625
void KEdit()
626
{
3434 leency 627
	if (Form.width<480) return;
3363 leency 628
	PathShow.area_size_x = Form.cwidth-306;
629
	DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff);
630
	PathShow_prepare stdcall(#PathShow);
631
	PathShow_draw stdcall(#PathShow);
632
}
633
 
634
 
5511 leency 635
void List_Current(signed int cur)
3363 leency 636
{
3434 leency 637
	if (cur<=0) //up
3363 leency 638
	{
3434 leency 639
		IF (files.first==0) && (files.current<=0) return;
640
		IF (-cur-1
3363 leency 641
		{
3434 leency 642
			Line_ReDraw(0xFFFFFF, files.current);
643
			files.current+=cur;
644
			Line_ReDraw(col_selec, files.current);
3363 leency 645
			return;
646
		}
647
		ELSE
648
		{
3434 leency 649
			IF (-cur
650
			files.current=0;
3363 leency 651
			List_ReDraw();
652
			return;
653
		}
654
	}
3434 leency 655
	else  //down
3363 leency 656
	{
5511 leency 657
		IF (files.first==files.count-files.visible) && (files.current==files.visible-1)
658
		{
659
			Line_ReDraw(col_selec, files.current);
660
			return;
661
		}
3434 leency 662
		IF (files.visible-files.current>cur)
3363 leency 663
		{
3434 leency 664
			Line_ReDraw(0xFFFFFF, files.current);
665
			files.current+=cur;
666
			Line_ReDraw(col_selec, files.current);
3363 leency 667
			return;
668
		}
669
		else
670
		{
3434 leency 671
			IF(files.first+files.current+cur>=files.count)
3363 leency 672
			{
3434 leency 673
				files.first=files.count-files.visible;
674
				files.current=cur-files.first+files.current;
3363 leency 675
				}
676
			ELSE
677
			{
3434 leency 678
				files.first+=cur+files.current-files.visible+1;
679
				files.current=files.visible-1;
3363 leency 680
			}
681
 
3434 leency 682
			IF (files.current<0) || (files.current>files.visible)
3363 leency 683
			{
3434 leency 684
				files.current=files.visible-1;
3363 leency 685
			}
686
			List_ReDraw();
687
		}
688
	}
689
}
690
 
691
 
692
void List_ReDraw()
693
{
3434 leency 694
	int paint_y;
3876 leency 695
	//we are in the end of the list => maximize window => there will be white lines after the last element
3434 leency 696
	if (files.count-files.firstfiles.visible-1)
697
	{ files.first=files.count-files.visible; files.current=files.visible-1; }
3444 leency 698
	for (j=0; j
3434 leency 699
	//in the bottom
700
	paint_y = j * files.line_h + files.y;
701
	DrawBar(files.x,paint_y,files.w,onTop(paint_y,6),0xFFFFFF);
4076 leency 702
	DrawBar(Form.cwidth-159,paint_y,1,onTop(paint_y,6),sc.work);
703
	DrawBar(Form.cwidth-86,paint_y,1,onTop(paint_y,6),sc.work);
3434 leency 704
	Scroll();
3363 leency 705
}
706
 
3444 leency 707
 
3363 leency 708
void Line_ReDraw(dword color, filenum){
3467 leency 709
	dword text_col=0,
5487 leency 710
	      ext1, attr,
4897 leency 711
	      file_offet,
712
	      file_name_off,
4042 leency 713
	      y=filenum*files.line_h+files.y;
4897 leency 714
	      BDVK file;
4859 leency 715
	if (filenum==-1) return;
3447 leency 716
	DrawBar(files.x,y,3,files.line_h,color);
717
	DrawBar(files.x+19,y,files.w-19,files.line_h,color);
718
	DrawBar(files.x+3,y+17,16,1,color);
719
	if (files.line_h>18) DrawBar(files.x+3,y+18,16,files.line_h-18,color);
720
	if (files.line_h>15) DrawBar(files.x+3,y,16,files.line_h-15,color);
3363 leency 721
 
4897 leency 722
	file_offet = file_mas[filenum+files.first]*304 + buf+32;
5487 leency 723
	attr = ESDWORD[file_offet];
4897 leency 724
	file.selected = ESBYTE[file_offet+7];
725
	file.sizelo   = ESDWORD[file_offet+32];
726
	file_name_off = file_offet+40;
3363 leency 727
 
5487 leency 728
	if (! TestBit(attr, 4) ) //file or folder?
3363 leency 729
	{
4897 leency 730
		Put_icon(file_name_off+_strrchr(file_name_off,'.'), files.x+3, files.line_h/2-7+y, color, 0);
5532 leency 731
		WriteText(7-strlen(ConvertSize(file.sizelo))*6+Form.cwidth - 76,files.line_h-6/2+y,font_type,0,ConvertSize(file.sizelo));
3363 leency 732
	}
733
	else
4846 leency 734
	{
4897 leency 735
		if (strcmp("..",file_name_off)==0) ext1=".."; else ext1="";
4846 leency 736
		Put_icon(ext1, files.x+3, files.line_h/2-7+y, color, 0);
737
	}
738
 
5487 leency 739
	if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=0xA6A6B7; //system or hiden?
3444 leency 740
	if (color!=0xFFFfff)
3363 leency 741
	{
5487 leency 742
		itdir = TestBit(attr, 4);
4897 leency 743
		strcpy(#file_name, file_name_off);
3363 leency 744
		strcpy(#file_path, #path);
3434 leency 745
		strcat(#file_path, #file_name);
3363 leency 746
		if (text_col==0xA6A6B7) text_col=0xFFFFFF;
747
	}
4897 leency 748
	if (file.selected) text_col=0xFF0000;
3434 leency 749
	if (Form.width>=480)
750
	{
3447 leency 751
		FileShow.start_x = files.x + 23;
3434 leency 752
		FileShow.font_color = text_col;
753
		FileShow.area_size_x = Form.width - 380;
4897 leency 754
		FileShow.text_pointer = file_name_off;
755
		FileShow.start_y = files.text_y+y;
3434 leency 756
		PathShow_prepare stdcall(#FileShow);
757
		PathShow_draw stdcall(#FileShow);
758
	}
4076 leency 759
	DrawBar(Form.cwidth-159,y,1,files.line_h,sc.work); //gray line 1
760
	DrawBar(Form.cwidth-86,y,1,files.line_h,sc.work); //gray line 2
3363 leency 761
}
762
 
763
 
3444 leency 764
void Open_Dir(dword dir_path, redraw){
765
	int errornum, maxcount;
3434 leency 766
 
3444 leency 767
	if (redraw!=ONLY_SHOW)
3363 leency 768
	{
3444 leency 769
		if (ESBYTE[dir_path+1]!='\0') ESBYTE[dir_path+strlen(dir_path)-1] = '\0';
3363 leency 770
		if (buf) free(buf);
3444 leency 771
		errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
772
		if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/');
773
		if (errornum)
3363 leency 774
		{
775
			HistoryPath(ADD_NEW_PATH);
776
			GoBack();
777
			Write_Error(errornum);
778
			return;
779
		}
3444 leency 780
		maxcount = sizeof(file_mas)/sizeof(dword)-1;
4225 punk_joker 781
		if (files.count>maxcount) files.count = maxcount;
4859 leency 782
		if (files.count>0) && (files.current==-1) files.current=0;
3363 leency 783
	}
3444 leency 784
	if (files.count!=-1)
3363 leency 785
	{
786
		KEdit();
787
		HistoryPath(ADD_NEW_PATH);
3444 leency 788
		files.visible = files.h / files.line_h;
789
		IF (files.count < files.visible) files.visible = files.count;
4022 leency 790
		IF (sort_num==1) sorting_arrow_x = Form.width+60/2;
791
		IF (sort_num==2) sorting_arrow_x = Form.width-115;
792
		IF (sort_num==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
4076 leency 793
		WriteText(sorting_arrow_x,45,0x80,sc.work_graph,"\x19");
3444 leency 794
		IF (redraw!=ONLY_SHOW) Sorting();
795
		IF (redraw!=ONLY_OPEN) List_ReDraw();
3363 leency 796
	}
3444 leency 797
	IF (files.count==-1) && (redraw!=ONLY_OPEN) {files.visible=files.count=0; List_ReDraw();}
3363 leency 798
}
799
 
800
 
801
inline Sorting()
802
{
803
	dword k=0, l=1;
4897 leency 804
	dword file_off;
3363 leency 805
	int i;
3434 leency 806
	if (!strcmp(#path,"/")) //do not sort
3363 leency 807
	{
3434 leency 808
		FOR(k=1;k
3363 leency 809
		return;
810
	}
4897 leency 811
	FOR (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
3363 leency 812
	{
4897 leency 813
		if (!real_files_names_case) strttl(file_off+40);
814
		if (TestBit(ESDWORD[file_off],4)) //directory?
3363 leency 815
		{
816
			file_mas[k]=j;
817
			k++;
818
		}
819
		else
820
		{
3434 leency 821
			file_mas[files.count-l]=j;
3363 leency 822
			l++;
823
		}
824
	}
3434 leency 825
	//sorting: files first, then folders
3363 leency 826
	Sort_by_Name(0,k-1);
3434 leency 827
	IF (sort_num==1) Sort_by_Name(k,files.count-1);
828
	IF (sort_num==2) Sort_by_Type(k,files.count-1);
829
	IF (sort_num==3) Sort_by_Size(k,files.count-1);
830
	//".." should be first
3444 leency 831
	IF (k>0) && (strcmp(file_mas[0]*304+buf+72,"..")!=0)
832
		FOR(k--; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) {file_mas[k]>
3363 leency 833
}
834
 
835
 
836
void Del_Form()
837
{
5512 punk_joker 838
	dword selected_offset2;
839
	int cont = 0;
840
	byte f_count[128];
4002 leency 841
	int dform_x=files.w-220/2+files.x;
4022 leency 842
	if (strcmp(#file_name,".")==0) || (strcmp(#file_name,"..")==0) return;
4002 leency 843
	if (del_active==2)
3991 leency 844
	{
4002 leency 845
		if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
3991 leency 846
	}
847
	else
848
	{
4002 leency 849
		if (!files.count) return;
4076 leency 850
		DrawPopup(dform_x,160,220,80,1,sc.work,sc.work_graph);
851
		WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,sc.work_text,T_DELETE_FILE);
5512 punk_joker 852
		for (i=0; i
4002 leency 853
		{
5512 punk_joker 854
			selected_offset2 = file_mas[i]*304 + buf+32 + 7;
855
			if (ESBYTE[selected_offset2]) cont++;
4002 leency 856
		}
5512 punk_joker 857
		if (cont)
858
		{
859
			strcpy(#f_count, DEL_MORE_FILES_1);
860
			strcat(#f_count, itoa(cont));
861
			strcat(#f_count, DEL_MORE_FILES_2);
862
			WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,sc.work_text,#f_count);
863
		}
4002 leency 864
		else
865
		{
5512 punk_joker 866
			IF (strlen(#file_name)<28)
867
			{
868
				WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,sc.work_text,"?");
869
				WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,sc.work_text,#file_name);
870
			}
871
			else
872
			{
873
				WriteText(164+dform_x,190,0x80,0,"...?");
874
				ESI = 24;
875
				WriteText(dform_x+20,190,0,0,#file_name);
876
			}
4002 leency 877
		}
878
		DrawFlatButton(dform_x+27,208,70,20,301,0xFFB6B5,T_YES);
879
		DrawFlatButton(dform_x+120,208,70,20,302,0xC6DFC6,T_NO);
880
		del_active=1;
3991 leency 881
	}
3363 leency 882
}
883
 
4022 leency 884
int del_error;
885
int Del_File2(dword way)
3980 punk_joker 886
{
887
	dword dirbuf, fcount, i, filename;
4022 leency 888
	int error;
889
	char del_from[4096];
890
	if (isdir(way))
3997 leency 891
	{
4022 leency 892
		if (error = GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL)) del_error = error;
3997 leency 893
		for (i=0; i
3980 punk_joker 894
		{
4002 leency 895
			if (CheckEvent()==evReDraw) draw_window();
3997 leency 896
			filename = i*304+dirbuf+72;
897
			strcpy(#del_from, way);
898
			chrcat(#del_from, '/');
899
			strcat(#del_from, filename);
900
			if ( TestBit(ESDWORD[filename-40], 4) )
901
				Del_File2(#del_from);
902
			else
4022 leency 903
			{
904
				if (error = DeleteFile(#del_from)) del_error = error;
905
			}
3980 punk_joker 906
		}
3997 leency 907
	}
4022 leency 908
	if (error = DeleteFile(way)) del_error = error;
3980 punk_joker 909
}
910
 
911
 
3363 leency 912
void Del_File(byte dodel)
4022 leency 913
{
4896 punk_joker 914
	byte del_from[4096];
5214 punk_joker 915
	dword selected_offset2;
916
	int tst, count, i;
4896 punk_joker 917
 
3980 punk_joker 918
	if (dodel==true)
3363 leency 919
	{
4002 leency 920
		del_active=2;
3997 leency 921
		if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
4022 leency 922
		del_error = 0;
5214 punk_joker 923
 
5513 punk_joker 924
		if (selected_count)
5214 punk_joker 925
		{
5513 punk_joker 926
   		   for (i=0; i
927
           {
928
                selected_offset2 = file_mas[i]*304 + buf+32 + 7;
929
                if (ESBYTE[selected_offset2]) {
930
                    strcpy(#del_from, #path);
931
                    strcat(#del_from, file_mas[i]*304+buf+72);
932
                    Del_File2(#del_from);
933
                }
934
            }
5214 punk_joker 935
		}
936
		else
937
		{
5513 punk_joker 938
		   Del_File2(#file_path);
5214 punk_joker 939
		}
4022 leency 940
		if (del_error) Write_Error(del_error);
3363 leency 941
 	}
942
	del_active=0;
3997 leency 943
	DeleteButton(301);
944
	DeleteButton(302);
3444 leency 945
	Open_Dir(#path,WITH_REDRAW);
3363 leency 946
}
947
 
948
 
949
void ReName(byte rename)
950
{
3404 leency 951
	int del_rezult, copy_rezult;
3363 leency 952
	char edit_name[256];
953
	rename_active=0;
954
	edit2.flags=64;
955
	if (rename==true)
956
	{
957
		strcpy(#temp, #path);
3434 leency 958
		strcpy(#edit_name, #file_name); //save edit name to select it later
3363 leency 959
		strcat(#temp, #file_name);
5437 leency 960
		if (strcmpi(#file_path,#temp)!=0) && (file_name)
3444 leency 961
		if (itdir)
3363 leency 962
		{
4029 leency 963
			if (del_rezult = DeleteFile(#file_path))
3363 leency 964
			{
3404 leency 965
				Write_Error(del_rezult);
3997 leency 966
				ShowMessage(T_DEL_ERROR_1, 150);
3363 leency 967
				return;
968
			}
4029 leency 969
			if (CreateDir(#temp)) CreateDir(#file_path);
3444 leency 970
			Open_Dir(#path,WITH_REDRAW);
4029 leency 971
			SelectFile(#edit_name);
3363 leency 972
		}
3877 leency 973
		else
3363 leency 974
		{
4029 leency 975
			if (copy_rezult = CopyFile(#file_path,#temp))
976
			{
977
				Write_Error(copy_rezult);
978
			}
979
			else
980
			{
981
				Del_File(true);
982
				SelectFile(#edit_name);
983
			}
3363 leency 984
		}
985
	}
3434 leency 986
	Line_ReDraw(col_selec,files.current);
3363 leency 987
}
988
 
989
 
990
void SelectFile(dword that_file)
991
{
3434 leency 992
	files.first=files.current=0;
3363 leency 993
   	Open_Dir(#path,ONLY_OPEN);
4225 punk_joker 994
	if (!real_files_names_case) strttl(that_file);
3434 leency 995
	for (i=files.count-1; i>=0; i--;)
3363 leency 996
		if (!strcmp(file_mas[i]*304+buf+72,that_file)) break;
3444 leency 997
	List_Current(i);
3363 leency 998
	List_ReDraw();
999
}
1000
 
1001
 
1002
void Dir_Up()
1003
{
1004
	char cur_folder[4096];
1005
	i=strlen(#path)-1;
1006
	if (i==0) return;
1007
	path[i]=0x00;
1008
	i = strrchr(#path, '/');
1009
	strcpy(#cur_folder, #path+i);
1010
	path[i]=0x00;
1011
	SelectFile(#cur_folder);
1012
}
1013
 
5444 leency 1014
void Open(byte rez)
3434 leency 1015
{
5443 punk_joker 1016
	byte temp[4096];
5513 punk_joker 1017
	selected_count = 0;
5443 punk_joker 1018
	if (rez)
1019
	{
1020
		if (!strcmp(#file_name,"..")) return;
1021
		strcpy(#temp, #file_path);
1022
		if (path[strlen(#temp)-1]!='/') chrcat(#temp, '/'); //need "/" in the end
1023
		RunProgram("/sys/File Managers/Eolite", #temp);
1024
		return;
1025
	}
3444 leency 1026
	if (!files.count) return;
3441 leency 1027
	if (!itdir)
3434 leency 1028
	{
5401 leency 1029
		if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
3434 leency 1030
	}
1031
	else
1032
	{
1033
		if (!strcmp(#file_name,"..")) { Dir_Up(); return; }
1034
		strcpy(#path, #file_path);
1035
		if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //need "/" in the end
1036
		files.first=files.current=0;
3444 leency 1037
		Open_Dir(#path,WITH_REDRAW);
3434 leency 1038
	}
1039
}
3363 leency 1040
 
3434 leency 1041
 
1042
inline fastcall void GoBack()
3363 leency 1043
{
1044
	char cur_folder[4096];
1045
	strcpy(#cur_folder, GetCurrentFolder());
1046
	if (HistoryPath(GO_BACK)) SelectFile(#cur_folder);
1047
}
1048
 
5397 punk_joker 1049
void ShowOpenWithDialog()
1050
{
1051
	byte param[4097];
1052
	param[0] = '~';
5398 punk_joker 1053
	param[1] = '\0';
5397 punk_joker 1054
	strcat(#param, #file_path);
1055
	RunProgram("/sys/@open", #param);
1056
}
1057
 
5555 punk_joker 1058
void NewElement(byte newf)
1059
{
1060
	if (newf)
1061
	{
1062
		strcpy(#temp, #path);
1063
		strcat(#temp, new_file_ed.text);
1064
		if (new_element_active==1)
1065
		{
1066
			WriteFile(0, 0, #temp);
1067
			if (EAX)
1068
			{
1069
				Write_Error(EAX);
1070
				ShowMessage(NOT_CREATE_FILE, 150);
1071
			}
1072
		}
1073
		else
1074
		{
1075
			CreateDir(#temp);
1076
			if (EAX)
1077
			{
1078
				Write_Error(EAX);
1079
				ShowMessage(NOT_CREATE_FOLDER, 150);
1080
			}
1081
		}
1082
	}
1083
	new_element_active = 0;
1084
	SelectFile(new_file_ed.text);
1085
}
1086
 
1087
void NewElement_Form(byte crt)
1088
{
1089
	int dform_x=files.w-220/2+files.x;
1090
	new_element_active = crt;
1091
	if (new_element_active==1)
1092
	{
1093
		strcpy(#new_element_name, T_NEW_FILE);
1094
		new_file_ed.size = strlen(T_NEW_FILE);
1095
	}
1096
	else
1097
	{
1098
		strcpy(#new_element_name, T_NEW_FOLDER);
1099
		new_file_ed.size = strlen(T_NEW_FOLDER);
1100
	}
1101
	DrawPopup(dform_x,160,220,80,1,sc.work,sc.work_graph);
1102
	new_file_ed.left = dform_x+27;
1103
	new_file_ed.top = 180;
1104
	edit_box_draw  stdcall (#new_file_ed);
1105
	DrawFlatButton(dform_x+27,208,70,20,301,0xFFB6B5,T_CREATE);
1106
	DrawFlatButton(dform_x+120,208,70,20,302,0xC6DFC6,T_CANCEL);
1107
}
1108
 
3444 leency 1109
void FnProcess(char N)
3434 leency 1110
{
1111
	switch(N)
1112
	{
1113
		case 1:
4395 punk_joker 1114
			if (!active_about)
1115
			{
1116
				SwitchToAnotherThread();
1117
				about_window=CreateThread(#about_dialog,#about_stak+4092);
1118
				break;
1119
			}
1120
			else
1121
			{
1122
				ActivateWindow(GetProcessSlot(about_window));
1123
			}
3434 leency 1124
			break;
1125
		case 2:
1126
			if (!files.count) break;
3447 leency 1127
			edit2.flags = 100000000000010b; //set active
1128
			edit2.left = files.x + 21;
1129
			edit2.width = files.w - 26;
3434 leency 1130
			edit2.top=files.current*files.line_h+59;
1131
			edit2.size=edit2.pos=strlen(#file_name);
1132
			edit_box_draw  stdcall (#edit2);
3447 leency 1133
			DrawBar(edit2.left,files.current*files.line_h+58,edit2.width+1,1,0xFFFFCC); //bg
3434 leency 1134
			rename_active=1;
1135
			break;
1136
		case 3:
3441 leency 1137
			IF (!itdir) RunProgram("/sys/tinypad", #file_path);
3434 leency 1138
			break;
1139
		case 4:
3441 leency 1140
			IF (!itdir) RunProgram("/sys/develop/heed", #file_path);
3434 leency 1141
			break;
3440 leency 1142
		case 5: //refresh cur dir & devs
3854 leency 1143
			Tip(56, T_DEVICES, 55, "-");
3440 leency 1144
			Open_Dir(#path,WITH_REDRAW);
1145
			pause(10);
5441 leency 1146
			LoadIniSettings();
1147
			GetSystemDiscs();
3444 leency 1148
			Open_Dir(#path,WITH_REDRAW);
3440 leency 1149
			DrawLeftPanel();
3434 leency 1150
			break;
1151
		case 6:
5555 punk_joker 1152
			/*strcpy(#temp, #path);
3848 punk_joker 1153
			strcat(#temp, T_NEW_FOLDER);
3434 leency 1154
			CreateDir(#temp);
1155
			if (!EAX){
3848 punk_joker 1156
				SelectFile(T_NEW_FOLDER);
3444 leency 1157
				FnProcess(2);
3434 leency 1158
			}
1159
			else
1160
			{
1161
				Write_Error(EAX);
3997 leency 1162
				ShowMessage(NOT_CREATE_FOLDER, 150);
5555 punk_joker 1163
			}*/
1164
			NewElement_Form(2);
3434 leency 1165
			break;
1166
		case 7:
5555 punk_joker 1167
			/*strcpy(#temp, #path);
3848 punk_joker 1168
			strcat(#temp, T_NEW_FILE);
3434 leency 1169
			WriteFile(0, 0, #temp);
1170
			if (!EAX){
3848 punk_joker 1171
				SelectFile(T_NEW_FILE);
3444 leency 1172
				FnProcess(2);
3434 leency 1173
			}
1174
			else
1175
			{
1176
				Write_Error(EAX);
3997 leency 1177
				ShowMessage(NOT_CREATE_FILE, 150);
5555 punk_joker 1178
			}*/
1179
			NewElement_Form(1);
3434 leency 1180
			break;
5447 punk_joker 1181
		case 8:
1182
			SwitchToAnotherThread();
5463 leency 1183
			CreateThread(#properties_dialog, #properties_stak+4092);
5447 punk_joker 1184
			break;
3434 leency 1185
		case 10: //F10
5416 punk_joker 1186
			if (!active_settings)
1187
			{
1188
				SwitchToAnotherThread();
5463 leency 1189
				settings_window=CreateThread(#settings_dialog, #settings_stak+4092);
5416 punk_joker 1190
				break;
1191
			}
1192
			else
1193
			{
1194
				ActivateWindow(GetProcessSlot(settings_window));
1195
			}
3434 leency 1196
			break;
1197
	}
1198
}
1199
 
5435 leency 1200
//need to remove these functiones, they are a very old shit :)
1201
dword onTop(dword down,up) {EAX=Form.height-GetSkinHeight()-down-up;}
3434 leency 1202
 
5435 leency 1203
 
3363 leency 1204
stop:
1205
 
4057 leency 1206
char menu_stak[4096];
3846 punk_joker 1207
char copy_stak[4096];
4057 leency 1208
char open_with_stak[4096];
5463 leency 1209
char about_stak[4096];
1210
char properties_stak[4096];
1211
char settings_stak[4096];