Subversion Repositories Kolibri OS

Rev

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