Subversion Repositories Kolibri OS

Rev

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