Subversion Repositories Kolibri OS

Rev

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