Subversion Repositories Kolibri OS

Rev

Rev 7314 | Rev 7369 | 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
 
7361 leency 4
// 70.5 - get volume info and label
5
 
4022 leency 6
#ifndef AUTOBUILD
7
#include "lang.h--"
8
#endif
9
 
3363 leency 10
//libraries
7220 leency 11
#define MEMSIZE 1024 * 720
7054 leency 12
#include "../lib/clipboard.h"
13
#include "../lib/strings.h"
14
#include "../lib/mem.h"
7219 leency 15
#include "../lib/fs.h"
7054 leency 16
#include "../lib/gui.h"
17
#include "../lib/list_box.h"
18
#include "../lib/random.h"
19
#include "../lib/kfont.h"
20
#include "../lib/collection.h"
21
#include "../lib/menu.h"
22
#include "../lib/copyf.h"
5834 pavelyakov 23
 
7054 leency 24
#include "../lib/obj/libini.h"
25
#include "../lib/obj/box_lib.h"
7230 leency 26
#include "../lib/obj/libimg.h"
7054 leency 27
 
28
#include "../lib/patterns/history.h"
29
 
3363 leency 30
//images
7054 leency 31
#include "imgs/left_p.txt"
3363 leency 32
 
6278 leency 33
//Button IDs
34
enum {
35
	POPUP_BTN1 = 201,
6289 leency 36
	POPUP_BTN2 = 202,
37
	BREADCRUMB_ID = 300
6278 leency 38
};
3444 leency 39
 
6278 leency 40
//NewElement options
41
enum {
42
	CREATE_FILE=1,
43
	CREATE_FOLDER,
44
	RENAME_ITEM
45
};
46
 
47
//OpenDir options
48
enum {
49
	ONLY_SHOW,
50
	WITH_REDRAW,
51
	ONLY_OPEN
52
};
53
 
6949 leency 54
dword col_padding, col_selec, col_lpanel, col_work, col_graph, col_list_line=0xDDD7CF;
3363 leency 55
 
3434 leency 56
int toolbar_buttons_x[7]={9,46,85,134,167,203};
3363 leency 57
 
4136 punk_joker 58
byte active_about=0;
4070 punk_joker 59
word about_window;
5416 punk_joker 60
word settings_window;
5753 leency 61
byte active_settings=0;
5606 pavelyakov 62
dword _not_draw = false;
4136 punk_joker 63
byte menu_call_mouse=0;
6403 punk_joker 64
byte exif_load=0;
4136 punk_joker 65
 
5733 leency 66
byte del_active=0;
67
byte new_element_active=0;
5698 leency 68
 
5733 leency 69
llist files, files_active, files_inactive;
3434 leency 70
 
5694 leency 71
byte list_full_redraw;
72
 
5698 leency 73
dword buf;
74
dword file_mas[6898];
75
int selected_count;
6406 punk_joker 76
int count_dir;
5698 leency 77
 
3434 leency 78
byte
3363 leency 79
	path[4096],
80
	file_path[4096],
3404 leency 81
	file_name[256],
5555 punk_joker 82
	new_element_name[256],
5698 leency 83
	temp[4096],
3441 leency 84
	itdir;
3363 leency 85
 
5719 leency 86
char active_path[4096], inactive_path[4096];
5698 leency 87
 
7202 leency 88
dword eolite_ini_path[4096];
89
_ini ini;
5441 leency 90
 
5698 leency 91
char scroll_used=false;
5695 leency 92
 
5804 punk_joker 93
dword menu_stak,about_stak,properties_stak,settings_stak,copy_stak,delete_stak;
5608 leency 94
 
3363 leency 95
proc_info Form;
7252 leency 96
int sc_slider_h;
3434 leency 97
int j, i;
4028 leency 98
int action_buf;
4863 leency 99
int rand_n;
3363 leency 100
 
6291 leency 101
char sort_num=2;
7244 leency 102
int active_panel=1;
5549 punk_joker 103
 
7054 leency 104
libimg_image icons16_default;
105
libimg_image icons16_selected;
106
 
7242 leency 107
libimg_image icons32_default;
108
libimg_image icons32_selected;
7197 leency 109
 
6564 leency 110
#define STATUS_BAR_H 16;
111
int status_bar_h = 0;
112
 
7197 leency 113
int icon_size = 16;
114
 
7252 leency 115
edit_box new_file_ed = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x10000000,
116
	248,#new_element_name,0,100000000000010b,6,0};
7004 leency 117
PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
5694 leency 118
byte cmd_free=0;
5698 leency 119
#include "include\translations.h"
5804 punk_joker 120
#include "include\fs.h"
5834 pavelyakov 121
 
5748 leency 122
#include "include\settings.h"
5804 punk_joker 123
#include "include\progress_dialog.h"
4042 leency 124
#include "include\copy.h"
5435 leency 125
#include "include\gui.h"
3363 leency 126
#include "include\sorting.h"
4042 leency 127
#include "include\icons.h"
3363 leency 128
#include "include\left_panel.h"
4042 leency 129
#include "include\menu.h"
6278 leency 130
#include "include\delete.h"
4042 leency 131
#include "include\about.h"
5447 punk_joker 132
#include "include\properties.h"
6289 leency 133
#include "include\breadcrumbs.h"
3363 leency 134
 
135
void main()
136
{
7314 pavelyakov 137
	byte update = 0;
138
	dword files_count = 0;
139
	dword countPathFile = 0;
140
	dword countPathFile2 = 0;
7311 pavelyakov 141
	dword files_y = 0;
7313 pavelyakov 142
	dword countDisk = 0;
6289 leency 143
	dword id;
7313 pavelyakov 144
	dword devbuf;
5834 pavelyakov 145
	byte count_sl = 0;
5748 leency 146
	signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
6735 leency 147
	char stats;
4863 leency 148
	rand_n = random(40);
5651 pavelyakov 149
 
7313 pavelyakov 150
	devbuf = malloc(10000);
151
 
5626 leency 152
	load_dll(boxlib, #box_lib_init,0);
5991 leency 153
	load_dll(libini, #lib_init,1);
7054 leency 154
	load_dll(libio,  #libio_init,1);
155
	load_dll(libimg, #libimg_init,1);
5834 pavelyakov 156
 
5441 leency 157
	LoadIniSettings();
6034 leency 158
	SystemDiscs.Get();
4076 leency 159
	SetAppColors();
7041 leency 160
 
7054 leency 161
	Libimg_LoadImage(#icons16_default, "/sys/icons16.png");
162
	Libimg_LoadImage(#icons16_selected, "/sys/icons16.png");
7203 leency 163
	Libimg_ReplaceColor(icons16_selected.image, icons16_selected.w, icons16_selected.h, 0xffFFFfff, col_selec);
164
	Libimg_ReplaceColor(icons16_selected.image, icons16_selected.w, icons16_selected.h, 0xffCACBD6, MixColors(col_selec, 0, 200));
7054 leency 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
	{
7245 leency 177
		if (strlen(#param)>1) && (param[strlen(#param)-1]=='/') param[strlen(#param)-1]=NULL; //no "/" at 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(){
7310 pavelyakov 194
		switch(WaitEventTimeout(50))
5591 pavelyakov 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
 
7244 leency 316
				if (two_panels.checked) && (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
								{
7244 leency 423
									if (!two_panels.checked)
5723 leency 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:
7244 leency 481
								if (!two_panels.checked) break;
5738 leency 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
				}
7310 pavelyakov 541
			break;
542
			default:
7313 pavelyakov 543
 
7314 pavelyakov 544
				ReadDir(19, devbuf, "/"); // get disk
545
				IF(countDisk != EBX) // if different then
7311 pavelyakov 546
				{
7313 pavelyakov 547
					countDisk = EBX;
548
					FnProcess(5);
7311 pavelyakov 549
				}
7314 pavelyakov 550
				else // get current files
551
				{
552
					if(two_panels.checked)
553
					{
554
						// this add code update list files
555
						update = 0;
556
						//strcpy(#inactive_path,#path);
557
						ReadDir(19, devbuf, #inactive_path);
558
						IF(countPathFile != EBX) // if different then
559
						{
560
							countPathFile = EBX;
561
							update = 0xFF;
562
						}
563
 
564
						//strcpy(#active_path,#path);
565
						ReadDir(19, devbuf, #active_path);
566
						IF(countPathFile2 != EBX) // if different then
567
						{
568
							countPathFile2 = EBX;
569
							update = 0xFF;
570
						}
571
						IF(update) DrawFilePanels();
572
					}
573
					ELSE
574
					{
575
						ReadDir(19, devbuf, #path);
576
						IF(countPathFile != EBX) // if different then
577
						{
578
							countPathFile = EBX;
579
							Open_Dir(#path,WITH_REDRAW);
580
						}
581
					}
582
				}
5591 pavelyakov 583
		}
7310 pavelyakov 584
 
585
 
586
 
5591 pavelyakov 587
		if(cmd_free)
588
		{
5991 leency 589
			if(cmd_free==1)      menu_stak=free(menu_stak);
590
			else if(cmd_free==2) about_stak=free(about_stak);
591
			else if(cmd_free==3) properties_stak=free(properties_stak);
592
			else if(cmd_free==4) settings_stak=free(settings_stak);
593
			else if(cmd_free==5) copy_stak=free(copy_stak);
594
			else if(cmd_free==6) delete_stak=free(delete_stak);
5591 pavelyakov 595
			cmd_free = false;
5576 pavelyakov 596
		}
597
	}
3363 leency 598
}
599
 
6291 leency 600
void DrawFavButton(int x)
601
{
602
	_PutImage(x,10,20,22,#fav);
603
	DefineButton(x,11,20-2,22-2,61+BT_HIDE+BT_NOFRAME,0);
604
}
605
 
3444 leency 606
void draw_window()
607
{
7244 leency 608
	if (show_status_bar.checked) status_bar_h = STATUS_BAR_H; else status_bar_h = 0;
7278 leency 609
	DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,TITLE,0);
3444 leency 610
	GetProcessInfo(#Form, SelfInfo);
611
	if (Form.status_window>2) return;
5811 leency 612
	if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
613
	if (Form.width  < 480) { MoveSize(OLD,OLD,480,OLD); return; }
3444 leency 614
	GetProcessInfo(#Form, SelfInfo); //if win_size changed
6291 leency 615
	_PutImage(0,0,246,34,#toolbar);
6191 leency 616
	DrawBar(127, 8, 1, 25, col_graph);
617
	for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,NULL);
618
	for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,NULL);
6289 leency 619
	DrawBar(246,0, Form.cwidth - 246, 34, col_work);
6291 leency 620
	_PutImage(Form.cwidth-17,11,6,18,#dots);
621
	DefineButton(Form.cwidth-24,7,20,25,51+BT_HIDE+BT_NOFRAME,0); //dots
3434 leency 622
	//main rectangles
6564 leency 623
	DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42-status_bar_h,col_graph);
5698 leency 624
	DrawRectangle(0,39,Form.cwidth-1,Form.cheight - 40,col_palette[4]); //bg
5723 leency 625
	for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]);
5733 leency 626
	llist_copy(#files_active, #files);
5723 leency 627
	strcpy(#active_path, #path);
6564 leency 628
	DrawStatusBar();
6973 leency 629
	if (selected_count==0) Open_Dir(#path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001]
5723 leency 630
	DrawFilePanels();
631
	if (del_active) Del_Form();
632
	if (new_element_active) NewElement_Form(new_element_active, #new_element_name);
633
}
634
 
635
void DrawList()
636
{
5733 leency 637
	word sorting_arrow_x;
6678 leency 638
	DrawFlatButtonSmall(files.x, files.y-17,     files.w - 141,16,31,T_FILE);
639
	DrawFlatButtonSmall(files.x + files.w - 141, files.y-17,73,16,32,T_TYPE);
640
	DrawFlatButtonSmall(files.x + files.w -  68, files.y-17,68,16,33,T_SIZE);
641
	DrawFlatButtonSmall(files.x + files.w,       files.y-17,16,16, 0,"\x18");
642
	DrawFlatButtonSmall(files.x + files.w,files.y+files.h-16,16,16,0,"\x19");
5733 leency 643
	if (sort_num==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
644
	if (sort_num==2) sorting_arrow_x = files.x + files.w - 90;
645
	if (sort_num==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
6191 leency 646
	WriteText(sorting_arrow_x,files.y-12,0x80,col_graph,"\x19");
647
	DrawBar(files.x+files.w,files.y,1,files.h,col_graph);
7244 leency 648
	if (two_panels.checked) && (files.x<5) DrawBar(files.x+files.w+16,files.y,1,files.h,col_graph);
5723 leency 649
}
650
 
6404 punk_joker 651
void DrawStatusBar()
652
{
6572 leency 653
	char status_bar_str[80];
6570 leency 654
	int go_up_folder_exists=0;
7244 leency 655
	if (!show_status_bar.checked) return;
6604 leency 656
	if (files.count>0) && (strcmp(file_mas[0]*304+buf+72,"..")==0) go_up_folder_exists=1;
6783 leency 657
	DrawBar(1, Form.cheight - status_bar_h-1, Form.cwidth-2,  status_bar_h, system.color.work);
6570 leency 658
	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 659
	WriteText(6,Form.cheight - 13,0x80,system.color.work_text,#status_bar_str);
6404 punk_joker 660
}
661
 
5723 leency 662
void DrawFilePanels()
663
{
6034 leency 664
	int files_y;
7244 leency 665
	if (!two_panels.checked)
5698 leency 666
	{
5723 leency 667
		DrawDeviceAndActionsLeftPanel();
6564 leency 668
		files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h);
5719 leency 669
		DrawList();
5733 leency 670
		Open_Dir(#path,ONLY_SHOW);
5698 leency 671
	}
672
	else
673
	{
6158 leency 674
		SystemDiscs.Get();
5733 leency 675
		llist_copy(#files, #files_inactive);
676
		strcpy(#path, #inactive_path);
677
		col_selec = 0xCCCccc;
6034 leency 678
		SystemDiscs.Draw();
679
		files_y = files.y;
5733 leency 680
 
5719 leency 681
		if (active_panel==1)
682
		{
5761 leency 683
			llist_copy(#files, #files_inactive);
684
			strcpy(#path, #inactive_path);
685
			col_selec = 0xCCCccc;
6564 leency 686
			files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 687
			DrawList();
5733 leency 688
			Open_Dir(#path,WITH_REDRAW);
689
			llist_copy(#files, #files_active);
5719 leency 690
			strcpy(#path, #active_path);
5733 leency 691
			col_selec = 0x94AECE;
6564 leency 692
			files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 693
			DrawList();
5733 leency 694
			Open_Dir(#path,WITH_REDRAW);
5719 leency 695
		}
696
		if (active_panel==2)
697
		{
6564 leency 698
			files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 699
			DrawList();
5733 leency 700
			Open_Dir(#path,WITH_REDRAW);
701
			llist_copy(#files, #files_active);
5719 leency 702
			strcpy(#path, #active_path);
5733 leency 703
			col_selec = 0x94AECE;
6564 leency 704
			files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 705
			DrawList();
5733 leency 706
			Open_Dir(#path,WITH_REDRAW);
5719 leency 707
		}
5698 leency 708
	}
3363 leency 709
}
710
 
711
 
5694 leency 712
void List_ReDraw()
3363 leency 713
{
5719 leency 714
	int all_lines_h;
5825 leency 715
	static int old_cur_y, old_first;
3363 leency 716
 
5694 leency 717
	files.CheckDoesValuesOkey(); //prevent some shit
3363 leency 718
 
5694 leency 719
	if (list_full_redraw) || (old_first != files.first)
3363 leency 720
	{
5825 leency 721
		old_cur_y = files.cur_y;
5694 leency 722
		old_first = files.first;
723
		list_full_redraw = false;
724
		goto _ALL_LIST_REDRAW;
3363 leency 725
	}
5825 leency 726
	if (old_cur_y != files.cur_y)
3363 leency 727
	{
5825 leency 728
		if (old_cur_y-files.first
729
		Line_ReDraw(col_selec, files.cur_y-files.first);
730
		old_cur_y = files.cur_y;
5694 leency 731
		return;
3363 leency 732
	}
733
 
5694 leency 734
	_ALL_LIST_REDRAW:
3363 leency 735
 
5825 leency 736
	for (j=0; j
3434 leency 737
	//in the bottom
5825 leency 738
	all_lines_h = j * files.item_h;
5719 leency 739
	DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h,0xFFFFFF);
6949 leency 740
	DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h,col_list_line);
741
	DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h,col_list_line);
3434 leency 742
	Scroll();
3363 leency 743
}
744
 
3444 leency 745
 
5761 leency 746
void Line_ReDraw(dword bgcol, filenum){
3467 leency 747
	dword text_col=0,
5991 leency 748
		  ext1, attr,
749
		  file_offet,
750
		  file_name_off,
6290 leency 751
		  y=filenum*files.item_h+files.y,
7197 leency 752
		  icon_y = files.item_h-icon_size/2+1+y;
5991 leency 753
		  BDVK file;
6757 leency 754
		  char temp_path[sizeof(file_path)];
5996 leency 755
	char label_file_name[4096];
4859 leency 756
	if (filenum==-1) return;
7054 leency 757
	DrawBar(files.x,y,4,files.item_h,bgcol);
758
	DrawBar(files.x+20,y,files.w-20,files.item_h,bgcol);
7197 leency 759
	DrawBar(files.x+4,y,icon_size,icon_y-y,bgcol);
760
	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 761
 
4897 leency 762
	file_offet = file_mas[filenum+files.first]*304 + buf+32;
5487 leency 763
	attr = ESDWORD[file_offet];
4897 leency 764
	file.selected = ESBYTE[file_offet+7];
765
	file.sizelo   = ESDWORD[file_offet+32];
6987 leency 766
	file.sizehi   = ESDWORD[file_offet+36];
4897 leency 767
	file_name_off = file_offet+40;
3363 leency 768
 
5487 leency 769
	if (! TestBit(attr, 4) ) //file or folder?
3363 leency 770
	{
5698 leency 771
		ext1 = strrchr(file_name_off,'.') + file_name_off;
6278 leency 772
		if (ext1==file_name_off) ext1 = NULL; //if no extension then show nothing
6987 leency 773
		WriteText(
774
			7-strlen(ConvertSize64(file.sizelo, file.sizehi))*6+files.x+files.w - 58,
775
			files.text_y+y+1,
776
			files.font_type,
777
			0,
778
			ConvertSize64(file.sizelo, file.sizehi)
779
		);
6278 leency 780
		if (ext1) && (strlen(ext1)<9) WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, 0, ext1);
3363 leency 781
	}
782
	else
4846 leency 783
	{
7149 leency 784
		if (!strcmp(file_name_off,"..")) ext1=""; else {
6278 leency 785
			ext1="";
786
			WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, 0, ext1);
787
		}
4846 leency 788
	}
6757 leency 789
	sprintf(#temp_path,"%s/%s",#path,file_name_off);
7054 leency 790
	DrawIconByExtension(#temp_path, ext1, files.x+4, icon_y, bgcol);
4846 leency 791
 
5487 leency 792
	if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=0xA6A6B7; //system or hiden?
5761 leency 793
	if (bgcol!=0xFFFfff)
3363 leency 794
	{
5487 leency 795
		itdir = TestBit(attr, 4);
4897 leency 796
		strcpy(#file_name, file_name_off);
6635 leency 797
		if (!strcmp(#path,"/")) sprintf(#file_path,"%s%s",#path,file_name_off);
798
			else sprintf(#file_path,"%s/%s",#path,file_name_off);
3363 leency 799
		if (text_col==0xA6A6B7) text_col=0xFFFFFF;
800
	}
4897 leency 801
	if (file.selected) text_col=0xFF0000;
6806 leency 802
	if (kfont.size.pt==9) || (!kfont.font)
3434 leency 803
	{
5745 leency 804
		if (Form.width>=480)
805
		{
806
			FileShow.start_x = files.x + 23;
807
			FileShow.font_color = text_col;
808
			FileShow.area_size_x = files.w - 164;
809
			FileShow.text_pointer = file_name_off;
7004 leency 810
			FileShow.start_y = files.text_y + y - 3;
5745 leency 811
			PathShow_prepare stdcall(#FileShow);
812
			PathShow_draw stdcall(#FileShow);
813
		}
3434 leency 814
	}
5745 leency 815
	else
816
	{
5996 leency 817
		strcpy(#label_file_name, file_name_off);
6806 leency 818
		if (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w)
5996 leency 819
		{
6806 leency 820
			while (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w) {
5996 leency 821
				ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL;
822
			}
823
			strcpy(#label_file_name+strlen(#label_file_name)-2, "...");
824
		}
7197 leency 825
		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 826
	}
6949 leency 827
	DrawBar(files.x+files.w-141,y,1,files.item_h,col_list_line); //gray line 1
828
	DrawBar(files.x+files.w-68,y,1,files.item_h,col_list_line); //gray line 2
3363 leency 829
}
830
 
831
 
3444 leency 832
void Open_Dir(dword dir_path, redraw){
6406 punk_joker 833
	int errornum, maxcount, i;
3444 leency 834
	if (redraw!=ONLY_SHOW)
3363 leency 835
	{
6602 leency 836
		selected_count = 0;
3363 leency 837
		if (buf) free(buf);
3444 leency 838
		errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
839
		if (errornum)
3363 leency 840
		{
6021 leency 841
			history.add(#path);
3363 leency 842
			GoBack();
843
			Write_Error(errornum);
844
			return;
845
		}
3444 leency 846
		maxcount = sizeof(file_mas)/sizeof(dword)-1;
4225 punk_joker 847
		if (files.count>maxcount) files.count = maxcount;
5825 leency 848
		if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
3363 leency 849
	}
3444 leency 850
	if (files.count!=-1)
3363 leency 851
	{
7244 leency 852
		if(!_not_draw) if (show_breadcrumb.checked) DrawBreadCrumbs(); else DrawPathBar();
6021 leency 853
		history.add(#path);
6034 leency 854
		SystemDiscs.Draw();
5825 leency 855
		files.visible = files.h / files.item_h;
5591 pavelyakov 856
		if (files.count < files.visible) files.visible = files.count;
857
		if (redraw!=ONLY_SHOW) Sorting();
5694 leency 858
		list_full_redraw = true;
6564 leency 859
		if (redraw!=ONLY_OPEN)&&(!_not_draw) {DrawStatusBar(); List_ReDraw();}
6570 leency 860
		SetCurDir(dir_path);
3363 leency 861
	}
5694 leency 862
	if (files.count==-1) && (redraw!=ONLY_OPEN)
863
	{
864
		files.KeyHome();
6564 leency 865
		if(!_not_draw) { list_full_redraw=true; DrawStatusBar(); List_ReDraw(); }
5694 leency 866
	}
3363 leency 867
}
868
 
869
inline Sorting()
870
{
871
	dword k=0, l=1;
4897 leency 872
	dword file_off;
6604 leency 873
	if (!strcmp(#path,"/")) //do not sort root folder
3363 leency 874
	{
5591 pavelyakov 875
		for(k=1;k
6604 leency 876
		count_dir = k;
3363 leency 877
		return;
878
	}
5591 pavelyakov 879
	for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
3363 leency 880
	{
7244 leency 881
		if (!show_real_names.checked) strttl(file_off+40);
4897 leency 882
		if (TestBit(ESDWORD[file_off],4)) //directory?
3363 leency 883
		{
884
			file_mas[k]=j;
885
			k++;
886
		}
887
		else
888
		{
3434 leency 889
			file_mas[files.count-l]=j;
3363 leency 890
			l++;
891
		}
892
	}
6570 leency 893
	count_dir = k;
3434 leency 894
	//sorting: files first, then folders
3363 leency 895
	Sort_by_Name(0,k-1);
5591 pavelyakov 896
	if (sort_num==1) Sort_by_Name(k,files.count-1);
897
	if (sort_num==2) Sort_by_Type(k,files.count-1);
898
	if (sort_num==3) Sort_by_Size(k,files.count-1);
5581 leency 899
	//make ".." first item in list
5733 leency 900
	if (k>0) && (strncmp(file_mas[0]*304+buf+72,"..",2)!=0)
901
		for(k--; k>0; k--;) if (!strncmp(file_mas[k]*304+buf+72,"..",2)) {file_mas[k]>
3363 leency 902
}
903
 
904
 
905
void Del_Form()
906
{
5512 punk_joker 907
	byte f_count[128];
5581 leency 908
	int dform_x = files.w - 220 / 2 + files.x;
7004 leency 909
	if (selected_count==0) && (!strncmp(#file_name,"..",2)) return;
3991 leency 910
	else
911
	{
4002 leency 912
		if (!files.count) return;
6008 leency 913
		DrawEolitePopup(T_YES, T_NO);
5674 pavelyakov 914
		WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,system.color.work_text,T_DELETE_FILE);
6278 leency 915
		if (selected_count)
5512 punk_joker 916
		{
6278 leency 917
			sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,selected_count,DEL_MORE_FILES_2);
5674 pavelyakov 918
			WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,system.color.work_text,#f_count);
5512 punk_joker 919
		}
4002 leency 920
		else
921
		{
5591 pavelyakov 922
			if (strlen(#file_name)<28)
5512 punk_joker 923
			{
5674 pavelyakov 924
				WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,system.color.work_text,"?");
925
				WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,system.color.work_text,#file_name);
5512 punk_joker 926
			}
927
			else
928
			{
929
				WriteText(164+dform_x,190,0x80,0,"...?");
930
				ESI = 24;
931
				WriteText(dform_x+20,190,0,0,#file_name);
932
			}
6008 leency 933
		}
4002 leency 934
		del_active=1;
3991 leency 935
	}
3363 leency 936
}
937
 
5694 leency 938
void SelectFileByName(dword that_file)
3363 leency 939
{
5694 leency 940
	int ind;
941
	files.KeyHome();
5991 leency 942
	Open_Dir(#path,ONLY_OPEN);
7244 leency 943
	if (!show_real_names.checked) strttl(that_file);
5694 leency 944
	for (ind=files.count-1; ind>=0; ind--;) { if (!strcmp(file_mas[ind]*304+buf+72,that_file)) break; }
5825 leency 945
	files.cur_y = ind - 1;
5694 leency 946
	files.KeyDown();
6570 leency 947
	DrawStatusBar();
3363 leency 948
	List_ReDraw();
949
}
950
 
951
 
952
void Dir_Up()
953
{
6635 leency 954
	char old_folder_name[4096];
3363 leency 955
	i=strlen(#path)-1;
956
	if (i==0) return;
6635 leency 957
	//path[i]=0x00;
3363 leency 958
	i = strrchr(#path, '/');
6635 leency 959
	strcpy(#old_folder_name, #path+i);
960
	if (i>1) path[i-1]=NULL; else path[i]=NULL;
961
	SelectFileByName(#old_folder_name);
3363 leency 962
}
963
 
5444 leency 964
void Open(byte rez)
3434 leency 965
{
5443 punk_joker 966
	byte temp[4096];
5513 punk_joker 967
	selected_count = 0;
5443 punk_joker 968
	if (rez)
969
	{
5606 pavelyakov 970
		if (!strncmp(#file_name,"..",3)) return;
5443 punk_joker 971
		strcpy(#temp, #file_path);
6735 leency 972
		RunProgram(I_Path, #temp);
5443 punk_joker 973
		return;
974
	}
3444 leency 975
	if (!files.count) return;
3441 leency 976
	if (!itdir)
3434 leency 977
	{
5401 leency 978
		if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
3434 leency 979
	}
980
	else
981
	{
5606 pavelyakov 982
		if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
3434 leency 983
		strcpy(#path, #file_path);
5825 leency 984
		files.first=files.cur_y=0;
3444 leency 985
		Open_Dir(#path,WITH_REDRAW);
3434 leency 986
	}
987
}
3363 leency 988
 
3434 leency 989
inline fastcall void GoBack()
3363 leency 990
{
991
	char cur_folder[4096];
5974 leency 992
	strcpy(#cur_folder, #path);
6021 leency 993
	if (history.back()) {
994
		strcpy(#path, history.current());
5977 leency 995
		SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
996
	}
3363 leency 997
}
998
 
5397 punk_joker 999
void ShowOpenWithDialog()
1000
{
6930 leency 1001
	byte open_param[4097];
1002
	sprintf(#open_param,"~%s",#file_path);
1003
	RunProgram("/sys/@open", #open_param);
5397 punk_joker 1004
}
1005
 
5555 punk_joker 1006
void NewElement(byte newf)
1007
{
5557 punk_joker 1008
	BDVK element_info;
5581 leency 1009
	byte del_rezult, copy_rezult, info_result;
5555 punk_joker 1010
	if (newf)
1011
	{
6635 leency 1012
		sprintf(#temp,"%s/%s",#path,new_file_ed.text);
5581 leency 1013
		info_result = GetFileInfo(#temp, #element_info);
5571 punk_joker 1014
		switch(new_element_active)
5555 punk_joker 1015
		{
5581 leency 1016
			case CREATE_FILE:
1017
				if (info_result==5)
5557 punk_joker 1018
				{
7227 leency 1019
					CreateFile(0, 0, #temp);
5571 punk_joker 1020
					if (EAX)
1021
					{
6008 leency 1022
						if (EAX==5) notify(NOT_CREATE_FILE);
1023
						else Write_Error(EAX);
5571 punk_joker 1024
					}
5557 punk_joker 1025
				}
5571 punk_joker 1026
				else
5557 punk_joker 1027
				{
5620 leency 1028
					notify(FS_ITEM_ALREADY_EXISTS);
5557 punk_joker 1029
				}
5581 leency 1030
				break;
1031
			case CREATE_FOLDER:
1032
				if (info_result==5)
5571 punk_joker 1033
				{
1034
					CreateDir(#temp);
1035
					if (EAX)
1036
					{
6008 leency 1037
						if (EAX==5) notify(NOT_CREATE_FOLDER);
1038
						else Write_Error(EAX);
5571 punk_joker 1039
					}
1040
				}
1041
				else
1042
				{
5620 leency 1043
					notify(FS_ITEM_ALREADY_EXISTS);
5571 punk_joker 1044
				}
5581 leency 1045
				break;
1046
			case RENAME_ITEM:
1047
				if (info_result==5)
5571 punk_joker 1048
				{
1049
					if (itdir)
1050
					{
6038 leency 1051
						//rename only empty folders
5571 punk_joker 1052
						if (del_rezult = DeleteFile(#file_path))
1053
						{
1054
							Write_Error(del_rezult);
1055
							return;
1056
						}
1057
						if (CreateDir(#temp)) CreateDir(#file_path);
1058
						Open_Dir(#path,WITH_REDRAW);
5694 leency 1059
						SelectFileByName(new_file_ed.text);
5571 punk_joker 1060
					}
1061
					else
1062
					{
1063
						if (copy_rezult = CopyFile(#file_path,#temp))
1064
						{
1065
							Write_Error(copy_rezult);
1066
						}
1067
						else
1068
						{
6038 leency 1069
							DeleteFile(#file_path);
5694 leency 1070
							SelectFileByName(new_file_ed.text);
5571 punk_joker 1071
						}
1072
					}
1073
				}
1074
				else
1075
				{
5620 leency 1076
					notify(FS_ITEM_ALREADY_EXISTS);
5571 punk_joker 1077
				}
5555 punk_joker 1078
		}
5557 punk_joker 1079
		new_element_active = 0;
1080
		Open_Dir(#path,WITH_REDRAW);
5694 leency 1081
		SelectFileByName(new_file_ed.text);
5555 punk_joker 1082
	}
1083
	new_element_active = 0;
5557 punk_joker 1084
	Open_Dir(#path,WITH_REDRAW);
5555 punk_joker 1085
}
1086
 
5571 punk_joker 1087
void NewElement_Form(byte crt, dword strng)
5555 punk_joker 1088
{
1089
	int dform_x=files.w-220/2+files.x;
5557 punk_joker 1090
	if (!new_element_active)
5555 punk_joker 1091
	{
5557 punk_joker 1092
		new_element_active = crt;
5571 punk_joker 1093
		strcpy(#new_element_name, strng);
1094
		new_file_ed.size = new_file_ed.pos = strlen(strng);
5555 punk_joker 1095
	}
6008 leency 1096
	if (new_element_active==3) DrawEolitePopup(T_RENAME, T_CANCEL);
1097
	else DrawEolitePopup(T_CREATE, T_CANCEL);
6678 leency 1098
	new_file_ed.left = dform_x+10;
6278 leency 1099
	DrawEditBox(#new_file_ed);
5555 punk_joker 1100
}
1101
 
5576 pavelyakov 1102
void FnProcess(byte N)
3434 leency 1103
{
1104
	switch(N)
1105
	{
1106
		case 1:
4395 punk_joker 1107
			if (!active_about)
1108
			{
5576 pavelyakov 1109
				about_stak = malloc(4096);
1110
				about_window = CreateThread(#about_dialog,about_stak+4092);
4395 punk_joker 1111
				break;
1112
			}
1113
			else
1114
			{
1115
				ActivateWindow(GetProcessSlot(about_window));
1116
			}
3434 leency 1117
			break;
1118
		case 2:
1119
			if (!files.count) break;
5581 leency 1120
			NewElement_Form(RENAME_ITEM, #file_name);
3434 leency 1121
			break;
1122
		case 3:
5591 pavelyakov 1123
			if (!itdir) RunProgram("/sys/tinypad", #file_path);
3434 leency 1124
			break;
1125
		case 4:
5591 pavelyakov 1126
			if (!itdir) RunProgram("/sys/develop/heed", #file_path);
3434 leency 1127
			break;
3440 leency 1128
		case 5: //refresh cur dir & devs
7244 leency 1129
			if (two_panels.checked)
5719 leency 1130
			{
5723 leency 1131
				DrawFilePanels();
5719 leency 1132
			}
1133
			else
1134
			{
1135
				Tip(56, T_DEVICES, 55, "-");
1136
				Open_Dir(#path,WITH_REDRAW);
1137
				pause(10);
6034 leency 1138
				SystemDiscs.Get();
5719 leency 1139
				Open_Dir(#path,WITH_REDRAW);
5723 leency 1140
				DrawDeviceAndActionsLeftPanel();
5719 leency 1141
			}
3434 leency 1142
			break;
1143
		case 6:
5581 leency 1144
			NewElement_Form(CREATE_FOLDER, T_NEW_FOLDER);
3434 leency 1145
			break;
1146
		case 7:
5581 leency 1147
			NewElement_Form(CREATE_FILE, T_NEW_FILE);
3434 leency 1148
			break;
5447 punk_joker 1149
		case 8:
5576 pavelyakov 1150
			properties_stak = malloc(8096);
1151
			CreateThread(#properties_dialog, properties_stak+8092);
5447 punk_joker 1152
			break;
3434 leency 1153
		case 10: //F10
5753 leency 1154
			if (!active_settings)
5416 punk_joker 1155
			{
5576 pavelyakov 1156
				settings_stak = malloc(4096);
1157
				settings_window = CreateThread(#settings_dialog, settings_stak+4092);
5416 punk_joker 1158
				break;
1159
			}
1160
			else
1161
			{
1162
				ActivateWindow(GetProcessSlot(settings_window));
1163
			}
3434 leency 1164
			break;
1165
	}
1166
}
1167
 
5738 leency 1168
void ChangeActivePanel()
1169
{
1170
	llist_copy(#files_active, #files_inactive);
1171
	llist_copy(#files_inactive, #files);
1172
	strcpy(#active_path, #inactive_path);
1173
	strcpy(#inactive_path, #path);
1174
	DrawFilePanels();
1175
}
1176
 
3434 leency 1177
 
3363 leency 1178
stop: