Subversion Repositories Kolibri OS

Rev

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