Subversion Repositories Kolibri OS

Rev

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

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