Subversion Repositories Kolibri OS

Rev

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