Subversion Repositories Kolibri OS

Rev

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