Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
3363 leency 1
//Leency & Veliant 2008-2013
2
//GNU GPL licence.
3
 
4022 leency 4
#ifndef AUTOBUILD
5
#include "lang.h--"
6
#endif
7
 
3363 leency 8
//libraries
9
#define MEMSIZE 0xA0000
10
#include "..\lib\kolibri.h"
11
#include "..\lib\strings.h"
12
#include "..\lib\mem.h"
13
#include "..\lib\dll.h"
14
#include "..\lib\lib.obj\box_lib.h"
15
#include "..\lib\file_system.h"
16
#include "..\lib\figures.h"
3412 leency 17
#include "..\lib\encoding.h"
3434 leency 18
#include "..\lib\list_box.h"
19
#include "..\lib\copyf.h"
3363 leency 20
//images
21
#include "imgs\toolbar.txt"
22
#include "imgs\left_p.txt"
23
 
3848 punk_joker 24
#ifdef LANG_RUS
25
	?define T_FILE "Файл"
26
	?define T_TYPE "Тип"
27
	?define T_SIZE "Размер"
28
	?define T_NEW_FOLDER "Новая папка"
29
	?define T_NEW_FILE "Новый файл"
30
	?define T_DELETE_FILE "Вы действительно хотите удалить"
31
	?define T_YES "Да"
32
	?define T_NO "Нет"
33
	?define T_DEL_ERROR_1 "Ошибка. Папка не пустая."
3997 leency 34
	?define WAIT_DELETING_FOLDER "Удаляется папка. Подожите..."
3848 punk_joker 35
	?define NOT_CREATE_FOLDER "Не удалось создать папку."
36
	?define NOT_CREATE_FILE "Не удалось создать файл."
37
	?define ERROR_1 "Ошибка при загрузке библиотеки /rd/1/lib/box_lib.obj"
3883 leency 38
	?define T_PASTE_WINDOW "Копирую..."
39
	?define T_PASTE_WINDOW_TEXT "Копируется файл:"
4022 leency 40
	?define T_CANCEL_PASTE "Копирование прекращено. Папка скопирована не полностью."
3933 kaitz 41
#elif LANG_EST
42
	?define T_FILE "Fail"
43
	?define T_TYPE "T№№p"
44
	?define T_SIZE "Suurus"
45
	?define T_NEW_FOLDER "Uus kataloog"
46
	?define T_NEW_FILE "Uus fail"
47
	?define T_DELETE_FILE "Kas sa tahad tїesti kustutada"
48
	?define T_YES "Jah"
49
	?define T_NO "Ei"
50
	?define T_DEL_ERROR_1 "Viga. Kataloog ei ole t№hi."
3997 leency 51
	?define WAIT_DELETING_FOLDER "Deleting folder. Please, wait..."
3933 kaitz 52
	?define NOT_CREATE_FOLDER "Kataloogi ei saa luua."
53
	?define NOT_CREATE_FILE "Faili ei saa luua."
54
	?define ERROR_1 "Viga teegi laadimisel /rd/1/lib/box_lib.obj"
55
	?define T_PASTE_WINDOW "Kopeerin..."
56
	?define T_PASTE_WINDOW_TEXT "Kopeerin faili:"
4022 leency 57
	?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
3848 punk_joker 58
#else
59
	?define T_FILE "File"
60
	?define T_TYPE "Type"
61
	?define T_SIZE "Size"
62
	?define T_NEW_FOLDER "New folder"
63
	?define T_NEW_FILE "New file"
64
	?define T_DELETE_FILE "Do you really want to delete"
65
	?define T_YES "Yes"
66
	?define T_NO "No"
67
	?define T_DEL_ERROR_1 "Error. Folder isn't empty."
3997 leency 68
	?define WAIT_DELETING_FOLDER "Deleting folder. Please, wait..."
3848 punk_joker 69
	?define NOT_CREATE_FOLDER "Folder can not be created."
70
	?define NOT_CREATE_FILE "File can not be created."
71
	?define ERROR_1 "Error while loading library /rd/1/lib/box_lib.obj"
3883 leency 72
	?define T_PASTE_WINDOW "Copying..."
73
	?define T_PASTE_WINDOW_TEXT "Copying file:"
4022 leency 74
	?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
3848 punk_joker 75
#endif
76
 
3444 leency 77
enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir
78
 
4028 leency 79
#define TITLE "Eolite File Manager v1.98.4"
80
#define ABOUT_TITLE "Eolite v1.98.4"
3363 leency 81
dword col_work    = 0xE4DFE1;
3444 leency 82
dword col_border  = 0x9098B0; //A0A0B8; //0x819FC5;
3363 leency 83
dword col_padding = 0xC8C9C9;
84
dword col_selec   = 0x94AECE;
85
dword col_lpanel  = 0x00699C;
86
 
3434 leency 87
int toolbar_buttons_x[7]={9,46,85,134,167,203};
88
char tmp_disk_del_param[3]="d0";
89
struct path_string { char Item[4096]; };
3363 leency 90
 
3434 leency 91
llist files;
92
 
93
byte
3363 leency 94
	path[4096],
95
	file_path[4096],
3404 leency 96
	file_name[256],
3434 leency 97
	temp[4096];
98
byte
3439 leency 99
	rename_active=0,
100
	del_active=0,
3434 leency 101
	show_dev_name=1,
102
	sort_num=2,
3441 leency 103
	itdir;
3363 leency 104
 
105
proc_info Form;
106
mouse m;
4022 leency 107
int mouse_dd, scroll_used, scroll_size, sorting_arrow_x;
3434 leency 108
dword buf, off;
109
dword file_mas[6898];
110
int j, i;
4028 leency 111
int action_buf;
3363 leency 112
 
4028 leency 113
edit_box edit2 = {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xffffff,0,248,#file_name,#mouse_dd,64,6,6};
3434 leency 114
PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0};
3363 leency 115
PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
116
 
3695 leency 117
#include "include\copypaste.h"
3363 leency 118
#include "include\some_code.h"
119
#include "include\sorting.h"
120
#include "include\icons_f.h"
121
#include "include\ini.h"
122
#include "include\left_panel.h"
123
#include "include\history.h"
3434 leency 124
#include "include\file_menu.h"
3695 leency 125
#include "include\about_dialog.h"
3363 leency 126
 
127
void main()
128
{
3444 leency 129
	word key, id, can_show, can_select, m_selected;
3363 leency 130
 
3434 leency 131
	files.line_h=18;
3363 leency 132
	mem_Init();
3848 punk_joker 133
	if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(ERROR_1);
3434 leency 134
	SystemDiscsGet();
3432 leency 135
	GetIni(1);
3363 leency 136
	if (param)
137
	{
138
		strcpy(#path, #param);
3434 leency 139
		if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //add "/" to the end of the string
3363 leency 140
	}
141
	else
3695 leency 142
	{
3432 leency 143
		strcpy(#path, "/rd/1/");
3695 leency 144
	}
3363 leency 145
	Open_Dir(#path,ONLY_OPEN);
3432 leency 146
	SetEventMask(0x27);
3434 leency 147
	loop() switch(WaitEvent())
3363 leency 148
	{
149
		case evMouse:
3434 leency 150
			IF (del_active) break;
3363 leency 151
			id=GetProcessSlot(Form.ID);
3444 leency 152
			IF (id!=GetActiveProcess()) || (Form.status_window>2) break;
3434 leency 153
			IF (rename_active) { edit_box_mouse stdcall(#edit2); break; }
3363 leency 154
 
155
			m.get();
156
 
3444 leency 157
			if (m.x > files.x) && (m.x < files.x + files.w) && (m.y > files.y) && (m.y < files.y+files.h) && (!can_select)
3363 leency 158
			{
3444 leency 159
				m_selected = m.y - 57 / files.line_h;
3434 leency 160
				if (m.lkm) can_select = 1;
161
				if (m.pkm)
162
				{
163
					can_show = 1;
164
					if (m.y - 57 / files.line_h != files.current) can_select = 1;
165
				}
166
			}
167
 
168
			//select/open file {
169
			if (!m.lkm) && (!m.pkm) && (can_select)
170
			{
171
				can_select = 0;
3695 leency 172
				if (m.y>=57)
173
				{
174
					id = m.y - 57 / files.line_h;
175
					if (id!=m_selected)
176
					{
177
						can_show=0;
178
						break;
179
					}
180
					if (files.current!=id)
3876 leency 181
					{
182
						if (id
183
					}
3695 leency 184
					else
185
						Open();
186
				}
3434 leency 187
			};
188
			// } select/open file
189
 
190
			//file menu {
191
			if (!m.pkm) && (!m.lkm) && (can_show)
192
			{
193
				can_show = 0;
3695 leency 194
				if (m.y>=57)
195
				{
196
					SwitchToAnotherThread();
197
					CreateThread(#FileMenu,#menu_stak);
198
				}
3434 leency 199
				break;
200
			}
201
			// } file menu
3363 leency 202
 
3434 leency 203
			if (m.vert)
204
			{
205
				files.MouseScroll(m.vert);
206
				List_ReDraw();
207
				break;
208
			}
209
 
3363 leency 210
			if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>40) && (m.y<57)
211
			{
212
				IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),41,14,14,0xC7C7C7,0xFFFFFF);
3434 leency 213
				WHILE (m.lkm==1) && (files.first>0)
3363 leency 214
				{
3434 leency 215
					pause(8);
216
					files.first--;
3363 leency 217
					List_ReDraw();
218
					m.get();
219
				}
220
				DrawRectangle3D(onLeft(26,0),41,14,14,0xFFFFFF,0xC7C7C7);
221
			}
222
 
223
			if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>onTop(22,0)+1) && (m.y
224
			{
225
				IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xC7C7C7,0xFFFFFF);
3434 leency 226
				while (m.lkm==1) && (files.first
3363 leency 227
				{
3434 leency 228
					pause(8);
229
					files.first++;
3363 leency 230
					List_ReDraw();
231
					m.get();
232
				}
233
				DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xFFFFFF,0xC7C7C7);
234
			}
235
 
3434 leency 236
			//Scrooll
237
			if (!m.lkm) && (scroll_used) { scroll_used=NULL; Scroll(); }
238
			if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>56) && (m.y
3363 leency 239
 
240
			if (scroll_used)
241
			{
3434 leency 242
				IF (scroll_size/2+57>m.y) || (m.y<0) || (m.y>4000) m.y=scroll_size/2+57; //anee eo?ni? iaa ieiii
243
				id=files.first;
3363 leency 244
				j= scroll_size/2;
3434 leency 245
				files.first = m.y -j -57 * files.count;
246
				files.first /= onTop(22,57);
247
				IF (files.visible+files.first>files.count) files.first=files.count-files.visible;
3444 leency 248
				IF (id!=files.first) List_ReDraw();
3363 leency 249
			}
250
			break;
251
//Button pressed-----------------------------------------------------------------------------
252
		case evButton:
253
			id=GetButtonID();
3439 leency 254
			if (id==1) ExitProcess();
255
			if (rename_active) break;
256
			if (del_active)
3363 leency 257
			{
258
				IF (id==301) || (id==302) Del_File(302-id);
259
				break;
260
			}
3439 leency 261
 
3363 leency 262
			switch(id)
263
			{
264
				case 21: //Back
265
						GoBack();
266
						break;
267
				case 22: //Forward
268
						if (HistoryPath(GO_FORWARD))
269
						{
3434 leency 270
							files.first=files.current=NULL; //aaa?o nienea
3363 leency 271
							Open_Dir(#path,WITH_REDRAW);
272
						}
273
						break;
274
				case 23: //up!
275
						Dir_Up();
276
						break;
277
				case 24: //cut
3846 punk_joker 278
						Copy(#file_path, CUT);
3444 leency 279
						break;
3363 leency 280
				case 25: //copy
3846 punk_joker 281
						Copy(#file_path, NOCUT);
3444 leency 282
						break;
3363 leency 283
				case 26: //paste
3444 leency 284
						CreateThread(#Paste,#copy_stak);
3363 leency 285
						break;
286
				case 31...33: //sort
4022 leency 287
						IF(sort_num==1) DrawFilledBar(sorting_arrow_x,42,6,10);
288
						IF(sort_num==2) DrawFilledBar(sorting_arrow_x,42,6,10);
289
						IF(sort_num==3) DrawFilledBar(sorting_arrow_x,42,6,10);
3363 leency 290
						sort_num=id-30;
3434 leency 291
						Open_Dir(#path,WITH_REDRAW);
3363 leency 292
						break;
3434 leency 293
				case 50...60: //Actions
3444 leency 294
						FnProcess(id-50);
3363 leency 295
						break;
296
				case 100...120:
297
					DEVICE_MARK:
3444 leency 298
						DrawRectangle(17,id-100*16+74,159,16, 0); //auaaeaiea
3363 leency 299
						strcpy(#path, #disk_list[id-100].Item);
3434 leency 300
						files.first=files.current=0;
3444 leency 301
						Open_Dir(#path,WITH_REDRAW);
3363 leency 302
						pause(5);
3444 leency 303
						DrawRectangle(17,id-100*16+74,159,16, 0xFFFFFF);
3363 leency 304
						break;
305
				case 130...160:
306
						tmp_disk_del_param[1]=disk_list[id-130].Item[4];
307
						RunProgram("/sys/tmpdisk", #tmp_disk_del_param);
308
						pause(10);
3434 leency 309
						SystemDiscsGet();
3363 leency 310
						Open_Dir(#path,WITH_REDRAW);
311
						DrawLeftPanel();
312
						break;
313
			}
314
			break;
315
//Key pressed-----------------------------------------------------------------------------
316
		case evKey:
317
			key = GetKey();
318
			if (Form.status_window>2) break;
319
			IF (del_active)
320
			{
321
				IF (key==013) Del_File(true);
322
				IF (key==027) Del_File(false);
323
				break;
324
			}
3444 leency 325
			IF (edit2.flags!=64) && (key!=13) && (key!=27)
3363 leency 326
			{
327
				EAX=key<<8;
328
				edit_box_key stdcall (#edit2);
329
				break;
330
			}
331
			switch (key)
332
			{
333
					case 209...217:
334
							id=key-110;
335
							IF (id-100>=disc_num) break;
336
							GOTO DEVICE_MARK;
3434 leency 337
					case 008:
3363 leency 338
							//GoBack();
339
							Dir_Up();
340
							break;
3434 leency 341
					case 004: //Ctrl+D set as bg
3363 leency 342
							strcpy(#temp, "\\S__");
343
							strcat(#temp, #file_path);
344
							RunProgram("/sys/media/kiv", #temp);
345
							break;
3434 leency 346
					case 014: //Ctrl+N new window
3363 leency 347
							IF (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD);
348
							RunProgram("/sys/File Managers/Eolite", #path);
349
							break;
350
					case 024: //Ctrl+X
3444 leency 351
							Copy(#file_path, CUT);
352
							break;
3363 leency 353
					case 003: //Ctrl+C
3444 leency 354
							Copy(#file_path, NOCUT);
3363 leency 355
							break;
356
					case 022: //Ctrl+V
3444 leency 357
							CreateThread(#Paste,#copy_stak);
3363 leency 358
							break;
359
					case 027: //Esc
360
							IF (rename_active==1) ReName(false);
361
							break;
362
					case 013: //Enter
363
							IF (rename_active==1) {ReName(true); break;}
3434 leency 364
							Open();
3363 leency 365
							break;
366
					case 178: //up
3444 leency 367
							List_Current(-1);
3363 leency 368
							break;
369
					case 177: //down
3444 leency 370
							List_Current(1);
3363 leency 371
							break;
372
					case 180: //home
3434 leency 373
							files.first=0;
374
							files.current=0;
3363 leency 375
							List_ReDraw();
376
							break;
377
					case 181: //end
3447 leency 378
							files.first = files.count - files.visible;
379
							files.current = files.visible - 1;
3363 leency 380
							List_ReDraw();
381
							break;
382
					case 183: //Page Down
3444 leency 383
							List_Current(files.visible-1);
3363 leency 384
							break;
385
					case 184: //Page Up
3444 leency 386
							List_Current(-files.visible+1);
3363 leency 387
							break;
3434 leency 388
					case 182: //del
389
							Del_Form();
3363 leency 390
							break;
3434 leency 391
					case 050...059: //F1-F10
3444 leency 392
							FnProcess(key-49);
3363 leency 393
							break;
394
					default:
3434 leency 395
							for (i=files.current+files.first+1; i
3363 leency 396
							{
397
								strcpy(#temp, file_mas[i]*304+buf+72);
398
								IF (temp[0]==key) || (temp[0]==key-32)
399
								{
3444 leency 400
									List_Current(i-files.current-files.first);
3363 leency 401
									break;
402
								}
403
							}
404
			}
405
			break;
406
		case evReDraw:
4028 leency 407
			if (action_buf) { menu_action(action_buf); action_buf=0;}
3363 leency 408
			draw_window();
409
	}
410
}
411
 
4028 leency 412
void menu_action(dword id)
413
{
414
	if (id==COPY_PASTE_END)
415
	{
416
		FnProcess(5);
417
		SelectFile(#copy_to+strrchr(#copy_to,'/'));
418
	}
419
	if (id==100) Open();
420
	if (id==201) notify("Not compleated yet");
421
	if (id==202) FnProcess(3); //F3
422
	if (id==203) FnProcess(4); //F4
423
	if (id==104) Copy(#file_path, NOCUT);
424
	if (id==105) Copy(#file_path, CUT);
425
	if (id==106) CreateThread(#Paste,#copy_stak);
426
	if (id==107) FnProcess(2);
427
	if (id==108) Del_Form();
428
	if (id==109) FnProcess(5);
429
}
3363 leency 430
 
4028 leency 431
 
3444 leency 432
void draw_window()
433
{
434
	DefineAndDrawWindow(40,20,550,500,0x73,col_work,TITLE);
435
	GetProcessInfo(#Form, SelfInfo);
436
	if (Form.status_window>2) return;
437
	files.SetSizes(192, 57, onLeft(192,27), onTop(57,6), disc_num*16+195,files.line_h);
438
	if (Form.height < files.min_h) MoveSize(OLD,OLD,OLD,files.min_h);
439
	if (Form.width<480) MoveSize(OLD,OLD,480,OLD);
440
	GetProcessInfo(#Form, SelfInfo); //if win_size changed
441
 
3363 leency 442
	PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal);
3444 leency 443
	DrawBar(127, 8, 1, 25, col_border);
3363 leency 444
	for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,col_work);
445
	for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,col_work);
3444 leency 446
	DrawBar(246,0,onLeft(246,60),12, col_work); //upper editbox
447
	DrawBar(246,29,onLeft(246,60),5,col_work);  //under editbox
448
	DrawRectangle(246,12,onLeft(66,246),16,col_border);
449
	DefineButton(onLeft(34,0),6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about
3363 leency 450
	PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal);
3434 leency 451
	//main rectangles
3444 leency 452
	DrawRectangle(1,40,Form.cwidth-3,onTop(46,0),col_border);
453
	DrawRectangle(0,39,Form.cwidth-1,onTop(44,0),col_palette[4]); //bg
3363 leency 454
	for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]);
455
	DrawLeftPanel();
3434 leency 456
	//ListBox
3848 punk_joker 457
	DrawFlatButton(files.x,40,onLeft(files.x,168),16,31,col_work,T_FILE);
458
	DrawFlatButton(onLeft(168,0),40,73,16,32,col_work,T_TYPE);
459
	DrawFlatButton(onLeft(95,0),40,68,16,33,col_work,T_SIZE);
3434 leency 460
	DrawBar(onLeft(27,0),57,1,onTop(22,57),col_border); //line to the left from the scroll
461
	DrawFlatButton(onLeft(27,0),40,16,16,0,col_work,"\x18");
462
	DrawFlatButton(onLeft(27,0),onTop(22,0),16,16,0,col_work,"\x19");
3363 leency 463
	Open_Dir(#path,ONLY_SHOW);
464
	if (del_active) Del_Form();
4002 leency 465
	//if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
3444 leency 466
	if (rename_active) FnProcess(2);
3363 leency 467
}
468
 
469
 
470
void KEdit()
471
{
3434 leency 472
	if (Form.width<480) return;
3363 leency 473
	PathShow.area_size_x = Form.cwidth-306;
474
	DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff);
475
	PathShow_prepare stdcall(#PathShow);
476
	PathShow_draw stdcall(#PathShow);
477
}
478
 
479
 
3444 leency 480
void List_Current(int cur)
3363 leency 481
{
3434 leency 482
	if (cur<=0) //up
3363 leency 483
	{
3434 leency 484
		IF (files.first==0) && (files.current<=0) return;
485
		IF (-cur-1
3363 leency 486
		{
3434 leency 487
			Line_ReDraw(0xFFFFFF, files.current);
488
			files.current+=cur;
489
			Line_ReDraw(col_selec, files.current);
3363 leency 490
			return;
491
		}
492
		ELSE
493
		{
3434 leency 494
			IF (-cur
495
			files.current=0;
3363 leency 496
			List_ReDraw();
497
			return;
498
		}
499
	}
3434 leency 500
	else  //down
3363 leency 501
	{
3434 leency 502
		IF (files.first==files.count-files.visible) && (files.current==files.visible-1) return;
503
		IF (files.visible-files.current>cur)
3363 leency 504
		{
3434 leency 505
			Line_ReDraw(0xFFFFFF, files.current);
506
			files.current+=cur;
507
			Line_ReDraw(col_selec, files.current);
3363 leency 508
			return;
509
		}
510
		else
511
		{
3434 leency 512
			IF(files.first+files.current+cur>=files.count)
3363 leency 513
			{
3434 leency 514
				files.first=files.count-files.visible;
515
				files.current=cur-files.first+files.current;
3363 leency 516
				}
517
			ELSE
518
			{
3434 leency 519
				files.first+=cur+files.current-files.visible+1;
520
				files.current=files.visible-1;
3363 leency 521
			}
522
 
3434 leency 523
			IF (files.current<0) || (files.current>files.visible)
3363 leency 524
			{
3434 leency 525
				files.current=files.visible-1;
3363 leency 526
			}
527
			List_ReDraw();
528
		}
529
	}
530
}
531
 
532
 
533
void List_ReDraw()
534
{
3434 leency 535
	int paint_y;
3876 leency 536
	//we are in the end of the list => maximize window => there will be white lines after the last element
3434 leency 537
	if (files.count-files.firstfiles.visible-1)
538
	{ files.first=files.count-files.visible; files.current=files.visible-1; }
3444 leency 539
	for (j=0; j
3434 leency 540
	//in the bottom
541
	paint_y = j * files.line_h + files.y;
542
	DrawBar(files.x,paint_y,files.w,onTop(paint_y,6),0xFFFFFF);
3447 leency 543
	DrawBar(Form.cwidth-159,paint_y,1,onTop(paint_y,6),col_work);
544
	DrawBar(Form.cwidth-86,paint_y,1,onTop(paint_y,6),col_work);
3434 leency 545
	Scroll();
3363 leency 546
}
547
 
3444 leency 548
 
3363 leency 549
void Line_ReDraw(dword color, filenum){
3467 leency 550
	dword text_col=0,
551
	      name_len=0,
552
	      attr,
553
	      y=filenum*files.line_h+57;
3447 leency 554
	DrawBar(files.x,y,3,files.line_h,color);
555
	DrawBar(files.x+19,y,files.w-19,files.line_h,color);
556
	DrawBar(files.x+3,y+17,16,1,color);
557
	if (files.line_h>18) DrawBar(files.x+3,y+18,16,files.line_h-18,color);
558
	if (files.line_h>15) DrawBar(files.x+3,y,16,files.line_h-15,color);
3363 leency 559
 
3434 leency 560
	off=file_mas[filenum+files.first]*304 + buf+72;
3467 leency 561
	attr = ESDWORD[off - 40];
3363 leency 562
 
3467 leency 563
	if (! TestBit(attr, 4) ) //file or folder?
3363 leency 564
	{
3447 leency 565
		Put_icon(off+_strrchr(off,'.'), files.line_h/2-7+y, color);
3434 leency 566
		WriteText(7-strlen(ConvertMemSize(ESDWORD[off-8]))*6+onLeft(75,0),files.line_h-6/2+y,0x80,0,ConvertMemSize(ESDWORD[off-8])); //size
3363 leency 567
	}
568
	else
569
		if (!strcmp("..",off))
3434 leency 570
			Put_icon("..", files.line_h/2-7+y, color);
3363 leency 571
		else
3434 leency 572
			Put_icon("", files.line_h/2-7+y, color);
3467 leency 573
	if ( TestBit(attr, 1) ) || ( TestBit(attr, 2) ) text_col=0xA6A6B7; //system or hiden?
3444 leency 574
	if (color!=0xFFFfff)
3363 leency 575
	{
3467 leency 576
		itdir = TestBit(attr, 4);
3363 leency 577
		strcpy(#file_name, off);
578
		strcpy(#file_path, #path);
3434 leency 579
		strcat(#file_path, #file_name);
3363 leency 580
		if (text_col==0xA6A6B7) text_col=0xFFFFFF;
581
	}
3434 leency 582
	if (Form.width>=480)
583
	{
3447 leency 584
		FileShow.start_x = files.x + 23;
3434 leency 585
		FileShow.font_color = text_col;
586
		FileShow.area_size_x = Form.width - 380;
587
		FileShow.text_pointer = off;
588
		FileShow.start_y = files.line_h/2-3+y;
589
		PathShow_prepare stdcall(#FileShow);
590
		PathShow_draw stdcall(#FileShow);
591
	}
3447 leency 592
	DrawBar(Form.cwidth-159,y,1,files.line_h,col_work); //gray line 1
593
	DrawBar(Form.cwidth-86,y,1,files.line_h,col_work); //gray line 2
3363 leency 594
}
595
 
596
 
3444 leency 597
void Open_Dir(dword dir_path, redraw){
598
	int errornum, maxcount;
3434 leency 599
 
3444 leency 600
	if (redraw!=ONLY_SHOW)
3363 leency 601
	{
3444 leency 602
		if (ESBYTE[dir_path+1]!='\0') ESBYTE[dir_path+strlen(dir_path)-1] = '\0';
3363 leency 603
		if (buf) free(buf);
3444 leency 604
		errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
605
		if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/');
606
		if (errornum)
3363 leency 607
		{
608
			HistoryPath(ADD_NEW_PATH);
609
			GoBack();
610
			Write_Error(errornum);
611
			return;
612
		}
3444 leency 613
		maxcount = sizeof(file_mas)/sizeof(dword)-1;
614
		if (files.count>maxcount) files.count = maxcount;
3363 leency 615
	}
3444 leency 616
	if (files.count!=-1)
3363 leency 617
	{
618
		KEdit();
619
		HistoryPath(ADD_NEW_PATH);
3444 leency 620
		files.visible = files.h / files.line_h;
621
		IF (files.count < files.visible) files.visible = files.count;
4022 leency 622
		IF (sort_num==1) sorting_arrow_x = Form.width+60/2;
623
		IF (sort_num==2) sorting_arrow_x = Form.width-115;
624
		IF (sort_num==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
625
		WriteText(sorting_arrow_x,45,0x80,col_border,"\x19");
3444 leency 626
		IF (redraw!=ONLY_SHOW) Sorting();
627
		IF (redraw!=ONLY_OPEN) List_ReDraw();
3363 leency 628
	}
3444 leency 629
	IF (files.count==-1) && (redraw!=ONLY_OPEN) {files.visible=files.count=0; List_ReDraw();}
3363 leency 630
}
631
 
632
 
633
inline Sorting()
634
{
635
	dword k=0, l=1;
636
	int i;
3434 leency 637
	if (!strcmp(#path,"/")) //do not sort
3363 leency 638
	{
3434 leency 639
		FOR(k=1;k
3363 leency 640
		return;
641
	}
3434 leency 642
	FOR (j=files.count-1, off=files.count-1*304+buf+32; j>=0; j--, off-=304;)  //files | folders
3363 leency 643
	{
644
		strttl(off+40);
3441 leency 645
		if (TestBit(ESDWORD[off],4)) //directory?
3363 leency 646
		{
647
			file_mas[k]=j;
648
			k++;
649
		}
650
		else
651
		{
3434 leency 652
			file_mas[files.count-l]=j;
3363 leency 653
			l++;
654
		}
655
	}
3434 leency 656
	//sorting: files first, then folders
3363 leency 657
	Sort_by_Name(0,k-1);
3434 leency 658
	IF (sort_num==1) Sort_by_Name(k,files.count-1);
659
	IF (sort_num==2) Sort_by_Type(k,files.count-1);
660
	IF (sort_num==3) Sort_by_Size(k,files.count-1);
661
	//".." should be first
3444 leency 662
	IF (k>0) && (strcmp(file_mas[0]*304+buf+72,"..")!=0)
663
		FOR(k--; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) {file_mas[k]>
3363 leency 664
}
665
 
666
 
667
void Del_Form()
668
{
4002 leency 669
	int dform_x=files.w-220/2+files.x;
4022 leency 670
	if (strcmp(#file_name,".")==0) || (strcmp(#file_name,"..")==0) return;
4002 leency 671
	if (del_active==2)
3991 leency 672
	{
4002 leency 673
		if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
3991 leency 674
	}
675
	else
676
	{
4002 leency 677
		if (!files.count) return;
678
		DrawPopup(dform_x,160,220,80,1,col_work,col_border);
679
		WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,0,T_DELETE_FILE);
680
		IF (strlen(#file_name)<28)
681
		{
682
			WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,0,"?");
683
			WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,0,#file_name);
684
		}
685
		else
686
		{
687
			WriteText(164+dform_x,190,0x80,0,"...?");
688
			ESI = 24;
689
			WriteText(dform_x+20,190,0,0,#file_name);
690
		}
691
		DrawFlatButton(dform_x+27,208,70,20,301,0xFFB6B5,T_YES);
692
		DrawFlatButton(dform_x+120,208,70,20,302,0xC6DFC6,T_NO);
693
		del_active=1;
3991 leency 694
	}
3363 leency 695
}
696
 
4022 leency 697
int del_error;
698
int Del_File2(dword way)
3980 punk_joker 699
{
700
	dword dirbuf, fcount, i, filename;
4022 leency 701
	int error;
702
	char del_from[4096];
703
	if (isdir(way))
3997 leency 704
	{
4022 leency 705
		if (error = GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL)) del_error = error;
3997 leency 706
		for (i=0; i
3980 punk_joker 707
		{
4002 leency 708
			if (CheckEvent()==evReDraw) draw_window();
3997 leency 709
			filename = i*304+dirbuf+72;
710
			strcpy(#del_from, way);
711
			chrcat(#del_from, '/');
712
			strcat(#del_from, filename);
713
			if ( TestBit(ESDWORD[filename-40], 4) )
714
				Del_File2(#del_from);
715
			else
4022 leency 716
			{
717
				if (error = DeleteFile(#del_from)) del_error = error;
718
			}
3980 punk_joker 719
		}
3997 leency 720
	}
4022 leency 721
	if (error = DeleteFile(way)) del_error = error;
3980 punk_joker 722
}
723
 
724
 
3363 leency 725
void Del_File(byte dodel)
4022 leency 726
{
3980 punk_joker 727
	if (dodel==true)
3363 leency 728
	{
4002 leency 729
		del_active=2;
3997 leency 730
		if (itdir) ShowMessage(WAIT_DELETING_FOLDER, 0);
4022 leency 731
		del_error = 0;
3980 punk_joker 732
		Del_File2(#file_path);
4022 leency 733
		if (del_error) Write_Error(del_error);
3363 leency 734
 	}
735
	del_active=0;
3997 leency 736
	DeleteButton(301);
737
	DeleteButton(302);
3444 leency 738
	Open_Dir(#path,WITH_REDRAW);
3363 leency 739
}
740
 
741
 
742
void ReName(byte rename)
743
{
3404 leency 744
	int del_rezult, copy_rezult;
3363 leency 745
	char edit_name[256];
746
	rename_active=0;
747
	edit2.flags=64;
748
	if (rename==true)
749
	{
750
		strcpy(#temp, #path);
3434 leency 751
		strcpy(#edit_name, #file_name); //save edit name to select it later
3363 leency 752
		strcat(#temp, #file_name);
3444 leency 753
		if (strcmp(#file_path,#temp)!=0) && (file_name)
754
		if (itdir)
3363 leency 755
		{
3404 leency 756
			del_rezult = DeleteFile(#file_path);
3444 leency 757
			if (del_rezult!=0)
3363 leency 758
			{
3404 leency 759
				Write_Error(del_rezult);
3997 leency 760
				ShowMessage(T_DEL_ERROR_1, 150);
3363 leency 761
				return;
762
			}
763
			ELSE CreateDir(#temp);
3444 leency 764
			Open_Dir(#path,WITH_REDRAW);
3363 leency 765
		}
3877 leency 766
		else
3363 leency 767
		{
3404 leency 768
			copy_rezult = CopyFile(#file_path,#temp);
769
			if (copy_rezult!=0) Write_Error(copy_rezult); else Del_File(true);
3363 leency 770
		}
771
		SelectFile(#edit_name);
772
	}
3434 leency 773
	Line_ReDraw(col_selec,files.current);
3363 leency 774
}
775
 
776
 
777
void SelectFile(dword that_file)
778
{
3434 leency 779
	files.first=files.current=0;
3363 leency 780
   	Open_Dir(#path,ONLY_OPEN);
781
	strttl(that_file);
3434 leency 782
	for (i=files.count-1; i>=0; i--;)
3363 leency 783
		if (!strcmp(file_mas[i]*304+buf+72,that_file)) break;
3444 leency 784
	List_Current(i);
3363 leency 785
	List_ReDraw();
786
}
787
 
788
 
789
void Dir_Up()
790
{
791
	char cur_folder[4096];
792
	i=strlen(#path)-1;
793
	if (i==0) return;
794
	path[i]=0x00;
795
	i = strrchr(#path, '/');
796
	strcpy(#cur_folder, #path+i);
797
	path[i]=0x00;
798
	SelectFile(#cur_folder);
799
}
800
 
3434 leency 801
void Open()
802
{
3444 leency 803
	if (!files.count) return;
3441 leency 804
	if (!itdir)
3434 leency 805
	{
806
		GetIni(0);
807
	}
808
	else
809
	{
810
		if (!strcmp(#file_name,"..")) { Dir_Up(); return; }
811
		strcpy(#path, #file_path);
812
		if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //need "/" in the end
813
		files.first=files.current=0;
3444 leency 814
		Open_Dir(#path,WITH_REDRAW);
3434 leency 815
	}
816
}
3363 leency 817
 
3434 leency 818
 
819
inline fastcall void GoBack()
3363 leency 820
{
821
	char cur_folder[4096];
822
	strcpy(#cur_folder, GetCurrentFolder());
823
	if (HistoryPath(GO_BACK)) SelectFile(#cur_folder);
824
}
825
 
3444 leency 826
void FnProcess(char N)
3434 leency 827
{
828
	switch(N)
829
	{
830
		case 1:
831
			SwitchToAnotherThread();
3444 leency 832
			CreateThread(#about_dialog,#about_stak);
3434 leency 833
			break;
834
		case 2:
835
			if (!files.count) break;
3447 leency 836
			edit2.flags = 100000000000010b; //set active
837
			edit2.left = files.x + 21;
838
			edit2.width = files.w - 26;
3434 leency 839
			edit2.top=files.current*files.line_h+59;
840
			edit2.size=edit2.pos=strlen(#file_name);
841
			edit_box_draw  stdcall (#edit2);
3447 leency 842
			DrawBar(edit2.left,files.current*files.line_h+58,edit2.width+1,1,0xFFFFCC); //bg
3434 leency 843
			rename_active=1;
844
			break;
845
		case 3:
3441 leency 846
			IF (!itdir) RunProgram("/sys/tinypad", #file_path);
3434 leency 847
			break;
848
		case 4:
3441 leency 849
			IF (!itdir) RunProgram("/sys/develop/heed", #file_path);
3434 leency 850
			break;
3440 leency 851
		case 5: //refresh cur dir & devs
3854 leency 852
			Tip(56, T_DEVICES, 55, "-");
3440 leency 853
			Open_Dir(#path,WITH_REDRAW);
854
			pause(10);
855
			GetIni(1);
856
			SystemDiscsGet();
3444 leency 857
			Open_Dir(#path,WITH_REDRAW);
3440 leency 858
			DrawLeftPanel();
3434 leency 859
			break;
860
		case 6:
861
			strcpy(#temp, #path);
3848 punk_joker 862
			strcat(#temp, T_NEW_FOLDER);
3434 leency 863
			CreateDir(#temp);
864
			if (!EAX){
3848 punk_joker 865
				SelectFile(T_NEW_FOLDER);
3444 leency 866
				FnProcess(2);
3434 leency 867
			}
868
			else
869
			{
870
				Write_Error(EAX);
3997 leency 871
				ShowMessage(NOT_CREATE_FOLDER, 150);
3434 leency 872
			}
873
			break;
874
		case 7:
875
			strcpy(#temp, #path);
3848 punk_joker 876
			strcat(#temp, T_NEW_FILE);
3434 leency 877
			WriteFile(0, 0, #temp);
878
			if (!EAX){
3848 punk_joker 879
				SelectFile(T_NEW_FILE);
3444 leency 880
				FnProcess(2);
3434 leency 881
			}
882
			else
883
			{
884
				Write_Error(EAX);
3997 leency 885
				ShowMessage(NOT_CREATE_FILE, 150);
3434 leency 886
			}
887
			break;
888
		case 10: //F10
889
			RunProgram(EDITOR_PATH, abspath("Eolite.ini"));
890
			break;
891
	}
892
}
893
 
894
 
3363 leency 895
stop:
896
 
3444 leency 897
char about_stak[512];
898
char menu_stak[512];
3846 punk_joker 899
char copy_stak[4096];