Subversion Repositories Kolibri OS

Rev

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

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