Subversion Repositories Kolibri OS

Rev

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