Subversion Repositories Kolibri OS

Rev

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