Subversion Repositories Kolibri OS

Rev

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

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