Subversion Repositories Kolibri OS

Rev

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