Subversion Repositories Kolibri OS

Rev

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