Subversion Repositories Kolibri OS

Rev

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