Subversion Repositories Kolibri OS

Rev

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