Subversion Repositories Kolibri OS

Rev

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

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