Subversion Repositories Kolibri OS

Rev

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