Subversion Repositories Kolibri OS

Rev

Rev 5883 | Rev 5957 | 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:
5955 leency 510
								files.KeyDown();
511
								List_ReDraw();
5591 pavelyakov 512
								break;
5702 punk_joker 513
						case 059...068: //F1-F10
5706 leency 514
								FnProcess(key_scancode-58);
5591 pavelyakov 515
								break;
516
						default:
5825 leency 517
								for (i=files.cur_y+1; i
5591 pavelyakov 518
								{
519
									strcpy(#temp, file_mas[i]*304+buf+72);
5706 leency 520
									if (temp[0]==key_ascii) || (temp[0]==key_ascii-32)
5591 pavelyakov 521
									{
5825 leency 522
										files.cur_y = i - 1;
5694 leency 523
										files.KeyDown();
524
										List_ReDraw();
5591 pavelyakov 525
										break;
526
									}
527
								}
528
				}
3363 leency 529
			break;
5698 leency 530
			case evIPC:
5591 pavelyakov 531
			case evReDraw:
532
				draw_window();
533
				if (action_buf)
534
				{
5804 punk_joker 535
					if (action_buf==OPERATION_END)
5698 leency 536
					{
537
						FnProcess(5);
538
						SelectFileByName(#copy_to+strrchr(#copy_to,'/'));
539
					}
540
					if (action_buf==100) Open(0);
541
					if (action_buf==201) ShowOpenWithDialog();
542
					if (action_buf==202) FnProcess(3); //F3
543
					if (action_buf==203) FnProcess(4); //F4
544
					if (action_buf==104) Copy(#file_path, NOCUT);
545
					if (action_buf==105) Copy(#file_path, CUT);
546
					if (action_buf==106) Paste();
547
					if (action_buf==207) FnProcess(2);
548
					if (action_buf==108) Del_Form();
549
					if (action_buf==109) FnProcess(5);
550
					if (action_buf==110) FnProcess(8);
5591 pavelyakov 551
					action_buf=0;
552
				}
553
		}
554
 
555
		if(cmd_free)
556
		{
5576 pavelyakov 557
			if(cmd_free==1)     free(menu_stak);
558
			else if(cmd_free==2)free(about_stak);
559
			else if(cmd_free==3)free(properties_stak);
560
			else if(cmd_free==4)free(settings_stak);
561
			else if(cmd_free==5)free(copy_stak);
5591 pavelyakov 562
			cmd_free = false;
5576 pavelyakov 563
		}
564
	}
3363 leency 565
}
566
 
3444 leency 567
void draw_window()
568
{
5748 leency 569
	DefineAndDrawWindow(WinX+rand_n,WinY+rand_n,WinW,WinH,0x73,system.color.work,TITLE,0);
3444 leency 570
	GetProcessInfo(#Form, SelfInfo);
571
	if (Form.status_window>2) return;
5811 leency 572
	if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
573
	if (Form.width  < 480) { MoveSize(OLD,OLD,480,OLD); return; }
3444 leency 574
	GetProcessInfo(#Form, SelfInfo); //if win_size changed
3363 leency 575
	PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal);
5674 pavelyakov 576
	DrawBar(127, 8, 1, 25, system.color.work_graph);
577
	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);
578
	for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,system.color.work);
579
	DrawBar(246,0,Form.cwidth - 297,12, system.color.work); //upper editbox
580
	DrawBar(246,29,Form.cwidth - 297,5,system.color.work);  //under editbox
581
	DrawRectangle(246,12,Form.cwidth - 303,16,system.color.work_graph);
5576 pavelyakov 582
	DefineButton(Form.cwidth - 32,6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about
3363 leency 583
	PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal);
3434 leency 584
	//main rectangles
5698 leency 585
	DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42,system.color.work_graph);
586
	DrawRectangle(0,39,Form.cwidth-1,Form.cheight - 40,col_palette[4]); //bg
5723 leency 587
	for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]);
5733 leency 588
	llist_copy(#files_active, #files);
5723 leency 589
	strcpy(#active_path, #path);
590
	DrawFilePanels();
591
	if (del_active) Del_Form();
592
	if (new_element_active) NewElement_Form(new_element_active, #new_element_name);
593
}
594
 
595
void DrawList()
596
{
5733 leency 597
	word sorting_arrow_x;
598
	DrawFlatButton(files.x, files.y-17, files.w - 141,16,31,system.color.work,T_FILE);
599
	DrawFlatButton(files.x + files.w - 141, files.y-17,73,16,32,system.color.work,T_TYPE);
600
	DrawFlatButton(files.x + files.w -  68, files.y-17,68,16,33,system.color.work,T_SIZE);
601
	DrawFlatButton(files.x + files.w,       files.y-17,16,16, 0,system.color.work,"\x18");
602
	DrawFlatButton(files.x + files.w,files.y+files.h-16,16,16,0,system.color.work,"\x19");
603
	if (sort_num==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
604
	if (sort_num==2) sorting_arrow_x = files.x + files.w - 90;
605
	if (sort_num==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
606
	WriteText(sorting_arrow_x,files.y-12,0x80,system.color.work_graph,"\x19");
5723 leency 607
	DrawBar(files.x+files.w,files.y,1,files.h,system.color.work_graph);
5733 leency 608
	if (two_panels) && (files.x<5) DrawBar(files.x+files.w+16,files.y,1,files.h,system.color.work_graph);
5723 leency 609
}
610
 
611
void DrawFilePanels()
612
{
5698 leency 613
	if (!two_panels)
614
	{
5723 leency 615
		DrawDeviceAndActionsLeftPanel();
5825 leency 616
		files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59, files.item_h);
5719 leency 617
		DrawList();
5733 leency 618
		Open_Dir(#path,ONLY_SHOW);
5698 leency 619
	}
620
	else
621
	{
5733 leency 622
		llist_copy(#files, #files_inactive);
623
		strcpy(#path, #inactive_path);
624
		col_selec = 0xCCCccc;
625
 
5719 leency 626
		if (active_panel==1)
627
		{
5761 leency 628
			llist_copy(#files, #files_inactive);
629
			strcpy(#path, #inactive_path);
630
			col_selec = 0xCCCccc;
5825 leency 631
			files.SetSizes(Form.cwidth/2, 57+22, Form.cwidth/2 -17, Form.cheight-59-22, files.item_h);
5719 leency 632
			DrawList();
5733 leency 633
			Open_Dir(#path,WITH_REDRAW);
634
			llist_copy(#files, #files_active);
5719 leency 635
			strcpy(#path, #active_path);
5733 leency 636
			col_selec = 0x94AECE;
5825 leency 637
			files.SetSizes(2, 57+22, Form.cwidth/2-2-17, Form.cheight-59-22, files.item_h);
5719 leency 638
			DrawList();
5733 leency 639
			Open_Dir(#path,WITH_REDRAW);
5719 leency 640
		}
641
		if (active_panel==2)
642
		{
5825 leency 643
			files.SetSizes(2, 57+22, Form.cwidth/2-2-17, Form.cheight-59-22, files.item_h);
5719 leency 644
			DrawList();
5733 leency 645
			Open_Dir(#path,WITH_REDRAW);
646
			llist_copy(#files, #files_active);
5719 leency 647
			strcpy(#path, #active_path);
5733 leency 648
			col_selec = 0x94AECE;
5825 leency 649
			files.SetSizes(Form.cwidth/2, 57+22, Form.cwidth/2 -17, Form.cheight-59-22, files.item_h);
5719 leency 650
			DrawList();
5733 leency 651
			Open_Dir(#path,WITH_REDRAW);
5719 leency 652
		}
5698 leency 653
	}
3363 leency 654
}
655
 
656
 
5694 leency 657
void List_ReDraw()
3363 leency 658
{
5719 leency 659
	int all_lines_h;
5825 leency 660
	static int old_cur_y, old_first;
3363 leency 661
 
5694 leency 662
	files.CheckDoesValuesOkey(); //prevent some shit
3363 leency 663
 
5694 leency 664
	if (list_full_redraw) || (old_first != files.first)
3363 leency 665
	{
5825 leency 666
		old_cur_y = files.cur_y;
5694 leency 667
		old_first = files.first;
668
		list_full_redraw = false;
669
		goto _ALL_LIST_REDRAW;
3363 leency 670
	}
5825 leency 671
	if (old_cur_y != files.cur_y)
3363 leency 672
	{
5825 leency 673
		if (old_cur_y-files.first
674
		Line_ReDraw(col_selec, files.cur_y-files.first);
675
		old_cur_y = files.cur_y;
5694 leency 676
		return;
3363 leency 677
	}
678
 
5694 leency 679
	_ALL_LIST_REDRAW:
3363 leency 680
 
5825 leency 681
	for (j=0; j
3434 leency 682
	//in the bottom
5825 leency 683
	all_lines_h = j * files.item_h;
5719 leency 684
	DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h,0xFFFFFF);
685
	DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h,system.color.work);
686
	DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h,system.color.work);
3434 leency 687
	Scroll();
3363 leency 688
}
689
 
3444 leency 690
 
5761 leency 691
void Line_ReDraw(dword bgcol, filenum){
3467 leency 692
	dword text_col=0,
5487 leency 693
	      ext1, attr,
4897 leency 694
	      file_offet,
695
	      file_name_off,
5825 leency 696
	      y=filenum*files.item_h+files.y;
4897 leency 697
	      BDVK file;
4859 leency 698
	if (filenum==-1) return;
5825 leency 699
	DrawBar(files.x,y,3,files.item_h,bgcol);
700
	DrawBar(files.x+19,y,files.w-19,files.item_h,bgcol);
5761 leency 701
	DrawBar(files.x+3,y+17,16,1,bgcol);
5825 leency 702
	if (files.item_h>18) DrawBar(files.x+3,y+18,16,files.item_h-18,bgcol);
703
	if (files.item_h>15) DrawBar(files.x+3,y,16,files.item_h-15,bgcol);
3363 leency 704
 
4897 leency 705
	file_offet = file_mas[filenum+files.first]*304 + buf+32;
5487 leency 706
	attr = ESDWORD[file_offet];
4897 leency 707
	file.selected = ESBYTE[file_offet+7];
708
	file.sizelo   = ESDWORD[file_offet+32];
709
	file_name_off = file_offet+40;
3363 leency 710
 
5487 leency 711
	if (! TestBit(attr, 4) ) //file or folder?
3363 leency 712
	{
5698 leency 713
		ext1 = strrchr(file_name_off,'.') + file_name_off;
714
		if (ext1==file_name_off) ext1 = " \0"; //if no extension then show nothing
5825 leency 715
		Put_icon(ext1, files.x+3, files.item_h/2-7+y, bgcol, 0);
5776 leency 716
		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 717
	}
718
	else
4846 leency 719
	{
5606 pavelyakov 720
		if (!strncmp(file_name_off,"..",3)) ext1=".."; else ext1="";
5825 leency 721
		Put_icon(ext1, files.x+3, files.item_h/2-7+y, bgcol, 0);
4846 leency 722
	}
723
 
5487 leency 724
	if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=0xA6A6B7; //system or hiden?
5761 leency 725
	if (bgcol!=0xFFFfff)
3363 leency 726
	{
5487 leency 727
		itdir = TestBit(attr, 4);
4897 leency 728
		strcpy(#file_name, file_name_off);
5606 pavelyakov 729
		sprintf(#file_path,"%s%s",#path,file_name_off);
3363 leency 730
		if (text_col==0xA6A6B7) text_col=0xFFFFFF;
731
	}
4897 leency 732
	if (file.selected) text_col=0xFF0000;
5753 leency 733
	if (font.size.text==9) || (!font.data)
3434 leency 734
	{
5745 leency 735
		if (Form.width>=480)
736
		{
737
			FileShow.start_x = files.x + 23;
738
			FileShow.font_color = text_col;
739
			FileShow.area_size_x = files.w - 164;
740
			FileShow.text_pointer = file_name_off;
5776 leency 741
			FileShow.start_y = files.text_y + y + 1;
5745 leency 742
			PathShow_prepare stdcall(#FileShow);
743
			PathShow_draw stdcall(#FileShow);
744
		}
3434 leency 745
	}
5745 leency 746
	else
747
	{
5761 leency 748
		font.bg_color = bgcol;
5846 pavelyakov 749
		font.use_smooth = smooth_font;
5825 leency 750
		font.prepare(files.x + 23, files.item_h - font.height / 2 + y, file_name_off);
5814 pavelyakov 751
		font.show();
5745 leency 752
	}
5825 leency 753
	DrawBar(files.x+files.w-141,y,1,files.item_h,system.color.work); //gray line 1
754
	DrawBar(files.x+files.w-68,y,1,files.item_h,system.color.work); //gray line 2
3363 leency 755
}
756
 
757
 
3444 leency 758
void Open_Dir(dword dir_path, redraw){
759
	int errornum, maxcount;
3434 leency 760
 
3444 leency 761
	if (redraw!=ONLY_SHOW)
3363 leency 762
	{
3444 leency 763
		if (ESBYTE[dir_path+1]!='\0') ESBYTE[dir_path+strlen(dir_path)-1] = '\0';
3363 leency 764
		if (buf) free(buf);
3444 leency 765
		errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
766
		if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/');
767
		if (errornum)
3363 leency 768
		{
769
			HistoryPath(ADD_NEW_PATH);
770
			GoBack();
771
			Write_Error(errornum);
772
			return;
773
		}
3444 leency 774
		maxcount = sizeof(file_mas)/sizeof(dword)-1;
4225 punk_joker 775
		if (files.count>maxcount) files.count = maxcount;
5825 leency 776
		if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
3363 leency 777
	}
3444 leency 778
	if (files.count!=-1)
3363 leency 779
	{
5694 leency 780
		if(!_not_draw)
781
		{
782
			PathShow.area_size_x = Form.cwidth-306;
783
			DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff);
784
			PathShow_prepare stdcall(#PathShow);
785
			PathShow_draw stdcall(#PathShow);
786
		}
3363 leency 787
		HistoryPath(ADD_NEW_PATH);
5825 leency 788
		files.visible = files.h / files.item_h;
5591 pavelyakov 789
		if (files.count < files.visible) files.visible = files.count;
790
		if (redraw!=ONLY_SHOW) Sorting();
5694 leency 791
		list_full_redraw = true;
5606 pavelyakov 792
		if (redraw!=ONLY_OPEN)&&(!_not_draw) List_ReDraw();
5633 leency 793
		DrawSystemDiscs();
3363 leency 794
	}
5694 leency 795
	if (files.count==-1) && (redraw!=ONLY_OPEN)
796
	{
797
		files.KeyHome();
798
		if(!_not_draw) { list_full_redraw=true; List_ReDraw(); }
799
	}
3363 leency 800
}
801
 
802
 
803
inline Sorting()
804
{
805
	dword k=0, l=1;
4897 leency 806
	dword file_off;
5606 pavelyakov 807
	if (!strncmp(#path,"/",2)) //do not sort
3363 leency 808
	{
5591 pavelyakov 809
		for(k=1;k
3363 leency 810
		return;
811
	}
5591 pavelyakov 812
	for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
3363 leency 813
	{
4897 leency 814
		if (!real_files_names_case) strttl(file_off+40);
815
		if (TestBit(ESDWORD[file_off],4)) //directory?
3363 leency 816
		{
817
			file_mas[k]=j;
818
			k++;
819
		}
820
		else
821
		{
3434 leency 822
			file_mas[files.count-l]=j;
3363 leency 823
			l++;
824
		}
825
	}
3434 leency 826
	//sorting: files first, then folders
3363 leency 827
	Sort_by_Name(0,k-1);
5591 pavelyakov 828
	if (sort_num==1) Sort_by_Name(k,files.count-1);
829
	if (sort_num==2) Sort_by_Type(k,files.count-1);
830
	if (sort_num==3) Sort_by_Size(k,files.count-1);
5581 leency 831
	//make ".." first item in list
5733 leency 832
	if (k>0) && (strncmp(file_mas[0]*304+buf+72,"..",2)!=0)
833
		for(k--; k>0; k--;) if (!strncmp(file_mas[k]*304+buf+72,"..",2)) {file_mas[k]>
3363 leency 834
}
835
 
836
 
837
void Del_Form()
838
{
5512 punk_joker 839
	dword selected_offset2;
840
	int cont = 0;
841
	byte f_count[128];
5581 leency 842
	int dform_x = files.w - 220 / 2 + files.x;
5606 pavelyakov 843
	if (!strncmp(#file_name,".",2)) || (!strncmp(#file_name,"..",2)) return;
3991 leency 844
	else
845
	{
4002 leency 846
		if (!files.count) return;
5674 pavelyakov 847
		DrawPopup(dform_x,160,220,85,1,system.color.work,system.color.work_graph);
848
		WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,system.color.work_text,T_DELETE_FILE);
5512 punk_joker 849
		for (i=0; i
4002 leency 850
		{
5512 punk_joker 851
			selected_offset2 = file_mas[i]*304 + buf+32 + 7;
852
			if (ESBYTE[selected_offset2]) cont++;
4002 leency 853
		}
5512 punk_joker 854
		if (cont)
855
		{
5576 pavelyakov 856
			sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,cont,DEL_MORE_FILES_2);
5674 pavelyakov 857
			WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,system.color.work_text,#f_count);
5512 punk_joker 858
		}
4002 leency 859
		else
860
		{
5591 pavelyakov 861
			if (strlen(#file_name)<28)
5512 punk_joker 862
			{
5674 pavelyakov 863
				WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,system.color.work_text,"?");
864
				WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,system.color.work_text,#file_name);
5512 punk_joker 865
			}
866
			else
867
			{
868
				WriteText(164+dform_x,190,0x80,0,"...?");
869
				ESI = 24;
870
				WriteText(dform_x+20,190,0,0,#file_name);
871
			}
4002 leency 872
		}
873
		DrawFlatButton(dform_x+27,208,70,20,301,0xFFB6B5,T_YES);
874
		DrawFlatButton(dform_x+120,208,70,20,302,0xC6DFC6,T_NO);
875
		del_active=1;
3991 leency 876
	}
3363 leency 877
}
878
 
4022 leency 879
int del_error;
5804 punk_joker 880
int Del_File2(dword way, sh_progr)
3980 punk_joker 881
{
5883 pavelyakov 882
	/*dword dirbuf, fcount, i, filename;
4022 leency 883
	int error;
884
	char del_from[4096];
885
	if (isdir(way))
3997 leency 886
	{
4022 leency 887
		if (error = GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL)) del_error = error;
3997 leency 888
		for (i=0; i
3980 punk_joker 889
		{
4002 leency 890
			if (CheckEvent()==evReDraw) draw_window();
3997 leency 891
			filename = i*304+dirbuf+72;
5591 pavelyakov 892
			sprintf(#del_from,"%s/%s",way,filename);
3997 leency 893
			if ( TestBit(ESDWORD[filename-40], 4) )
5581 leency 894
			{
5804 punk_joker 895
				Del_File2(#del_from, 1);
5581 leency 896
			}
3997 leency 897
			else
4022 leency 898
			{
5804 punk_joker 899
				if (sh_progr) Operation_Draw_Progress(#del_from);
4022 leency 900
				if (error = DeleteFile(#del_from)) del_error = error;
901
			}
3980 punk_joker 902
		}
3997 leency 903
	}
5883 pavelyakov 904
	if (error = DeleteFile(way)) del_error = error;*/
905
	fs.remove(way);
3980 punk_joker 906
}
907
 
5804 punk_joker 908
void Del_File_Thread()
4022 leency 909
{
4896 punk_joker 910
	byte del_from[4096];
5214 punk_joker 911
	dword selected_offset2;
912
	int tst, count, i;
4896 punk_joker 913
 
5804 punk_joker 914
	file_count_copy = 0;
915
	copy_bar.value = 0;
916
	operation_flag = DELETE_FLAG;
917
 
918
	if (selected_count)
3363 leency 919
	{
5804 punk_joker 920
   	   for (i=0; i
921
          {
922
               selected_offset2 = file_mas[i]*304 + buf+32 + 7;
923
			    if (ESBYTE[selected_offset2]) {
924
					sprintf(#del_from,"%s%s",#path,file_mas[i]*304+buf+72);
925
					GetFileInfo(#del_from, #file_info_count);
926
					if ( file_info_count.isfolder ) DirFileCount(#del_from);
927
					else file_count_copy++;
928
				}
929
           }
930
	}
931
	else
932
	{
933
		if (itdir) DirFileCount(#file_path);
934
		else file_count_copy++;
935
	}
936
 
937
	copy_bar.max = file_count_copy;
938
 
939
	//if (dodel==true)
940
	//{
941
		//del_active=2;
942
		//if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
4022 leency 943
		del_error = 0;
5804 punk_joker 944
		DisplayOperationForm();
5513 punk_joker 945
		if (selected_count)
5214 punk_joker 946
		{
5513 punk_joker 947
   		   for (i=0; i
948
           {
949
                selected_offset2 = file_mas[i]*304 + buf+32 + 7;
950
                if (ESBYTE[selected_offset2]) {
5591 pavelyakov 951
					sprintf(#del_from,"%s%s",#path,file_mas[i]*304+buf+72);
5804 punk_joker 952
                    Del_File2(#del_from, 1);
5513 punk_joker 953
                }
954
            }
5214 punk_joker 955
		}
956
		else
957
		{
5804 punk_joker 958
		   Del_File2(#file_path, 1);
5214 punk_joker 959
		}
4022 leency 960
		if (del_error) Write_Error(del_error);
5804 punk_joker 961
 	DialogExit();
962
	//}
963
	//del_active=0;
964
	//DeleteButton(301);
965
	//DeleteButton(302);
966
	//Open_Dir(#path,WITH_REDRAW);
967
}
968
 
969
void Del_File(byte dodel) {
3363 leency 970
	del_active=0;
5804 punk_joker 971
	if (dodel)
972
	{
973
		delete_stak = malloc(20000);
974
		CreateThread(#Del_File_Thread,delete_stak+20000-4);
975
	}
976
	else draw_window();
3363 leency 977
}
978
 
5694 leency 979
void SelectFileByName(dword that_file)
3363 leency 980
{
5694 leency 981
	int ind;
982
	files.KeyHome();
3363 leency 983
   	Open_Dir(#path,ONLY_OPEN);
4225 punk_joker 984
	if (!real_files_names_case) strttl(that_file);
5694 leency 985
	for (ind=files.count-1; ind>=0; ind--;) { if (!strcmp(file_mas[ind]*304+buf+72,that_file)) break; }
5825 leency 986
	files.cur_y = ind - 1;
5694 leency 987
	files.KeyDown();
3363 leency 988
	List_ReDraw();
989
}
990
 
991
 
992
void Dir_Up()
993
{
994
	char cur_folder[4096];
995
	i=strlen(#path)-1;
996
	if (i==0) return;
997
	path[i]=0x00;
998
	i = strrchr(#path, '/');
999
	strcpy(#cur_folder, #path+i);
1000
	path[i]=0x00;
5694 leency 1001
	SelectFileByName(#cur_folder);
3363 leency 1002
}
1003
 
5444 leency 1004
void Open(byte rez)
3434 leency 1005
{
5443 punk_joker 1006
	byte temp[4096];
5513 punk_joker 1007
	selected_count = 0;
5443 punk_joker 1008
	if (rez)
1009
	{
5606 pavelyakov 1010
		if (!strncmp(#file_name,"..",3)) return;
5443 punk_joker 1011
		strcpy(#temp, #file_path);
1012
		if (path[strlen(#temp)-1]!='/') chrcat(#temp, '/'); //need "/" in the end
1013
		RunProgram("/sys/File Managers/Eolite", #temp);
1014
		return;
1015
	}
3444 leency 1016
	if (!files.count) return;
3441 leency 1017
	if (!itdir)
3434 leency 1018
	{
5401 leency 1019
		if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
3434 leency 1020
	}
1021
	else
1022
	{
5606 pavelyakov 1023
		if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
3434 leency 1024
		strcpy(#path, #file_path);
1025
		if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //need "/" in the end
5825 leency 1026
		files.first=files.cur_y=0;
3444 leency 1027
		Open_Dir(#path,WITH_REDRAW);
3434 leency 1028
	}
1029
}
3363 leency 1030
 
3434 leency 1031
 
1032
inline fastcall void GoBack()
3363 leency 1033
{
1034
	char cur_folder[4096];
1035
	strcpy(#cur_folder, GetCurrentFolder());
5694 leency 1036
	if (HistoryPath(GO_BACK)) SelectFileByName(#cur_folder);
3363 leency 1037
}
1038
 
5397 punk_joker 1039
void ShowOpenWithDialog()
1040
{
1041
	byte param[4097];
5591 pavelyakov 1042
	sprintf(#param,"~%s",#file_path);
5397 punk_joker 1043
	RunProgram("/sys/@open", #param);
1044
}
1045
 
5555 punk_joker 1046
void NewElement(byte newf)
1047
{
5557 punk_joker 1048
	BDVK element_info;
5581 leency 1049
	byte del_rezult, copy_rezult, info_result;
5555 punk_joker 1050
	if (newf)
1051
	{
5591 pavelyakov 1052
		sprintf(#temp,"%s%s",#path,new_file_ed.text);
5581 leency 1053
		info_result = GetFileInfo(#temp, #element_info);
5571 punk_joker 1054
		switch(new_element_active)
5555 punk_joker 1055
		{
5581 leency 1056
			case CREATE_FILE:
1057
				if (info_result==5)
5557 punk_joker 1058
				{
5571 punk_joker 1059
					WriteFile(0, 0, #temp);
1060
					if (EAX)
1061
					{
1062
						Write_Error(EAX);
1063
						ShowMessage(NOT_CREATE_FILE, 150);
1064
					}
5557 punk_joker 1065
				}
5571 punk_joker 1066
				else
5557 punk_joker 1067
				{
5620 leency 1068
					notify(FS_ITEM_ALREADY_EXISTS);
5557 punk_joker 1069
				}
5581 leency 1070
				break;
1071
			case CREATE_FOLDER:
1072
				if (info_result==5)
5571 punk_joker 1073
				{
1074
					CreateDir(#temp);
1075
					if (EAX)
1076
					{
1077
						Write_Error(EAX);
1078
						ShowMessage(NOT_CREATE_FOLDER, 150);
1079
					}
1080
				}
1081
				else
1082
				{
5620 leency 1083
					notify(FS_ITEM_ALREADY_EXISTS);
5571 punk_joker 1084
				}
5581 leency 1085
				break;
1086
			case RENAME_ITEM:
1087
				if (info_result==5)
5571 punk_joker 1088
				{
1089
					if (itdir)
1090
					{
1091
						if (del_rezult = DeleteFile(#file_path))
1092
						{
1093
							Write_Error(del_rezult);
1094
							ShowMessage(T_DEL_ERROR_1, 150);
1095
							return;
1096
						}
1097
						if (CreateDir(#temp)) CreateDir(#file_path);
1098
						Open_Dir(#path,WITH_REDRAW);
5694 leency 1099
						SelectFileByName(new_file_ed.text);
5571 punk_joker 1100
					}
1101
					else
1102
					{
1103
						if (copy_rezult = CopyFile(#file_path,#temp))
1104
						{
1105
							Write_Error(copy_rezult);
1106
						}
1107
						else
1108
						{
1109
							Del_File(true);
5694 leency 1110
							SelectFileByName(new_file_ed.text);
5571 punk_joker 1111
						}
1112
					}
1113
				}
1114
				else
1115
				{
5620 leency 1116
					notify(FS_ITEM_ALREADY_EXISTS);
5571 punk_joker 1117
				}
5555 punk_joker 1118
		}
5557 punk_joker 1119
		new_element_active = 0;
1120
		Open_Dir(#path,WITH_REDRAW);
5694 leency 1121
		SelectFileByName(new_file_ed.text);
5555 punk_joker 1122
	}
1123
	new_element_active = 0;
5557 punk_joker 1124
	Open_Dir(#path,WITH_REDRAW);
5555 punk_joker 1125
}
1126
 
5571 punk_joker 1127
void NewElement_Form(byte crt, dword strng)
5555 punk_joker 1128
{
1129
	int dform_x=files.w-220/2+files.x;
5557 punk_joker 1130
	if (!new_element_active)
5555 punk_joker 1131
	{
5557 punk_joker 1132
		new_element_active = crt;
5571 punk_joker 1133
		strcpy(#new_element_name, strng);
1134
		new_file_ed.size = new_file_ed.pos = strlen(strng);
5555 punk_joker 1135
	}
5674 pavelyakov 1136
	DrawPopup(dform_x,160,220,85,1,system.color.work,system.color.work_graph);
5581 leency 1137
	new_file_ed.left = dform_x+24;
5555 punk_joker 1138
	edit_box_draw  stdcall (#new_file_ed);
5581 leency 1139
	DrawRectangle(new_file_ed.left-1, new_file_ed.top-1, new_file_ed.width+2, 16, 0xFFFfff);
5674 pavelyakov 1140
	DrawRectangle(new_file_ed.left-2, new_file_ed.top-2, new_file_ed.width+4, 18, system.color.work_graph);
5591 pavelyakov 1141
	if (new_element_active==3) DrawFlatButton(dform_x+22,208,85,22,301,0xFFB6B5,T_RENAME);
1142
	else DrawFlatButton(dform_x+27,208,70,22,301,0xFFB6B5,T_CREATE);
5581 leency 1143
	DrawFlatButton(dform_x+120,208,70,22,302,0xC6DFC6,T_CANCEL);
5555 punk_joker 1144
}
1145
 
5576 pavelyakov 1146
void FnProcess(byte N)
3434 leency 1147
{
1148
	switch(N)
1149
	{
1150
		case 1:
4395 punk_joker 1151
			if (!active_about)
1152
			{
5576 pavelyakov 1153
				about_stak = malloc(4096);
1154
				about_window = CreateThread(#about_dialog,about_stak+4092);
4395 punk_joker 1155
				break;
1156
			}
1157
			else
1158
			{
1159
				ActivateWindow(GetProcessSlot(about_window));
1160
			}
3434 leency 1161
			break;
1162
		case 2:
1163
			if (!files.count) break;
5581 leency 1164
			NewElement_Form(RENAME_ITEM, #file_name);
3434 leency 1165
			break;
1166
		case 3:
5591 pavelyakov 1167
			if (!itdir) RunProgram("/sys/tinypad", #file_path);
3434 leency 1168
			break;
1169
		case 4:
5591 pavelyakov 1170
			if (!itdir) RunProgram("/sys/develop/heed", #file_path);
3434 leency 1171
			break;
3440 leency 1172
		case 5: //refresh cur dir & devs
5719 leency 1173
			if (two_panels)
1174
			{
5723 leency 1175
				DrawFilePanels();
5719 leency 1176
			}
1177
			else
1178
			{
1179
				Tip(56, T_DEVICES, 55, "-");
1180
				Open_Dir(#path,WITH_REDRAW);
1181
				pause(10);
1182
				GetSystemDiscs();
1183
				Open_Dir(#path,WITH_REDRAW);
5723 leency 1184
				DrawDeviceAndActionsLeftPanel();
5719 leency 1185
			}
3434 leency 1186
			break;
1187
		case 6:
5581 leency 1188
			NewElement_Form(CREATE_FOLDER, T_NEW_FOLDER);
3434 leency 1189
			break;
1190
		case 7:
5581 leency 1191
			NewElement_Form(CREATE_FILE, T_NEW_FILE);
3434 leency 1192
			break;
5447 punk_joker 1193
		case 8:
5576 pavelyakov 1194
			properties_stak = malloc(8096);
1195
			CreateThread(#properties_dialog, properties_stak+8092);
5447 punk_joker 1196
			break;
3434 leency 1197
		case 10: //F10
5753 leency 1198
			if (!active_settings)
5416 punk_joker 1199
			{
5576 pavelyakov 1200
				settings_stak = malloc(4096);
1201
				settings_window = CreateThread(#settings_dialog, settings_stak+4092);
5416 punk_joker 1202
				break;
1203
			}
1204
			else
1205
			{
1206
				ActivateWindow(GetProcessSlot(settings_window));
1207
			}
3434 leency 1208
			break;
1209
	}
1210
}
1211
 
5738 leency 1212
void ChangeActivePanel()
1213
{
1214
	llist_copy(#files_active, #files_inactive);
1215
	llist_copy(#files_inactive, #files);
1216
	strcpy(#active_path, #inactive_path);
1217
	strcpy(#inactive_path, #path);
1218
	DrawFilePanels();
1219
}
1220
 
3434 leency 1221
 
3363 leency 1222
stop: