Subversion Repositories Kolibri OS

Rev

Rev 8334 | Rev 8392 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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