Subversion Repositories Kolibri OS

Rev

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