Subversion Repositories Kolibri OS

Rev

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

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