Subversion Repositories Kolibri OS

Rev

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

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