Subversion Repositories Kolibri OS

Rev

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