Subversion Repositories Kolibri OS

Rev

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

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