Subversion Repositories Kolibri OS

Rev

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

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