Subversion Repositories Kolibri OS

Rev

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