Subversion Repositories Kolibri OS

Rev

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