Subversion Repositories Kolibri OS

Rev

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

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