Subversion Repositories Kolibri OS

Rev

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