Subversion Repositories Kolibri OS

Rev

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