Subversion Repositories Kolibri OS

Rev

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