Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
7606 leency 1
//Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2019
7490 leency 2
//GNU GPL license.
3363 leency 3
 
7361 leency 4
// 70.5 - get volume info and label
5
 
4022 leency 6
#ifndef AUTOBUILD
7
#include "lang.h--"
8
#endif
9
 
3363 leency 10
//libraries
7220 leency 11
#define MEMSIZE 1024 * 720
7054 leency 12
#include "../lib/clipboard.h"
13
#include "../lib/strings.h"
14
#include "../lib/mem.h"
7219 leency 15
#include "../lib/fs.h"
7054 leency 16
#include "../lib/gui.h"
17
#include "../lib/list_box.h"
18
#include "../lib/random.h"
19
#include "../lib/kfont.h"
20
#include "../lib/collection.h"
21
#include "../lib/copyf.h"
5834 pavelyakov 22
 
7054 leency 23
#include "../lib/obj/libini.h"
24
#include "../lib/obj/box_lib.h"
7230 leency 25
#include "../lib/obj/libimg.h"
7054 leency 26
 
27
#include "../lib/patterns/history.h"
28
 
7462 leency 29
#include "imgs/images.h"
3363 leency 30
 
6278 leency 31
//Button IDs
32
enum {
7422 leency 33
	PATH_BTN = 10,
6278 leency 34
	POPUP_BTN1 = 201,
6289 leency 35
	POPUP_BTN2 = 202,
36
	BREADCRUMB_ID = 300
6278 leency 37
};
3444 leency 38
 
6278 leency 39
//NewElement options
40
enum {
41
	CREATE_FILE=1,
42
	CREATE_FOLDER,
43
	RENAME_ITEM
44
};
45
 
46
//OpenDir options
47
enum {
48
	ONLY_SHOW,
49
	WITH_REDRAW,
50
	ONLY_OPEN
51
};
52
 
7462 leency 53
dword col_selec, col_lpanel, col_work, col_graph, col_list_line=0xDDD7CF;
3363 leency 54
 
3434 leency 55
int toolbar_buttons_x[7]={9,46,85,134,167,203};
3363 leency 56
 
4136 punk_joker 57
byte active_about=0;
4070 punk_joker 58
word about_window;
5416 punk_joker 59
word settings_window;
5753 leency 60
byte active_settings=0;
5606 pavelyakov 61
dword _not_draw = false;
4136 punk_joker 62
byte menu_call_mouse=0;
6403 punk_joker 63
byte exif_load=0;
4136 punk_joker 64
 
5733 leency 65
byte del_active=0;
66
byte new_element_active=0;
5698 leency 67
 
5733 leency 68
llist files, files_active, files_inactive;
3434 leency 69
 
5694 leency 70
byte list_full_redraw;
71
 
5698 leency 72
dword buf;
73
dword file_mas[6898];
74
int selected_count;
6406 punk_joker 75
int count_dir;
5698 leency 76
 
3434 leency 77
byte
3363 leency 78
	path[4096],
79
	file_path[4096],
3404 leency 80
	file_name[256],
5555 punk_joker 81
	new_element_name[256],
5698 leency 82
	temp[4096],
3441 leency 83
	itdir;
3363 leency 84
 
5719 leency 85
char active_path[4096], inactive_path[4096];
5698 leency 86
 
7202 leency 87
dword eolite_ini_path[4096];
88
_ini ini;
5441 leency 89
 
5698 leency 90
char scroll_used=false;
5695 leency 91
 
5804 punk_joker 92
dword menu_stak,about_stak,properties_stak,settings_stak,copy_stak,delete_stak;
5608 leency 93
 
3363 leency 94
proc_info Form;
7252 leency 95
int sc_slider_h;
4028 leency 96
int action_buf;
4863 leency 97
int rand_n;
3363 leency 98
 
7490 leency 99
char sort_type=2;
100
bool sort_desc=false;
7244 leency 101
int active_panel=1;
5549 punk_joker 102
 
7054 leency 103
libimg_image icons16_default;
104
libimg_image icons16_selected;
105
 
7242 leency 106
libimg_image icons32_default;
107
libimg_image icons32_selected;
7197 leency 108
 
6564 leency 109
#define STATUS_BAR_H 16;
110
int status_bar_h = 0;
111
 
7197 leency 112
int icon_size = 16;
113
 
7252 leency 114
edit_box new_file_ed = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x10000000,
115
	248,#new_element_name,0,100000000000010b,6,0};
7004 leency 116
PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
5694 leency 117
byte cmd_free=0;
5698 leency 118
#include "include\translations.h"
5834 pavelyakov 119
 
7462 leency 120
#include "include\gui.h"
5748 leency 121
#include "include\settings.h"
5804 punk_joker 122
#include "include\progress_dialog.h"
4042 leency 123
#include "include\copy.h"
3363 leency 124
#include "include\sorting.h"
4042 leency 125
#include "include\icons.h"
3363 leency 126
#include "include\left_panel.h"
4042 leency 127
#include "include\menu.h"
6278 leency 128
#include "include\delete.h"
4042 leency 129
#include "include\about.h"
5447 punk_joker 130
#include "include\properties.h"
6289 leency 131
#include "include\breadcrumbs.h"
3363 leency 132
 
133
void main()
134
{
7490 leency 135
	char selected_filename[256];
6289 leency 136
	dword id;
5834 pavelyakov 137
	byte count_sl = 0;
5748 leency 138
	signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
6735 leency 139
	char stats;
4863 leency 140
	rand_n = random(40);
5651 pavelyakov 141
 
5626 leency 142
	load_dll(boxlib, #box_lib_init,0);
5991 leency 143
	load_dll(libini, #lib_init,1);
7054 leency 144
	load_dll(libio,  #libio_init,1);
145
	load_dll(libimg, #libimg_init,1);
5834 pavelyakov 146
 
7375 leency 147
	SetAppColors();
5441 leency 148
	LoadIniSettings();
6034 leency 149
	SystemDiscs.Get();
7041 leency 150
 
7054 leency 151
	Libimg_LoadImage(#icons16_default, "/sys/icons16.png");
152
	Libimg_LoadImage(#icons16_selected, "/sys/icons16.png");
7203 leency 153
	Libimg_ReplaceColor(icons16_selected.image, icons16_selected.w, icons16_selected.h, 0xffFFFfff, col_selec);
154
	Libimg_ReplaceColor(icons16_selected.image, icons16_selected.w, icons16_selected.h, 0xffCACBD6, MixColors(col_selec, 0, 200));
7054 leency 155
 
7041 leency 156
	//-p just show file/folder properties dialog
157
	if (param) && (param[0]=='-') && (param[1]=='p')
158
	{
159
		strcpy(#file_path, #param + 3);
160
		strcpy(#file_name, #param + strrchr(#param, '/'));
161
		properties_dialog();
162
		ExitProcess();
163
	}
164
 
7422 leency 165
	ESBYTE[0] = NULL;
166
 
3363 leency 167
	if (param)
168
	{
7245 leency 169
		if (strlen(#param)>1) && (param[strlen(#param)-1]=='/') param[strlen(#param)-1]=NULL; //no "/" at the end
6930 leency 170
 
171
		if (dir_exists(#param)==true)
172
		{
173
			strcpy(#path, #param);
174
		}
175
		else
176
		{
177
			notify(T_NOTIFY_APP_PARAM_WRONG);
178
		}
7041 leency 179
	}
5833 pavelyakov 180
 
5733 leency 181
	Open_Dir(#path,ONLY_OPEN);
5719 leency 182
	strcpy(#inactive_path, #path);
5733 leency 183
	llist_copy(#files_inactive, #files);
7051 leency 184
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
5591 pavelyakov 185
	loop(){
7310 pavelyakov 186
		switch(WaitEventTimeout(50))
5591 pavelyakov 187
		{
188
			case evMouse:
7051 leency 189
				if (del_active) || (Form.status_window>2) break;
190
				if (new_element_active)
5591 pavelyakov 191
				{
192
					edit_box_mouse stdcall(#new_file_ed);
193
					break;
194
				}
5549 punk_joker 195
 
5640 pavelyakov 196
				mouse.get();
7422 leency 197
 
5640 pavelyakov 198
				if (!mouse.mkm) && (stats>0) stats = 0;
5657 pavelyakov 199
				if (mouse.mkm) && (!stats)
5549 punk_joker 200
				{
5640 pavelyakov 201
					x_old = mouse.x;
202
					y_old = mouse.y;
5591 pavelyakov 203
					stats = 1;
204
				}
5640 pavelyakov 205
				if (mouse.mkm) && (stats==1)
5591 pavelyakov 206
				{
5640 pavelyakov 207
					dif_x = mouse.x-x_old;
208
					dif_y = mouse.y-y_old;
5591 pavelyakov 209
					adif_x = fabs(dif_x);
210
					adif_y = fabs(dif_y);
211
 
212
					if (adif_x>adif_y)
5549 punk_joker 213
					{
5591 pavelyakov 214
						if (dif_x > 150)
215
						{
6021 leency 216
							if (history.forward())
5591 pavelyakov 217
								{
6021 leency 218
									strcpy(#path, history.current());
5694 leency 219
									files.KeyHome();
5591 pavelyakov 220
									Open_Dir(#path,WITH_REDRAW);
221
								}
222
							stats = 0;
223
						}
224
						if (dif_x < -150)
225
						{
226
							GoBack();
227
							stats = 0;
228
						}
5549 punk_joker 229
					}
5591 pavelyakov 230
					else
5549 punk_joker 231
					{
5591 pavelyakov 232
						if (dif_y < -100)
233
						{
234
							Dir_Up();
235
							stats = 0;
236
						}
5549 punk_joker 237
					}
5591 pavelyakov 238
				}
6191 leency 239
				if (files.MouseOver(mouse.x, mouse.y))
5549 punk_joker 240
				{
6191 leency 241
					//select file
6278 leency 242
					if (mouse.key&MOUSE_LEFT) && (mouse.up)
5575 pavelyakov 243
					{
7104 leency 244
						if (files.ProcessMouse(mouse.x, mouse.y)) List_ReDraw(); else {
245
							if (mouse.y - files.y / files.item_h + files.first == files.cur_y) Open(0);
246
						}
6191 leency 247
					}
248
					//file menu
6278 leency 249
					if (mouse.key&MOUSE_RIGHT)
6191 leency 250
					{
5591 pavelyakov 251
						menu_call_mouse = 1;
6278 leency 252
						if (files.ProcessMouse(mouse.x, mouse.y)) List_ReDraw();
6973 leency 253
						if (getElementSelectedFlag(files.cur_y) == false) selected_count = 0; //on redraw selection would be flashed, see [L001]
6278 leency 254
						menu_stak = malloc(4096);
255
						CreateThread(#FileMenu,menu_stak+4092);
5591 pavelyakov 256
						break;
5575 pavelyakov 257
					}
258
				}
5591 pavelyakov 259
 
5640 pavelyakov 260
				if (mouse.vert)
5575 pavelyakov 261
				{
5640 pavelyakov 262
					if (files.MouseScroll(mouse.vert)) List_ReDraw();
5591 pavelyakov 263
					break;
264
				}
265
 
5723 leency 266
				if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y-17) && (mouse.y
5591 pavelyakov 267
				{
7462 leency 268
					if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,system.color.work_dark,system.color.work_light);
269
					WHILE (mouse.lkm) && (files.first>0)
5575 pavelyakov 270
					{
5591 pavelyakov 271
						pause(8);
272
						files.first--;
273
						List_ReDraw();
5640 pavelyakov 274
						mouse.get();
5575 pavelyakov 275
					}
7462 leency 276
					DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,system.color.work_light,system.color.work_dark);
5575 pavelyakov 277
				}
3363 leency 278
 
5723 leency 279
				if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y+files.h-16) && (mouse.y
3363 leency 280
				{
7462 leency 281
					if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,system.color.work_dark,system.color.work_light);
282
					while (mouse.lkm) && (files.first
5591 pavelyakov 283
					{
284
						pause(8);
285
						files.first++;
286
						List_ReDraw();
5640 pavelyakov 287
						mouse.get();
5591 pavelyakov 288
					}
7462 leency 289
					DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,system.color.work_light,system.color.work_dark);
3363 leency 290
				}
291
 
5591 pavelyakov 292
				//Scrooll
5723 leency 293
				if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+18) && (mouse.y>files.y) && (mouse.y
7462 leency 294
				if (scroll_used) && (mouse.up) { scroll_used=false; Scroll(); }
5591 pavelyakov 295
 
296
				if (scroll_used)
3363 leency 297
				{
5640 pavelyakov 298
					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
5723 leency 299
					id = files.first;
7422 leency 300
					files.first = -sc_slider_h / 2 + mouse.y -files.y * files.count;
5743 leency 301
					files.first /= files.h - 18;
5591 pavelyakov 302
					if (files.visible+files.first>files.count) files.first=files.count-files.visible;
5743 leency 303
					if (files.first<0) files.first=0;
5591 pavelyakov 304
					if (id!=files.first) List_ReDraw();
5719 leency 305
					break;
3363 leency 306
				}
5719 leency 307
 
7244 leency 308
				if (two_panels.checked) && (mouse.y > files.y) && (mouse.down) {
5719 leency 309
					if (mouse.x
310
					{
311
						if (active_panel!=1)
312
						{
313
							active_panel = 1;
5738 leency 314
							ChangeActivePanel();
5719 leency 315
						}
316
					}
317
					else
318
					{
319
						if (active_panel!=2)
320
						{
321
							active_panel = 2;
5738 leency 322
							ChangeActivePanel();
5719 leency 323
						}
324
					}
325
				}
5591 pavelyakov 326
				break;
327
	//Button pressed-----------------------------------------------------------------------------
328
			case evButton:
7398 leency 329
				id=GetButtonID();
330
 
331
				if (new_element_active) || (del_active) {
332
					if(POPUP_BTN1==id) || (POPUP_BTN2==id) {
333
						if (del_active) Del_File(id-POPUP_BTN2);
334
						if (new_element_active) NewElement(id-POPUP_BTN2);
335
						DeleteButton(POPUP_BTN1);
336
						DeleteButton(POPUP_BTN2);
337
					}
338
					break;
339
				}
340
 
5591 pavelyakov 341
				switch(id)
342
				{
7054 leency 343
					case CLOSE_BTN:
6278 leency 344
							KillProcess(about_window);
345
							SaveIniSettings();
346
							ExitProcess();
7422 leency 347
					case PATH_BTN:
348
							notify(COPY_PATH_STR);
349
							Clipboard__CopyText(#path);
350
							break;
5591 pavelyakov 351
					case 21: //Back
352
							GoBack();
353
							break;
354
					case 22: //Forward
6021 leency 355
							if (history.forward())
5591 pavelyakov 356
							{
6021 leency 357
								strcpy(#path, history.current());
5694 leency 358
								files.KeyHome();
5591 pavelyakov 359
								Open_Dir(#path,WITH_REDRAW);
360
							}
361
							break;
5608 leency 362
					case 23:
3363 leency 363
							Dir_Up();
364
							break;
5608 leency 365
					case 24:
3444 leency 366
							Copy(#file_path, CUT);
367
							break;
5608 leency 368
					case 25:
3444 leency 369
							Copy(#file_path, NOCUT);
3363 leency 370
							break;
5608 leency 371
					case 26:
372
							Paste();
3363 leency 373
							break;
5733 leency 374
					case 31...33: //sorting
7490 leency 375
							id -= 30;
376
							if (sort_type == id) sort_desc ^= 1;
377
							else sort_type = id;
378
							strcpy(#selected_filename, #file_name);
5733 leency 379
							DrawList();
5591 pavelyakov 380
							Open_Dir(#path,WITH_REDRAW);
7490 leency 381
							SelectFileByName(#selected_filename);
5512 punk_joker 382
							break;
5591 pavelyakov 383
					case 50...60: //Actions
384
							FnProcess(id-50);
5512 punk_joker 385
							break;
7386 pavelyakov 386
					case 61: // Set path as default
7462 leency 387
							SetDefaultPath(#path);
7386 pavelyakov 388
							break;
5591 pavelyakov 389
					case 100...120:
6034 leency 390
						SystemDiscs.Click(id-100);
5698 leency 391
						break;
7054 leency 392
					case BREADCRUMB_ID...360:
6289 leency 393
						ClickOnBreadCrumb(id-BREADCRUMB_ID);
394
						break;
5591 pavelyakov 395
				}
396
				break;
6885 pavelyakov 397
 
5591 pavelyakov 398
	//Key pressed-----------------------------------------------------------------------------
399
			case evKey:
5706 leency 400
				GetKeys();
5698 leency 401
 
5591 pavelyakov 402
				if (Form.status_window>2) break;
7398 leency 403
 
404
				if (new_element_active) || (del_active)
5591 pavelyakov 405
				{
7398 leency 406
					if (del_active)
407
					{
408
						if (key_scancode == SCAN_CODE_ENTER) Del_File(true);
409
						if (key_scancode == SCAN_CODE_ESC) Del_File(false);
410
					}
411
					if (new_element_active)
412
					{
413
						if (key_scancode == SCAN_CODE_ENTER) NewElement(true);
414
						if (key_scancode == SCAN_CODE_ESC) NewElement(false);
415
						EAX = key_editbox;
416
						edit_box_key stdcall (#new_file_ed);
417
					}
5591 pavelyakov 418
					break;
419
				}
7398 leency 420
 
5706 leency 421
				if (files.ProcessKey(key_scancode))
5694 leency 422
				{
423
					List_ReDraw();
424
					break;
425
				}
5698 leency 426
 
5795 leency 427
				if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
5591 pavelyakov 428
				{
5706 leency 429
					switch(key_scancode)
5697 punk_joker 430
					{
5702 punk_joker 431
						case 059...068:
5706 leency 432
								key_scancode -= 59;
6034 leency 433
								if (key_scancode < SystemDiscs.list.count)
5702 punk_joker 434
								{
7244 leency 435
									if (!two_panels.checked)
5723 leency 436
									{
437
										DrawRectangle(17,key_scancode*16+74,159,16, 0); //display click
438
										pause(7);
439
									}
6034 leency 440
									SystemDiscs.Click(key_scancode);
5702 punk_joker 441
								}
442
								break;
7490 leency 443
						case SCAN_CODE_KEY_X:
5697 punk_joker 444
								Copy(#file_path, CUT);
445
								break;
7490 leency 446
						case SCAN_CODE_KEY_C:
5697 punk_joker 447
								Copy(#file_path, NOCUT);
448
								break;
7490 leency 449
						case SCAN_CODE_KEY_V:
5697 punk_joker 450
								Paste();
451
								break;
7490 leency 452
						case SCAN_CODE_KEY_D: //set image as bg
5803 leency 453
								strlcpy(#temp, "\\S__",4);
5591 pavelyakov 454
								strcat(#temp, #file_path);
455
								RunProgram("/sys/media/kiv", #temp);
456
								break;
7490 leency 457
						case SCAN_CODE_KEY_N: //create new window
5591 pavelyakov 458
								if (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD);
6735 leency 459
								RunProgram(I_Path, #path);
5591 pavelyakov 460
								break;
7490 leency 461
						case SCAN_CODE_KEY_M:
6157 punk_joker 462
								Open_Dir(#inactive_path,WITH_REDRAW);
463
								break;
7490 leency 464
						case SCAN_CODE_ENTER:
5702 punk_joker 465
								if (!itdir) ShowOpenWithDialog();
466
								else Open(1);
467
								break;
7490 leency 468
						case SCAN_CODE_KEY_A:
7422 leency 469
								EventSelectAllFiles(true);
5591 pavelyakov 470
								break;
7490 leency 471
						case SCAN_CODE_KEY_U: //unselect all files
5591 pavelyakov 472
								selected_count = 0;
7422 leency 473
								EventSelectAllFiles(false);
5591 pavelyakov 474
								break;
5697 punk_joker 475
					}
476
					break;
477
				}
5698 leency 478
 
5706 leency 479
				switch (key_scancode)
5697 punk_joker 480
				{
5702 punk_joker 481
						case SCAN_CODE_BS:
5697 punk_joker 482
								//GoBack();
483
								Dir_Up();
484
								break;
5702 punk_joker 485
						case SCAN_CODE_ENTER:
5591 pavelyakov 486
								Open(0);
487
								break;
5738 leency 488
						case SCAN_CODE_TAB:
7244 leency 489
								if (!two_panels.checked) break;
5738 leency 490
								if (active_panel==1) active_panel=2; else active_panel=1;
491
								ChangeActivePanel();
7422 leency 492
								DrawFilePanels();
5738 leency 493
								break;
7490 leency 494
						case SCAN_CODE_MENU:
5591 pavelyakov 495
								menu_call_mouse=0;
496
								menu_stak = malloc(4096);
497
								CreateThread(#FileMenu,menu_stak+4092);
498
								break;
5702 punk_joker 499
						case SCAN_CODE_DEL:
5591 pavelyakov 500
								Del_Form();
501
								break;
5702 punk_joker 502
						case SCAN_CODE_INS:
6646 leency 503
								if (getElementSelectedFlag(files.cur_y) == true) setElementSelectedFlag(files.cur_y, false);
6602 leency 504
								else setElementSelectedFlag(files.cur_y, true);
5955 leency 505
								files.KeyDown();
506
								List_ReDraw();
6564 leency 507
								DrawStatusBar();
5591 pavelyakov 508
								break;
7490 leency 509
						case SCAN_CODE_F1...SCAN_CODE_F10:
5706 leency 510
								FnProcess(key_scancode-58);
5591 pavelyakov 511
								break;
5974 leency 512
						default:
7422 leency 513
								EventSelectFileByKeyPress();
5591 pavelyakov 514
				}
3363 leency 515
			break;
5698 leency 516
			case evIPC:
5591 pavelyakov 517
			case evReDraw:
518
				draw_window();
519
				if (action_buf)
520
				{
5804 punk_joker 521
					if (action_buf==OPERATION_END)
5698 leency 522
					{
523
						FnProcess(5);
5991 leency 524
						if (copy_stak) SelectFileByName(#copy_to+strrchr(#copy_to,'/'));
5698 leency 525
					}
526
					if (action_buf==100) Open(0);
527
					if (action_buf==201) ShowOpenWithDialog();
528
					if (action_buf==202) FnProcess(3); //F3
529
					if (action_buf==203) FnProcess(4); //F4
530
					if (action_buf==104) Copy(#file_path, NOCUT);
531
					if (action_buf==105) Copy(#file_path, CUT);
532
					if (action_buf==106) Paste();
533
					if (action_buf==207) FnProcess(2);
534
					if (action_buf==108) Del_Form();
535
					if (action_buf==109) FnProcess(5);
536
					if (action_buf==110) FnProcess(8);
5591 pavelyakov 537
					action_buf=0;
538
				}
7310 pavelyakov 539
			break;
540
			default:
7422 leency 541
				if (Form.status_window>2) break;
542
				EventRefreshDisksAndFolders();
5591 pavelyakov 543
		}
7310 pavelyakov 544
 
5591 pavelyakov 545
		if(cmd_free)
546
		{
5991 leency 547
			if(cmd_free==1)      menu_stak=free(menu_stak);
548
			else if(cmd_free==2) about_stak=free(about_stak);
549
			else if(cmd_free==3) properties_stak=free(properties_stak);
550
			else if(cmd_free==4) settings_stak=free(settings_stak);
551
			else if(cmd_free==5) copy_stak=free(copy_stak);
552
			else if(cmd_free==6) delete_stak=free(delete_stak);
5591 pavelyakov 553
			cmd_free = false;
5576 pavelyakov 554
		}
555
	}
3363 leency 556
}
557
 
3444 leency 558
void draw_window()
559
{
7422 leency 560
	int i;
7244 leency 561
	if (show_status_bar.checked) status_bar_h = STATUS_BAR_H; else status_bar_h = 0;
7278 leency 562
	DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,TITLE,0);
3444 leency 563
	GetProcessInfo(#Form, SelfInfo);
564
	if (Form.status_window>2) return;
5811 leency 565
	if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
7551 leency 566
	if (!two_panels.checked) && (Form.width < 480) { MoveSize(OLD,OLD,480,OLD); return; }
567
	if ( two_panels.checked) && (Form.width < 573) { MoveSize(OLD,OLD,573,OLD); return; }
7490 leency 568
	GetProcessInfo(#Form, SelfInfo);
7462 leency 569
	ESDWORD[#toolbar_pal] = col_work;
570
	ESDWORD[#toolbar_pal+4] = MixColors(0, col_work, 35);
571
	PutPaletteImage(#toolbar, 246, 34, 0, 0, 8, #toolbar_pal);
6191 leency 572
	DrawBar(127, 8, 1, 25, col_graph);
7422 leency 573
	for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,21+i);
574
	for (i=3; i<6; i++) DefineHiddenButton(toolbar_buttons_x[i],  5,31,  29,  21+i);
6289 leency 575
	DrawBar(246,0, Form.cwidth - 246, 34, col_work);
7462 leency 576
	DrawDot(Form.cwidth-17,12);
577
	DrawDot(Form.cwidth-17,12+6);
578
	DrawDot(Form.cwidth-17,12+12);
7422 leency 579
	DefineHiddenButton(Form.cwidth-24,7,20,25,51+BT_NOFRAME); //dots
3434 leency 580
	//main rectangles
6564 leency 581
	DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42-status_bar_h,col_graph);
7462 leency 582
	DrawRectangle(0,39,Form.cwidth-1,-show_status_bar.checked*status_bar_h + Form.cheight - 40,col_work_gradient[4]); //bg
583
	for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_work_gradient[11-i]);
5733 leency 584
	llist_copy(#files_active, #files);
5723 leency 585
	strcpy(#active_path, #path);
6564 leency 586
	DrawStatusBar();
6973 leency 587
	if (selected_count==0) Open_Dir(#path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001]
5723 leency 588
	DrawFilePanels();
589
}
590
 
591
void DrawList()
592
{
5733 leency 593
	word sorting_arrow_x;
7490 leency 594
	dword sorting_arrow_t = "\x19";
595
	if (sort_desc) sorting_arrow_t = "\x18";
6678 leency 596
	DrawFlatButtonSmall(files.x, files.y-17,     files.w - 141,16,31,T_FILE);
597
	DrawFlatButtonSmall(files.x + files.w - 141, files.y-17,73,16,32,T_TYPE);
598
	DrawFlatButtonSmall(files.x + files.w -  68, files.y-17,68,16,33,T_SIZE);
599
	DrawFlatButtonSmall(files.x + files.w,       files.y-17,16,16, 0,"\x18");
600
	DrawFlatButtonSmall(files.x + files.w,files.y+files.h-16,16,16,0,"\x19");
7490 leency 601
	if (sort_type==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
602
	if (sort_type==2) sorting_arrow_x = files.x + files.w - 90;
603
	if (sort_type==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
604
	WriteText(sorting_arrow_x,files.y-12,0x80, system.color.work_text, sorting_arrow_t);
6191 leency 605
	DrawBar(files.x+files.w,files.y,1,files.h,col_graph);
7244 leency 606
	if (two_panels.checked) && (files.x<5) DrawBar(files.x+files.w+16,files.y,1,files.h,col_graph);
5723 leency 607
}
608
 
6404 punk_joker 609
void DrawStatusBar()
610
{
6572 leency 611
	char status_bar_str[80];
6570 leency 612
	int go_up_folder_exists=0;
7244 leency 613
	if (!show_status_bar.checked) return;
6604 leency 614
	if (files.count>0) && (strcmp(file_mas[0]*304+buf+72,"..")==0) go_up_folder_exists=1;
7462 leency 615
	DrawBar(0, Form.cheight - status_bar_h, Form.cwidth,  status_bar_h, system.color.work);
6570 leency 616
	sprintf(#status_bar_str, STATUS_STR, files.count-go_up_folder_exists, count_dir-go_up_folder_exists, files.count-count_dir, selected_count);
6783 leency 617
	WriteText(6,Form.cheight - 13,0x80,system.color.work_text,#status_bar_str);
6404 punk_joker 618
}
619
 
5723 leency 620
void DrawFilePanels()
621
{
6034 leency 622
	int files_y;
7244 leency 623
	if (!two_panels.checked)
5698 leency 624
	{
5723 leency 625
		DrawDeviceAndActionsLeftPanel();
6564 leency 626
		files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h);
5719 leency 627
		DrawList();
5733 leency 628
		Open_Dir(#path,ONLY_SHOW);
5698 leency 629
	}
630
	else
631
	{
6158 leency 632
		SystemDiscs.Get();
5733 leency 633
		llist_copy(#files, #files_inactive);
634
		strcpy(#path, #inactive_path);
635
		col_selec = 0xCCCccc;
6034 leency 636
		SystemDiscs.Draw();
637
		files_y = files.y;
5733 leency 638
 
5719 leency 639
		if (active_panel==1)
640
		{
5761 leency 641
			llist_copy(#files, #files_inactive);
642
			strcpy(#path, #inactive_path);
7551 leency 643
			col_selec = 0xCCCccc; //this is a bad code: need to use some var to set inactive panel for DrawList();
6564 leency 644
			files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 645
			DrawList();
5733 leency 646
			Open_Dir(#path,WITH_REDRAW);
647
			llist_copy(#files, #files_active);
5719 leency 648
			strcpy(#path, #active_path);
5733 leency 649
			col_selec = 0x94AECE;
6564 leency 650
			files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 651
			DrawList();
5733 leency 652
			Open_Dir(#path,WITH_REDRAW);
5719 leency 653
		}
654
		if (active_panel==2)
655
		{
6564 leency 656
			files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 657
			DrawList();
5733 leency 658
			Open_Dir(#path,WITH_REDRAW);
659
			llist_copy(#files, #files_active);
5719 leency 660
			strcpy(#path, #active_path);
5733 leency 661
			col_selec = 0x94AECE;
6564 leency 662
			files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 663
			DrawList();
5733 leency 664
			Open_Dir(#path,WITH_REDRAW);
5719 leency 665
		}
5698 leency 666
	}
3363 leency 667
}
668
 
669
 
5694 leency 670
void List_ReDraw()
3363 leency 671
{
5719 leency 672
	int all_lines_h;
7422 leency 673
	dword j;
5825 leency 674
	static int old_cur_y, old_first;
3363 leency 675
 
5694 leency 676
	files.CheckDoesValuesOkey(); //prevent some shit
3363 leency 677
 
5694 leency 678
	if (list_full_redraw) || (old_first != files.first)
3363 leency 679
	{
5825 leency 680
		old_cur_y = files.cur_y;
5694 leency 681
		old_first = files.first;
682
		list_full_redraw = false;
683
		goto _ALL_LIST_REDRAW;
3363 leency 684
	}
5825 leency 685
	if (old_cur_y != files.cur_y)
3363 leency 686
	{
5825 leency 687
		if (old_cur_y-files.first
688
		Line_ReDraw(col_selec, files.cur_y-files.first);
689
		old_cur_y = files.cur_y;
5694 leency 690
		return;
3363 leency 691
	}
692
 
5694 leency 693
	_ALL_LIST_REDRAW:
3363 leency 694
 
5825 leency 695
	for (j=0; j
3434 leency 696
	//in the bottom
5825 leency 697
	all_lines_h = j * files.item_h;
5719 leency 698
	DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h,0xFFFFFF);
6949 leency 699
	DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h,col_list_line);
700
	DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h,col_list_line);
3434 leency 701
	Scroll();
7398 leency 702
 
703
	if (del_active) Del_Form();
7551 leency 704
	if (new_element_active) && (col_selec != 0xCCCccc) NewElement_Form(new_element_active, #new_element_name);
3363 leency 705
}
706
 
3444 leency 707
 
5761 leency 708
void Line_ReDraw(dword bgcol, filenum){
3467 leency 709
	dword text_col=0,
5991 leency 710
		  ext1, attr,
711
		  file_offet,
712
		  file_name_off,
7515 leency 713
		  file_size=0,
6290 leency 714
		  y=filenum*files.item_h+files.y,
7197 leency 715
		  icon_y = files.item_h-icon_size/2+1+y;
5991 leency 716
		  BDVK file;
6757 leency 717
		  char temp_path[sizeof(file_path)];
5996 leency 718
	char label_file_name[4096];
4859 leency 719
	if (filenum==-1) return;
7054 leency 720
	DrawBar(files.x,y,4,files.item_h,bgcol);
7197 leency 721
	DrawBar(files.x+4,y,icon_size,icon_y-y,bgcol);
722
	if (files.item_h>icon_size) DrawBar(files.x+4,icon_y+icon_size-1,icon_size,y+files.item_h-icon_y-icon_size+1,bgcol);
7422 leency 723
	if (colored_lines.checked) && (bgcol!=col_selec) && (filenum%2) bgcol=0xF1F1F1;
724
	DrawBar(files.x+icon_size+4,y,files.w-icon_size-4,files.item_h,bgcol);
3363 leency 725
 
4897 leency 726
	file_offet = file_mas[filenum+files.first]*304 + buf+32;
5487 leency 727
	attr = ESDWORD[file_offet];
4897 leency 728
	file.selected = ESBYTE[file_offet+7];
729
	file.sizelo   = ESDWORD[file_offet+32];
6987 leency 730
	file.sizehi   = ESDWORD[file_offet+36];
4897 leency 731
	file_name_off = file_offet+40;
7515 leency 732
	sprintf(#temp_path,"%s/%s",#path,file_name_off);
3363 leency 733
 
5487 leency 734
	if (! TestBit(attr, 4) ) //file or folder?
3363 leency 735
	{
5698 leency 736
		ext1 = strrchr(file_name_off,'.') + file_name_off;
7515 leency 737
		if (ext1==file_name_off) ext1 = NULL; //if no extension then show nothing
738
		file_size = ConvertSize64(file.sizelo, file.sizehi);
6278 leency 739
		if (ext1) && (strlen(ext1)<9) WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, 0, ext1);
3363 leency 740
	}
741
	else
4846 leency 742
	{
7149 leency 743
		if (!strcmp(file_name_off,"..")) ext1=""; else {
6278 leency 744
			ext1="";
745
			WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, 0, ext1);
746
		}
7515 leency 747
		if (chrnum(#path, '/')==1) file_size = GetDeviceSizeLabel(#temp_path);
4846 leency 748
	}
7515 leency 749
	if (file_size) WriteText(7-strlen(file_size)*6+files.x+files.w-58,
750
			files.text_y+y+1, files.font_type, 0, file_size);
7054 leency 751
	DrawIconByExtension(#temp_path, ext1, files.x+4, icon_y, bgcol);
4846 leency 752
 
5487 leency 753
	if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=0xA6A6B7; //system or hiden?
7422 leency 754
	if (bgcol==col_selec)
3363 leency 755
	{
5487 leency 756
		itdir = TestBit(attr, 4);
4897 leency 757
		strcpy(#file_name, file_name_off);
6635 leency 758
		if (!strcmp(#path,"/")) sprintf(#file_path,"%s%s",#path,file_name_off);
759
			else sprintf(#file_path,"%s/%s",#path,file_name_off);
3363 leency 760
		if (text_col==0xA6A6B7) text_col=0xFFFFFF;
761
	}
4897 leency 762
	if (file.selected) text_col=0xFF0000;
6806 leency 763
	if (kfont.size.pt==9) || (!kfont.font)
3434 leency 764
	{
5745 leency 765
		if (Form.width>=480)
766
		{
767
			FileShow.start_x = files.x + 23;
768
			FileShow.font_color = text_col;
769
			FileShow.area_size_x = files.w - 164;
770
			FileShow.text_pointer = file_name_off;
7004 leency 771
			FileShow.start_y = files.text_y + y - 3;
5745 leency 772
			PathShow_prepare stdcall(#FileShow);
773
			PathShow_draw stdcall(#FileShow);
774
		}
3434 leency 775
	}
5745 leency 776
	else
777
	{
5996 leency 778
		strcpy(#label_file_name, file_name_off);
6806 leency 779
		if (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w)
5996 leency 780
		{
6806 leency 781
			while (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w) {
5996 leency 782
				ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL;
783
			}
784
			strcpy(#label_file_name+strlen(#label_file_name)-2, "...");
785
		}
7197 leency 786
		kfont.WriteIntoWindow(files.x + icon_size+7, files.item_h - kfont.height / 2 + y, bgcol, text_col, kfont.size.pt, #label_file_name);
5745 leency 787
	}
6949 leency 788
	DrawBar(files.x+files.w-141,y,1,files.item_h,col_list_line); //gray line 1
789
	DrawBar(files.x+files.w-68,y,1,files.item_h,col_list_line); //gray line 2
3363 leency 790
}
791
 
792
 
3444 leency 793
void Open_Dir(dword dir_path, redraw){
6406 punk_joker 794
	int errornum, maxcount, i;
3444 leency 795
	if (redraw!=ONLY_SHOW)
3363 leency 796
	{
6602 leency 797
		selected_count = 0;
3363 leency 798
		if (buf) free(buf);
3444 leency 799
		errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
800
		if (errornum)
3363 leency 801
		{
6021 leency 802
			history.add(#path);
3363 leency 803
			GoBack();
804
			Write_Error(errornum);
805
			return;
806
		}
3444 leency 807
		maxcount = sizeof(file_mas)/sizeof(dword)-1;
4225 punk_joker 808
		if (files.count>maxcount) files.count = maxcount;
5825 leency 809
		if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
3363 leency 810
	}
3444 leency 811
	if (files.count!=-1)
3363 leency 812
	{
7244 leency 813
		if(!_not_draw) if (show_breadcrumb.checked) DrawBreadCrumbs(); else DrawPathBar();
6021 leency 814
		history.add(#path);
6034 leency 815
		SystemDiscs.Draw();
5825 leency 816
		files.visible = files.h / files.item_h;
5591 pavelyakov 817
		if (files.count < files.visible) files.visible = files.count;
818
		if (redraw!=ONLY_SHOW) Sorting();
5694 leency 819
		list_full_redraw = true;
6564 leency 820
		if (redraw!=ONLY_OPEN)&&(!_not_draw) {DrawStatusBar(); List_ReDraw();}
6570 leency 821
		SetCurDir(dir_path);
3363 leency 822
	}
5694 leency 823
	if (files.count==-1) && (redraw!=ONLY_OPEN)
824
	{
825
		files.KeyHome();
6564 leency 826
		if(!_not_draw) { list_full_redraw=true; DrawStatusBar(); List_ReDraw(); }
5694 leency 827
	}
3363 leency 828
}
829
 
830
inline Sorting()
831
{
7490 leency 832
	dword d=0, f=1;
7422 leency 833
	int j=0;
4897 leency 834
	dword file_off;
7422 leency 835
 
6604 leency 836
	if (!strcmp(#path,"/")) //do not sort root folder
3363 leency 837
	{
7490 leency 838
		for(d=1;d
839
		count_dir = d;
3363 leency 840
		return;
841
	}
5591 pavelyakov 842
	for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
3363 leency 843
	{
7244 leency 844
		if (!show_real_names.checked) strttl(file_off+40);
4897 leency 845
		if (TestBit(ESDWORD[file_off],4)) //directory?
3363 leency 846
		{
7490 leency 847
			file_mas[d]=j;
848
			d++;
3363 leency 849
		}
850
		else
851
		{
7490 leency 852
			file_mas[files.count-f]=j;
853
			f++;
3363 leency 854
		}
855
	}
7490 leency 856
	count_dir = d;
3434 leency 857
	//sorting: files first, then folders
7490 leency 858
	Sort_by_Name(0,d-1);
859
	if (sort_type==1) Sort_by_Name(d,files.count-1);
860
	else if (sort_type==2) Sort_by_Type(d,files.count-1);
861
	else if (sort_type==3) Sort_by_Size(d,files.count-1);
862
	//reversed sorting
863
	if (sort_desc) {
864
		for (j=0; j
865
		//if (sort_type==1) for (j=0; j
866
	}
5581 leency 867
	//make ".." first item in list
7490 leency 868
	if (d>0) && (strncmp(file_mas[0]*304+buf+72,"..",2)!=0)
869
		for(d--; d>0; d--;) if (!strncmp(file_mas[d]*304+buf+72,"..",2)) {file_mas[d]>
3363 leency 870
}
871
 
872
 
873
void Del_Form()
874
{
5512 punk_joker 875
	byte f_count[128];
5581 leency 876
	int dform_x = files.w - 220 / 2 + files.x;
7004 leency 877
	if (selected_count==0) && (!strncmp(#file_name,"..",2)) return;
3991 leency 878
	else
879
	{
4002 leency 880
		if (!files.count) return;
6008 leency 881
		DrawEolitePopup(T_YES, T_NO);
5674 pavelyakov 882
		WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,system.color.work_text,T_DELETE_FILE);
6278 leency 883
		if (selected_count)
5512 punk_joker 884
		{
6278 leency 885
			sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,selected_count,DEL_MORE_FILES_2);
5674 pavelyakov 886
			WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,system.color.work_text,#f_count);
5512 punk_joker 887
		}
4002 leency 888
		else
889
		{
5591 pavelyakov 890
			if (strlen(#file_name)<28)
5512 punk_joker 891
			{
5674 pavelyakov 892
				WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,system.color.work_text,"?");
893
				WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,system.color.work_text,#file_name);
5512 punk_joker 894
			}
895
			else
896
			{
897
				WriteText(164+dform_x,190,0x80,0,"...?");
898
				ESI = 24;
899
				WriteText(dform_x+20,190,0,0,#file_name);
900
			}
6008 leency 901
		}
4002 leency 902
		del_active=1;
3991 leency 903
	}
3363 leency 904
}
905
 
5694 leency 906
void SelectFileByName(dword that_file)
3363 leency 907
{
5694 leency 908
	int ind;
909
	files.KeyHome();
5991 leency 910
	Open_Dir(#path,ONLY_OPEN);
7244 leency 911
	if (!show_real_names.checked) strttl(that_file);
5694 leency 912
	for (ind=files.count-1; ind>=0; ind--;) { if (!strcmp(file_mas[ind]*304+buf+72,that_file)) break; }
5825 leency 913
	files.cur_y = ind - 1;
5694 leency 914
	files.KeyDown();
6570 leency 915
	DrawStatusBar();
3363 leency 916
	List_ReDraw();
917
}
918
 
919
 
920
void Dir_Up()
921
{
7422 leency 922
	int iii;
6635 leency 923
	char old_folder_name[4096];
7422 leency 924
	iii=strlen(#path)-1;
925
	if (iii==0) return;
926
	iii = strrchr(#path, '/');
927
	strcpy(#old_folder_name, #path+iii);
928
	if (iii>1) path[iii-1]=NULL; else path[iii]=NULL;
6635 leency 929
	SelectFileByName(#old_folder_name);
3363 leency 930
}
931
 
5444 leency 932
void Open(byte rez)
3434 leency 933
{
5443 punk_joker 934
	byte temp[4096];
5513 punk_joker 935
	selected_count = 0;
5443 punk_joker 936
	if (rez)
937
	{
5606 pavelyakov 938
		if (!strncmp(#file_name,"..",3)) return;
5443 punk_joker 939
		strcpy(#temp, #file_path);
6735 leency 940
		RunProgram(I_Path, #temp);
5443 punk_joker 941
		return;
942
	}
3444 leency 943
	if (!files.count) return;
3441 leency 944
	if (!itdir)
3434 leency 945
	{
5401 leency 946
		if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
3434 leency 947
	}
948
	else
949
	{
5606 pavelyakov 950
		if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
3434 leency 951
		strcpy(#path, #file_path);
5825 leency 952
		files.first=files.cur_y=0;
3444 leency 953
		Open_Dir(#path,WITH_REDRAW);
3434 leency 954
	}
955
}
3363 leency 956
 
3434 leency 957
inline fastcall void GoBack()
3363 leency 958
{
959
	char cur_folder[4096];
5974 leency 960
	strcpy(#cur_folder, #path);
6021 leency 961
	if (history.back()) {
962
		strcpy(#path, history.current());
5977 leency 963
		SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
964
	}
3363 leency 965
}
966
 
5397 punk_joker 967
void ShowOpenWithDialog()
968
{
6930 leency 969
	byte open_param[4097];
970
	sprintf(#open_param,"~%s",#file_path);
971
	RunProgram("/sys/@open", #open_param);
5397 punk_joker 972
}
973
 
5555 punk_joker 974
void NewElement(byte newf)
975
{
5557 punk_joker 976
	BDVK element_info;
5581 leency 977
	byte del_rezult, copy_rezult, info_result;
5555 punk_joker 978
	if (newf)
979
	{
6635 leency 980
		sprintf(#temp,"%s/%s",#path,new_file_ed.text);
5581 leency 981
		info_result = GetFileInfo(#temp, #element_info);
5571 punk_joker 982
		switch(new_element_active)
5555 punk_joker 983
		{
5581 leency 984
			case CREATE_FILE:
985
				if (info_result==5)
5557 punk_joker 986
				{
7227 leency 987
					CreateFile(0, 0, #temp);
5571 punk_joker 988
					if (EAX)
989
					{
6008 leency 990
						if (EAX==5) notify(NOT_CREATE_FILE);
991
						else Write_Error(EAX);
5571 punk_joker 992
					}
5557 punk_joker 993
				}
5571 punk_joker 994
				else
5557 punk_joker 995
				{
5620 leency 996
					notify(FS_ITEM_ALREADY_EXISTS);
5557 punk_joker 997
				}
5581 leency 998
				break;
999
			case CREATE_FOLDER:
1000
				if (info_result==5)
5571 punk_joker 1001
				{
1002
					CreateDir(#temp);
1003
					if (EAX)
1004
					{
6008 leency 1005
						if (EAX==5) notify(NOT_CREATE_FOLDER);
1006
						else Write_Error(EAX);
5571 punk_joker 1007
					}
1008
				}
1009
				else
1010
				{
5620 leency 1011
					notify(FS_ITEM_ALREADY_EXISTS);
5571 punk_joker 1012
				}
5581 leency 1013
				break;
1014
			case RENAME_ITEM:
1015
				if (info_result==5)
5571 punk_joker 1016
				{
1017
					if (itdir)
1018
					{
6038 leency 1019
						//rename only empty folders
5571 punk_joker 1020
						if (del_rezult = DeleteFile(#file_path))
1021
						{
1022
							Write_Error(del_rezult);
1023
							return;
1024
						}
1025
						if (CreateDir(#temp)) CreateDir(#file_path);
1026
						Open_Dir(#path,WITH_REDRAW);
5694 leency 1027
						SelectFileByName(new_file_ed.text);
5571 punk_joker 1028
					}
1029
					else
1030
					{
1031
						if (copy_rezult = CopyFile(#file_path,#temp))
1032
						{
1033
							Write_Error(copy_rezult);
1034
						}
1035
						else
1036
						{
6038 leency 1037
							DeleteFile(#file_path);
5694 leency 1038
							SelectFileByName(new_file_ed.text);
5571 punk_joker 1039
						}
1040
					}
1041
				}
1042
				else
1043
				{
5620 leency 1044
					notify(FS_ITEM_ALREADY_EXISTS);
5571 punk_joker 1045
				}
5555 punk_joker 1046
		}
5557 punk_joker 1047
		new_element_active = 0;
1048
		Open_Dir(#path,WITH_REDRAW);
5694 leency 1049
		SelectFileByName(new_file_ed.text);
5555 punk_joker 1050
	}
1051
	new_element_active = 0;
5557 punk_joker 1052
	Open_Dir(#path,WITH_REDRAW);
5555 punk_joker 1053
}
1054
 
5571 punk_joker 1055
void NewElement_Form(byte crt, dword strng)
5555 punk_joker 1056
{
1057
	int dform_x=files.w-220/2+files.x;
5557 punk_joker 1058
	if (!new_element_active)
5555 punk_joker 1059
	{
5557 punk_joker 1060
		new_element_active = crt;
5571 punk_joker 1061
		strcpy(#new_element_name, strng);
7506 leency 1062
		EditBox_UpdateText(#new_file_ed, ed_focus+ed_always_focus);
5555 punk_joker 1063
	}
6008 leency 1064
	if (new_element_active==3) DrawEolitePopup(T_RENAME, T_CANCEL);
1065
	else DrawEolitePopup(T_CREATE, T_CANCEL);
6678 leency 1066
	new_file_ed.left = dform_x+10;
6278 leency 1067
	DrawEditBox(#new_file_ed);
5555 punk_joker 1068
}
1069
 
5576 pavelyakov 1070
void FnProcess(byte N)
3434 leency 1071
{
1072
	switch(N)
1073
	{
1074
		case 1:
4395 punk_joker 1075
			if (!active_about)
1076
			{
5576 pavelyakov 1077
				about_stak = malloc(4096);
1078
				about_window = CreateThread(#about_dialog,about_stak+4092);
4395 punk_joker 1079
				break;
1080
			}
1081
			else
1082
			{
1083
				ActivateWindow(GetProcessSlot(about_window));
1084
			}
3434 leency 1085
			break;
1086
		case 2:
1087
			if (!files.count) break;
5581 leency 1088
			NewElement_Form(RENAME_ITEM, #file_name);
3434 leency 1089
			break;
1090
		case 3:
5591 pavelyakov 1091
			if (!itdir) RunProgram("/sys/tinypad", #file_path);
3434 leency 1092
			break;
1093
		case 4:
5591 pavelyakov 1094
			if (!itdir) RunProgram("/sys/develop/heed", #file_path);
3434 leency 1095
			break;
3440 leency 1096
		case 5: //refresh cur dir & devs
7244 leency 1097
			if (two_panels.checked)
5719 leency 1098
			{
5723 leency 1099
				DrawFilePanels();
5719 leency 1100
			}
1101
			else
1102
			{
1103
				Tip(56, T_DEVICES, 55, "-");
1104
				Open_Dir(#path,WITH_REDRAW);
1105
				pause(10);
6034 leency 1106
				SystemDiscs.Get();
5719 leency 1107
				Open_Dir(#path,WITH_REDRAW);
5723 leency 1108
				DrawDeviceAndActionsLeftPanel();
5719 leency 1109
			}
3434 leency 1110
			break;
1111
		case 6:
5581 leency 1112
			NewElement_Form(CREATE_FOLDER, T_NEW_FOLDER);
3434 leency 1113
			break;
1114
		case 7:
5581 leency 1115
			NewElement_Form(CREATE_FILE, T_NEW_FILE);
3434 leency 1116
			break;
5447 punk_joker 1117
		case 8:
5576 pavelyakov 1118
			properties_stak = malloc(8096);
1119
			CreateThread(#properties_dialog, properties_stak+8092);
5447 punk_joker 1120
			break;
3434 leency 1121
		case 10: //F10
5753 leency 1122
			if (!active_settings)
5416 punk_joker 1123
			{
5576 pavelyakov 1124
				settings_stak = malloc(4096);
1125
				settings_window = CreateThread(#settings_dialog, settings_stak+4092);
5416 punk_joker 1126
				break;
1127
			}
1128
			else
1129
			{
1130
				ActivateWindow(GetProcessSlot(settings_window));
1131
			}
3434 leency 1132
			break;
1133
	}
1134
}
1135
 
5738 leency 1136
void ChangeActivePanel()
1137
{
1138
	llist_copy(#files_active, #files_inactive);
1139
	llist_copy(#files_inactive, #files);
1140
	strcpy(#active_path, #inactive_path);
1141
	strcpy(#inactive_path, #path);
1142
	DrawFilePanels();
1143
}
1144
 
7422 leency 1145
void EventSelectAllFiles(dword state)
1146
{
1147
	int i;
1148
	for (i=0; i
1149
	List_ReDraw();
1150
	DrawStatusBar();
1151
}
3434 leency 1152
 
7422 leency 1153
void EventSelectFileByKeyPress()
1154
{
1155
	int i;
1156
	for (i=files.cur_y+1; i
1157
	{
1158
		strcpy(#temp, file_mas[i]*304+buf+72);
1159
		if (temp[0]==key_ascii) || (temp[0]==key_ascii-32)
1160
		{
1161
			files.cur_y = i - 1;
1162
			files.KeyDown();
1163
			List_ReDraw();
1164
			return;
1165
		}
1166
	}
1167
}
1168
 
7515 leency 1169
dword GetDeviceSizeLabel(dword path)
1170
{
1171
	BDVK bdvk;
1172
	char cdname[8];
1173
	if (ESBYTE[path+1] == '/') path++;
1174
	if (ESBYTE[path+1] == 'c') && (ESBYTE[path+2] == 'd')
7518 leency 1175
		&& (ESBYTE[path+4] == 0) return 0;
7515 leency 1176
	GetFileInfo(path, #bdvk);
1177
	return ConvertSize64(bdvk.sizelo, bdvk.sizehi);
1178
}
1179
 
7422 leency 1180
int GetRealFileCountInFolder(dword folder_path)
1181
{
1182
	int fcount;
1183
	dword countbuf;
1184
 
1185
	GetDir(#countbuf, #fcount, folder_path, DIRS_NOROOT);
1186
	if (countbuf) free(countbuf);
1187
 
1188
	return fcount;
1189
}
1190
 
1191
void EventRefreshDisksAndFolders()
1192
{
1193
	if(GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
1194
		FnProcess(5);
1195
	}
1196
	if(two_panels.checked)
1197
	{
1198
		if(GetRealFileCountInFolder(#inactive_path) != files_inactive.count) {
1199
			ChangeActivePanel();
1200
			Open_Dir(#path,WITH_REDRAW);
1201
			ChangeActivePanel();
1202
		}
1203
		if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
1204
	}
1205
	else
1206
	{
1207
		if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
1208
	}
1209
}
1210
 
3363 leency 1211
stop: