Subversion Repositories Kolibri OS

Rev

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