Subversion Repositories Kolibri OS

Rev

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