Subversion Repositories Kolibri OS

Rev

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