Subversion Repositories Kolibri OS

Rev

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