Subversion Repositories Kolibri OS

Rev

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