Subversion Repositories Kolibri OS

Rev

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