Subversion Repositories Kolibri OS

Rev

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

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