Subversion Repositories Kolibri OS

Rev

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