Subversion Repositories Kolibri OS

Rev

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