Subversion Repositories Kolibri OS

Rev

Rev 9044 | Rev 9269 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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