Subversion Repositories Kolibri OS

Rev

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