Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
5481 leency 1
//Leency, Veliant, Punk_Joker & KolibriOS Team 2008-2015
3363 leency 2
//GNU GPL licence.
3
 
4022 leency 4
#ifndef AUTOBUILD
5
#include "lang.h--"
6
#endif
7
 
3363 leency 8
//libraries
5676 pavelyakov 9
#define MEMSIZE 500000
4427 punk_joker 10
#include "..\lib\clipboard.h"
3363 leency 11
#include "..\lib\strings.h"
12
#include "..\lib\mem.h"
13
#include "..\lib\file_system.h"
5499 leency 14
#include "..\lib\gui.h"
3434 leency 15
#include "..\lib\list_box.h"
16
#include "..\lib\copyf.h"
4863 leency 17
#include "..\lib\random.h"
5487 leency 18
//obj
5499 leency 19
#include "..\lib\obj\libini.h"
20
#include "..\lib\obj\box_lib.h"
3363 leency 21
//images
22
#include "imgs\toolbar.txt"
23
#include "imgs\left_p.txt"
4846 leency 24
#include "imgs\icons.txt"
3363 leency 25
 
3848 punk_joker 26
#ifdef LANG_RUS
5623 leency 27
	?define T_FILE "Файл"
28
	?define T_TYPE "Тип"
29
	?define T_SIZE "Размер"
30
	?define T_NEW_FOLDER "Новая папка"
31
	?define T_NEW_FILE "Новый файл"
32
	?define T_DELETE_FILE "Вы действительно хотите удалить"
33
	?define T_YES "Да"
34
	?define T_NO "Нет"
35
	?define T_CANCEL "Отмена"
36
	?define T_CREATE "Создать"
37
	?define T_RENAME "Переименовать"
38
	?define FS_ITEM_ALREADY_EXISTS "'Элемент с таким именем уже существует' -E"
39
	?define T_DEL_ERROR_1 "Ошибка. Папка не пустая."
40
	?define WAIT_DELETING_FOLDER "Удаляется папка. Подожите..."
41
	?define NOT_CREATE_FOLDER "Не удалось создать папку."
42
	?define NOT_CREATE_FILE "Не удалось создать файл."
43
	?define T_PASTE_WINDOW_TITLE "Копирую..."
44
	?define T_PASTE_WINDOW_TEXT "Копируется файл:"
45
	?define T_PASTE_WINDOW_BUTTON "Прервать"
46
	?define INFO_AFTER_COPY "Копирование завершено"
47
	?define T_CANCEL_PASTE "Копирование прекращено. Папка скопирована не полностью."
48
	?define T_SELECT_APP_TO_OPEN_WITH "Выберите программу для открытия файла"
49
	?define DEL_MORE_FILES_1 "выбранные элементы ("
50
	?define DEL_MORE_FILES_2 " шт.)?"
3933 kaitz 51
#elif LANG_EST
52
	?define T_FILE "Fail"
5620 leency 53
	?define T_TYPE "TтДЦтДЦp"
3933 kaitz 54
	?define T_SIZE "Suurus"
55
	?define T_NEW_FOLDER "Uus kataloog"
56
	?define T_NEW_FILE "Uus fail"
5620 leency 57
	?define T_DELETE_FILE "Kas sa tahad t╤Чesti kustutada"
3933 kaitz 58
	?define T_YES "Jah"
59
	?define T_NO "Ei"
5556 punk_joker 60
	?define T_CANCEL "Cancel"
61
	?define T_CREATE "Create"
5571 punk_joker 62
	?define T_RENAME "Rename"
5620 leency 63
	?define FS_ITEM_ALREADY_EXISTS "'An item with that name already exists' -E"
64
	?define T_DEL_ERROR_1 "Viga. Kataloog ei ole tтДЦhi."
3997 leency 65
	?define WAIT_DELETING_FOLDER "Deleting folder. Please, wait..."
3933 kaitz 66
	?define NOT_CREATE_FOLDER "Kataloogi ei saa luua."
67
	?define NOT_CREATE_FILE "Faili ei saa luua."
5514 leency 68
	?define T_PASTE_WINDOW_TITLE "Kopeerin..."
3933 kaitz 69
	?define T_PASTE_WINDOW_TEXT "Kopeerin faili:"
5514 leency 70
	?define T_PASTE_WINDOW_BUTTON "Abort"
71
	?define INFO_AFTER_COPY "Copy finished"
4022 leency 72
	?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
4049 leency 73
	?define T_SELECT_APP_TO_OPEN_WITH "Select application to open file"
5514 leency 74
	?define DEL_MORE_FILES_1 "selected items("
75
	?define DEL_MORE_FILES_2 " pcs.)?"
3848 punk_joker 76
#else
77
	?define T_FILE "File"
78
	?define T_TYPE "Type"
79
	?define T_SIZE "Size"
80
	?define T_NEW_FOLDER "New folder"
81
	?define T_NEW_FILE "New file"
82
	?define T_DELETE_FILE "Do you really want to delete"
83
	?define T_YES "Yes"
84
	?define T_NO "No"
5556 punk_joker 85
	?define T_CANCEL "Cancel"
86
	?define T_CREATE "Create"
5571 punk_joker 87
	?define T_RENAME "Rename"
5620 leency 88
	?define FS_ITEM_ALREADY_EXISTS "'An item with that name already exists' -E"
3848 punk_joker 89
	?define T_DEL_ERROR_1 "Error. Folder isn't empty."
3997 leency 90
	?define WAIT_DELETING_FOLDER "Deleting folder. Please, wait..."
3848 punk_joker 91
	?define NOT_CREATE_FOLDER "Folder can not be created."
92
	?define NOT_CREATE_FILE "File can not be created."
5514 leency 93
	?define T_PASTE_WINDOW_TITLE "Copying..."
3883 leency 94
	?define T_PASTE_WINDOW_TEXT "Copying file:"
5514 leency 95
	?define T_PASTE_WINDOW_BUTTON "Abort"
96
	?define INFO_AFTER_COPY "Copy finished"
4022 leency 97
	?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
4049 leency 98
	?define T_SELECT_APP_TO_OPEN_WITH "Select application to open file"
5514 leency 99
	?define DEL_MORE_FILES_1 "selected items("
100
	?define DEL_MORE_FILES_2 " pcs.)?"
3848 punk_joker 101
#endif
102
 
3444 leency 103
enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir
5581 leency 104
enum { CREATE_FILE=1, CREATE_FOLDER, RENAME_ITEM }; //NewElement
3444 leency 105
 
5688 punk_joker 106
#define TITLE "Eolite File Manager v2.94"
107
#define ABOUT_TITLE "Eolite 2.94"
4076 leency 108
dword col_padding, col_selec, col_lpanel;
3363 leency 109
 
3434 leency 110
int toolbar_buttons_x[7]={9,46,85,134,167,203};
111
struct path_string { char Item[4096]; };
3363 leency 112
 
4136 punk_joker 113
byte active_about=0;
4070 punk_joker 114
word about_window;
5416 punk_joker 115
byte active_settings=0;
116
word settings_window;
5606 pavelyakov 117
dword _not_draw = false;
4136 punk_joker 118
byte menu_call_mouse=0;
119
 
3434 leency 120
llist files;
121
 
122
byte
3363 leency 123
	path[4096],
124
	file_path[4096],
3404 leency 125
	file_name[256],
5555 punk_joker 126
	new_element_name[256],
3434 leency 127
	temp[4096];
128
byte
3439 leency 129
	del_active=0,
5555 punk_joker 130
	new_element_active=0,
4399 punk_joker 131
	show_dev_name=1,
4225 punk_joker 132
	real_files_names_case=0,
5532 leency 133
	use_big_fonts=0,
134
	font_type,
5687 leency 135
	font_h,
5459 punk_joker 136
	info_after_copy=0,
3434 leency 137
	sort_num=2,
3441 leency 138
	itdir;
3363 leency 139
 
5441 leency 140
dword eolite_ini_path;
141
 
5608 leency 142
dword menu_stak,about_stak,properties_stak,settings_stak,copy_stak;
143
 
3363 leency 144
proc_info Form;
5532 leency 145
int mouse_dd, scroll_used, sc_slider_h, sorting_arrow_x, kolibrios_drive;
4897 leency 146
dword buf;
3434 leency 147
dword file_mas[6898];
148
int j, i;
4028 leency 149
int action_buf;
4863 leency 150
int rand_n;
5513 punk_joker 151
int selected_count;
5591 pavelyakov 152
byte CMD_REFRESH;
3363 leency 153
 
5549 punk_joker 154
signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
155
byte stats;
156
 
5557 punk_joker 157
edit_box edit2 = {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xFFFFFF,0,248,#file_name,#mouse_dd,64,6,6};
5581 leency 158
edit_box new_file_ed = {171,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0,248,#new_element_name,#mouse_dd,100000000000010b,6,0};
3434 leency 159
PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0};
3363 leency 160
PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
5576 pavelyakov 161
byte cmd_free;
4042 leency 162
#include "include\copy.h"
5435 leency 163
#include "include\gui.h"
3363 leency 164
#include "include\sorting.h"
4042 leency 165
#include "include\icons.h"
3363 leency 166
#include "include\left_panel.h"
167
#include "include\history.h"
4042 leency 168
#include "include\menu.h"
169
#include "include\about.h"
5416 punk_joker 170
#include "include\settings.h"
5447 punk_joker 171
#include "include\properties.h"
3363 leency 172
 
5576 pavelyakov 173
 
3363 leency 174
void main()
175
{
3444 leency 176
	word key, id, can_show, can_select, m_selected;
4897 leency 177
	dword selected_offset;
5591 pavelyakov 178
	dword IPC_LEN,IPC_ID;
179
	char IPC_BUF[10];
180
	dword tmp;
4863 leency 181
	rand_n = random(40);
5651 pavelyakov 182
 
5626 leency 183
	load_dll(boxlib, #box_lib_init,0);
184
    load_dll(libini, #lib_init,1);
5441 leency 185
	eolite_ini_path = abspath("Eolite.ini");
186
	LoadIniSettings();
187
	GetSystemDiscs();
4076 leency 188
	SetAppColors();
3363 leency 189
	if (param)
190
	{
5591 pavelyakov 191
		tmp = strlen(#path);
5657 pavelyakov 192
		strlcpy(#path, #param, tmp);
5591 pavelyakov 193
		$dec tmp
194
		if (path[tmp]!='/') DSBYTE[#path+tmp] = '/'; //add "/" to the end of the string
3363 leency 195
	}
196
	else
3695 leency 197
	{
5657 pavelyakov 198
		strlcpy(#path, "/rd/1/", 6);
3695 leency 199
	}
3363 leency 200
	Open_Dir(#path,ONLY_OPEN);
5606 pavelyakov 201
	SetEventMask(1100111b);
5591 pavelyakov 202
	loop(){
203
		switch(WaitEvent())
204
		{
205
			case evMouse:
206
				if (del_active) || (!CheckActiveProcess(Form.ID)) || (Form.status_window>2) break;
207
				if (new_element_active) || (!CheckActiveProcess(Form.ID)) || (Form.status_window>2)
208
				{
209
					edit_box_mouse stdcall(#new_file_ed);
210
					break;
211
				}
5549 punk_joker 212
 
5640 pavelyakov 213
				mouse.get();
5591 pavelyakov 214
 
5640 pavelyakov 215
				if (!mouse.mkm) && (stats>0) stats = 0;
5657 pavelyakov 216
				if (mouse.mkm) && (!stats)
5549 punk_joker 217
				{
5640 pavelyakov 218
					x_old = mouse.x;
219
					y_old = mouse.y;
5591 pavelyakov 220
					stats = 1;
221
				}
5640 pavelyakov 222
				if (mouse.mkm) && (stats==1)
5591 pavelyakov 223
				{
5640 pavelyakov 224
					dif_x = mouse.x-x_old;
225
					dif_y = mouse.y-y_old;
5591 pavelyakov 226
					adif_x = fabs(dif_x);
227
					adif_y = fabs(dif_y);
228
 
229
					if (adif_x>adif_y)
5549 punk_joker 230
					{
5591 pavelyakov 231
						if (dif_x > 150)
232
						{
233
							if (HistoryPath(GO_FORWARD))
234
								{
235
									files.first=files.current=NULL;
236
									Open_Dir(#path,WITH_REDRAW);
237
								}
238
							stats = 0;
239
						}
240
						if (dif_x < -150)
241
						{
242
							GoBack();
243
							stats = 0;
244
						}
5549 punk_joker 245
					}
5591 pavelyakov 246
					else
5549 punk_joker 247
					{
5591 pavelyakov 248
						if (dif_y < -100)
249
						{
250
							Dir_Up();
251
							stats = 0;
252
						}
5549 punk_joker 253
					}
5591 pavelyakov 254
				}
5658 pavelyakov 255
				if (files.MouseOver(mouse.x, mouse.y))&&((mouse.down|mouse.dblclick|mouse.up))
5549 punk_joker 256
				{
5591 pavelyakov 257
					//select/open file {
5640 pavelyakov 258
					if (mouse.key&MOUSE_LEFT)&&((mouse.down)||(mouse.dblclick))
5549 punk_joker 259
					{
5640 pavelyakov 260
						if (mouse.y>=files.y)//&&(mouse.click)
5591 pavelyakov 261
						{
5640 pavelyakov 262
							id = mouse.y - files.y / files.line_h;
5658 pavelyakov 263
							IF (files.current!=id)
5591 pavelyakov 264
							{
5640 pavelyakov 265
								mouse.clearTime();
5658 pavelyakov 266
								if(!mouse.up)&&(id
5591 pavelyakov 267
							}
5658 pavelyakov 268
							else IF(mouse.dblclick)Open(0);
5591 pavelyakov 269
						}
5549 punk_joker 270
					}
5591 pavelyakov 271
					// } select/open file
272
					else
273
					//file menu {
5640 pavelyakov 274
					if (mouse.key&MOUSE_RIGHT)&&(mouse.up)
5575 pavelyakov 275
					{
5591 pavelyakov 276
						menu_call_mouse = 1;
5640 pavelyakov 277
						if (mouse.y>=files.y)//&&(mouse.click)
5575 pavelyakov 278
						{
5640 pavelyakov 279
							id = mouse.y - files.y / files.line_h;
5591 pavelyakov 280
							if (files.current!=id) List_Current(id-files.current);
281
							//SwitchToAnotherThread();
282
							menu_stak = malloc(4096);
283
							CreateThread(#FileMenu,menu_stak+4092);
5575 pavelyakov 284
						}
5591 pavelyakov 285
						break;
5575 pavelyakov 286
					}
5591 pavelyakov 287
					// } file menu
5575 pavelyakov 288
				}
5591 pavelyakov 289
 
5640 pavelyakov 290
				if (mouse.vert)
5575 pavelyakov 291
				{
5640 pavelyakov 292
					if (files.MouseScroll(mouse.vert)) List_ReDraw();
5591 pavelyakov 293
					break;
294
				}
295
 
5640 pavelyakov 296
				if (mouse.x>=Form.width-26) && (mouse.x<=Form.width-6) && (mouse.y>40) && (mouse.y
5591 pavelyakov 297
				{
5640 pavelyakov 298
					if (mouse.lkm==1) DrawRectangle3D(Form.cwidth - 17,41,14,14,0xC7C7C7,0xFFFFFF);
299
					WHILE (mouse.lkm==1) && (files.first>0)
5575 pavelyakov 300
					{
5591 pavelyakov 301
						pause(8);
302
						files.first--;
303
						List_ReDraw();
5640 pavelyakov 304
						mouse.get();
5575 pavelyakov 305
					}
5591 pavelyakov 306
					DrawRectangle3D(Form.cwidth - 17,41,14,14,0xFFFFFF,0xC7C7C7);
5575 pavelyakov 307
				}
3363 leency 308
 
5640 pavelyakov 309
				if (mouse.x>=Form.width-26) && (mouse.x<=Form.width-6) && (mouse.y>onTop(22,0)+1) && (mouse.y
3363 leency 310
				{
5640 pavelyakov 311
					if (mouse.lkm==1) DrawRectangle3D(Form.cwidth - 17,onTop(21,0),14,14,0xC7C7C7,0xFFFFFF);
312
					while (mouse.lkm==1) && (files.first
5591 pavelyakov 313
					{
314
						pause(8);
315
						files.first++;
316
						List_ReDraw();
5640 pavelyakov 317
						mouse.get();
5591 pavelyakov 318
					}
319
					DrawRectangle3D(Form.cwidth - 17,onTop(21,0),14,14,0xFFFFFF,0xC7C7C7);
3363 leency 320
				}
321
 
5591 pavelyakov 322
				//Scrooll
5640 pavelyakov 323
				if (!mouse.lkm) && (scroll_used) { scroll_used=NULL; Scroll(); }
324
				if (mouse.x>=Form.width-26) && (mouse.x<=Form.width-6) && (mouse.y>56) && (mouse.y
5591 pavelyakov 325
 
326
				if (scroll_used)
3363 leency 327
				{
5640 pavelyakov 328
					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
5591 pavelyakov 329
					id=files.first;
330
					j= sc_slider_h/2;
5640 pavelyakov 331
					files.first = mouse.y -j -files.y * files.count;
5591 pavelyakov 332
					files.first /= onTop(22,files.y);
333
					if (files.visible+files.first>files.count) files.first=files.count-files.visible;
334
					if (id!=files.first) List_ReDraw();
3363 leency 335
				}
5591 pavelyakov 336
				break;
337
	//Button pressed-----------------------------------------------------------------------------
338
			case evButton:
339
				id=GetButtonID();
340
				if (id==1)
341
				{
342
					KillProcess(about_window);
343
					ExitProcess();
344
				}
345
				if (del_active)
346
				{
347
					if (id==301) || (id==302) Del_File(302-id);
348
					break;
349
				}
350
				if (new_element_active)
351
				{
352
					if (id==301) || (id==302) NewElement(302-id);
353
					break;
354
				}
355
 
356
				switch(id)
357
				{
358
					case 21: //Back
359
							GoBack();
360
							break;
361
					case 22: //Forward
362
							if (HistoryPath(GO_FORWARD))
363
							{
364
								files.first=files.current=NULL; //aaa?o nienea
365
								Open_Dir(#path,WITH_REDRAW);
366
							}
367
							break;
5608 leency 368
					case 23:
3363 leency 369
							Dir_Up();
370
							break;
5608 leency 371
					case 24:
3444 leency 372
							Copy(#file_path, CUT);
373
							break;
5608 leency 374
					case 25:
3444 leency 375
							Copy(#file_path, NOCUT);
3363 leency 376
							break;
5608 leency 377
					case 26:
378
							Paste();
3363 leency 379
							break;
5591 pavelyakov 380
					case 31...33: //sort
381
							if(sort_num==1) DrawFilledBar(sorting_arrow_x,42,6,10);
382
							if(sort_num==2) DrawFilledBar(sorting_arrow_x,42,6,10);
383
							if(sort_num==3) DrawFilledBar(sorting_arrow_x,42,6,10);
384
							sort_num=id-30;
385
							Open_Dir(#path,WITH_REDRAW);
5512 punk_joker 386
							break;
5591 pavelyakov 387
					case 50...60: //Actions
388
							FnProcess(id-50);
5512 punk_joker 389
							break;
5591 pavelyakov 390
					case 100...120:
391
						DEVICE_MARK:
392
							DrawRectangle(17,id-100*16+74,159,16, 0); //auaaeaiea
393
							strcpy(#path, #disk_list[id-100].Item);
394
							files.first=files.current=0;
395
							Open_Dir(#path,WITH_REDRAW);
396
							pause(5);
397
							DrawRectangle(17,id-100*16+74,159,16, 0xFFFFFF);
3363 leency 398
							break;
5591 pavelyakov 399
				}
400
				break;
401
	//Key pressed-----------------------------------------------------------------------------
402
			case evKey:
403
				key = GetKey();
404
				if (Form.status_window>2) break;
405
				if (del_active)
406
				{
407
					if (key==013) Del_File(true);
408
					if (key==027) Del_File(false);
409
					break;
410
				}
411
				if (new_element_active)
412
				{
413
					if (key==027) NewElement(0);
414
					if (key==013) NewElement(1);
415
					EAX=key<<8;
416
					edit_box_key stdcall (#new_file_ed);
417
					break;
418
				}
419
				if (edit2.flags!=64) && (key!=13) && (key!=27)
420
				{
421
					EAX=key<<8;
422
					edit_box_key stdcall (#edit2);
423
					break;
424
				}
425
				switch (key)
426
				{
427
						case 209...217:
428
								id=key-110;
429
								if (id-100>=disc_num) break;
430
								GOTO DEVICE_MARK;
431
						case ASCII_KEY_BS:
432
								//GoBack();
433
								Dir_Up();
434
								break;
5661 leency 435
						case 004: //Ctrl+D - set as bg
5591 pavelyakov 436
								strncpy(#temp, "\\S__",4);
437
								strcat(#temp, #file_path);
438
								RunProgram("/sys/media/kiv", #temp);
439
								break;
5661 leency 440
						case 014: //Ctrl+N - create new window
5591 pavelyakov 441
								if (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD);
442
								RunProgram("/sys/File Managers/Eolite", #path);
443
								break;
444
						case 024: //Ctrl+X
445
								Copy(#file_path, CUT);
446
								break;
447
						case 003: //Ctrl+C
448
								Copy(#file_path, NOCUT);
449
								break;
450
						case 022: //Ctrl+V
5608 leency 451
								Paste();
5591 pavelyakov 452
								break;
5661 leency 453
						case 001: //Ctrl+A - select all files
5591 pavelyakov 454
								for (i=0; i
3363 leency 455
								{
5591 pavelyakov 456
									selected_offset = file_mas[i]*304 + buf+32 + 7;
5661 leency 457
									if (!i) if (!strncmp(selected_offset+33, "..", 2)) continue; //do not selec ".." directory
5591 pavelyakov 458
									ESBYTE[selected_offset] = 1;
459
									selected_count++;
3363 leency 460
								}
5591 pavelyakov 461
								List_ReDraw();
462
								break;
5661 leency 463
						case 021: //Ctrl+U - unselect all files
5591 pavelyakov 464
								for (i=0; i
465
								{
466
									selected_offset = file_mas[i]*304 + buf+32 + 7;
467
									ESBYTE[selected_offset] = 0;
468
								}
469
								selected_count = 0;
470
								List_ReDraw();
471
								break;
472
						case ASCII_KEY_ESC:
473
								break;
474
						case ASCII_KEY_ENTER:
475
								Open(0);
476
								break;
477
						case 074: //menu
478
								menu_call_mouse=0;
479
								//SwitchToAnotherThread();
480
								menu_stak = malloc(4096);
481
								CreateThread(#FileMenu,menu_stak+4092);
482
								break;
483
						case 173: //Ctrl+Enter
484
								if (!itdir) ShowOpenWithDialog();
485
								else Open(1);
486
								break;
487
						case ASCII_KEY_UP:
488
								List_Current(-1);
489
								break;
490
						case ASCII_KEY_DOWN:
491
								List_Current(1);
492
								break;
493
						case ASCII_KEY_HOME:
494
								if (files.KeyHome()) List_ReDraw();
495
								break;
496
						case ASCII_KEY_END:
497
								if (files.KeyEnd()) List_ReDraw();
498
								break;
499
						case ASCII_KEY_PGDN:
500
								List_Current(files.visible-1);
501
								break;
502
						case ASCII_KEY_PGUP:
503
								List_Current(-files.visible+1);
504
								break;
505
						case ASCII_KEY_DEL:
506
								Del_Form();
507
								break;
508
						case ASCII_KEY_INS:
509
								selected_offset = file_mas[files.current+files.first]*304 + buf+32 + 7;
5661 leency 510
								if (files.current+files.first==0) && (!strncmp(selected_offset+33, "..", 2)) goto _INSERT_END; //do not selec ".." directory
5591 pavelyakov 511
								if (ESBYTE[selected_offset])
512
								{
513
									ESBYTE[selected_offset]=0;
514
									selected_count--;
515
								}
516
								else
517
								{
518
									ESBYTE[selected_offset] = 1;
519
									selected_count++;
520
								}
5661 leency 521
								_INSERT_END:
5591 pavelyakov 522
								List_Current(1);
523
								break;
524
						case 048...059: //F1-F10
525
								FnProcess(key-49);
526
								break;
527
						default:
528
								for (i=files.current+files.first+1; i
529
								{
530
									strcpy(#temp, file_mas[i]*304+buf+72);
531
									if (temp[0]==key) || (temp[0]==key-32)
532
									{
533
										List_Current(i-files.current-files.first);
534
										break;
535
									}
536
								}
537
				}
3363 leency 538
			break;
5591 pavelyakov 539
			case evReDraw:
540
				DRAW_WINDOW:
541
				draw_window();
542
				if (action_buf)
543
				{
544
					menu_action(action_buf);
545
					action_buf=0;
546
				}
547
			break;
5606 pavelyakov 548
			case evIPC:
549
				goto DRAW_WINDOW;
550
			break;
5591 pavelyakov 551
		}
552
 
553
		if(cmd_free)
554
		{
5576 pavelyakov 555
			if(cmd_free==1)     free(menu_stak);
556
			else if(cmd_free==2)free(about_stak);
557
			else if(cmd_free==3)free(properties_stak);
558
			else if(cmd_free==4)free(settings_stak);
559
			else if(cmd_free==5)free(copy_stak);
5591 pavelyakov 560
			cmd_free = false;
5576 pavelyakov 561
		}
562
	}
3363 leency 563
}
564
 
4225 punk_joker 565
 
5435 leency 566
inline fastcall signed int _strrchr( ESI,BL)
567
{
568
	int jj=0, last=strlen(ESI);
5591 pavelyakov 569
	do {
5435 leency 570
		jj++;
571
		$lodsb
5591 pavelyakov 572
		if(AL==BL) last=jj;
5435 leency 573
	} while(AL!=0);
574
	return last;
575
}
4225 punk_joker 576
 
5435 leency 577
 
4028 leency 578
void menu_action(dword id)
579
{
580
	if (id==COPY_PASTE_END)
581
	{
582
		FnProcess(5);
583
		SelectFile(#copy_to+strrchr(#copy_to,'/'));
584
	}
5443 punk_joker 585
	if (id==100) Open(0);
4225 punk_joker 586
	if (id==201) ShowOpenWithDialog();
4028 leency 587
	if (id==202) FnProcess(3); //F3
588
	if (id==203) FnProcess(4); //F4
589
	if (id==104) Copy(#file_path, NOCUT);
590
	if (id==105) Copy(#file_path, CUT);
5608 leency 591
	if (id==106) Paste();
4034 leency 592
	if (id==207) FnProcess(2);
4028 leency 593
	if (id==108) Del_Form();
594
	if (id==109) FnProcess(5);
5447 punk_joker 595
	if (id==110) FnProcess(8);
5591 pavelyakov 596
	if (id==300)
597
	{
598
		FnProcess(5);
599
		List_ReDraw();
600
	}
4028 leency 601
}
3363 leency 602
 
4028 leency 603
 
3444 leency 604
void draw_window()
605
{
5674 pavelyakov 606
	DefineAndDrawWindow(GetScreenWidth()-550/4+rand_n,rand_n+30,550,500,0x73,system.color.work,TITLE,0);
3444 leency 607
	GetProcessInfo(#Form, SelfInfo);
608
	if (Form.status_window>2) return;
5441 leency 609
	files.SetSizes(192, 57, Form.cwidth - 210, onTop(57,6), disc_num*16+195,files.line_h);
3444 leency 610
	if (Form.height < files.min_h) MoveSize(OLD,OLD,OLD,files.min_h);
611
	if (Form.width<480) MoveSize(OLD,OLD,480,OLD);
612
	GetProcessInfo(#Form, SelfInfo); //if win_size changed
613
 
3363 leency 614
	PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal);
5674 pavelyakov 615
	DrawBar(127, 8, 1, 25, system.color.work_graph);
616
	for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,system.color.work);
617
	for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,system.color.work);
618
	DrawBar(246,0,Form.cwidth - 297,12, system.color.work); //upper editbox
619
	DrawBar(246,29,Form.cwidth - 297,5,system.color.work);  //under editbox
620
	DrawRectangle(246,12,Form.cwidth - 303,16,system.color.work_graph);
5576 pavelyakov 621
	DefineButton(Form.cwidth - 32,6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about
3363 leency 622
	PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal);
3434 leency 623
	//main rectangles
5674 pavelyakov 624
	DrawRectangle(1,40,Form.cwidth-3,onTop(46,0),system.color.work_graph);
3444 leency 625
	DrawRectangle(0,39,Form.cwidth-1,onTop(44,0),col_palette[4]); //bg
3363 leency 626
	for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]);
627
	DrawLeftPanel();
3434 leency 628
	//ListBox
5674 pavelyakov 629
	DrawFlatButton(files.x,40,Form.cwidth - files.x - 159,16,31,system.color.work,T_FILE);
630
	DrawFlatButton(Form.cwidth - 159,40,73,16,32,system.color.work,T_TYPE);
631
	DrawFlatButton(Form.cwidth - 86,40,68,16,33,system.color.work,T_SIZE);
632
	DrawBar(files.x+files.w,files.y,1,onTop(22,files.y),system.color.work_graph); //line to the left from the scroll
633
	DrawFlatButton(files.x+files.w,40,16,16,0,system.color.work,"\x18");
634
	DrawFlatButton(files.x+files.w,onTop(22,0),16,16,0,system.color.work,"\x19");
3363 leency 635
	Open_Dir(#path,ONLY_SHOW);
636
	if (del_active) Del_Form();
5581 leency 637
	if (new_element_active) NewElement_Form(new_element_active, #new_element_name);
3363 leency 638
}
639
 
640
 
641
void KEdit()
642
{
3434 leency 643
	if (Form.width<480) return;
3363 leency 644
	PathShow.area_size_x = Form.cwidth-306;
645
	DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff);
646
	PathShow_prepare stdcall(#PathShow);
647
	PathShow_draw stdcall(#PathShow);
648
}
649
 
650
 
5511 leency 651
void List_Current(signed int cur)
3363 leency 652
{
3434 leency 653
	if (cur<=0) //up
3363 leency 654
	{
5591 pavelyakov 655
		if (files.first==0) && (files.current<=0) return;
656
		if (-cur-1
3363 leency 657
		{
3434 leency 658
			Line_ReDraw(0xFFFFFF, files.current);
659
			files.current+=cur;
660
			Line_ReDraw(col_selec, files.current);
3363 leency 661
			return;
662
		}
5591 pavelyakov 663
		else
3363 leency 664
		{
5591 pavelyakov 665
			if (-cur
3434 leency 666
			files.current=0;
3363 leency 667
			List_ReDraw();
668
			return;
669
		}
670
	}
3434 leency 671
	else  //down
3363 leency 672
	{
5591 pavelyakov 673
		if (files.first==files.count-files.visible) && (files.current==files.visible-1)
5511 leency 674
		{
675
			Line_ReDraw(col_selec, files.current);
676
			return;
677
		}
5591 pavelyakov 678
		if (files.visible-files.current>cur)
3363 leency 679
		{
3434 leency 680
			Line_ReDraw(0xFFFFFF, files.current);
681
			files.current+=cur;
682
			Line_ReDraw(col_selec, files.current);
3363 leency 683
			return;
684
		}
685
		else
686
		{
5591 pavelyakov 687
			if(files.first+files.current+cur>=files.count)
3363 leency 688
			{
3434 leency 689
				files.first=files.count-files.visible;
690
				files.current=cur-files.first+files.current;
3363 leency 691
				}
5591 pavelyakov 692
			else
3363 leency 693
			{
3434 leency 694
				files.first+=cur+files.current-files.visible+1;
695
				files.current=files.visible-1;
3363 leency 696
			}
697
 
5591 pavelyakov 698
			if (files.current<0) || (files.current>files.visible)
3363 leency 699
			{
3434 leency 700
				files.current=files.visible-1;
3363 leency 701
			}
702
			List_ReDraw();
703
		}
704
	}
705
}
706
 
707
 
708
void List_ReDraw()
709
{
3434 leency 710
	int paint_y;
3876 leency 711
	//we are in the end of the list => maximize window => there will be white lines after the last element
3434 leency 712
	if (files.count-files.firstfiles.visible-1)
713
	{ files.first=files.count-files.visible; files.current=files.visible-1; }
3444 leency 714
	for (j=0; j
3434 leency 715
	//in the bottom
716
	paint_y = j * files.line_h + files.y;
717
	DrawBar(files.x,paint_y,files.w,onTop(paint_y,6),0xFFFFFF);
5674 pavelyakov 718
	DrawBar(Form.cwidth-159,paint_y,1,onTop(paint_y,6),system.color.work);
719
	DrawBar(Form.cwidth-86,paint_y,1,onTop(paint_y,6),system.color.work);
3434 leency 720
	Scroll();
3363 leency 721
}
722
 
3444 leency 723
 
3363 leency 724
void Line_ReDraw(dword color, filenum){
3467 leency 725
	dword text_col=0,
5487 leency 726
	      ext1, attr,
4897 leency 727
	      file_offet,
728
	      file_name_off,
4042 leency 729
	      y=filenum*files.line_h+files.y;
4897 leency 730
	      BDVK file;
4859 leency 731
	if (filenum==-1) return;
3447 leency 732
	DrawBar(files.x,y,3,files.line_h,color);
733
	DrawBar(files.x+19,y,files.w-19,files.line_h,color);
734
	DrawBar(files.x+3,y+17,16,1,color);
735
	if (files.line_h>18) DrawBar(files.x+3,y+18,16,files.line_h-18,color);
736
	if (files.line_h>15) DrawBar(files.x+3,y,16,files.line_h-15,color);
3363 leency 737
 
4897 leency 738
	file_offet = file_mas[filenum+files.first]*304 + buf+32;
5487 leency 739
	attr = ESDWORD[file_offet];
4897 leency 740
	file.selected = ESBYTE[file_offet+7];
741
	file.sizelo   = ESDWORD[file_offet+32];
742
	file_name_off = file_offet+40;
3363 leency 743
 
5487 leency 744
	if (! TestBit(attr, 4) ) //file or folder?
3363 leency 745
	{
4897 leency 746
		Put_icon(file_name_off+_strrchr(file_name_off,'.'), files.x+3, files.line_h/2-7+y, color, 0);
5687 leency 747
		WriteText(7-strlen(ConvertSize(file.sizelo))*6+Form.cwidth - 76, files.line_h - font_h/ 2 + y,font_type,0,ConvertSize(file.sizelo));
3363 leency 748
	}
749
	else
4846 leency 750
	{
5606 pavelyakov 751
		if (!strncmp(file_name_off,"..",3)) ext1=".."; else ext1="";
4846 leency 752
		Put_icon(ext1, files.x+3, files.line_h/2-7+y, color, 0);
753
	}
754
 
5487 leency 755
	if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=0xA6A6B7; //system or hiden?
3444 leency 756
	if (color!=0xFFFfff)
3363 leency 757
	{
5487 leency 758
		itdir = TestBit(attr, 4);
4897 leency 759
		strcpy(#file_name, file_name_off);
5606 pavelyakov 760
		sprintf(#file_path,"%s%s",#path,file_name_off);
3363 leency 761
		if (text_col==0xA6A6B7) text_col=0xFFFFFF;
762
	}
4897 leency 763
	if (file.selected) text_col=0xFF0000;
3434 leency 764
	if (Form.width>=480)
765
	{
3447 leency 766
		FileShow.start_x = files.x + 23;
3434 leency 767
		FileShow.font_color = text_col;
5687 leency 768
		FileShow.area_size_x = files.w - 164;
4897 leency 769
		FileShow.text_pointer = file_name_off;
5687 leency 770
		FileShow.start_y = files.line_h - font_h/ 2 + y;
3434 leency 771
		PathShow_prepare stdcall(#FileShow);
772
		PathShow_draw stdcall(#FileShow);
773
	}
5674 pavelyakov 774
	DrawBar(Form.cwidth-159,y,1,files.line_h,system.color.work); //gray line 1
775
	DrawBar(Form.cwidth-86,y,1,files.line_h,system.color.work); //gray line 2
3363 leency 776
}
777
 
778
 
3444 leency 779
void Open_Dir(dword dir_path, redraw){
780
	int errornum, maxcount;
3434 leency 781
 
3444 leency 782
	if (redraw!=ONLY_SHOW)
3363 leency 783
	{
3444 leency 784
		if (ESBYTE[dir_path+1]!='\0') ESBYTE[dir_path+strlen(dir_path)-1] = '\0';
3363 leency 785
		if (buf) free(buf);
3444 leency 786
		errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
787
		if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/');
788
		if (errornum)
3363 leency 789
		{
790
			HistoryPath(ADD_NEW_PATH);
791
			GoBack();
792
			Write_Error(errornum);
793
			return;
794
		}
3444 leency 795
		maxcount = sizeof(file_mas)/sizeof(dword)-1;
4225 punk_joker 796
		if (files.count>maxcount) files.count = maxcount;
4859 leency 797
		if (files.count>0) && (files.current==-1) files.current=0;
3363 leency 798
	}
3444 leency 799
	if (files.count!=-1)
3363 leency 800
	{
5606 pavelyakov 801
		if(!_not_draw)KEdit();
3363 leency 802
		HistoryPath(ADD_NEW_PATH);
3444 leency 803
		files.visible = files.h / files.line_h;
5591 pavelyakov 804
		if (files.count < files.visible) files.visible = files.count;
805
		if (sort_num==1) sorting_arrow_x = Form.width+60/2;
806
		if (sort_num==2) sorting_arrow_x = Form.width-115;
807
		if (sort_num==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
5674 pavelyakov 808
		WriteText(sorting_arrow_x,45,0x80,system.color.work_graph,"\x19");
5591 pavelyakov 809
		if (redraw!=ONLY_SHOW) Sorting();
5606 pavelyakov 810
		if (redraw!=ONLY_OPEN)&&(!_not_draw) List_ReDraw();
5633 leency 811
		DrawSystemDiscs();
3363 leency 812
	}
5606 pavelyakov 813
	if (files.count==-1) && (redraw!=ONLY_OPEN) {files.visible=files.count=0; if(!_not_draw)List_ReDraw();}
3363 leency 814
}
815
 
816
 
817
inline Sorting()
818
{
819
	dword k=0, l=1;
4897 leency 820
	dword file_off;
3363 leency 821
	int i;
5606 pavelyakov 822
	if (!strncmp(#path,"/",2)) //do not sort
3363 leency 823
	{
5591 pavelyakov 824
		for(k=1;k
3363 leency 825
		return;
826
	}
5591 pavelyakov 827
	for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
3363 leency 828
	{
4897 leency 829
		if (!real_files_names_case) strttl(file_off+40);
830
		if (TestBit(ESDWORD[file_off],4)) //directory?
3363 leency 831
		{
832
			file_mas[k]=j;
833
			k++;
834
		}
835
		else
836
		{
3434 leency 837
			file_mas[files.count-l]=j;
3363 leency 838
			l++;
839
		}
840
	}
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
5606 pavelyakov 847
	if (k>0) && (!strncmp(file_mas[0]*304+buf+72,"..",3))
848
		for(k--; k>0; k--;) if (!strncmp(file_mas[k]*304+buf+72,"..",3)) {file_mas[k]>
3363 leency 849
}
850
 
851
 
852
void Del_Form()
853
{
5512 punk_joker 854
	dword selected_offset2;
855
	int cont = 0;
856
	byte f_count[128];
5581 leency 857
	int dform_x = files.w - 220 / 2 + files.x;
5606 pavelyakov 858
	if (!strncmp(#file_name,".",2)) || (!strncmp(#file_name,"..",2)) return;
4002 leency 859
	if (del_active==2)
3991 leency 860
	{
4002 leency 861
		if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
3991 leency 862
	}
863
	else
864
	{
4002 leency 865
		if (!files.count) return;
5674 pavelyakov 866
		DrawPopup(dform_x,160,220,85,1,system.color.work,system.color.work_graph);
867
		WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,system.color.work_text,T_DELETE_FILE);
5512 punk_joker 868
		for (i=0; i
4002 leency 869
		{
5512 punk_joker 870
			selected_offset2 = file_mas[i]*304 + buf+32 + 7;
871
			if (ESBYTE[selected_offset2]) cont++;
4002 leency 872
		}
5512 punk_joker 873
		if (cont)
874
		{
5576 pavelyakov 875
			sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,cont,DEL_MORE_FILES_2);
5674 pavelyakov 876
			WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,system.color.work_text,#f_count);
5512 punk_joker 877
		}
4002 leency 878
		else
879
		{
5591 pavelyakov 880
			if (strlen(#file_name)<28)
5512 punk_joker 881
			{
5674 pavelyakov 882
				WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,system.color.work_text,"?");
883
				WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,system.color.work_text,#file_name);
5512 punk_joker 884
			}
885
			else
886
			{
887
				WriteText(164+dform_x,190,0x80,0,"...?");
888
				ESI = 24;
889
				WriteText(dform_x+20,190,0,0,#file_name);
890
			}
4002 leency 891
		}
892
		DrawFlatButton(dform_x+27,208,70,20,301,0xFFB6B5,T_YES);
893
		DrawFlatButton(dform_x+120,208,70,20,302,0xC6DFC6,T_NO);
894
		del_active=1;
3991 leency 895
	}
3363 leency 896
}
897
 
4022 leency 898
int del_error;
899
int Del_File2(dword way)
3980 punk_joker 900
{
901
	dword dirbuf, fcount, i, filename;
4022 leency 902
	int error;
903
	char del_from[4096];
904
	if (isdir(way))
3997 leency 905
	{
4022 leency 906
		if (error = GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL)) del_error = error;
3997 leency 907
		for (i=0; i
3980 punk_joker 908
		{
4002 leency 909
			if (CheckEvent()==evReDraw) draw_window();
3997 leency 910
			filename = i*304+dirbuf+72;
5591 pavelyakov 911
			sprintf(#del_from,"%s/%s",way,filename);
3997 leency 912
			if ( TestBit(ESDWORD[filename-40], 4) )
5581 leency 913
			{
3997 leency 914
				Del_File2(#del_from);
5581 leency 915
			}
3997 leency 916
			else
4022 leency 917
			{
918
				if (error = DeleteFile(#del_from)) del_error = error;
919
			}
3980 punk_joker 920
		}
3997 leency 921
	}
4022 leency 922
	if (error = DeleteFile(way)) del_error = error;
3980 punk_joker 923
}
924
 
925
 
3363 leency 926
void Del_File(byte dodel)
4022 leency 927
{
4896 punk_joker 928
	byte del_from[4096];
5214 punk_joker 929
	dword selected_offset2;
930
	int tst, count, i;
4896 punk_joker 931
 
3980 punk_joker 932
	if (dodel==true)
3363 leency 933
	{
4002 leency 934
		del_active=2;
3997 leency 935
		if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
4022 leency 936
		del_error = 0;
5214 punk_joker 937
 
5513 punk_joker 938
		if (selected_count)
5214 punk_joker 939
		{
5513 punk_joker 940
   		   for (i=0; i
941
           {
942
                selected_offset2 = file_mas[i]*304 + buf+32 + 7;
943
                if (ESBYTE[selected_offset2]) {
5591 pavelyakov 944
					sprintf(#del_from,"%s%s",#path,file_mas[i]*304+buf+72);
5513 punk_joker 945
                    Del_File2(#del_from);
946
                }
947
            }
5214 punk_joker 948
		}
949
		else
950
		{
5513 punk_joker 951
		   Del_File2(#file_path);
5214 punk_joker 952
		}
4022 leency 953
		if (del_error) Write_Error(del_error);
3363 leency 954
 	}
955
	del_active=0;
3997 leency 956
	DeleteButton(301);
957
	DeleteButton(302);
3444 leency 958
	Open_Dir(#path,WITH_REDRAW);
3363 leency 959
}
960
 
961
 
962
void SelectFile(dword that_file)
963
{
3434 leency 964
	files.first=files.current=0;
3363 leency 965
   	Open_Dir(#path,ONLY_OPEN);
4225 punk_joker 966
	if (!real_files_names_case) strttl(that_file);
3434 leency 967
	for (i=files.count-1; i>=0; i--;)
3363 leency 968
		if (!strcmp(file_mas[i]*304+buf+72,that_file)) break;
3444 leency 969
	List_Current(i);
3363 leency 970
	List_ReDraw();
971
}
972
 
973
 
974
void Dir_Up()
975
{
976
	char cur_folder[4096];
977
	i=strlen(#path)-1;
978
	if (i==0) return;
979
	path[i]=0x00;
980
	i = strrchr(#path, '/');
981
	strcpy(#cur_folder, #path+i);
982
	path[i]=0x00;
983
	SelectFile(#cur_folder);
984
}
985
 
5444 leency 986
void Open(byte rez)
3434 leency 987
{
5443 punk_joker 988
	byte temp[4096];
5513 punk_joker 989
	selected_count = 0;
5443 punk_joker 990
	if (rez)
991
	{
5606 pavelyakov 992
		if (!strncmp(#file_name,"..",3)) return;
5443 punk_joker 993
		strcpy(#temp, #file_path);
994
		if (path[strlen(#temp)-1]!='/') chrcat(#temp, '/'); //need "/" in the end
995
		RunProgram("/sys/File Managers/Eolite", #temp);
996
		return;
997
	}
3444 leency 998
	if (!files.count) return;
3441 leency 999
	if (!itdir)
3434 leency 1000
	{
5401 leency 1001
		if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
3434 leency 1002
	}
1003
	else
1004
	{
5606 pavelyakov 1005
		if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
3434 leency 1006
		strcpy(#path, #file_path);
1007
		if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //need "/" in the end
1008
		files.first=files.current=0;
3444 leency 1009
		Open_Dir(#path,WITH_REDRAW);
3434 leency 1010
	}
1011
}
3363 leency 1012
 
3434 leency 1013
 
1014
inline fastcall void GoBack()
3363 leency 1015
{
1016
	char cur_folder[4096];
1017
	strcpy(#cur_folder, GetCurrentFolder());
1018
	if (HistoryPath(GO_BACK)) SelectFile(#cur_folder);
1019
}
1020
 
5397 punk_joker 1021
void ShowOpenWithDialog()
1022
{
1023
	byte param[4097];
5591 pavelyakov 1024
	sprintf(#param,"~%s",#file_path);
5397 punk_joker 1025
	RunProgram("/sys/@open", #param);
1026
}
1027
 
5555 punk_joker 1028
void NewElement(byte newf)
1029
{
5557 punk_joker 1030
	BDVK element_info;
5581 leency 1031
	byte del_rezult, copy_rezult, info_result;
5555 punk_joker 1032
	if (newf)
1033
	{
5591 pavelyakov 1034
		sprintf(#temp,"%s%s",#path,new_file_ed.text);
5581 leency 1035
		info_result = GetFileInfo(#temp, #element_info);
5571 punk_joker 1036
		switch(new_element_active)
5555 punk_joker 1037
		{
5581 leency 1038
			case CREATE_FILE:
1039
				if (info_result==5)
5557 punk_joker 1040
				{
5571 punk_joker 1041
					WriteFile(0, 0, #temp);
1042
					if (EAX)
1043
					{
1044
						Write_Error(EAX);
1045
						ShowMessage(NOT_CREATE_FILE, 150);
1046
					}
5557 punk_joker 1047
				}
5571 punk_joker 1048
				else
5557 punk_joker 1049
				{
5620 leency 1050
					notify(FS_ITEM_ALREADY_EXISTS);
5557 punk_joker 1051
				}
5581 leency 1052
				break;
1053
			case CREATE_FOLDER:
1054
				if (info_result==5)
5571 punk_joker 1055
				{
1056
					CreateDir(#temp);
1057
					if (EAX)
1058
					{
1059
						Write_Error(EAX);
1060
						ShowMessage(NOT_CREATE_FOLDER, 150);
1061
					}
1062
				}
1063
				else
1064
				{
5620 leency 1065
					notify(FS_ITEM_ALREADY_EXISTS);
5571 punk_joker 1066
				}
5581 leency 1067
				break;
1068
			case RENAME_ITEM:
1069
				if (info_result==5)
5571 punk_joker 1070
				{
1071
					if (itdir)
1072
					{
1073
						if (del_rezult = DeleteFile(#file_path))
1074
						{
1075
							Write_Error(del_rezult);
1076
							ShowMessage(T_DEL_ERROR_1, 150);
1077
							return;
1078
						}
1079
						if (CreateDir(#temp)) CreateDir(#file_path);
1080
						Open_Dir(#path,WITH_REDRAW);
1081
						SelectFile(new_file_ed.text);
1082
					}
1083
					else
1084
					{
1085
						if (copy_rezult = CopyFile(#file_path,#temp))
1086
						{
1087
							Write_Error(copy_rezult);
1088
						}
1089
						else
1090
						{
1091
							Del_File(true);
1092
							SelectFile(new_file_ed.text);
1093
						}
1094
					}
1095
				}
1096
				else
1097
				{
5620 leency 1098
					notify(FS_ITEM_ALREADY_EXISTS);
5571 punk_joker 1099
				}
5555 punk_joker 1100
		}
5557 punk_joker 1101
		new_element_active = 0;
1102
		Open_Dir(#path,WITH_REDRAW);
1103
		SelectFile(new_file_ed.text);
5555 punk_joker 1104
	}
1105
	new_element_active = 0;
5557 punk_joker 1106
	Open_Dir(#path,WITH_REDRAW);
5555 punk_joker 1107
}
1108
 
5571 punk_joker 1109
void NewElement_Form(byte crt, dword strng)
5555 punk_joker 1110
{
1111
	int dform_x=files.w-220/2+files.x;
5557 punk_joker 1112
	if (!new_element_active)
5555 punk_joker 1113
	{
5557 punk_joker 1114
		new_element_active = crt;
5571 punk_joker 1115
		strcpy(#new_element_name, strng);
1116
		new_file_ed.size = new_file_ed.pos = strlen(strng);
5555 punk_joker 1117
	}
5674 pavelyakov 1118
	DrawPopup(dform_x,160,220,85,1,system.color.work,system.color.work_graph);
5581 leency 1119
	new_file_ed.left = dform_x+24;
5555 punk_joker 1120
	edit_box_draw  stdcall (#new_file_ed);
5581 leency 1121
	DrawRectangle(new_file_ed.left-1, new_file_ed.top-1, new_file_ed.width+2, 16, 0xFFFfff);
5674 pavelyakov 1122
	DrawRectangle(new_file_ed.left-2, new_file_ed.top-2, new_file_ed.width+4, 18, system.color.work_graph);
5591 pavelyakov 1123
	if (new_element_active==3) DrawFlatButton(dform_x+22,208,85,22,301,0xFFB6B5,T_RENAME);
1124
	else DrawFlatButton(dform_x+27,208,70,22,301,0xFFB6B5,T_CREATE);
5581 leency 1125
	DrawFlatButton(dform_x+120,208,70,22,302,0xC6DFC6,T_CANCEL);
5555 punk_joker 1126
}
1127
 
5576 pavelyakov 1128
void FnProcess(byte N)
3434 leency 1129
{
1130
	switch(N)
1131
	{
1132
		case 1:
4395 punk_joker 1133
			if (!active_about)
1134
			{
5576 pavelyakov 1135
				//SwitchToAnotherThread();
1136
				about_stak = malloc(4096);
1137
				about_window = CreateThread(#about_dialog,about_stak+4092);
4395 punk_joker 1138
				break;
1139
			}
1140
			else
1141
			{
1142
				ActivateWindow(GetProcessSlot(about_window));
1143
			}
3434 leency 1144
			break;
1145
		case 2:
1146
			if (!files.count) break;
5581 leency 1147
			NewElement_Form(RENAME_ITEM, #file_name);
3434 leency 1148
			break;
1149
		case 3:
5591 pavelyakov 1150
			if (!itdir) RunProgram("/sys/tinypad", #file_path);
3434 leency 1151
			break;
1152
		case 4:
5591 pavelyakov 1153
			if (!itdir) RunProgram("/sys/develop/heed", #file_path);
3434 leency 1154
			break;
3440 leency 1155
		case 5: //refresh cur dir & devs
3854 leency 1156
			Tip(56, T_DEVICES, 55, "-");
3440 leency 1157
			Open_Dir(#path,WITH_REDRAW);
1158
			pause(10);
5441 leency 1159
			LoadIniSettings();
1160
			GetSystemDiscs();
3444 leency 1161
			Open_Dir(#path,WITH_REDRAW);
3440 leency 1162
			DrawLeftPanel();
3434 leency 1163
			break;
1164
		case 6:
5581 leency 1165
			NewElement_Form(CREATE_FOLDER, T_NEW_FOLDER);
3434 leency 1166
			break;
1167
		case 7:
5581 leency 1168
			NewElement_Form(CREATE_FILE, T_NEW_FILE);
3434 leency 1169
			break;
5447 punk_joker 1170
		case 8:
5576 pavelyakov 1171
			//SwitchToAnotherThread();
1172
			properties_stak = malloc(8096);
1173
			CreateThread(#properties_dialog, properties_stak+8092);
5447 punk_joker 1174
			break;
3434 leency 1175
		case 10: //F10
5416 punk_joker 1176
			if (!active_settings)
1177
			{
5576 pavelyakov 1178
				//SwitchToAnotherThread();
1179
				settings_stak = malloc(4096);
1180
				settings_window = CreateThread(#settings_dialog, settings_stak+4092);
5416 punk_joker 1181
				break;
1182
			}
1183
			else
1184
			{
1185
				ActivateWindow(GetProcessSlot(settings_window));
1186
			}
3434 leency 1187
			break;
1188
	}
1189
}
1190
 
5435 leency 1191
//need to remove these functiones, they are a very old shit :)
1192
dword onTop(dword down,up) {EAX=Form.height-GetSkinHeight()-down-up;}
3434 leency 1193
 
5435 leency 1194
 
3363 leency 1195
stop: