Subversion Repositories Kolibri OS

Rev

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