Subversion Repositories Kolibri OS

Rev

Rev 7447 | Rev 7490 | 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/copyf.h"
5834 pavelyakov 22
 
7054 leency 23
#include "../lib/obj/libini.h"
24
#include "../lib/obj/box_lib.h"
7230 leency 25
#include "../lib/obj/libimg.h"
7054 leency 26
 
27
#include "../lib/patterns/history.h"
28
 
7462 leency 29
#include "imgs/images.h"
3363 leency 30
 
6278 leency 31
//Button IDs
32
enum {
7422 leency 33
	PATH_BTN = 10,
6278 leency 34
	POPUP_BTN1 = 201,
6289 leency 35
	POPUP_BTN2 = 202,
36
	BREADCRUMB_ID = 300
6278 leency 37
};
3444 leency 38
 
6278 leency 39
//NewElement options
40
enum {
41
	CREATE_FILE=1,
42
	CREATE_FOLDER,
43
	RENAME_ITEM
44
};
45
 
46
//OpenDir options
47
enum {
48
	ONLY_SHOW,
49
	WITH_REDRAW,
50
	ONLY_OPEN
51
};
52
 
7462 leency 53
dword col_selec, col_lpanel, col_work, col_graph, col_list_line=0xDDD7CF;
3363 leency 54
 
3434 leency 55
int toolbar_buttons_x[7]={9,46,85,134,167,203};
3363 leency 56
 
4136 punk_joker 57
byte active_about=0;
4070 punk_joker 58
word about_window;
5416 punk_joker 59
word settings_window;
5753 leency 60
byte active_settings=0;
5606 pavelyakov 61
dword _not_draw = false;
4136 punk_joker 62
byte menu_call_mouse=0;
6403 punk_joker 63
byte exif_load=0;
4136 punk_joker 64
 
5733 leency 65
byte del_active=0;
66
byte new_element_active=0;
5698 leency 67
 
5733 leency 68
llist files, files_active, files_inactive;
3434 leency 69
 
5694 leency 70
byte list_full_redraw;
71
 
5698 leency 72
dword buf;
73
dword file_mas[6898];
74
int selected_count;
6406 punk_joker 75
int count_dir;
5698 leency 76
 
3434 leency 77
byte
3363 leency 78
	path[4096],
79
	file_path[4096],
3404 leency 80
	file_name[256],
5555 punk_joker 81
	new_element_name[256],
5698 leency 82
	temp[4096],
3441 leency 83
	itdir;
3363 leency 84
 
5719 leency 85
char active_path[4096], inactive_path[4096];
5698 leency 86
 
7202 leency 87
dword eolite_ini_path[4096];
88
_ini ini;
5441 leency 89
 
5698 leency 90
char scroll_used=false;
5695 leency 91
 
5804 punk_joker 92
dword menu_stak,about_stak,properties_stak,settings_stak,copy_stak,delete_stak;
5608 leency 93
 
3363 leency 94
proc_info Form;
7252 leency 95
int sc_slider_h;
4028 leency 96
int action_buf;
4863 leency 97
int rand_n;
3363 leency 98
 
6291 leency 99
char sort_num=2;
7244 leency 100
int active_panel=1;
5549 punk_joker 101
 
7054 leency 102
libimg_image icons16_default;
103
libimg_image icons16_selected;
104
 
7242 leency 105
libimg_image icons32_default;
106
libimg_image icons32_selected;
7197 leency 107
 
6564 leency 108
#define STATUS_BAR_H 16;
109
int status_bar_h = 0;
110
 
7197 leency 111
int icon_size = 16;
112
 
7252 leency 113
edit_box new_file_ed = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x10000000,
114
	248,#new_element_name,0,100000000000010b,6,0};
7004 leency 115
PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
5694 leency 116
byte cmd_free=0;
5698 leency 117
#include "include\translations.h"
5834 pavelyakov 118
 
7462 leency 119
#include "include\gui.h"
5748 leency 120
#include "include\settings.h"
5804 punk_joker 121
#include "include\progress_dialog.h"
4042 leency 122
#include "include\copy.h"
3363 leency 123
#include "include\sorting.h"
4042 leency 124
#include "include\icons.h"
3363 leency 125
#include "include\left_panel.h"
4042 leency 126
#include "include\menu.h"
6278 leency 127
#include "include\delete.h"
4042 leency 128
#include "include\about.h"
5447 punk_joker 129
#include "include\properties.h"
6289 leency 130
#include "include\breadcrumbs.h"
3363 leency 131
 
132
void main()
133
{
6289 leency 134
	dword id;
5834 pavelyakov 135
	byte count_sl = 0;
5748 leency 136
	signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
6735 leency 137
	char stats;
4863 leency 138
	rand_n = random(40);
5651 pavelyakov 139
 
5626 leency 140
	load_dll(boxlib, #box_lib_init,0);
5991 leency 141
	load_dll(libini, #lib_init,1);
7054 leency 142
	load_dll(libio,  #libio_init,1);
143
	load_dll(libimg, #libimg_init,1);
5834 pavelyakov 144
 
7375 leency 145
	SetAppColors();
5441 leency 146
	LoadIniSettings();
6034 leency 147
	SystemDiscs.Get();
7041 leency 148
 
7054 leency 149
	Libimg_LoadImage(#icons16_default, "/sys/icons16.png");
150
	Libimg_LoadImage(#icons16_selected, "/sys/icons16.png");
7203 leency 151
	Libimg_ReplaceColor(icons16_selected.image, icons16_selected.w, icons16_selected.h, 0xffFFFfff, col_selec);
152
	Libimg_ReplaceColor(icons16_selected.image, icons16_selected.w, icons16_selected.h, 0xffCACBD6, MixColors(col_selec, 0, 200));
7054 leency 153
 
7041 leency 154
	//-p just show file/folder properties dialog
155
	if (param) && (param[0]=='-') && (param[1]=='p')
156
	{
157
		strcpy(#file_path, #param + 3);
158
		strcpy(#file_name, #param + strrchr(#param, '/'));
159
		properties_dialog();
160
		ExitProcess();
161
	}
162
 
7422 leency 163
	ESBYTE[0] = NULL;
164
 
3363 leency 165
	if (param)
166
	{
7245 leency 167
		if (strlen(#param)>1) && (param[strlen(#param)-1]=='/') param[strlen(#param)-1]=NULL; //no "/" at the end
6930 leency 168
 
169
		if (dir_exists(#param)==true)
170
		{
171
			strcpy(#path, #param);
172
		}
173
		else
174
		{
175
			notify(T_NOTIFY_APP_PARAM_WRONG);
176
		}
7041 leency 177
	}
5833 pavelyakov 178
 
5733 leency 179
	Open_Dir(#path,ONLY_OPEN);
5719 leency 180
	strcpy(#inactive_path, #path);
5733 leency 181
	llist_copy(#files_inactive, #files);
7051 leency 182
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
5591 pavelyakov 183
	loop(){
7310 pavelyakov 184
		switch(WaitEventTimeout(50))
5591 pavelyakov 185
		{
186
			case evMouse:
7051 leency 187
				if (del_active) || (Form.status_window>2) break;
188
				if (new_element_active)
5591 pavelyakov 189
				{
190
					edit_box_mouse stdcall(#new_file_ed);
191
					break;
192
				}
5549 punk_joker 193
 
5640 pavelyakov 194
				mouse.get();
7422 leency 195
 
5640 pavelyakov 196
				if (!mouse.mkm) && (stats>0) stats = 0;
5657 pavelyakov 197
				if (mouse.mkm) && (!stats)
5549 punk_joker 198
				{
5640 pavelyakov 199
					x_old = mouse.x;
200
					y_old = mouse.y;
5591 pavelyakov 201
					stats = 1;
202
				}
5640 pavelyakov 203
				if (mouse.mkm) && (stats==1)
5591 pavelyakov 204
				{
5640 pavelyakov 205
					dif_x = mouse.x-x_old;
206
					dif_y = mouse.y-y_old;
5591 pavelyakov 207
					adif_x = fabs(dif_x);
208
					adif_y = fabs(dif_y);
209
 
210
					if (adif_x>adif_y)
5549 punk_joker 211
					{
5591 pavelyakov 212
						if (dif_x > 150)
213
						{
6021 leency 214
							if (history.forward())
5591 pavelyakov 215
								{
6021 leency 216
									strcpy(#path, history.current());
5694 leency 217
									files.KeyHome();
5591 pavelyakov 218
									Open_Dir(#path,WITH_REDRAW);
219
								}
220
							stats = 0;
221
						}
222
						if (dif_x < -150)
223
						{
224
							GoBack();
225
							stats = 0;
226
						}
5549 punk_joker 227
					}
5591 pavelyakov 228
					else
5549 punk_joker 229
					{
5591 pavelyakov 230
						if (dif_y < -100)
231
						{
232
							Dir_Up();
233
							stats = 0;
234
						}
5549 punk_joker 235
					}
5591 pavelyakov 236
				}
6191 leency 237
				if (files.MouseOver(mouse.x, mouse.y))
5549 punk_joker 238
				{
6191 leency 239
					//select file
6278 leency 240
					if (mouse.key&MOUSE_LEFT) && (mouse.up)
5575 pavelyakov 241
					{
7104 leency 242
						if (files.ProcessMouse(mouse.x, mouse.y)) List_ReDraw(); else {
243
							if (mouse.y - files.y / files.item_h + files.first == files.cur_y) Open(0);
244
						}
6191 leency 245
					}
246
					//file menu
6278 leency 247
					if (mouse.key&MOUSE_RIGHT)
6191 leency 248
					{
5591 pavelyakov 249
						menu_call_mouse = 1;
6278 leency 250
						if (files.ProcessMouse(mouse.x, mouse.y)) List_ReDraw();
6973 leency 251
						if (getElementSelectedFlag(files.cur_y) == false) selected_count = 0; //on redraw selection would be flashed, see [L001]
6278 leency 252
						menu_stak = malloc(4096);
253
						CreateThread(#FileMenu,menu_stak+4092);
5591 pavelyakov 254
						break;
5575 pavelyakov 255
					}
256
				}
5591 pavelyakov 257
 
5640 pavelyakov 258
				if (mouse.vert)
5575 pavelyakov 259
				{
5640 pavelyakov 260
					if (files.MouseScroll(mouse.vert)) List_ReDraw();
5591 pavelyakov 261
					break;
262
				}
263
 
5723 leency 264
				if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y-17) && (mouse.y
5591 pavelyakov 265
				{
7462 leency 266
					if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,system.color.work_dark,system.color.work_light);
267
					WHILE (mouse.lkm) && (files.first>0)
5575 pavelyakov 268
					{
5591 pavelyakov 269
						pause(8);
270
						files.first--;
271
						List_ReDraw();
5640 pavelyakov 272
						mouse.get();
5575 pavelyakov 273
					}
7462 leency 274
					DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,system.color.work_light,system.color.work_dark);
5575 pavelyakov 275
				}
3363 leency 276
 
5723 leency 277
				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 278
				{
7462 leency 279
					if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,system.color.work_dark,system.color.work_light);
280
					while (mouse.lkm) && (files.first
5591 pavelyakov 281
					{
282
						pause(8);
283
						files.first++;
284
						List_ReDraw();
5640 pavelyakov 285
						mouse.get();
5591 pavelyakov 286
					}
7462 leency 287
					DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,system.color.work_light,system.color.work_dark);
3363 leency 288
				}
289
 
5591 pavelyakov 290
				//Scrooll
5723 leency 291
				if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+18) && (mouse.y>files.y) && (mouse.y
7462 leency 292
				if (scroll_used) && (mouse.up) { scroll_used=false; Scroll(); }
5591 pavelyakov 293
 
294
				if (scroll_used)
3363 leency 295
				{
5640 pavelyakov 296
					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 297
					id = files.first;
7422 leency 298
					files.first = -sc_slider_h / 2 + mouse.y -files.y * files.count;
5743 leency 299
					files.first /= files.h - 18;
5591 pavelyakov 300
					if (files.visible+files.first>files.count) files.first=files.count-files.visible;
5743 leency 301
					if (files.first<0) files.first=0;
5591 pavelyakov 302
					if (id!=files.first) List_ReDraw();
5719 leency 303
					break;
3363 leency 304
				}
5719 leency 305
 
7244 leency 306
				if (two_panels.checked) && (mouse.y > files.y) && (mouse.down) {
5719 leency 307
					if (mouse.x
308
					{
309
						if (active_panel!=1)
310
						{
311
							active_panel = 1;
5738 leency 312
							ChangeActivePanel();
5719 leency 313
						}
314
					}
315
					else
316
					{
317
						if (active_panel!=2)
318
						{
319
							active_panel = 2;
5738 leency 320
							ChangeActivePanel();
5719 leency 321
						}
322
					}
323
				}
5591 pavelyakov 324
				break;
325
	//Button pressed-----------------------------------------------------------------------------
326
			case evButton:
7398 leency 327
				id=GetButtonID();
328
 
329
				if (new_element_active) || (del_active) {
330
					if(POPUP_BTN1==id) || (POPUP_BTN2==id) {
331
						if (del_active) Del_File(id-POPUP_BTN2);
332
						if (new_element_active) NewElement(id-POPUP_BTN2);
333
						DeleteButton(POPUP_BTN1);
334
						DeleteButton(POPUP_BTN2);
335
					}
336
					break;
337
				}
338
 
5591 pavelyakov 339
				switch(id)
340
				{
7054 leency 341
					case CLOSE_BTN:
6278 leency 342
							KillProcess(about_window);
343
							SaveIniSettings();
344
							ExitProcess();
7422 leency 345
					case PATH_BTN:
346
							notify(COPY_PATH_STR);
347
							Clipboard__CopyText(#path);
348
							break;
5591 pavelyakov 349
					case 21: //Back
350
							GoBack();
351
							break;
352
					case 22: //Forward
6021 leency 353
							if (history.forward())
5591 pavelyakov 354
							{
6021 leency 355
								strcpy(#path, history.current());
5694 leency 356
								files.KeyHome();
5591 pavelyakov 357
								Open_Dir(#path,WITH_REDRAW);
358
							}
359
							break;
5608 leency 360
					case 23:
3363 leency 361
							Dir_Up();
362
							break;
5608 leency 363
					case 24:
3444 leency 364
							Copy(#file_path, CUT);
365
							break;
5608 leency 366
					case 25:
3444 leency 367
							Copy(#file_path, NOCUT);
3363 leency 368
							break;
5608 leency 369
					case 26:
370
							Paste();
3363 leency 371
							break;
5733 leency 372
					case 31...33: //sorting
373
							sort_num = id - 30;
374
							DrawList();
5591 pavelyakov 375
							Open_Dir(#path,WITH_REDRAW);
5512 punk_joker 376
							break;
5591 pavelyakov 377
					case 50...60: //Actions
378
							FnProcess(id-50);
5512 punk_joker 379
							break;
7386 pavelyakov 380
					case 61: // Set path as default
7462 leency 381
							SetDefaultPath(#path);
7386 pavelyakov 382
							break;
5591 pavelyakov 383
					case 100...120:
6034 leency 384
						SystemDiscs.Click(id-100);
5698 leency 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;
7398 leency 397
 
398
				if (new_element_active) || (del_active)
5591 pavelyakov 399
				{
7398 leency 400
					if (del_active)
401
					{
402
						if (key_scancode == SCAN_CODE_ENTER) Del_File(true);
403
						if (key_scancode == SCAN_CODE_ESC) Del_File(false);
404
					}
405
					if (new_element_active)
406
					{
407
						if (key_scancode == SCAN_CODE_ENTER) NewElement(true);
408
						if (key_scancode == SCAN_CODE_ESC) NewElement(false);
409
						EAX = key_editbox;
410
						edit_box_key stdcall (#new_file_ed);
411
					}
5591 pavelyakov 412
					break;
413
				}
7398 leency 414
 
5706 leency 415
				if (files.ProcessKey(key_scancode))
5694 leency 416
				{
417
					List_ReDraw();
418
					break;
419
				}
5698 leency 420
 
5795 leency 421
				if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
5591 pavelyakov 422
				{
5706 leency 423
					switch(key_scancode)
5697 punk_joker 424
					{
5702 punk_joker 425
						case 059...068:
5706 leency 426
								key_scancode -= 59;
6034 leency 427
								if (key_scancode < SystemDiscs.list.count)
5702 punk_joker 428
								{
7244 leency 429
									if (!two_panels.checked)
5723 leency 430
									{
431
										DrawRectangle(17,key_scancode*16+74,159,16, 0); //display click
432
										pause(7);
433
									}
6034 leency 434
									SystemDiscs.Click(key_scancode);
5702 punk_joker 435
								}
436
								break;
5697 punk_joker 437
						case 45:  //Ctrl+X
438
								Copy(#file_path, CUT);
439
								break;
440
						case 46:  //Ctrl+C
441
								Copy(#file_path, NOCUT);
442
								break;
443
						case 47:  //Ctrl+V
444
								Paste();
445
								break;
446
						case 032: //Ctrl+D - set as bg
5803 leency 447
								strlcpy(#temp, "\\S__",4);
5591 pavelyakov 448
								strcat(#temp, #file_path);
449
								RunProgram("/sys/media/kiv", #temp);
450
								break;
5697 punk_joker 451
						case 049: //Ctrl+N - create new window
5591 pavelyakov 452
								if (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD);
6735 leency 453
								RunProgram(I_Path, #path);
5591 pavelyakov 454
								break;
6157 punk_joker 455
						case 050: //Ctrl+M
456
								Open_Dir(#inactive_path,WITH_REDRAW);
457
								break;
6278 leency 458
						case SCAN_CODE_ENTER: //Ctrl+Enter
5702 punk_joker 459
								if (!itdir) ShowOpenWithDialog();
460
								else Open(1);
461
								break;
5697 punk_joker 462
						case 030: //Ctrl+A - select all files
7422 leency 463
								EventSelectAllFiles(true);
5591 pavelyakov 464
								break;
5697 punk_joker 465
						case 022: //Ctrl+U - unselect all files
5591 pavelyakov 466
								selected_count = 0;
7422 leency 467
								EventSelectAllFiles(false);
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:
7244 leency 483
								if (!two_panels.checked) break;
5738 leency 484
								if (active_panel==1) active_panel=2; else active_panel=1;
485
								ChangeActivePanel();
7422 leency 486
								DrawFilePanels();
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:
7422 leency 507
								EventSelectFileByKeyPress();
5591 pavelyakov 508
				}
3363 leency 509
			break;
5698 leency 510
			case evIPC:
5591 pavelyakov 511
			case evReDraw:
512
				draw_window();
513
				if (action_buf)
514
				{
5804 punk_joker 515
					if (action_buf==OPERATION_END)
5698 leency 516
					{
517
						FnProcess(5);
5991 leency 518
						if (copy_stak) SelectFileByName(#copy_to+strrchr(#copy_to,'/'));
5698 leency 519
					}
520
					if (action_buf==100) Open(0);
521
					if (action_buf==201) ShowOpenWithDialog();
522
					if (action_buf==202) FnProcess(3); //F3
523
					if (action_buf==203) FnProcess(4); //F4
524
					if (action_buf==104) Copy(#file_path, NOCUT);
525
					if (action_buf==105) Copy(#file_path, CUT);
526
					if (action_buf==106) Paste();
527
					if (action_buf==207) FnProcess(2);
528
					if (action_buf==108) Del_Form();
529
					if (action_buf==109) FnProcess(5);
530
					if (action_buf==110) FnProcess(8);
5591 pavelyakov 531
					action_buf=0;
532
				}
7310 pavelyakov 533
			break;
534
			default:
7422 leency 535
				if (Form.status_window>2) break;
536
				EventRefreshDisksAndFolders();
5591 pavelyakov 537
		}
7310 pavelyakov 538
 
5591 pavelyakov 539
		if(cmd_free)
540
		{
5991 leency 541
			if(cmd_free==1)      menu_stak=free(menu_stak);
542
			else if(cmd_free==2) about_stak=free(about_stak);
543
			else if(cmd_free==3) properties_stak=free(properties_stak);
544
			else if(cmd_free==4) settings_stak=free(settings_stak);
545
			else if(cmd_free==5) copy_stak=free(copy_stak);
546
			else if(cmd_free==6) delete_stak=free(delete_stak);
5591 pavelyakov 547
			cmd_free = false;
5576 pavelyakov 548
		}
549
	}
3363 leency 550
}
551
 
3444 leency 552
void draw_window()
553
{
7422 leency 554
	int i;
7244 leency 555
	if (show_status_bar.checked) status_bar_h = STATUS_BAR_H; else status_bar_h = 0;
7278 leency 556
	DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,TITLE,0);
3444 leency 557
	GetProcessInfo(#Form, SelfInfo);
558
	if (Form.status_window>2) return;
5811 leency 559
	if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
560
	if (Form.width  < 480) { MoveSize(OLD,OLD,480,OLD); return; }
3444 leency 561
	GetProcessInfo(#Form, SelfInfo); //if win_size changed
7462 leency 562
	ESDWORD[#toolbar_pal] = col_work;
563
	ESDWORD[#toolbar_pal+4] = MixColors(0, col_work, 35);
564
	PutPaletteImage(#toolbar, 246, 34, 0, 0, 8, #toolbar_pal);
6191 leency 565
	DrawBar(127, 8, 1, 25, col_graph);
7422 leency 566
	for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,21+i);
567
	for (i=3; i<6; i++) DefineHiddenButton(toolbar_buttons_x[i],  5,31,  29,  21+i);
6289 leency 568
	DrawBar(246,0, Form.cwidth - 246, 34, col_work);
7462 leency 569
	DrawDot(Form.cwidth-17,12);
570
	DrawDot(Form.cwidth-17,12+6);
571
	DrawDot(Form.cwidth-17,12+12);
7422 leency 572
	DefineHiddenButton(Form.cwidth-24,7,20,25,51+BT_NOFRAME); //dots
3434 leency 573
	//main rectangles
6564 leency 574
	DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42-status_bar_h,col_graph);
7462 leency 575
	DrawRectangle(0,39,Form.cwidth-1,-show_status_bar.checked*status_bar_h + Form.cheight - 40,col_work_gradient[4]); //bg
576
	for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_work_gradient[11-i]);
5733 leency 577
	llist_copy(#files_active, #files);
5723 leency 578
	strcpy(#active_path, #path);
6564 leency 579
	DrawStatusBar();
6973 leency 580
	if (selected_count==0) Open_Dir(#path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001]
5723 leency 581
	DrawFilePanels();
582
}
583
 
584
void DrawList()
585
{
5733 leency 586
	word sorting_arrow_x;
6678 leency 587
	DrawFlatButtonSmall(files.x, files.y-17,     files.w - 141,16,31,T_FILE);
588
	DrawFlatButtonSmall(files.x + files.w - 141, files.y-17,73,16,32,T_TYPE);
589
	DrawFlatButtonSmall(files.x + files.w -  68, files.y-17,68,16,33,T_SIZE);
590
	DrawFlatButtonSmall(files.x + files.w,       files.y-17,16,16, 0,"\x18");
591
	DrawFlatButtonSmall(files.x + files.w,files.y+files.h-16,16,16,0,"\x19");
5733 leency 592
	if (sort_num==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
593
	if (sort_num==2) sorting_arrow_x = files.x + files.w - 90;
594
	if (sort_num==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
7462 leency 595
	WriteText(sorting_arrow_x,files.y-12,0x80, system.color.work_text,"\x19");
6191 leency 596
	DrawBar(files.x+files.w,files.y,1,files.h,col_graph);
7244 leency 597
	if (two_panels.checked) && (files.x<5) DrawBar(files.x+files.w+16,files.y,1,files.h,col_graph);
5723 leency 598
}
599
 
6404 punk_joker 600
void DrawStatusBar()
601
{
6572 leency 602
	char status_bar_str[80];
6570 leency 603
	int go_up_folder_exists=0;
7244 leency 604
	if (!show_status_bar.checked) return;
6604 leency 605
	if (files.count>0) && (strcmp(file_mas[0]*304+buf+72,"..")==0) go_up_folder_exists=1;
7462 leency 606
	DrawBar(0, Form.cheight - status_bar_h, Form.cwidth,  status_bar_h, system.color.work);
6570 leency 607
	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 608
	WriteText(6,Form.cheight - 13,0x80,system.color.work_text,#status_bar_str);
6404 punk_joker 609
}
610
 
5723 leency 611
void DrawFilePanels()
612
{
6034 leency 613
	int files_y;
7244 leency 614
	if (!two_panels.checked)
5698 leency 615
	{
5723 leency 616
		DrawDeviceAndActionsLeftPanel();
6564 leency 617
		files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h);
5719 leency 618
		DrawList();
5733 leency 619
		Open_Dir(#path,ONLY_SHOW);
5698 leency 620
	}
621
	else
622
	{
6158 leency 623
		SystemDiscs.Get();
5733 leency 624
		llist_copy(#files, #files_inactive);
625
		strcpy(#path, #inactive_path);
626
		col_selec = 0xCCCccc;
6034 leency 627
		SystemDiscs.Draw();
628
		files_y = files.y;
5733 leency 629
 
5719 leency 630
		if (active_panel==1)
631
		{
5761 leency 632
			llist_copy(#files, #files_inactive);
633
			strcpy(#path, #inactive_path);
634
			col_selec = 0xCCCccc;
6564 leency 635
			files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 636
			DrawList();
5733 leency 637
			Open_Dir(#path,WITH_REDRAW);
638
			llist_copy(#files, #files_active);
5719 leency 639
			strcpy(#path, #active_path);
5733 leency 640
			col_selec = 0x94AECE;
6564 leency 641
			files.SetSizes(2, files_y, Form.cwidth/2-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);
5719 leency 644
		}
645
		if (active_panel==2)
646
		{
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);
650
			llist_copy(#files, #files_active);
5719 leency 651
			strcpy(#path, #active_path);
5733 leency 652
			col_selec = 0x94AECE;
6564 leency 653
			files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
5719 leency 654
			DrawList();
5733 leency 655
			Open_Dir(#path,WITH_REDRAW);
5719 leency 656
		}
5698 leency 657
	}
3363 leency 658
}
659
 
660
 
5694 leency 661
void List_ReDraw()
3363 leency 662
{
5719 leency 663
	int all_lines_h;
7422 leency 664
	dword j;
5825 leency 665
	static int old_cur_y, old_first;
3363 leency 666
 
5694 leency 667
	files.CheckDoesValuesOkey(); //prevent some shit
3363 leency 668
 
5694 leency 669
	if (list_full_redraw) || (old_first != files.first)
3363 leency 670
	{
5825 leency 671
		old_cur_y = files.cur_y;
5694 leency 672
		old_first = files.first;
673
		list_full_redraw = false;
674
		goto _ALL_LIST_REDRAW;
3363 leency 675
	}
5825 leency 676
	if (old_cur_y != files.cur_y)
3363 leency 677
	{
5825 leency 678
		if (old_cur_y-files.first
679
		Line_ReDraw(col_selec, files.cur_y-files.first);
680
		old_cur_y = files.cur_y;
5694 leency 681
		return;
3363 leency 682
	}
683
 
5694 leency 684
	_ALL_LIST_REDRAW:
3363 leency 685
 
5825 leency 686
	for (j=0; j
3434 leency 687
	//in the bottom
5825 leency 688
	all_lines_h = j * files.item_h;
5719 leency 689
	DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h,0xFFFFFF);
6949 leency 690
	DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h,col_list_line);
691
	DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h,col_list_line);
3434 leency 692
	Scroll();
7398 leency 693
 
694
	if (del_active) Del_Form();
695
	if (new_element_active) NewElement_Form(new_element_active, #new_element_name);
3363 leency 696
}
697
 
3444 leency 698
 
5761 leency 699
void Line_ReDraw(dword bgcol, filenum){
3467 leency 700
	dword text_col=0,
5991 leency 701
		  ext1, attr,
702
		  file_offet,
703
		  file_name_off,
6290 leency 704
		  y=filenum*files.item_h+files.y,
7197 leency 705
		  icon_y = files.item_h-icon_size/2+1+y;
5991 leency 706
		  BDVK file;
6757 leency 707
		  char temp_path[sizeof(file_path)];
5996 leency 708
	char label_file_name[4096];
4859 leency 709
	if (filenum==-1) return;
7054 leency 710
	DrawBar(files.x,y,4,files.item_h,bgcol);
7197 leency 711
	DrawBar(files.x+4,y,icon_size,icon_y-y,bgcol);
712
	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);
7422 leency 713
	if (colored_lines.checked) && (bgcol!=col_selec) && (filenum%2) bgcol=0xF1F1F1;
714
	DrawBar(files.x+icon_size+4,y,files.w-icon_size-4,files.item_h,bgcol);
3363 leency 715
 
4897 leency 716
	file_offet = file_mas[filenum+files.first]*304 + buf+32;
5487 leency 717
	attr = ESDWORD[file_offet];
4897 leency 718
	file.selected = ESBYTE[file_offet+7];
719
	file.sizelo   = ESDWORD[file_offet+32];
6987 leency 720
	file.sizehi   = ESDWORD[file_offet+36];
4897 leency 721
	file_name_off = file_offet+40;
3363 leency 722
 
5487 leency 723
	if (! TestBit(attr, 4) ) //file or folder?
3363 leency 724
	{
5698 leency 725
		ext1 = strrchr(file_name_off,'.') + file_name_off;
6278 leency 726
		if (ext1==file_name_off) ext1 = NULL; //if no extension then show nothing
6987 leency 727
		WriteText(
728
			7-strlen(ConvertSize64(file.sizelo, file.sizehi))*6+files.x+files.w - 58,
729
			files.text_y+y+1,
730
			files.font_type,
731
			0,
732
			ConvertSize64(file.sizelo, file.sizehi)
733
		);
6278 leency 734
		if (ext1) && (strlen(ext1)<9) WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, 0, ext1);
3363 leency 735
	}
736
	else
4846 leency 737
	{
7149 leency 738
		if (!strcmp(file_name_off,"..")) ext1=""; else {
6278 leency 739
			ext1="";
740
			WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, 0, ext1);
741
		}
4846 leency 742
	}
6757 leency 743
	sprintf(#temp_path,"%s/%s",#path,file_name_off);
7054 leency 744
	DrawIconByExtension(#temp_path, ext1, files.x+4, icon_y, bgcol);
4846 leency 745
 
5487 leency 746
	if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=0xA6A6B7; //system or hiden?
7422 leency 747
	if (bgcol==col_selec)
3363 leency 748
	{
5487 leency 749
		itdir = TestBit(attr, 4);
4897 leency 750
		strcpy(#file_name, file_name_off);
6635 leency 751
		if (!strcmp(#path,"/")) sprintf(#file_path,"%s%s",#path,file_name_off);
752
			else sprintf(#file_path,"%s/%s",#path,file_name_off);
3363 leency 753
		if (text_col==0xA6A6B7) text_col=0xFFFFFF;
754
	}
4897 leency 755
	if (file.selected) text_col=0xFF0000;
6806 leency 756
	if (kfont.size.pt==9) || (!kfont.font)
3434 leency 757
	{
5745 leency 758
		if (Form.width>=480)
759
		{
760
			FileShow.start_x = files.x + 23;
761
			FileShow.font_color = text_col;
762
			FileShow.area_size_x = files.w - 164;
763
			FileShow.text_pointer = file_name_off;
7004 leency 764
			FileShow.start_y = files.text_y + y - 3;
5745 leency 765
			PathShow_prepare stdcall(#FileShow);
766
			PathShow_draw stdcall(#FileShow);
767
		}
3434 leency 768
	}
5745 leency 769
	else
770
	{
5996 leency 771
		strcpy(#label_file_name, file_name_off);
6806 leency 772
		if (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w)
5996 leency 773
		{
6806 leency 774
			while (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w) {
5996 leency 775
				ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL;
776
			}
777
			strcpy(#label_file_name+strlen(#label_file_name)-2, "...");
778
		}
7197 leency 779
		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 780
	}
6949 leency 781
	DrawBar(files.x+files.w-141,y,1,files.item_h,col_list_line); //gray line 1
782
	DrawBar(files.x+files.w-68,y,1,files.item_h,col_list_line); //gray line 2
3363 leency 783
}
784
 
785
 
3444 leency 786
void Open_Dir(dword dir_path, redraw){
6406 punk_joker 787
	int errornum, maxcount, i;
3444 leency 788
	if (redraw!=ONLY_SHOW)
3363 leency 789
	{
6602 leency 790
		selected_count = 0;
3363 leency 791
		if (buf) free(buf);
3444 leency 792
		errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
793
		if (errornum)
3363 leency 794
		{
6021 leency 795
			history.add(#path);
3363 leency 796
			GoBack();
797
			Write_Error(errornum);
798
			return;
799
		}
3444 leency 800
		maxcount = sizeof(file_mas)/sizeof(dword)-1;
4225 punk_joker 801
		if (files.count>maxcount) files.count = maxcount;
5825 leency 802
		if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
3363 leency 803
	}
3444 leency 804
	if (files.count!=-1)
3363 leency 805
	{
7244 leency 806
		if(!_not_draw) if (show_breadcrumb.checked) DrawBreadCrumbs(); else DrawPathBar();
6021 leency 807
		history.add(#path);
6034 leency 808
		SystemDiscs.Draw();
5825 leency 809
		files.visible = files.h / files.item_h;
5591 pavelyakov 810
		if (files.count < files.visible) files.visible = files.count;
811
		if (redraw!=ONLY_SHOW) Sorting();
5694 leency 812
		list_full_redraw = true;
6564 leency 813
		if (redraw!=ONLY_OPEN)&&(!_not_draw) {DrawStatusBar(); List_ReDraw();}
6570 leency 814
		SetCurDir(dir_path);
3363 leency 815
	}
5694 leency 816
	if (files.count==-1) && (redraw!=ONLY_OPEN)
817
	{
818
		files.KeyHome();
6564 leency 819
		if(!_not_draw) { list_full_redraw=true; DrawStatusBar(); List_ReDraw(); }
5694 leency 820
	}
3363 leency 821
}
822
 
823
inline Sorting()
824
{
825
	dword k=0, l=1;
7422 leency 826
	int j=0;
4897 leency 827
	dword file_off;
7422 leency 828
 
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
	{
7244 leency 837
		if (!show_real_names.checked) strttl(file_off+40);
4897 leency 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);
7422 leency 853
	else if (sort_num==2) Sort_by_Type(k,files.count-1);
854
	else 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);
7244 leency 899
	if (!show_real_names.checked) 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
{
7422 leency 910
	int iii;
6635 leency 911
	char old_folder_name[4096];
7422 leency 912
	iii=strlen(#path)-1;
913
	if (iii==0) return;
914
	iii = strrchr(#path, '/');
915
	strcpy(#old_folder_name, #path+iii);
916
	if (iii>1) path[iii-1]=NULL; else path[iii]=NULL;
6635 leency 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
7244 leency 1085
			if (two_panels.checked)
5719 leency 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
 
7422 leency 1133
void EventSelectAllFiles(dword state)
1134
{
1135
	int i;
1136
	for (i=0; i
1137
	List_ReDraw();
1138
	DrawStatusBar();
1139
}
3434 leency 1140
 
7422 leency 1141
void EventSelectFileByKeyPress()
1142
{
1143
	int i;
1144
	for (i=files.cur_y+1; i
1145
	{
1146
		strcpy(#temp, file_mas[i]*304+buf+72);
1147
		if (temp[0]==key_ascii) || (temp[0]==key_ascii-32)
1148
		{
1149
			files.cur_y = i - 1;
1150
			files.KeyDown();
1151
			List_ReDraw();
1152
			return;
1153
		}
1154
	}
1155
}
1156
 
1157
int GetRealFileCountInFolder(dword folder_path)
1158
{
1159
	int fcount;
1160
	dword countbuf;
1161
 
1162
	GetDir(#countbuf, #fcount, folder_path, DIRS_NOROOT);
1163
	if (countbuf) free(countbuf);
1164
 
1165
	return fcount;
1166
}
1167
 
1168
void EventRefreshDisksAndFolders()
1169
{
1170
	if(GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
1171
		FnProcess(5);
1172
	}
1173
	if(two_panels.checked)
1174
	{
1175
		if(GetRealFileCountInFolder(#inactive_path) != files_inactive.count) {
1176
			ChangeActivePanel();
1177
			Open_Dir(#path,WITH_REDRAW);
1178
			ChangeActivePanel();
1179
		}
1180
		if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
1181
	}
1182
	else
1183
	{
1184
		if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
1185
	}
1186
}
1187
 
3363 leency 1188
stop: