Subversion Repositories Kolibri OS

Rev

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