Subversion Repositories Kolibri OS

Rev

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