Subversion Repositories Kolibri OS

Rev

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