Subversion Repositories Kolibri OS

Rev

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