Subversion Repositories Kolibri OS

Rev

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