Subversion Repositories Kolibri OS

Rev

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