Subversion Repositories Kolibri OS

Rev

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