Subversion Repositories Kolibri OS

Rev

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