Subversion Repositories Kolibri OS

Rev

Rev 7999 | Rev 8020 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7778 leency 1
//Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2020
7490 leency 2
//GNU GPL license.
3363 leency 3
 
7361 leency 4
// 70.5 - get volume info and label
5
 
8012 leency 6
#define TITLE "Eolite File Manager 4.46c"
7
#define ABOUT_TITLE "EOLITE 4.46c"
8
 
4022 leency 9
#ifndef AUTOBUILD
10
#include "lang.h--"
11
#endif
12
 
3363 leency 13
//libraries
7220 leency 14
#define MEMSIZE 1024 * 720
7054 leency 15
#include "../lib/clipboard.h"
16
#include "../lib/strings.h"
17
#include "../lib/mem.h"
7219 leency 18
#include "../lib/fs.h"
7054 leency 19
#include "../lib/gui.h"
20
#include "../lib/list_box.h"
21
#include "../lib/random.h"
22
#include "../lib/kfont.h"
23
#include "../lib/collection.h"
24
#include "../lib/copyf.h"
5834 pavelyakov 25
 
7054 leency 26
#include "../lib/obj/libini.h"
27
#include "../lib/obj/box_lib.h"
7230 leency 28
#include "../lib/obj/libimg.h"
7054 leency 29
 
30
#include "../lib/patterns/history.h"
31
 
7462 leency 32
#include "imgs/images.h"
3363 leency 33
 
6278 leency 34
//Button IDs
35
enum {
7422 leency 36
	PATH_BTN = 10,
6278 leency 37
	POPUP_BTN1 = 201,
6289 leency 38
	POPUP_BTN2 = 202,
39
	BREADCRUMB_ID = 300
6278 leency 40
};
3444 leency 41
 
6278 leency 42
//NewElement options
43
enum {
44
	CREATE_FILE=1,
45
	CREATE_FOLDER,
46
	RENAME_ITEM
47
};
48
 
49
//OpenDir options
50
enum {
51
	ONLY_SHOW,
52
	WITH_REDRAW,
53
	ONLY_OPEN
54
};
55
 
7757 leency 56
_history history;
57
 
7634 leency 58
struct Eolite_colors
59
{
7647 leency 60
	bool  def;
7634 leency 61
	dword lpanel;
62
	dword list_vert_line; //vertical line between columns in list
63
	dword selec;
64
	dword selec_active;
65
	dword selec_inactive;
66
	dword selec_text;
67
	dword list_bg;
68
	dword list_gb_text;
69
	dword list_text_hidden;
70
	dword work_gradient[24];
71
	dword slider_bg_big;
72
	dword slider_bg_left;
73
	dword odd_line;
74
} col;
3363 leency 75
 
3434 leency 76
int toolbar_buttons_x[7]={9,46,85,134,167,203};
3363 leency 77
 
7628 leency 78
bool active_about = false;
79
bool active_settings = false;
80
bool _not_draw = false;
81
bool exif_load = false;
82
bool dir_at_fat16 = NULL;
83
 
84
word about_thread_id;
5416 punk_joker 85
word settings_window;
4136 punk_joker 86
 
5733 leency 87
byte del_active=0;
88
byte new_element_active=0;
5698 leency 89
 
5733 leency 90
llist files, files_active, files_inactive;
3434 leency 91
 
5694 leency 92
byte list_full_redraw;
93
 
5698 leency 94
dword buf;
7972 leency 95
collection_int items=0;
5698 leency 96
int selected_count;
6406 punk_joker 97
int count_dir;
5698 leency 98
 
7628 leency 99
byte path[4096];
100
byte file_path[4096];
101
byte file_name[256];
102
byte new_element_name[256];
103
byte temp[4096];
104
bool itdir;
3363 leency 105
 
5719 leency 106
char active_path[4096], inactive_path[4096];
5698 leency 107
 
7202 leency 108
dword eolite_ini_path[4096];
109
_ini ini;
5441 leency 110
 
5698 leency 111
char scroll_used=false;
5695 leency 112
 
7878 leency 113
dword about_stak=0,properties_stak=0,settings_stak=0,delete_stak=0;
5608 leency 114
 
3363 leency 115
proc_info Form;
7252 leency 116
int sc_slider_h;
4028 leency 117
int action_buf;
4863 leency 118
int rand_n;
3363 leency 119
 
7490 leency 120
char sort_type=2;
121
bool sort_desc=false;
7244 leency 122
int active_panel=1;
5549 punk_joker 123
 
7054 leency 124
libimg_image icons16_default;
125
libimg_image icons16_selected;
126
 
7242 leency 127
libimg_image icons32_default;
128
libimg_image icons32_selected;
7197 leency 129
 
6564 leency 130
#define STATUS_BAR_H 16;
131
int status_bar_h = 0;
132
 
7197 leency 133
int icon_size = 16;
134
 
7252 leency 135
edit_box new_file_ed = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x10000000,
136
	248,#new_element_name,0,100000000000010b,6,0};
7004 leency 137
PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
5694 leency 138
byte cmd_free=0;
5698 leency 139
#include "include\translations.h"
5834 pavelyakov 140
 
7462 leency 141
#include "include\gui.h"
5748 leency 142
#include "include\settings.h"
5804 punk_joker 143
#include "include\progress_dialog.h"
7878 leency 144
#include "include\copy_and_delete.h"
3363 leency 145
#include "include\sorting.h"
4042 leency 146
#include "include\icons.h"
3363 leency 147
#include "include\left_panel.h"
4042 leency 148
#include "include\menu.h"
149
#include "include\about.h"
5447 punk_joker 150
#include "include\properties.h"
6289 leency 151
#include "include\breadcrumbs.h"
3363 leency 152
 
7786 leency 153
void load_libraries()
154
{
155
	load_dll(boxlib, #box_lib_init,0);
156
	load_dll(libini, #lib_init,1);
157
	load_dll(libio,  #libio_init,1);
158
	load_dll(libimg, #libimg_init,1);
159
}
160
 
7878 leency 161
void handle_param()
162
{
7879 leency 163
	//-p  : just show file/folder properties dialog
164
	//-d  : delete file/folder
165
	//-v : paste files/folder from clipboard
7878 leency 166
	if (param) && (param[0]=='-') switch (param[1])
167
	{
168
		case 'p':
169
			strcpy(#file_path, #param + 3);
7920 leency 170
			itdir = dir_exists(#file_path);
7878 leency 171
			strcpy(#file_name, #param + strrchr(#param, '/'));
7920 leency 172
			param[strrchr(#param, '/')-1] = '\0';
173
			strcpy(#path, #param + 3);
7878 leency 174
			properties_dialog();
175
			return;
176
		case 'd':
177
			strcpy(#file_path, #param + 3);
178
			itdir = dir_exists(#file_path);
179
			DisplayOperationForm(DELETE_FLAG);
180
			DeleteSingleElement();
181
			return;
7879 leency 182
		case 'v':
183
			cut_active = param[2] - '0';
184
			strcpy(#path, #param + 4);
185
			PasteThread();
186
			return;
7878 leency 187
	}
188
}
189
 
3363 leency 190
void main()
191
{
6289 leency 192
	dword id;
7993 leency 193
	int old_cur_y;
7786 leency 194
 
7816 leency 195
	rand_n = random(80);
5651 pavelyakov 196
 
7786 leency 197
	load_libraries();
5834 pavelyakov 198
 
7375 leency 199
	SetAppColors();
5441 leency 200
	LoadIniSettings();
6034 leency 201
	SystemDiscs.Get();
7041 leency 202
 
7878 leency 203
	handle_param();
7041 leency 204
 
7422 leency 205
	ESBYTE[0] = NULL;
206
 
3363 leency 207
	if (param)
208
	{
7245 leency 209
		if (strlen(#param)>1) && (param[strlen(#param)-1]=='/') param[strlen(#param)-1]=NULL; //no "/" at the end
6930 leency 210
 
7786 leency 211
		if (dir_exists(#param)) {
6930 leency 212
			strcpy(#path, #param);
7786 leency 213
		} else {
7914 leency 214
			file_size stdcall (#param);
215
			if (EAX==-1) notify(T_NOTIFY_APP_PARAM_WRONG);
216
			else {
217
				param[strrchr(#param, '/')-1] = '\0';
218
				strcpy(#path, #param);
7921 leency 219
				SelectFileByName(#param+strlen(#param)+1);
7914 leency 220
			}
6930 leency 221
		}
7041 leency 222
	}
5833 pavelyakov 223
 
5733 leency 224
	Open_Dir(#path,ONLY_OPEN);
5719 leency 225
	strcpy(#inactive_path, #path);
5733 leency 226
	llist_copy(#files_inactive, #files);
7051 leency 227
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
7913 leency 228
	loop() switch(@WaitEventTimeout(80))
7786 leency 229
	{
230
		case evMouse:
231
			if (del_active) || (Form.status_window>2) break;
232
			if (new_element_active)
233
			{
234
				edit_box_mouse stdcall(#new_file_ed);
235
				break;
236
			}
237
 
238
			mouse.get();
7422 leency 239
 
7786 leency 240
			ProceedMouseGestures();
7989 leency 241
 
7993 leency 242
			if (mouse.vert)
243
			{
244
				if (files.MouseScroll(mouse.vert)) List_ReDraw();
7989 leency 245
				break;
246
			}
7993 leency 247
 
7786 leency 248
			if (files.MouseOver(mouse.x, mouse.y))
249
			{
250
				//select file
251
				if (mouse.key&MOUSE_LEFT) && (mouse.up)
5549 punk_joker 252
				{
7993 leency 253
					GetKeyModifier();
254
					old_cur_y = files.cur_y;
8012 leency 255
					if (files.ProcessMouse(mouse.x, mouse.y)) && (!key_modifier) {
256
						List_ReDraw();
257
						break;
258
					}
7993 leency 259
					if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
260
						EventChooseFilesRange(old_cur_y, files.cur_y);
261
					} else if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
262
						EventChooseFile(files.cur_y);
263
						DrawStatusBar();
7989 leency 264
						List_ReDraw();
265
					} else {
8012 leency 266
						if (mouse.y - files.y / files.item_h + files.first == files.cur_y) Open(0);
7786 leency 267
					}
5591 pavelyakov 268
				}
7786 leency 269
				//file menu
270
				if (mouse.key&MOUSE_RIGHT) && (mouse.up)
5591 pavelyakov 271
				{
7786 leency 272
					if (files.ProcessMouse(mouse.x, mouse.y)) List_ReDraw();
273
					if (getElementSelectedFlag(files.cur_y) == false) selected_count = 0; //on redraw selection would be flashed, see [L001]
274
					EventShowListMenu();
275
				}
276
				break;
277
			}
278
 
279
			if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y-17) && (mouse.y
280
			{
7806 leency 281
				if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,sc.work_dark,sc.work_light);
7786 leency 282
				WHILE (mouse.lkm) && (files.first>0)
5549 punk_joker 283
				{
7786 leency 284
					pause(8);
285
					files.first--;
286
					List_ReDraw();
287
					mouse.get();
5575 pavelyakov 288
				}
7806 leency 289
				DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,sc.work_light,sc.work_dark);
7786 leency 290
			}
5591 pavelyakov 291
 
7786 leency 292
			if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y+files.h-16) && (mouse.y
293
			{
7806 leency 294
				if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,sc.work_dark,sc.work_light);
7786 leency 295
				while (mouse.lkm) && (files.first
5575 pavelyakov 296
				{
7786 leency 297
					pause(8);
298
					files.first++;
299
					List_ReDraw();
300
					mouse.get();
5591 pavelyakov 301
				}
7806 leency 302
				DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,sc.work_light,sc.work_dark);
7786 leency 303
			}
5591 pavelyakov 304
 
7786 leency 305
			//Scrooll
306
			if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+18) && (mouse.y>files.y) && (mouse.y
307
			if (scroll_used) && (mouse.up) { scroll_used=false; Scroll(); }
308
 
309
			if (scroll_used)
310
			{
311
				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
312
				id = files.first;
313
				files.first = -sc_slider_h / 2 + mouse.y -files.y * files.count;
314
				files.first /= files.h - 18;
315
				if (files.visible+files.first>files.count) files.first=files.count-files.visible;
316
				if (files.first<0) files.first=0;
317
				if (id!=files.first) List_ReDraw();
318
				break;
319
			}
320
 
321
			if (two_panels.checked) && (mouse.y > files.y) && (mouse.down) {
322
				if (mouse.x
5591 pavelyakov 323
				{
7786 leency 324
					if (active_panel!=1)
5575 pavelyakov 325
					{
7786 leency 326
						active_panel = 1;
327
						ChangeActivePanel();
5575 pavelyakov 328
					}
329
				}
7786 leency 330
				else
3363 leency 331
				{
7786 leency 332
					if (active_panel!=2)
5591 pavelyakov 333
					{
7786 leency 334
						active_panel = 2;
335
						ChangeActivePanel();
5591 pavelyakov 336
					}
3363 leency 337
				}
7786 leency 338
			}
339
			break;
340
//Button pressed-----------------------------------------------------------------------------
341
		case evButton:
7992 leency 342
			id = @GetButtonID();
3363 leency 343
 
7786 leency 344
			if (new_element_active) || (del_active) {
7878 leency 345
				if (POPUP_BTN1==id) && (del_active) EventDelete();
346
				if (POPUP_BTN1==id) && (new_element_active) NewElement();
347
				if (POPUP_BTN2==id) EventClosePopinForm();
7786 leency 348
				break;
349
			}
5719 leency 350
 
7786 leency 351
			switch(id)
352
			{
353
				case CLOSE_BTN:
354
						KillProcess(about_thread_id);
355
						SaveIniSettings();
356
						ExitProcess();
357
				case PATH_BTN:
358
						notify(COPY_PATH_STR);
359
						Clipboard__CopyText(#path);
360
						break;
361
				case 21: //Back
362
						EventHistoryGoBack();
363
						break;
364
				case 22: //Forward
365
						EventHistoryGoForward();
366
						break;
367
				case 23:
368
						Dir_Up();
369
						break;
370
				case 24:
7878 leency 371
						EventCopy(CUT);
7786 leency 372
						break;
373
				case 25:
7878 leency 374
						EventCopy(NOCUT);
7786 leency 375
						break;
376
				case 26:
7878 leency 377
						EventPaste();
7786 leency 378
						break;
379
				case 31...33:
380
						EventSort(id-30);
381
						break;
7813 leency 382
				case 51:
383
						EventShowBurgerMenu();
384
						break;
385
				case 52...60: //Actions
7786 leency 386
						FnProcess(id-50);
387
						break;
388
				case 61: // Set path as default
389
						SetDefaultPath(#path);
390
						break;
391
				case 100...120:
392
					SystemDiscs.Click(id-100);
393
					break;
394
				case BREADCRUMB_ID...360:
395
					ClickOnBreadCrumb(id-BREADCRUMB_ID);
396
					break;
397
			}
398
			break;
399
 
400
//Key pressed-----------------------------------------------------------------------------
401
		case evKey:
402
			GetKeys();
7398 leency 403
 
7786 leency 404
			if (Form.status_window>2) break;
405
 
406
			if (new_element_active) || (del_active)
407
			{
408
				if (del_active)
409
				{
7878 leency 410
					if (key_scancode == SCAN_CODE_ENTER) EventDelete();
411
					if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
7398 leency 412
				}
7786 leency 413
				if (new_element_active)
414
				{
7878 leency 415
					if (key_scancode == SCAN_CODE_ENTER) NewElement();
416
					if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
7786 leency 417
					EAX = key_editbox;
418
					edit_box_key stdcall (#new_file_ed);
419
				}
420
				break;
421
			}
7398 leency 422
 
7989 leency 423
			if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
7993 leency 424
				old_cur_y = files.cur_y;
425
				files.ProcessKey(key_scancode);
426
				EventChooseFilesRange(old_cur_y, files.cur_y);
7989 leency 427
				break;
428
			}
429
 
7786 leency 430
			if (files.ProcessKey(key_scancode))
431
			{
432
				List_ReDraw();
433
				break;
434
			}
435
 
436
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
437
			{
438
				switch(key_scancode)
5591 pavelyakov 439
				{
7786 leency 440
					case SCAN_CODE_F1...SCAN_CODE_F3:
441
							EventSort(key_scancode - 58);
7422 leency 442
							break;
7786 leency 443
					case SCAN_CODE_1...SCAN_CODE_10:
444
							key_scancode-=2;
445
							if (key_scancode >= SystemDiscs.list.count) break;
446
							if (!two_panels.checked)
5591 pavelyakov 447
							{
7786 leency 448
								DrawRectangle(17,key_scancode*16+74,159,16, 0); //display click
449
								pause(7);
5591 pavelyakov 450
							}
7786 leency 451
							SystemDiscs.Click(key_scancode);
5591 pavelyakov 452
							break;
7786 leency 453
					case SCAN_CODE_KEY_X:
7878 leency 454
							EventCopy(CUT);
7786 leency 455
							break;
456
					case SCAN_CODE_KEY_C:
7878 leency 457
							EventCopy(NOCUT);
3363 leency 458
							break;
7813 leency 459
					case SCAN_CODE_KEY_G:
460
							EventOpenConsoleHere();
461
							break;
7786 leency 462
					case SCAN_CODE_KEY_V:
7878 leency 463
							EventPaste();
3363 leency 464
							break;
7786 leency 465
					case SCAN_CODE_KEY_D: //set image as bg
466
							strlcpy(#temp, "\\S__",4);
467
							strcat(#temp, #file_path);
468
							RunProgram("/sys/media/kiv", #temp);
5512 punk_joker 469
							break;
7813 leency 470
					case SCAN_CODE_KEY_N:
471
							EventOpenNewEolite();
7786 leency 472
							break;
473
					case SCAN_CODE_KEY_M:
474
							Open_Dir(#inactive_path,WITH_REDRAW);
475
							break;
476
					case SCAN_CODE_ENTER:
477
							if (!itdir) ShowOpenWithDialog();
478
							else Open(1);
5512 punk_joker 479
							break;
7786 leency 480
					case SCAN_CODE_KEY_A:
7993 leency 481
							EventChooseAllFiles(true);
7386 pavelyakov 482
							break;
7786 leency 483
					case SCAN_CODE_KEY_U: //unselect all files
7993 leency 484
							EventChooseAllFiles(false);
7786 leency 485
							break;
5591 pavelyakov 486
				}
487
				break;
7786 leency 488
			}
5698 leency 489
 
7786 leency 490
			switch (key_scancode)
491
			{
492
					case SCAN_CODE_BS:
493
							//EventHistoryGoBack();
494
							Dir_Up();
495
							break;
496
					case SCAN_CODE_ENTER:
497
							Open(0);
498
							break;
499
					case SCAN_CODE_TAB:
500
							if (!two_panels.checked) break;
501
							if (active_panel==1) active_panel=2; else active_panel=1;
502
							ChangeActivePanel();
503
							DrawFilePanels();
504
							break;
505
					case SCAN_CODE_MENU:
506
							mouse.x = files.x+15;
507
							mouse.y = files.cur_y - files.first * files.item_h + files.y + 5;
508
							EventShowListMenu();
509
							break;
510
					case SCAN_CODE_DEL:
511
							Del_Form();
512
							break;
513
					case SCAN_CODE_INS:
7989 leency 514
							EventChooseFile(files.cur_y);
7786 leency 515
							files.KeyDown();
7999 leency 516
							DrawStatusBar();
7786 leency 517
							List_ReDraw();
518
							break;
519
					case SCAN_CODE_F1...SCAN_CODE_F10:
520
							FnProcess(key_scancode-58);
521
							break;
522
					default:
523
							EventSelectFileByKeyPress();
524
			}
525
		break;
526
		case evIPC:
527
		case evReDraw:
528
			draw_window();
529
			if (CheckActiveProcess(Form.ID)) && (GetMenuClick()) break;
530
			if (action_buf==OPERATION_END)
531
			{
532
				FnProcess(5);
533
				action_buf=0;
534
			}
535
		break;
536
		default:
537
			if (Form.status_window>2) break;
538
			EventRefreshDisksAndFolders();
5576 pavelyakov 539
	}
7786 leency 540
 
541
	if(cmd_free)
542
	{
543
		if(cmd_free==2) about_stak=free(about_stak);
544
		else if(cmd_free==3) properties_stak=free(properties_stak);
545
		else if(cmd_free==4) settings_stak=free(settings_stak);
546
		else if(cmd_free==6) delete_stak=free(delete_stak);
547
		cmd_free = false;
548
	}
3363 leency 549
}
550
 
3444 leency 551
void draw_window()
552
{
7634 leency 553
	dword i;
7244 leency 554
	if (show_status_bar.checked) status_bar_h = STATUS_BAR_H; else status_bar_h = 0;
7278 leency 555
	DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,TITLE,0);
3444 leency 556
	GetProcessInfo(#Form, SelfInfo);
557
	if (Form.status_window>2) return;
5811 leency 558
	if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
7551 leency 559
	if (!two_panels.checked) && (Form.width < 480) { MoveSize(OLD,OLD,480,OLD); return; }
560
	if ( two_panels.checked) && (Form.width < 573) { MoveSize(OLD,OLD,573,OLD); return; }
7490 leency 561
	GetProcessInfo(#Form, SelfInfo);
7635 leency 562
	SetAppColors();
7806 leency 563
	ESDWORD[#toolbar_pal] = sc.work;
564
	ESDWORD[#toolbar_pal+4] = MixColors(0, sc.work, 35);
7462 leency 565
	PutPaletteImage(#toolbar, 246, 34, 0, 0, 8, #toolbar_pal);
7806 leency 566
	DrawBar(127, 8, 1, 25, sc.work_graph);
7422 leency 567
	for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,21+i);
568
	for (i=3; i<6; i++) DefineHiddenButton(toolbar_buttons_x[i],  5,31,  29,  21+i);
7806 leency 569
	DrawBar(246,0, Form.cwidth - 246, 34, sc.work);
7462 leency 570
	DrawDot(Form.cwidth-17,12);
571
	DrawDot(Form.cwidth-17,12+6);
572
	DrawDot(Form.cwidth-17,12+12);
7422 leency 573
	DefineHiddenButton(Form.cwidth-24,7,20,25,51+BT_NOFRAME); //dots
3434 leency 574
	//main rectangles
7806 leency 575
	DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42-status_bar_h,sc.work_graph);
7634 leency 576
	DrawRectangle(0,39,Form.cwidth-1,-show_status_bar.checked*status_bar_h + Form.cheight - 40,col.work_gradient[4]); //bg
7806 leency 577
	for (i=0; i<6; i++) DrawBar(0, 34+i, Form.cwidth, 1, MixColors(sc.work_dark, sc.work, i*10));
7819 leency 578
	for (i=0; i<6; i++) DrawBar(0, 5-i, Form.cwidth, 1, MixColors(sc.work_light, sc.work, i*10));
5733 leency 579
	llist_copy(#files_active, #files);
5723 leency 580
	strcpy(#active_path, #path);
6564 leency 581
	DrawStatusBar();
7993 leency 582
	if (!selected_count) Open_Dir(#path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001]
5723 leency 583
	DrawFilePanels();
584
}
585
 
586
void DrawList()
587
{
5733 leency 588
	word sorting_arrow_x;
7490 leency 589
	dword sorting_arrow_t = "\x19";
590
	if (sort_desc) sorting_arrow_t = "\x18";
6678 leency 591
	DrawFlatButtonSmall(files.x, files.y-17,     files.w - 141,16,31,T_FILE);
592
	DrawFlatButtonSmall(files.x + files.w - 141, files.y-17,73,16,32,T_TYPE);
593
	DrawFlatButtonSmall(files.x + files.w -  68, files.y-17,68,16,33,T_SIZE);
594
	DrawFlatButtonSmall(files.x + files.w,       files.y-17,16,16, 0,"\x18");
595
	DrawFlatButtonSmall(files.x + files.w,files.y+files.h-16,16,16,0,"\x19");
7490 leency 596
	if (sort_type==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
597
	if (sort_type==2) sorting_arrow_x = files.x + files.w - 90;
598
	if (sort_type==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
7806 leency 599
	WriteText(sorting_arrow_x,files.y-12,0x80, sc.work_text, sorting_arrow_t);
600
	DrawBar(files.x+files.w,files.y,1,files.h,sc.work_graph);
601
	if (two_panels.checked) && (files.x<5) DrawBar(files.x+files.w+16,files.y,1,files.h,sc.work_graph);
5723 leency 602
}
603
 
6404 punk_joker 604
void DrawStatusBar()
605
{
6572 leency 606
	char status_bar_str[80];
6570 leency 607
	int go_up_folder_exists=0;
7244 leency 608
	if (!show_status_bar.checked) return;
7972 leency 609
	if (files.count>0) && (streq(items.get(0)*304+buf+72,"..")) go_up_folder_exists=1;
7806 leency 610
	DrawBar(0, Form.cheight - status_bar_h, Form.cwidth,  status_bar_h, sc.work);
7804 leency 611
	sprintf(#status_bar_str, T_STATUS_EVEMENTS, count_dir-go_up_folder_exists, files.count-count_dir);
7806 leency 612
	WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str);
7804 leency 613
	if (selected_count) {
614
		sprintf(#status_bar_str, T_STATUS_SELECTED, selected_count);
615
		WriteText(Form.cwidth - calc(strlen(#status_bar_str)*6)-6,Form.cheight - 13,
7806 leency 616
			0x80,sc.work_text,#status_bar_str);
7804 leency 617
	}
6404 punk_joker 618
}
619
 
5723 leency 620
void DrawFilePanels()
621
{
6034 leency 622
	int files_y;
7244 leency 623
	if (!two_panels.checked)
5698 leency 624
	{
5723 leency 625
		DrawDeviceAndActionsLeftPanel();
6564 leency 626
		files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h);
5719 leency 627
		DrawList();
5733 leency 628
		Open_Dir(#path,ONLY_SHOW);
5698 leency 629
	}
630
	else
631
	{
6158 leency 632
		SystemDiscs.Get();
5733 leency 633
		llist_copy(#files, #files_inactive);
634
		strcpy(#path, #inactive_path);
7634 leency 635
		col.selec = col.selec_inactive;
6034 leency 636
		SystemDiscs.Draw();
637
		files_y = files.y;
5733 leency 638
 
5719 leency 639
		if (active_panel==1)
640
		{
5761 leency 641
			llist_copy(#files, #files_inactive);
642
			strcpy(#path, #inactive_path);
7634 leency 643
			col.selec = col.selec_inactive; //this is a bad code: need to use some var to set inactive panel for DrawList();
6564 leency 644
			files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 645
			DrawList();
5733 leency 646
			Open_Dir(#path,WITH_REDRAW);
647
			llist_copy(#files, #files_active);
5719 leency 648
			strcpy(#path, #active_path);
7634 leency 649
			col.selec = col.selec_active;
6564 leency 650
			files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 651
			DrawList();
5733 leency 652
			Open_Dir(#path,WITH_REDRAW);
5719 leency 653
		}
654
		if (active_panel==2)
655
		{
6564 leency 656
			files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 657
			DrawList();
5733 leency 658
			Open_Dir(#path,WITH_REDRAW);
659
			llist_copy(#files, #files_active);
5719 leency 660
			strcpy(#path, #active_path);
7634 leency 661
			col.selec = col.selec_active;
6564 leency 662
			files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 663
			DrawList();
5733 leency 664
			Open_Dir(#path,WITH_REDRAW);
5719 leency 665
		}
5698 leency 666
	}
3363 leency 667
}
668
 
669
 
5694 leency 670
void List_ReDraw()
3363 leency 671
{
5719 leency 672
	int all_lines_h;
7422 leency 673
	dword j;
5825 leency 674
	static int old_cur_y, old_first;
3363 leency 675
 
5694 leency 676
	files.CheckDoesValuesOkey(); //prevent some shit
3363 leency 677
 
5694 leency 678
	if (list_full_redraw) || (old_first != files.first)
3363 leency 679
	{
5825 leency 680
		old_cur_y = files.cur_y;
5694 leency 681
		old_first = files.first;
682
		list_full_redraw = false;
683
		goto _ALL_LIST_REDRAW;
3363 leency 684
	}
5825 leency 685
	if (old_cur_y != files.cur_y)
3363 leency 686
	{
7634 leency 687
		if (old_cur_y-files.first
688
		Line_ReDraw(col.selec, files.cur_y-files.first);
5825 leency 689
		old_cur_y = files.cur_y;
5694 leency 690
		return;
3363 leency 691
	}
692
 
5694 leency 693
	_ALL_LIST_REDRAW:
3363 leency 694
 
7634 leency 695
	for (j=0; j
696
		if (files.cur_y-files.first!=j) Line_ReDraw(col.list_bg, j);
697
		else Line_ReDraw(col.selec, files.cur_y-files.first);
698
	}
3434 leency 699
	//in the bottom
5825 leency 700
	all_lines_h = j * files.item_h;
7634 leency 701
	DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h, col.list_bg);
702
	DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h,col.list_vert_line);
703
	DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h,col.list_vert_line);
3434 leency 704
	Scroll();
7398 leency 705
 
706
	if (del_active) Del_Form();
7634 leency 707
	if (new_element_active) && (col.selec != 0xCCCccc) NewElement_Form(new_element_active, #new_element_name);
3363 leency 708
}
709
 
7628 leency 710
bool file_name_is_8_3(dword name)
711
{
712
	int name_len = strlen(name);
713
	int dot_pos = strrchr(name, '.');
714
	if (name_len<=12)
715
	{
716
		if (dot_pos) {
717
			if (name_len - dot_pos > 3) return false;
718
		}
719
		else {
720
			if (name_len>8) return false;
721
		}
722
		return true;
723
	}
724
	return false;
725
}
3444 leency 726
 
5761 leency 727
void Line_ReDraw(dword bgcol, filenum){
7634 leency 728
	dword text_col=col.list_gb_text,
5991 leency 729
		  ext1, attr,
730
		  file_offet,
731
		  file_name_off,
7515 leency 732
		  file_size=0,
6290 leency 733
		  y=filenum*files.item_h+files.y,
7197 leency 734
		  icon_y = files.item_h-icon_size/2+1+y;
5991 leency 735
		  BDVK file;
7921 leency 736
		  char full_path[4096];
5996 leency 737
	char label_file_name[4096];
4859 leency 738
	if (filenum==-1) return;
7054 leency 739
	DrawBar(files.x,y,4,files.item_h,bgcol);
7197 leency 740
	DrawBar(files.x+4,y,icon_size,icon_y-y,bgcol);
741
	if (files.item_h>icon_size) DrawBar(files.x+4,icon_y+icon_size-1,icon_size,y+files.item_h-icon_y-icon_size+1,bgcol);
7634 leency 742
	if (colored_lines.checked) && (bgcol!=col.selec) && (filenum%2) bgcol=col.odd_line;
7422 leency 743
	DrawBar(files.x+icon_size+4,y,files.w-icon_size-4,files.item_h,bgcol);
3363 leency 744
 
7972 leency 745
	file_offet = items.get(filenum+files.first)*304 + buf+32;
5487 leency 746
	attr = ESDWORD[file_offet];
4897 leency 747
	file.selected = ESBYTE[file_offet+7];
748
	file.sizelo   = ESDWORD[file_offet+32];
6987 leency 749
	file.sizehi   = ESDWORD[file_offet+36];
4897 leency 750
	file_name_off = file_offet+40;
7921 leency 751
	sprintf(#full_path,"%s/%s",#path,file_name_off);
3363 leency 752
 
5487 leency 753
	if (! TestBit(attr, 4) ) //file or folder?
3363 leency 754
	{
5698 leency 755
		ext1 = strrchr(file_name_off,'.') + file_name_off;
7515 leency 756
		if (ext1==file_name_off) ext1 = NULL; //if no extension then show nothing
757
		file_size = ConvertSize64(file.sizelo, file.sizehi);
7634 leency 758
		if (ext1) && (strlen(ext1)<9) WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
3363 leency 759
	}
760
	else
4846 leency 761
	{
7149 leency 762
		if (!strcmp(file_name_off,"..")) ext1=""; else {
6278 leency 763
			ext1="";
7634 leency 764
			WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
6278 leency 765
		}
7921 leency 766
		if (chrnum(#path, '/')==1) file_size = GetDeviceSizeLabel(#full_path);
4846 leency 767
	}
7515 leency 768
	if (file_size) WriteText(7-strlen(file_size)*6+files.x+files.w-58,
7634 leency 769
			files.text_y+y+1, files.font_type, col.list_gb_text, file_size);
7921 leency 770
	DrawIconByExtension(#full_path, ext1, files.x+4, icon_y, bgcol);
4846 leency 771
 
7634 leency 772
	if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=col.list_text_hidden; //system or hiden?
773
	if (bgcol==col.selec)
3363 leency 774
	{
7628 leency 775
		file_name_is_8_3(file_name_off);
5487 leency 776
		itdir = TestBit(attr, 4);
4897 leency 777
		strcpy(#file_name, file_name_off);
6635 leency 778
		if (!strcmp(#path,"/")) sprintf(#file_path,"%s%s",#path,file_name_off);
779
			else sprintf(#file_path,"%s/%s",#path,file_name_off);
7634 leency 780
		if (text_col==col.list_text_hidden) {
781
			text_col=MixColors(col.selec_text, col.list_text_hidden, 65);
782
		} else text_col=col.selec_text;
3363 leency 783
	}
4897 leency 784
	if (file.selected) text_col=0xFF0000;
6806 leency 785
	if (kfont.size.pt==9) || (!kfont.font)
3434 leency 786
	{
5745 leency 787
		if (Form.width>=480)
788
		{
789
			FileShow.start_x = files.x + 23;
790
			FileShow.font_color = text_col;
791
			FileShow.area_size_x = files.w - 164;
792
			FileShow.text_pointer = file_name_off;
7004 leency 793
			FileShow.start_y = files.text_y + y - 3;
5745 leency 794
			PathShow_prepare stdcall(#FileShow);
795
			PathShow_draw stdcall(#FileShow);
796
		}
3434 leency 797
	}
5745 leency 798
	else
799
	{
5996 leency 800
		strcpy(#label_file_name, file_name_off);
6806 leency 801
		if (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w)
5996 leency 802
		{
6806 leency 803
			while (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w) {
5996 leency 804
				ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL;
805
			}
806
			strcpy(#label_file_name+strlen(#label_file_name)-2, "...");
807
		}
7634 leency 808
		kfont.WriteIntoWindow(files.x + icon_size+7, files.item_h - kfont.height / 2 + y,
809
			bgcol, text_col, kfont.size.pt, #label_file_name);
5745 leency 810
	}
7634 leency 811
	DrawBar(files.x+files.w-141,y,1,files.item_h,col.list_vert_line); //gray line 1
812
	DrawBar(files.x+files.w-68,y,1,files.item_h,col.list_vert_line); //gray line 2
3363 leency 813
}
814
 
815
 
3444 leency 816
void Open_Dir(dword dir_path, redraw){
6406 punk_joker 817
	int errornum, maxcount, i;
3444 leency 818
	if (redraw!=ONLY_SHOW)
3363 leency 819
	{
6602 leency 820
		selected_count = 0;
3363 leency 821
		if (buf) free(buf);
3444 leency 822
		errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
823
		if (errornum)
3363 leency 824
		{
6021 leency 825
			history.add(#path);
7786 leency 826
			EventHistoryGoBack();
3363 leency 827
			Write_Error(errornum);
828
			return;
829
		}
5825 leency 830
		if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
3363 leency 831
	}
3444 leency 832
	if (files.count!=-1)
3363 leency 833
	{
7244 leency 834
		if(!_not_draw) if (show_breadcrumb.checked) DrawBreadCrumbs(); else DrawPathBar();
6021 leency 835
		history.add(#path);
6034 leency 836
		SystemDiscs.Draw();
5825 leency 837
		files.visible = files.h / files.item_h;
5591 pavelyakov 838
		if (files.count < files.visible) files.visible = files.count;
7628 leency 839
		if (!strncmp(dir_path, "/rd/1/",5))
840
			dir_at_fat16 = true; else dir_at_fat16 = false;
5591 pavelyakov 841
		if (redraw!=ONLY_SHOW) Sorting();
5694 leency 842
		list_full_redraw = true;
6564 leency 843
		if (redraw!=ONLY_OPEN)&&(!_not_draw) {DrawStatusBar(); List_ReDraw();}
6570 leency 844
		SetCurDir(dir_path);
3363 leency 845
	}
5694 leency 846
	if (files.count==-1) && (redraw!=ONLY_OPEN)
847
	{
848
		files.KeyHome();
6564 leency 849
		if(!_not_draw) { list_full_redraw=true; DrawStatusBar(); List_ReDraw(); }
5694 leency 850
	}
3363 leency 851
}
852
 
853
inline Sorting()
854
{
7490 leency 855
	dword d=0, f=1;
7422 leency 856
	int j=0;
7972 leency 857
	dword tmp;
4897 leency 858
	dword file_off;
7422 leency 859
 
7972 leency 860
	items.drop();
861
 
6604 leency 862
	if (!strcmp(#path,"/")) //do not sort root folder
3363 leency 863
	{
7972 leency 864
		for(d=1;d
7490 leency 865
		count_dir = d;
3363 leency 866
		return;
867
	}
5591 pavelyakov 868
	for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
3363 leency 869
	{
7628 leency 870
		if (dir_at_fat16) && (file_name_is_8_3(file_off+40)) strttl(file_off+40);
4897 leency 871
		if (TestBit(ESDWORD[file_off],4)) //directory?
3363 leency 872
		{
7972 leency 873
			items.set(d, j);
7490 leency 874
			d++;
3363 leency 875
		}
876
		else
877
		{
7972 leency 878
			items.set(files.count-f, j);
7490 leency 879
			f++;
3363 leency 880
		}
881
	}
7490 leency 882
	count_dir = d;
3434 leency 883
	//sorting: files first, then folders
7490 leency 884
	Sort_by_Name(0,d-1);
885
	if (sort_type==1) Sort_by_Name(d,files.count-1);
886
	else if (sort_type==2) Sort_by_Type(d,files.count-1);
887
	else if (sort_type==3) Sort_by_Size(d,files.count-1);
888
	//reversed sorting
889
	if (sort_desc) {
7972 leency 890
		for (j=0; j
891
			items.swap(files.count-j-1, d+j);
892
		}
893
		//if (sort_type==1) for (j=0; j
7490 leency 894
	}
5581 leency 895
	//make ".." first item in list
7972 leency 896
	if (d>0) && (strncmp(items.get(0)*304+buf+72,"..",2)!=0)
897
		for(d--; d>0; d--;) if (!strncmp(items.get(d)*304+buf+72,"..",2)) {items.swap(d,0); break;}
3363 leency 898
}
899
 
900
 
901
void Del_Form()
902
{
5512 punk_joker 903
	byte f_count[128];
5581 leency 904
	int dform_x = files.w - 220 / 2 + files.x;
7993 leency 905
	if (!selected_count) && (!strncmp(#file_name,"..",2)) return;
3991 leency 906
	else
907
	{
4002 leency 908
		if (!files.count) return;
6008 leency 909
		DrawEolitePopup(T_YES, T_NO);
7806 leency 910
		WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,sc.work_text,T_DELETE_FILE);
6278 leency 911
		if (selected_count)
5512 punk_joker 912
		{
6278 leency 913
			sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,selected_count,DEL_MORE_FILES_2);
7806 leency 914
			WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,sc.work_text,#f_count);
5512 punk_joker 915
		}
4002 leency 916
		else
917
		{
5591 pavelyakov 918
			if (strlen(#file_name)<28)
5512 punk_joker 919
			{
7806 leency 920
				WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,sc.work_text,"?");
921
				WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,sc.work_text,#file_name);
5512 punk_joker 922
			}
923
			else
924
			{
925
				WriteText(164+dform_x,190,0x80,0,"...?");
926
				ESI = 24;
927
				WriteText(dform_x+20,190,0,0,#file_name);
928
			}
6008 leency 929
		}
4002 leency 930
		del_active=1;
3991 leency 931
	}
3363 leency 932
}
933
 
5694 leency 934
void SelectFileByName(dword that_file)
3363 leency 935
{
5694 leency 936
	int ind;
937
	files.KeyHome();
5991 leency 938
	Open_Dir(#path,ONLY_OPEN);
7628 leency 939
	if (dir_at_fat16) && (file_name_is_8_3(that_file)) strttl(that_file);
7972 leency 940
	for (ind=files.count-1; ind>=0; ind--;) { if (streq(items.get(ind)*304+buf+72,that_file)) break; }
5825 leency 941
	files.cur_y = ind - 1;
5694 leency 942
	files.KeyDown();
6570 leency 943
	DrawStatusBar();
3363 leency 944
	List_ReDraw();
945
}
946
 
947
 
948
void Dir_Up()
949
{
7422 leency 950
	int iii;
6635 leency 951
	char old_folder_name[4096];
7422 leency 952
	iii=strlen(#path)-1;
953
	if (iii==0) return;
954
	iii = strrchr(#path, '/');
955
	strcpy(#old_folder_name, #path+iii);
956
	if (iii>1) path[iii-1]=NULL; else path[iii]=NULL;
6635 leency 957
	SelectFileByName(#old_folder_name);
3363 leency 958
}
959
 
5444 leency 960
void Open(byte rez)
3434 leency 961
{
5443 punk_joker 962
	byte temp[4096];
5513 punk_joker 963
	selected_count = 0;
5443 punk_joker 964
	if (rez)
965
	{
5606 pavelyakov 966
		if (!strncmp(#file_name,"..",3)) return;
5443 punk_joker 967
		strcpy(#temp, #file_path);
6735 leency 968
		RunProgram(I_Path, #temp);
5443 punk_joker 969
		return;
970
	}
3444 leency 971
	if (!files.count) return;
3441 leency 972
	if (!itdir)
3434 leency 973
	{
5401 leency 974
		if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
3434 leency 975
	}
976
	else
977
	{
5606 pavelyakov 978
		if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
3434 leency 979
		strcpy(#path, #file_path);
5825 leency 980
		files.first=files.cur_y=0;
3444 leency 981
		Open_Dir(#path,WITH_REDRAW);
3434 leency 982
	}
983
}
3363 leency 984
 
7786 leency 985
inline fastcall void EventHistoryGoBack()
3363 leency 986
{
987
	char cur_folder[4096];
5974 leency 988
	strcpy(#cur_folder, #path);
6021 leency 989
	if (history.back()) {
990
		strcpy(#path, history.current());
5977 leency 991
		SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
992
	}
3363 leency 993
}
994
 
5397 punk_joker 995
void ShowOpenWithDialog()
996
{
6930 leency 997
	byte open_param[4097];
998
	sprintf(#open_param,"~%s",#file_path);
999
	RunProgram("/sys/@open", #open_param);
5397 punk_joker 1000
}
1001
 
7878 leency 1002
void NewElement()
5555 punk_joker 1003
{
5557 punk_joker 1004
	BDVK element_info;
5581 leency 1005
	byte del_rezult, copy_rezult, info_result;
7878 leency 1006
 
1007
	sprintf(#temp,"%s/%s",#path,new_file_ed.text);
1008
	info_result = GetFileInfo(#temp, #element_info);
1009
	switch(new_element_active)
5555 punk_joker 1010
	{
7878 leency 1011
		case CREATE_FILE:
1012
			if (info_result==5)
1013
			{
1014
				CreateFile(0, 0, #temp);
1015
				if (EAX)
5557 punk_joker 1016
				{
7878 leency 1017
					if (EAX==5) notify(NOT_CREATE_FILE);
1018
					else Write_Error(EAX);
5557 punk_joker 1019
				}
7878 leency 1020
			}
1021
			else
1022
			{
1023
				notify(FS_ITEM_ALREADY_EXISTS);
1024
			}
1025
			break;
1026
		case CREATE_FOLDER:
1027
			if (info_result==5)
1028
			{
1029
				CreateDir(#temp);
1030
				if (EAX)
5557 punk_joker 1031
				{
7878 leency 1032
					if (EAX==5) notify(NOT_CREATE_FOLDER);
1033
					else Write_Error(EAX);
5557 punk_joker 1034
				}
7878 leency 1035
			}
1036
			else
1037
			{
1038
				notify(FS_ITEM_ALREADY_EXISTS);
1039
			}
1040
			break;
1041
		case RENAME_ITEM:
1042
			if (info_result==5)
1043
			{
1044
				if (itdir)
5571 punk_joker 1045
				{
7878 leency 1046
					//rename only empty folders
1047
					if (del_rezult = DeleteFile(#file_path))
5571 punk_joker 1048
					{
7878 leency 1049
						Write_Error(del_rezult);
1050
						return;
5571 punk_joker 1051
					}
7878 leency 1052
					if (CreateDir(#temp)) CreateDir(#file_path);
1053
					Open_Dir(#path,WITH_REDRAW);
1054
					SelectFileByName(new_file_ed.text);
5571 punk_joker 1055
				}
1056
				else
1057
				{
7878 leency 1058
					if (copy_rezult = CopyFile(#file_path,#temp))
5571 punk_joker 1059
					{
7878 leency 1060
						Write_Error(copy_rezult);
5571 punk_joker 1061
					}
1062
					else
1063
					{
7878 leency 1064
						DeleteFile(#file_path);
1065
						SelectFileByName(new_file_ed.text);
5571 punk_joker 1066
					}
1067
				}
7878 leency 1068
			}
1069
			else
1070
			{
1071
				notify(FS_ITEM_ALREADY_EXISTS);
1072
			}
5555 punk_joker 1073
	}
5557 punk_joker 1074
	Open_Dir(#path,WITH_REDRAW);
7878 leency 1075
	SelectFileByName(new_file_ed.text);
1076
	EventClosePopinForm();
5555 punk_joker 1077
}
1078
 
5571 punk_joker 1079
void NewElement_Form(byte crt, dword strng)
5555 punk_joker 1080
{
1081
	int dform_x=files.w-220/2+files.x;
5557 punk_joker 1082
	if (!new_element_active)
5555 punk_joker 1083
	{
5557 punk_joker 1084
		new_element_active = crt;
5571 punk_joker 1085
		strcpy(#new_element_name, strng);
7506 leency 1086
		EditBox_UpdateText(#new_file_ed, ed_focus+ed_always_focus);
5555 punk_joker 1087
	}
6008 leency 1088
	if (new_element_active==3) DrawEolitePopup(T_RENAME, T_CANCEL);
1089
	else DrawEolitePopup(T_CREATE, T_CANCEL);
6678 leency 1090
	new_file_ed.left = dform_x+10;
6278 leency 1091
	DrawEditBox(#new_file_ed);
5555 punk_joker 1092
}
1093
 
5576 pavelyakov 1094
void FnProcess(byte N)
3434 leency 1095
{
1096
	switch(N)
1097
	{
1098
		case 1:
7786 leency 1099
			if (!active_about) {
5576 pavelyakov 1100
				about_stak = malloc(4096);
7628 leency 1101
				about_thread_id = CreateThread(#about_dialog,about_stak+4092);
4395 punk_joker 1102
				break;
7786 leency 1103
			} else {
7628 leency 1104
				ActivateWindow(GetProcessSlot(about_thread_id));
4395 punk_joker 1105
			}
3434 leency 1106
			break;
1107
		case 2:
7786 leency 1108
			if (files.count) NewElement_Form(RENAME_ITEM, #file_name);
3434 leency 1109
			break;
1110
		case 3:
7786 leency 1111
			if (files.count) && (!itdir) RunProgram("/sys/tinypad", #file_path);
3434 leency 1112
			break;
1113
		case 4:
7786 leency 1114
			if (files.count) && (!itdir) RunProgram("/sys/develop/heed", #file_path);
3434 leency 1115
			break;
3440 leency 1116
		case 5: //refresh cur dir & devs
7244 leency 1117
			if (two_panels.checked)
5719 leency 1118
			{
5723 leency 1119
				DrawFilePanels();
5719 leency 1120
			}
1121
			else
1122
			{
1123
				Tip(56, T_DEVICES, 55, "-");
1124
				Open_Dir(#path,WITH_REDRAW);
1125
				pause(10);
6034 leency 1126
				SystemDiscs.Get();
5719 leency 1127
				Open_Dir(#path,WITH_REDRAW);
5723 leency 1128
				DrawDeviceAndActionsLeftPanel();
5719 leency 1129
			}
3434 leency 1130
			break;
1131
		case 6:
5581 leency 1132
			NewElement_Form(CREATE_FOLDER, T_NEW_FOLDER);
3434 leency 1133
			break;
1134
		case 7:
5581 leency 1135
			NewElement_Form(CREATE_FILE, T_NEW_FILE);
3434 leency 1136
			break;
5447 punk_joker 1137
		case 8:
7878 leency 1138
			EventShowProperties();
5447 punk_joker 1139
			break;
3434 leency 1140
		case 10: //F10
5753 leency 1141
			if (!active_settings)
5416 punk_joker 1142
			{
5576 pavelyakov 1143
				settings_stak = malloc(4096);
1144
				settings_window = CreateThread(#settings_dialog, settings_stak+4092);
5416 punk_joker 1145
				break;
1146
			}
1147
			else
1148
			{
1149
				ActivateWindow(GetProcessSlot(settings_window));
1150
			}
3434 leency 1151
			break;
1152
	}
1153
}
1154
 
5738 leency 1155
void ChangeActivePanel()
1156
{
1157
	llist_copy(#files_active, #files_inactive);
1158
	llist_copy(#files_inactive, #files);
1159
	strcpy(#active_path, #inactive_path);
1160
	strcpy(#inactive_path, #path);
1161
	DrawFilePanels();
1162
}
1163
 
7422 leency 1164
void EventSelectFileByKeyPress()
1165
{
1166
	int i;
1167
	for (i=files.cur_y+1; i
1168
	{
7972 leency 1169
		strcpy(#temp, items.get(i)*304+buf+72);
7422 leency 1170
		if (temp[0]==key_ascii) || (temp[0]==key_ascii-32)
1171
		{
1172
			files.cur_y = i - 1;
1173
			files.KeyDown();
1174
			List_ReDraw();
1175
			return;
1176
		}
1177
	}
1178
}
1179
 
7515 leency 1180
dword GetDeviceSizeLabel(dword path)
1181
{
1182
	BDVK bdvk;
1183
	char cdname[8];
1184
	if (ESBYTE[path+1] == '/') path++;
1185
	if (ESBYTE[path+1] == 'c') && (ESBYTE[path+2] == 'd')
7518 leency 1186
		&& (ESBYTE[path+4] == 0) return 0;
7515 leency 1187
	GetFileInfo(path, #bdvk);
1188
	return ConvertSize64(bdvk.sizelo, bdvk.sizehi);
1189
}
1190
 
7422 leency 1191
int GetRealFileCountInFolder(dword folder_path)
1192
{
1193
	int fcount;
1194
	dword countbuf;
1195
 
1196
	GetDir(#countbuf, #fcount, folder_path, DIRS_NOROOT);
1197
	if (countbuf) free(countbuf);
1198
 
1199
	return fcount;
1200
}
1201
 
1202
void EventRefreshDisksAndFolders()
1203
{
1204
	if(GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
1205
		FnProcess(5);
1206
	}
1207
	if(two_panels.checked)
1208
	{
1209
		if(GetRealFileCountInFolder(#inactive_path) != files_inactive.count) {
1210
			ChangeActivePanel();
1211
			Open_Dir(#path,WITH_REDRAW);
1212
			ChangeActivePanel();
1213
		}
1214
		if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
1215
	}
1216
	else
1217
	{
1218
		if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
1219
	}
1220
}
1221
 
7628 leency 1222
void EventSort(dword id)
1223
{
1224
	char selected_filename[256];
1225
	if (sort_type == id) sort_desc ^= 1;
1226
	else sort_type = id;
1227
	strcpy(#selected_filename, #file_name);
1228
	DrawList();
1229
	Open_Dir(#path,WITH_REDRAW);
1230
	SelectFileByName(#selected_filename);
1231
}
1232
 
7786 leency 1233
void EventHistoryGoForward()
1234
{
1235
	if (history.forward()) {
1236
		strcpy(#path, history.current());
1237
		files.KeyHome();
1238
		Open_Dir(#path,WITH_REDRAW);
1239
	}
1240
}
1241
 
7813 leency 1242
void EventOpenNewEolite()
1243
{
1244
	RunProgram(I_Path, #path);
1245
}
1246
 
1247
void EventOpenConsoleHere()
1248
{
1249
	sprintf(#param, "pwd cd %s", #path);
1250
	RunProgram("/sys/shell", #param);
1251
}
1252
 
7786 leency 1253
void ProceedMouseGestures()
1254
{
1255
	char stats;
1256
	signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
1257
	if (!mouse.mkm) && (stats>0) stats = 0;
1258
	if (mouse.mkm) && (!stats)
1259
	{
1260
		x_old = mouse.x;
1261
		y_old = mouse.y;
1262
		stats = 1;
1263
	}
1264
	if (mouse.mkm) && (stats==1)
1265
	{
1266
		dif_x = mouse.x-x_old;
1267
		dif_y = mouse.y-y_old;
1268
		adif_x = fabs(dif_x);
1269
		adif_y = fabs(dif_y);
1270
 
1271
		if (adif_x>adif_y) {
1272
			if (dif_x > 150) {
1273
				EventHistoryGoForward();
1274
				stats = 0;
1275
			}
1276
			if (dif_x < -150) {
1277
				EventHistoryGoBack();
1278
				stats = 0;
1279
			}
1280
		} else {
1281
			if (dif_y < -100) {
1282
				Dir_Up();
1283
				stats = 0;
1284
			}
1285
		}
1286
	}
1287
}
1288
 
7878 leency 1289
void EventPaste() {
1290
	char paste_line[4096+6];
1291
	sprintf(#paste_line, "-v%i %s", cut_active, #path);
1292
	RunProgram(#program_path, #paste_line);
1293
	EventClosePopinForm();
1294
}
1295
 
1296
void EventDelete()
1297
char line_param[4096+5];
1298
{
1299
	EventClosePopinForm();
1300
	if (!selected_count) {
1301
		sprintf(#line_param, "-d %s", #file_path);
1302
		RunProgram(#program_path, #line_param);
1303
	} else {
1304
		delete_stak = malloc(40000);
1305
		CreateThread(#DeleteSelectedElements,delete_stak+40000-4);
1306
	}
1307
}
1308
 
1309
void EventClosePopinForm()
1310
{
1311
	del_active=0;
1312
	new_element_active = 0;
1313
	draw_window();
1314
	DeleteButton(POPUP_BTN1);
1315
	DeleteButton(POPUP_BTN2);
1316
}
1317
 
1318
void EventShowProperties()
1319
char line_param[4096+5];
1320
{
1321
	if (!selected_count) {
1322
		sprintf(#line_param, "-p %s", #file_path);
1323
		RunProgram(#program_path, #line_param);
1324
	} else {
1325
		properties_stak = malloc(8096);
1326
		CreateThread(#properties_dialog, properties_stak+8092);
1327
	}
1328
}
1329
 
7989 leency 1330
void EventChooseFile(int _id)
1331
{
1332
	if (getElementSelectedFlag(_id) == true) {
1333
		setElementSelectedFlag(_id, false);
1334
	} else {
1335
		setElementSelectedFlag(_id, true);
1336
	}
7993 leency 1337
}
1338
 
1339
void EventChooseFilesRange(int _start, _end)
1340
{
1341
	if (_start > _end) _start >< _end;
1342
	if (_end - _start > 1) list_full_redraw = true;
1343
	while (_start < _end) {
1344
		EventChooseFile(_start);
1345
		_start++;
1346
	}
7989 leency 1347
	DrawStatusBar();
7993 leency 1348
	List_ReDraw();
7989 leency 1349
}
1350
 
7993 leency 1351
void EventChooseAllFiles(dword state)
1352
{
1353
	int i;
1354
	for (i=0; i
1355
	List_ReDraw();
1356
	DrawStatusBar();
1357
}
1358
 
1359
 
1360
 
3363 leency 1361
stop: