Subversion Repositories Kolibri OS

Rev

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