Subversion Repositories Kolibri OS

Rev

Rev 7878 | Rev 7914 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7878 Rev 7879
1
//Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2020
1
//Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2020
2
//GNU GPL license.
2
//GNU GPL license.
3
 
3
 
4
// 70.5 - get volume info and label
4
// 70.5 - get volume info and label
5
 
5
 
6
#ifndef AUTOBUILD
6
#ifndef AUTOBUILD
7
#include "lang.h--"
7
#include "lang.h--"
8
#endif
8
#endif
9
 
9
 
10
//libraries
10
//libraries
11
#define MEMSIZE 1024 * 720
11
#define MEMSIZE 1024 * 720
12
#include "../lib/clipboard.h"
12
#include "../lib/clipboard.h"
13
#include "../lib/strings.h"
13
#include "../lib/strings.h"
14
#include "../lib/mem.h"
14
#include "../lib/mem.h"
15
#include "../lib/fs.h"
15
#include "../lib/fs.h"
16
#include "../lib/gui.h"
16
#include "../lib/gui.h"
17
#include "../lib/list_box.h"
17
#include "../lib/list_box.h"
18
#include "../lib/random.h"
18
#include "../lib/random.h"
19
#include "../lib/kfont.h"
19
#include "../lib/kfont.h"
20
#include "../lib/collection.h"
20
#include "../lib/collection.h"
21
#include "../lib/copyf.h"
21
#include "../lib/copyf.h"
22
 
22
 
23
#include "../lib/obj/libini.h"
23
#include "../lib/obj/libini.h"
24
#include "../lib/obj/box_lib.h"
24
#include "../lib/obj/box_lib.h"
25
#include "../lib/obj/libimg.h"
25
#include "../lib/obj/libimg.h"
26
 
26
 
27
#include "../lib/patterns/history.h"
27
#include "../lib/patterns/history.h"
28
 
28
 
29
#include "imgs/images.h"
29
#include "imgs/images.h"
30
 
30
 
31
//Button IDs
31
//Button IDs
32
enum {
32
enum {
33
	PATH_BTN = 10,
33
	PATH_BTN = 10,
34
	POPUP_BTN1 = 201,
34
	POPUP_BTN1 = 201,
35
	POPUP_BTN2 = 202,
35
	POPUP_BTN2 = 202,
36
	BREADCRUMB_ID = 300
36
	BREADCRUMB_ID = 300
37
};
37
};
38
 
38
 
39
//NewElement options
39
//NewElement options
40
enum {
40
enum {
41
	CREATE_FILE=1, 
41
	CREATE_FILE=1, 
42
	CREATE_FOLDER, 
42
	CREATE_FOLDER, 
43
	RENAME_ITEM
43
	RENAME_ITEM
44
}; 
44
}; 
45
 
45
 
46
//OpenDir options
46
//OpenDir options
47
enum {
47
enum {
48
	ONLY_SHOW, 
48
	ONLY_SHOW, 
49
	WITH_REDRAW, 
49
	WITH_REDRAW, 
50
	ONLY_OPEN
50
	ONLY_OPEN
51
};
51
};
52
 
52
 
53
_history history;
53
_history history;
54
 
54
 
55
struct Eolite_colors
55
struct Eolite_colors
56
{
56
{
57
	bool  def;
57
	bool  def;
58
	dword lpanel;
58
	dword lpanel;
59
	dword list_vert_line; //vertical line between columns in list
59
	dword list_vert_line; //vertical line between columns in list
60
	dword selec;
60
	dword selec;
61
	dword selec_active;
61
	dword selec_active;
62
	dword selec_inactive;
62
	dword selec_inactive;
63
	dword selec_text;
63
	dword selec_text;
64
	dword list_bg;
64
	dword list_bg;
65
	dword list_gb_text;
65
	dword list_gb_text;
66
	dword list_text_hidden;
66
	dword list_text_hidden;
67
	dword work_gradient[24];
67
	dword work_gradient[24];
68
	dword slider_bg_big;
68
	dword slider_bg_big;
69
	dword slider_bg_left;
69
	dword slider_bg_left;
70
	dword odd_line;
70
	dword odd_line;
71
} col;
71
} col;
72
 
72
 
73
int toolbar_buttons_x[7]={9,46,85,134,167,203};
73
int toolbar_buttons_x[7]={9,46,85,134,167,203};
74
 
74
 
75
bool active_about = false;
75
bool active_about = false;
76
bool active_settings = false;
76
bool active_settings = false;
77
bool _not_draw = false;
77
bool _not_draw = false;
78
bool exif_load = false;
78
bool exif_load = false;
79
bool dir_at_fat16 = NULL;
79
bool dir_at_fat16 = NULL;
80
 
80
 
81
word about_thread_id;
81
word about_thread_id;
82
word settings_window;
82
word settings_window;
83
 
83
 
84
byte del_active=0;
84
byte del_active=0;
85
byte new_element_active=0;
85
byte new_element_active=0;
86
 
86
 
87
llist files, files_active, files_inactive;
87
llist files, files_active, files_inactive;
88
 
88
 
89
byte list_full_redraw;
89
byte list_full_redraw;
90
 
90
 
91
dword buf;
91
dword buf;
92
dword file_mas[6898];
92
dword file_mas[6898];
93
int selected_count;
93
int selected_count;
94
int count_dir;
94
int count_dir;
95
 
95
 
96
byte path[4096];
96
byte path[4096];
97
byte file_path[4096];
97
byte file_path[4096];
98
byte file_name[256];
98
byte file_name[256];
99
byte new_element_name[256];
99
byte new_element_name[256];
100
byte temp[4096];
100
byte temp[4096];
101
bool itdir;
101
bool itdir;
102
 
102
 
103
char active_path[4096], inactive_path[4096];
103
char active_path[4096], inactive_path[4096];
104
 
104
 
105
dword eolite_ini_path[4096];
105
dword eolite_ini_path[4096];
106
_ini ini;
106
_ini ini;
107
 
107
 
108
char scroll_used=false;
108
char scroll_used=false;
109
 
109
 
110
dword about_stak=0,properties_stak=0,settings_stak=0,delete_stak=0;
110
dword about_stak=0,properties_stak=0,settings_stak=0,delete_stak=0;
111
 
111
 
112
proc_info Form;
112
proc_info Form;
113
int sc_slider_h;
113
int sc_slider_h;
114
int action_buf;
114
int action_buf;
115
int rand_n;
115
int rand_n;
116
 
116
 
117
char sort_type=2;
117
char sort_type=2;
118
bool sort_desc=false;
118
bool sort_desc=false;
119
int active_panel=1;
119
int active_panel=1;
120
 
120
 
121
libimg_image icons16_default;
121
libimg_image icons16_default;
122
libimg_image icons16_selected;
122
libimg_image icons16_selected;
123
 
123
 
124
libimg_image icons32_default;
124
libimg_image icons32_default;
125
libimg_image icons32_selected;
125
libimg_image icons32_selected;
126
 
126
 
127
#define STATUS_BAR_H 16;
127
#define STATUS_BAR_H 16;
128
int status_bar_h = 0;
128
int status_bar_h = 0;
129
 
129
 
130
int icon_size = 16;
130
int icon_size = 16;
131
 
131
 
132
edit_box new_file_ed = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x10000000,
132
edit_box new_file_ed = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x10000000,
133
	248,#new_element_name,0,100000000000010b,6,0};
133
	248,#new_element_name,0,100000000000010b,6,0};
134
PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
134
PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
135
byte cmd_free=0;
135
byte cmd_free=0;
136
#include "include\translations.h"
136
#include "include\translations.h"
137
 
137
 
138
#include "include\gui.h"
138
#include "include\gui.h"
139
#include "include\settings.h"
139
#include "include\settings.h"
140
#include "include\progress_dialog.h"
140
#include "include\progress_dialog.h"
141
#include "include\copy_and_delete.h"
141
#include "include\copy_and_delete.h"
142
#include "include\sorting.h"
142
#include "include\sorting.h"
143
#include "include\icons.h"
143
#include "include\icons.h"
144
#include "include\left_panel.h"
144
#include "include\left_panel.h"
145
#include "include\menu.h"
145
#include "include\menu.h"
146
#include "include\about.h"
146
#include "include\about.h"
147
#include "include\properties.h"
147
#include "include\properties.h"
148
#include "include\breadcrumbs.h"
148
#include "include\breadcrumbs.h"
149
 
149
 
150
void load_libraries()
150
void load_libraries()
151
{
151
{
152
	load_dll(boxlib, #box_lib_init,0);
152
	load_dll(boxlib, #box_lib_init,0);
153
	load_dll(libini, #lib_init,1);
153
	load_dll(libini, #lib_init,1);
154
	load_dll(libio,  #libio_init,1);
154
	load_dll(libio,  #libio_init,1);
155
	load_dll(libimg, #libimg_init,1);
155
	load_dll(libimg, #libimg_init,1);
156
}
156
}
157
 
157
 
158
void handle_param()
158
void handle_param()
159
{
159
{
160
	//-p : just show file/folder properties dialog
160
	//-p  : just show file/folder properties dialog
161
	//-v : paste thread
161
	//-d  : delete file/folder
162
	//-d : delete thread
162
	//-v : paste files/folder from clipboard
163
	if (param) && (param[0]=='-') switch (param[1]) 
163
	if (param) && (param[0]=='-') switch (param[1]) 
164
	{
164
	{
165
		case 'p':
165
		case 'p':
166
			strcpy(#file_path, #param + 3);
166
			strcpy(#file_path, #param + 3);
167
			strcpy(#file_name, #param + strrchr(#param, '/'));
167
			strcpy(#file_name, #param + strrchr(#param, '/'));
168
			itdir = dir_exists(#file_path);
168
			itdir = dir_exists(#file_path);
169
			properties_dialog();
169
			properties_dialog();
170
			return;
170
			return;
171
		case 'v':
-
 
172
			cut_active = param[2] - '0';
-
 
173
			strcpy(#path, #param + 4);
-
 
174
			PasteThread();
-
 
175
			return;
-
 
176
		case 'd':
171
		case 'd':
177
			strcpy(#file_path, #param + 3);
172
			strcpy(#file_path, #param + 3);
178
			itdir = dir_exists(#file_path);
173
			itdir = dir_exists(#file_path);
179
			DisplayOperationForm(DELETE_FLAG);
174
			DisplayOperationForm(DELETE_FLAG);
180
			DeleteSingleElement();
175
			DeleteSingleElement();
181
			return;
176
			return;
-
 
177
		case 'v':
-
 
178
			cut_active = param[2] - '0';
-
 
179
			strcpy(#path, #param + 4);
-
 
180
			PasteThread();
-
 
181
			return;
182
	}
182
	}
183
}
183
}
184
 
184
 
185
void main() 
185
void main() 
186
{
186
{
187
	dword id;
187
	dword id;
188
	byte count_sl = 0;
188
	byte count_sl = 0;
189
 
189
 
190
	rand_n = random(80);
190
	rand_n = random(80);
191
 
191
 
192
	load_libraries();
192
	load_libraries();
193
	
193
	
194
	SetAppColors();
194
	SetAppColors();
195
	LoadIniSettings();
195
	LoadIniSettings();
196
	SystemDiscs.Get();
196
	SystemDiscs.Get();
197
 
197
 
198
	handle_param();
198
	handle_param();
199
 
199
 
200
	ESBYTE[0] = NULL;
200
	ESBYTE[0] = NULL;
201
 
201
 
202
	if (param)
202
	if (param)
203
	{
203
	{
204
		if (strlen(#param)>1) && (param[strlen(#param)-1]=='/') param[strlen(#param)-1]=NULL; //no "/" at the end
204
		if (strlen(#param)>1) && (param[strlen(#param)-1]=='/') param[strlen(#param)-1]=NULL; //no "/" at the end
205
 
205
 
206
		if (dir_exists(#param)) {
206
		if (dir_exists(#param)) {
207
			strcpy(#path, #param);
207
			strcpy(#path, #param);
208
		} else {
208
		} else {
209
			notify(T_NOTIFY_APP_PARAM_WRONG);
209
			notify(T_NOTIFY_APP_PARAM_WRONG);
210
		}
210
		}
211
	}
211
	}
212
	
212
	
213
	Open_Dir(#path,ONLY_OPEN);
213
	Open_Dir(#path,ONLY_OPEN);
214
	strcpy(#inactive_path, #path);
214
	strcpy(#inactive_path, #path);
215
	llist_copy(#files_inactive, #files);
215
	llist_copy(#files_inactive, #files);
216
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
216
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
217
	loop() switch(WaitEventTimeout(50))
217
	loop() switch(WaitEventTimeout(50))
218
	{
218
	{
219
		case evMouse:
219
		case evMouse:
220
			if (del_active) || (Form.status_window>2) break;
220
			if (del_active) || (Form.status_window>2) break;
221
			if (new_element_active) 
221
			if (new_element_active) 
222
			{
222
			{
223
				edit_box_mouse stdcall(#new_file_ed);
223
				edit_box_mouse stdcall(#new_file_ed);
224
				break;
224
				break;
225
			}				
225
			}				
226
			
226
			
227
			mouse.get();
227
			mouse.get();
228
 
228
 
229
			ProceedMouseGestures();
229
			ProceedMouseGestures();
230
			
230
			
231
			if (files.MouseOver(mouse.x, mouse.y))
231
			if (files.MouseOver(mouse.x, mouse.y))
232
			{
232
			{
233
				//select file
233
				//select file
234
				if (mouse.key&MOUSE_LEFT) && (mouse.up)
234
				if (mouse.key&MOUSE_LEFT) && (mouse.up)
235
				{
235
				{
236
					if (files.ProcessMouse(mouse.x, mouse.y)) List_ReDraw(); else {
236
					if (files.ProcessMouse(mouse.x, mouse.y)) List_ReDraw(); else {
237
						if (mouse.y - files.y / files.item_h + files.first == files.cur_y) Open(0);
237
						if (mouse.y - files.y / files.item_h + files.first == files.cur_y) Open(0);
238
					}
238
					}
239
				}
239
				}
240
				//file menu
240
				//file menu
241
				if (mouse.key&MOUSE_RIGHT) && (mouse.up)
241
				if (mouse.key&MOUSE_RIGHT) && (mouse.up)
242
				{
242
				{
243
					if (files.ProcessMouse(mouse.x, mouse.y)) List_ReDraw();
243
					if (files.ProcessMouse(mouse.x, mouse.y)) List_ReDraw();
244
					if (getElementSelectedFlag(files.cur_y) == false) selected_count = 0; //on redraw selection would be flashed, see [L001] 
244
					if (getElementSelectedFlag(files.cur_y) == false) selected_count = 0; //on redraw selection would be flashed, see [L001] 
245
					EventShowListMenu();
245
					EventShowListMenu();
246
					break;
246
					break;
247
				}
247
				}
248
			}
248
			}
249
 
249
 
250
			if (mouse.vert)
250
			if (mouse.vert)
251
			{
251
			{
252
				if (files.MouseScroll(mouse.vert)) List_ReDraw();
252
				if (files.MouseScroll(mouse.vert)) List_ReDraw();
253
				break;
253
				break;
254
			}
254
			}
255
 
255
 
256
			if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y-17) && (mouse.y
256
			if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y-17) && (mouse.y
257
			{
257
			{
258
				if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,sc.work_dark,sc.work_light);
258
				if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,sc.work_dark,sc.work_light);
259
				WHILE (mouse.lkm) && (files.first>0)
259
				WHILE (mouse.lkm) && (files.first>0)
260
				{
260
				{
261
					pause(8);
261
					pause(8);
262
					files.first--;
262
					files.first--;
263
					List_ReDraw();
263
					List_ReDraw();
264
					mouse.get();
264
					mouse.get();
265
				}
265
				}
266
				DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,sc.work_light,sc.work_dark);
266
				DrawRectangle3D(files.x+files.w+1,files.y-16,14,14,sc.work_light,sc.work_dark);
267
			}
267
			}
268
 
268
 
269
			if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y+files.h-16) && (mouse.y
269
			if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+16) && (mouse.y>files.y+files.h-16) && (mouse.y
270
			{
270
			{
271
				if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,sc.work_dark,sc.work_light);
271
				if (mouse.lkm) DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,sc.work_dark,sc.work_light);
272
				while (mouse.lkm) && (files.first
272
				while (mouse.lkm) && (files.first
273
				{
273
				{
274
					pause(8);
274
					pause(8);
275
					files.first++;
275
					files.first++;
276
					List_ReDraw();
276
					List_ReDraw();
277
					mouse.get();
277
					mouse.get();
278
				}
278
				}
279
				DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,sc.work_light,sc.work_dark);
279
				DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,sc.work_light,sc.work_dark);
280
			}
280
			}
281
 
281
 
282
			//Scrooll
282
			//Scrooll
283
			if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+18) && (mouse.y>files.y) && (mouse.y
283
			if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+18) && (mouse.y>files.y) && (mouse.y
284
			if (scroll_used) && (mouse.up) { scroll_used=false; Scroll(); }
284
			if (scroll_used) && (mouse.up) { scroll_used=false; Scroll(); }
285
			
285
			
286
			if (scroll_used)
286
			if (scroll_used)
287
			{
287
			{
288
				if (sc_slider_h/2+files.y>mouse.y) || (mouse.y<0) || (mouse.y>4000) mouse.y=sc_slider_h/2+files.y; //anee eo?ni? iaa ieiii
288
				if (sc_slider_h/2+files.y>mouse.y) || (mouse.y<0) || (mouse.y>4000) mouse.y=sc_slider_h/2+files.y; //anee eo?ni? iaa ieiii
289
				id = files.first;
289
				id = files.first;
290
				files.first = -sc_slider_h / 2 + mouse.y -files.y * files.count;
290
				files.first = -sc_slider_h / 2 + mouse.y -files.y * files.count;
291
				files.first /= files.h - 18;
291
				files.first /= files.h - 18;
292
				if (files.visible+files.first>files.count) files.first=files.count-files.visible;
292
				if (files.visible+files.first>files.count) files.first=files.count-files.visible;
293
				if (files.first<0) files.first=0;
293
				if (files.first<0) files.first=0;
294
				if (id!=files.first) List_ReDraw();
294
				if (id!=files.first) List_ReDraw();
295
				break;
295
				break;
296
			}
296
			}
297
 
297
 
298
			if (two_panels.checked) && (mouse.y > files.y) && (mouse.down) {
298
			if (two_panels.checked) && (mouse.y > files.y) && (mouse.down) {
299
				if (mouse.x
299
				if (mouse.x
300
				{
300
				{
301
					if (active_panel!=1)
301
					if (active_panel!=1)
302
					{
302
					{
303
						active_panel = 1;
303
						active_panel = 1;
304
						ChangeActivePanel();
304
						ChangeActivePanel();
305
					}
305
					}
306
				}
306
				}
307
				else
307
				else
308
				{
308
				{
309
					if (active_panel!=2)
309
					if (active_panel!=2)
310
					{
310
					{
311
						active_panel = 2;
311
						active_panel = 2;
312
						ChangeActivePanel();
312
						ChangeActivePanel();
313
					}
313
					}
314
				}
314
				}
315
			}
315
			}
316
			break;  
316
			break;  
317
//Button pressed-----------------------------------------------------------------------------
317
//Button pressed-----------------------------------------------------------------------------
318
		case evButton:
318
		case evButton:
319
			id=GetButtonID();
319
			id=GetButtonID();
320
 
320
 
321
			if (new_element_active) || (del_active) {
321
			if (new_element_active) || (del_active) {
322
				if (POPUP_BTN1==id) && (del_active) EventDelete();
322
				if (POPUP_BTN1==id) && (del_active) EventDelete();
323
				if (POPUP_BTN1==id) && (new_element_active) NewElement();
323
				if (POPUP_BTN1==id) && (new_element_active) NewElement();
324
				if (POPUP_BTN2==id) EventClosePopinForm();
324
				if (POPUP_BTN2==id) EventClosePopinForm();
325
				break;					
325
				break;					
326
			}
326
			}
327
 
327
 
328
			switch(id) 
328
			switch(id) 
329
			{
329
			{
330
				case CLOSE_BTN:
330
				case CLOSE_BTN:
331
						KillProcess(about_thread_id);
331
						KillProcess(about_thread_id);
332
						SaveIniSettings();
332
						SaveIniSettings();
333
						ExitProcess();
333
						ExitProcess();
334
				case PATH_BTN:
334
				case PATH_BTN:
335
						notify(COPY_PATH_STR);
335
						notify(COPY_PATH_STR);
336
						Clipboard__CopyText(#path);
336
						Clipboard__CopyText(#path);
337
						break;
337
						break;
338
				case 21: //Back
338
				case 21: //Back
339
						EventHistoryGoBack();
339
						EventHistoryGoBack();
340
						break;
340
						break;
341
				case 22: //Forward
341
				case 22: //Forward
342
						EventHistoryGoForward();
342
						EventHistoryGoForward();
343
						break;
343
						break;
344
				case 23:
344
				case 23:
345
						Dir_Up();
345
						Dir_Up();
346
						break;
346
						break;
347
				case 24:
347
				case 24:
348
						EventCopy(CUT);
348
						EventCopy(CUT);
349
						break;
349
						break;
350
				case 25:
350
				case 25:
351
						EventCopy(NOCUT);
351
						EventCopy(NOCUT);
352
						break;
352
						break;
353
				case 26:
353
				case 26:
354
						EventPaste();
354
						EventPaste();
355
						break;
355
						break;
356
				case 31...33:
356
				case 31...33:
357
						EventSort(id-30);
357
						EventSort(id-30);
358
						break;
358
						break;
359
				case 51:
359
				case 51:
360
						EventShowBurgerMenu();
360
						EventShowBurgerMenu();
361
						break;
361
						break;
362
				case 52...60: //Actions
362
				case 52...60: //Actions
363
						FnProcess(id-50);
363
						FnProcess(id-50);
364
						break;
364
						break;
365
				case 61: // Set path as default
365
				case 61: // Set path as default
366
						SetDefaultPath(#path);
366
						SetDefaultPath(#path);
367
						break;
367
						break;
368
				case 100...120:
368
				case 100...120:
369
					SystemDiscs.Click(id-100);
369
					SystemDiscs.Click(id-100);
370
					break;
370
					break;
371
				case BREADCRUMB_ID...360:
371
				case BREADCRUMB_ID...360:
372
					ClickOnBreadCrumb(id-BREADCRUMB_ID);
372
					ClickOnBreadCrumb(id-BREADCRUMB_ID);
373
					break;
373
					break;
374
			}
374
			}
375
			break;
375
			break;
376
			
376
			
377
//Key pressed-----------------------------------------------------------------------------
377
//Key pressed-----------------------------------------------------------------------------
378
		case evKey:
378
		case evKey:
379
			GetKeys();
379
			GetKeys();
380
 
380
 
381
			if (Form.status_window>2) break;
381
			if (Form.status_window>2) break;
382
 
382
 
383
			if (new_element_active) || (del_active)
383
			if (new_element_active) || (del_active)
384
			{
384
			{
385
				if (del_active)
385
				if (del_active)
386
				{
386
				{
387
					if (key_scancode == SCAN_CODE_ENTER) EventDelete();
387
					if (key_scancode == SCAN_CODE_ENTER) EventDelete();
388
					if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
388
					if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
389
				}
389
				}
390
				if (new_element_active)
390
				if (new_element_active)
391
				{
391
				{
392
					if (key_scancode == SCAN_CODE_ENTER) NewElement();
392
					if (key_scancode == SCAN_CODE_ENTER) NewElement();
393
					if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
393
					if (key_scancode == SCAN_CODE_ESC) EventClosePopinForm();
394
					EAX = key_editbox;
394
					EAX = key_editbox;
395
					edit_box_key stdcall (#new_file_ed);
395
					edit_box_key stdcall (#new_file_ed);
396
				}
396
				}
397
				break;
397
				break;
398
			}
398
			}
399
 
399
 
400
			if (files.ProcessKey(key_scancode))
400
			if (files.ProcessKey(key_scancode))
401
			{
401
			{
402
				List_ReDraw();
402
				List_ReDraw();
403
				break;
403
				break;
404
			}
404
			}
405
 
405
 
406
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
406
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
407
			{
407
			{
408
				switch(key_scancode)
408
				switch(key_scancode)
409
				{
409
				{
410
					case SCAN_CODE_F1...SCAN_CODE_F3:
410
					case SCAN_CODE_F1...SCAN_CODE_F3:
411
							EventSort(key_scancode - 58);
411
							EventSort(key_scancode - 58);
412
							break;
412
							break;
413
					case SCAN_CODE_1...SCAN_CODE_10:
413
					case SCAN_CODE_1...SCAN_CODE_10:
414
							key_scancode-=2;
414
							key_scancode-=2;
415
							if (key_scancode >= SystemDiscs.list.count) break;
415
							if (key_scancode >= SystemDiscs.list.count) break;
416
							if (!two_panels.checked)
416
							if (!two_panels.checked)
417
							{
417
							{
418
								DrawRectangle(17,key_scancode*16+74,159,16, 0); //display click
418
								DrawRectangle(17,key_scancode*16+74,159,16, 0); //display click
419
								pause(7);										
419
								pause(7);										
420
							}
420
							}
421
							SystemDiscs.Click(key_scancode);
421
							SystemDiscs.Click(key_scancode);
422
							break;
422
							break;
423
					case SCAN_CODE_KEY_X:
423
					case SCAN_CODE_KEY_X:
424
							EventCopy(CUT);
424
							EventCopy(CUT);
425
							break;						
425
							break;						
426
					case SCAN_CODE_KEY_C:
426
					case SCAN_CODE_KEY_C:
427
							EventCopy(NOCUT);
427
							EventCopy(NOCUT);
428
							break;
428
							break;
429
					case SCAN_CODE_KEY_G:
429
					case SCAN_CODE_KEY_G:
430
							EventOpenConsoleHere();
430
							EventOpenConsoleHere();
431
							break;
431
							break;
432
					case SCAN_CODE_KEY_V:
432
					case SCAN_CODE_KEY_V:
433
							EventPaste();
433
							EventPaste();
434
							break;
434
							break;
435
					case SCAN_CODE_KEY_D: //set image as bg
435
					case SCAN_CODE_KEY_D: //set image as bg
436
							strlcpy(#temp, "\\S__",4);
436
							strlcpy(#temp, "\\S__",4);
437
							strcat(#temp, #file_path);
437
							strcat(#temp, #file_path);
438
							RunProgram("/sys/media/kiv", #temp);
438
							RunProgram("/sys/media/kiv", #temp);
439
							break;
439
							break;
440
					case SCAN_CODE_KEY_N:
440
					case SCAN_CODE_KEY_N:
441
							EventOpenNewEolite();
441
							EventOpenNewEolite();
442
							break; 
442
							break; 
443
					case SCAN_CODE_KEY_M:
443
					case SCAN_CODE_KEY_M:
444
							Open_Dir(#inactive_path,WITH_REDRAW);
444
							Open_Dir(#inactive_path,WITH_REDRAW);
445
							break; 
445
							break; 
446
					case SCAN_CODE_ENTER:
446
					case SCAN_CODE_ENTER:
447
							if (!itdir) ShowOpenWithDialog();
447
							if (!itdir) ShowOpenWithDialog();
448
							else Open(1);
448
							else Open(1);
449
							break;
449
							break;
450
					case SCAN_CODE_KEY_A:
450
					case SCAN_CODE_KEY_A:
451
							EventSelectAllFiles(true);
451
							EventSelectAllFiles(true);
452
							break;
452
							break;
453
					case SCAN_CODE_KEY_U: //unselect all files
453
					case SCAN_CODE_KEY_U: //unselect all files
454
							EventSelectAllFiles(false);
454
							EventSelectAllFiles(false);
455
							break;
455
							break;
456
				}
456
				}
457
				break;
457
				break;
458
			}
458
			}
459
 
459
 
460
			switch (key_scancode)
460
			switch (key_scancode)
461
			{
461
			{
462
					case SCAN_CODE_BS:
462
					case SCAN_CODE_BS:
463
							//EventHistoryGoBack();
463
							//EventHistoryGoBack();
464
							Dir_Up();
464
							Dir_Up();
465
							break; 
465
							break; 
466
					case SCAN_CODE_ENTER:
466
					case SCAN_CODE_ENTER:
467
							Open(0);
467
							Open(0);
468
							break; 
468
							break; 
469
					case SCAN_CODE_TAB:
469
					case SCAN_CODE_TAB:
470
							if (!two_panels.checked) break;
470
							if (!two_panels.checked) break;
471
							if (active_panel==1) active_panel=2; else active_panel=1;
471
							if (active_panel==1) active_panel=2; else active_panel=1;
472
							ChangeActivePanel();
472
							ChangeActivePanel();
473
							DrawFilePanels();
473
							DrawFilePanels();
474
							break;
474
							break;
475
					case SCAN_CODE_MENU:
475
					case SCAN_CODE_MENU:
476
							mouse.x = files.x+15;
476
							mouse.x = files.x+15;
477
							mouse.y = files.cur_y - files.first * files.item_h + files.y + 5;
477
							mouse.y = files.cur_y - files.first * files.item_h + files.y + 5;
478
							EventShowListMenu();
478
							EventShowListMenu();
479
							break;
479
							break;
480
					case SCAN_CODE_DEL:
480
					case SCAN_CODE_DEL:
481
							Del_Form();
481
							Del_Form();
482
							break;
482
							break;
483
					case SCAN_CODE_INS:
483
					case SCAN_CODE_INS:
484
							if (getElementSelectedFlag(files.cur_y) == true) setElementSelectedFlag(files.cur_y, false);
484
							if (getElementSelectedFlag(files.cur_y) == true) setElementSelectedFlag(files.cur_y, false);
485
							else setElementSelectedFlag(files.cur_y, true);
485
							else setElementSelectedFlag(files.cur_y, true);
486
							files.KeyDown();
486
							files.KeyDown();
487
							List_ReDraw();
487
							List_ReDraw();
488
							DrawStatusBar();
488
							DrawStatusBar();
489
							break;
489
							break;
490
					case SCAN_CODE_F1...SCAN_CODE_F10:
490
					case SCAN_CODE_F1...SCAN_CODE_F10:
491
							FnProcess(key_scancode-58);
491
							FnProcess(key_scancode-58);
492
							break; 
492
							break; 
493
					default:
493
					default:
494
							EventSelectFileByKeyPress();
494
							EventSelectFileByKeyPress();
495
			}                         
495
			}                         
496
		break;
496
		break;
497
		case evIPC:
497
		case evIPC:
498
		case evReDraw:
498
		case evReDraw:
499
			draw_window();
499
			draw_window();
500
			if (CheckActiveProcess(Form.ID)) && (GetMenuClick()) break;
500
			if (CheckActiveProcess(Form.ID)) && (GetMenuClick()) break;
501
			if (action_buf==OPERATION_END)
501
			if (action_buf==OPERATION_END)
502
			{
502
			{
503
				FnProcess(5);
503
				FnProcess(5);
504
				action_buf=0;
504
				action_buf=0;
505
			}
505
			}
506
		break;
506
		break;
507
		default:
507
		default:
508
			if (Form.status_window>2) break;
508
			if (Form.status_window>2) break;
509
			EventRefreshDisksAndFolders();
509
			EventRefreshDisksAndFolders();
510
	}
510
	}
511
	
511
	
512
	if(cmd_free)
512
	if(cmd_free)
513
	{
513
	{
514
		if(cmd_free==2) about_stak=free(about_stak);
514
		if(cmd_free==2) about_stak=free(about_stak);
515
		else if(cmd_free==3) properties_stak=free(properties_stak);
515
		else if(cmd_free==3) properties_stak=free(properties_stak);
516
		else if(cmd_free==4) settings_stak=free(settings_stak);
516
		else if(cmd_free==4) settings_stak=free(settings_stak);
517
		else if(cmd_free==6) delete_stak=free(delete_stak);
517
		else if(cmd_free==6) delete_stak=free(delete_stak);
518
		cmd_free = false;
518
		cmd_free = false;
519
	}
519
	}
520
}
520
}
521
 
521
 
522
void draw_window()
522
void draw_window()
523
{
523
{
524
	dword i;
524
	dword i;
525
	if (show_status_bar.checked) status_bar_h = STATUS_BAR_H; else status_bar_h = 0;
525
	if (show_status_bar.checked) status_bar_h = STATUS_BAR_H; else status_bar_h = 0;
526
	DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,TITLE,0);
526
	DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,TITLE,0);
527
	GetProcessInfo(#Form, SelfInfo);
527
	GetProcessInfo(#Form, SelfInfo);
528
	if (Form.status_window>2) return;
528
	if (Form.status_window>2) return;
529
	if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
529
	if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
530
	if (!two_panels.checked) && (Form.width < 480) { MoveSize(OLD,OLD,480,OLD); return; }
530
	if (!two_panels.checked) && (Form.width < 480) { MoveSize(OLD,OLD,480,OLD); return; }
531
	if ( two_panels.checked) && (Form.width < 573) { MoveSize(OLD,OLD,573,OLD); return; }
531
	if ( two_panels.checked) && (Form.width < 573) { MoveSize(OLD,OLD,573,OLD); return; }
532
	GetProcessInfo(#Form, SelfInfo);
532
	GetProcessInfo(#Form, SelfInfo);
533
	SetAppColors();
533
	SetAppColors();
534
	ESDWORD[#toolbar_pal] = sc.work;
534
	ESDWORD[#toolbar_pal] = sc.work;
535
	ESDWORD[#toolbar_pal+4] = MixColors(0, sc.work, 35);
535
	ESDWORD[#toolbar_pal+4] = MixColors(0, sc.work, 35);
536
	PutPaletteImage(#toolbar, 246, 34, 0, 0, 8, #toolbar_pal);
536
	PutPaletteImage(#toolbar, 246, 34, 0, 0, 8, #toolbar_pal);
537
	DrawBar(127, 8, 1, 25, sc.work_graph);
537
	DrawBar(127, 8, 1, 25, sc.work_graph);
538
	for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,21+i);
538
	for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,21+i);
539
	for (i=3; i<6; i++) DefineHiddenButton(toolbar_buttons_x[i],  5,31,  29,  21+i);
539
	for (i=3; i<6; i++) DefineHiddenButton(toolbar_buttons_x[i],  5,31,  29,  21+i);
540
	DrawBar(246,0, Form.cwidth - 246, 34, sc.work);
540
	DrawBar(246,0, Form.cwidth - 246, 34, sc.work);
541
	DrawDot(Form.cwidth-17,12);
541
	DrawDot(Form.cwidth-17,12);
542
	DrawDot(Form.cwidth-17,12+6);
542
	DrawDot(Form.cwidth-17,12+6);
543
	DrawDot(Form.cwidth-17,12+12);
543
	DrawDot(Form.cwidth-17,12+12);
544
	DefineHiddenButton(Form.cwidth-24,7,20,25,51+BT_NOFRAME); //dots
544
	DefineHiddenButton(Form.cwidth-24,7,20,25,51+BT_NOFRAME); //dots
545
	//main rectangles
545
	//main rectangles
546
	DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42-status_bar_h,sc.work_graph);
546
	DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42-status_bar_h,sc.work_graph);
547
	DrawRectangle(0,39,Form.cwidth-1,-show_status_bar.checked*status_bar_h + Form.cheight - 40,col.work_gradient[4]); //bg
547
	DrawRectangle(0,39,Form.cwidth-1,-show_status_bar.checked*status_bar_h + Form.cheight - 40,col.work_gradient[4]); //bg
548
	for (i=0; i<6; i++) DrawBar(0, 34+i, Form.cwidth, 1, MixColors(sc.work_dark, sc.work, i*10));
548
	for (i=0; i<6; i++) DrawBar(0, 34+i, Form.cwidth, 1, MixColors(sc.work_dark, sc.work, i*10));
549
	for (i=0; i<6; i++) DrawBar(0, 5-i, Form.cwidth, 1, MixColors(sc.work_light, sc.work, i*10));
549
	for (i=0; i<6; i++) DrawBar(0, 5-i, Form.cwidth, 1, MixColors(sc.work_light, sc.work, i*10));
550
	llist_copy(#files_active, #files);
550
	llist_copy(#files_active, #files);
551
	strcpy(#active_path, #path);
551
	strcpy(#active_path, #path);
552
	DrawStatusBar();
552
	DrawStatusBar();
553
	if (selected_count==0) Open_Dir(#path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001] 
553
	if (selected_count==0) Open_Dir(#path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001] 
554
	DrawFilePanels();
554
	DrawFilePanels();
555
}
555
}
556
 
556
 
557
void DrawList() 
557
void DrawList() 
558
{
558
{
559
	word sorting_arrow_x;
559
	word sorting_arrow_x;
560
	dword sorting_arrow_t = "\x19";
560
	dword sorting_arrow_t = "\x19";
561
	if (sort_desc) sorting_arrow_t = "\x18";
561
	if (sort_desc) sorting_arrow_t = "\x18";
562
	DrawFlatButtonSmall(files.x, files.y-17,     files.w - 141,16,31,T_FILE);
562
	DrawFlatButtonSmall(files.x, files.y-17,     files.w - 141,16,31,T_FILE);
563
	DrawFlatButtonSmall(files.x + files.w - 141, files.y-17,73,16,32,T_TYPE);
563
	DrawFlatButtonSmall(files.x + files.w - 141, files.y-17,73,16,32,T_TYPE);
564
	DrawFlatButtonSmall(files.x + files.w -  68, files.y-17,68,16,33,T_SIZE);
564
	DrawFlatButtonSmall(files.x + files.w -  68, files.y-17,68,16,33,T_SIZE);
565
	DrawFlatButtonSmall(files.x + files.w,       files.y-17,16,16, 0,"\x18");
565
	DrawFlatButtonSmall(files.x + files.w,       files.y-17,16,16, 0,"\x18");
566
	DrawFlatButtonSmall(files.x + files.w,files.y+files.h-16,16,16,0,"\x19");
566
	DrawFlatButtonSmall(files.x + files.w,files.y+files.h-16,16,16,0,"\x19");
567
	if (sort_type==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
567
	if (sort_type==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
568
	if (sort_type==2) sorting_arrow_x = files.x + files.w - 90;
568
	if (sort_type==2) sorting_arrow_x = files.x + files.w - 90;
569
	if (sort_type==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
569
	if (sort_type==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
570
	WriteText(sorting_arrow_x,files.y-12,0x80, sc.work_text, sorting_arrow_t);
570
	WriteText(sorting_arrow_x,files.y-12,0x80, sc.work_text, sorting_arrow_t);
571
	DrawBar(files.x+files.w,files.y,1,files.h,sc.work_graph);
571
	DrawBar(files.x+files.w,files.y,1,files.h,sc.work_graph);
572
	if (two_panels.checked) && (files.x<5) DrawBar(files.x+files.w+16,files.y,1,files.h,sc.work_graph);	
572
	if (two_panels.checked) && (files.x<5) DrawBar(files.x+files.w+16,files.y,1,files.h,sc.work_graph);	
573
}
573
}
574
 
574
 
575
void DrawStatusBar()
575
void DrawStatusBar()
576
{
576
{
577
	char status_bar_str[80];
577
	char status_bar_str[80];
578
	int go_up_folder_exists=0;
578
	int go_up_folder_exists=0;
579
	if (!show_status_bar.checked) return;
579
	if (!show_status_bar.checked) return;
580
	if (files.count>0) && (strcmp(file_mas[0]*304+buf+72,"..")==0) go_up_folder_exists=1;
580
	if (files.count>0) && (strcmp(file_mas[0]*304+buf+72,"..")==0) go_up_folder_exists=1;
581
	DrawBar(0, Form.cheight - status_bar_h, Form.cwidth,  status_bar_h, sc.work);
581
	DrawBar(0, Form.cheight - status_bar_h, Form.cwidth,  status_bar_h, sc.work);
582
	sprintf(#status_bar_str, T_STATUS_EVEMENTS, count_dir-go_up_folder_exists, files.count-count_dir);
582
	sprintf(#status_bar_str, T_STATUS_EVEMENTS, count_dir-go_up_folder_exists, files.count-count_dir);
583
	WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str);
583
	WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str);
584
	if (selected_count) {
584
	if (selected_count) {
585
		sprintf(#status_bar_str, T_STATUS_SELECTED, selected_count);
585
		sprintf(#status_bar_str, T_STATUS_SELECTED, selected_count);
586
		WriteText(Form.cwidth - calc(strlen(#status_bar_str)*6)-6,Form.cheight - 13,
586
		WriteText(Form.cwidth - calc(strlen(#status_bar_str)*6)-6,Form.cheight - 13,
587
			0x80,sc.work_text,#status_bar_str);
587
			0x80,sc.work_text,#status_bar_str);
588
	}
588
	}
589
}
589
}
590
 
590
 
591
void DrawFilePanels()
591
void DrawFilePanels()
592
{
592
{
593
	int files_y;
593
	int files_y;
594
	if (!two_panels.checked)
594
	if (!two_panels.checked)
595
	{
595
	{
596
		DrawDeviceAndActionsLeftPanel();
596
		DrawDeviceAndActionsLeftPanel();
597
		files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h);
597
		files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h);
598
		DrawList();
598
		DrawList();
599
		Open_Dir(#path,ONLY_SHOW);
599
		Open_Dir(#path,ONLY_SHOW);
600
	}
600
	}
601
	else
601
	else
602
	{
602
	{
603
		SystemDiscs.Get();
603
		SystemDiscs.Get();
604
		llist_copy(#files, #files_inactive);
604
		llist_copy(#files, #files_inactive);
605
		strcpy(#path, #inactive_path);
605
		strcpy(#path, #inactive_path);
606
		col.selec = col.selec_inactive;
606
		col.selec = col.selec_inactive;
607
		SystemDiscs.Draw();
607
		SystemDiscs.Draw();
608
		files_y = files.y;
608
		files_y = files.y;
609
 
609
 
610
		if (active_panel==1)
610
		if (active_panel==1)
611
		{
611
		{
612
			llist_copy(#files, #files_inactive);
612
			llist_copy(#files, #files_inactive);
613
			strcpy(#path, #inactive_path);
613
			strcpy(#path, #inactive_path);
614
			col.selec = col.selec_inactive; //this is a bad code: need to use some var to set inactive panel for DrawList();
614
			col.selec = col.selec_inactive; //this is a bad code: need to use some var to set inactive panel for DrawList();
615
			files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
615
			files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
616
			DrawList();
616
			DrawList();
617
			Open_Dir(#path,WITH_REDRAW);
617
			Open_Dir(#path,WITH_REDRAW);
618
			llist_copy(#files, #files_active);
618
			llist_copy(#files, #files_active);
619
			strcpy(#path, #active_path);
619
			strcpy(#path, #active_path);
620
			col.selec = col.selec_active;
620
			col.selec = col.selec_active;
621
			files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
621
			files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
622
			DrawList();
622
			DrawList();
623
			Open_Dir(#path,WITH_REDRAW);
623
			Open_Dir(#path,WITH_REDRAW);
624
		}
624
		}
625
		if (active_panel==2)
625
		if (active_panel==2)
626
		{
626
		{
627
			files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
627
			files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
628
			DrawList();
628
			DrawList();
629
			Open_Dir(#path,WITH_REDRAW);
629
			Open_Dir(#path,WITH_REDRAW);
630
			llist_copy(#files, #files_active);
630
			llist_copy(#files, #files_active);
631
			strcpy(#path, #active_path);
631
			strcpy(#path, #active_path);
632
			col.selec = col.selec_active;
632
			col.selec = col.selec_active;
633
			files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
633
			files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
634
			DrawList();
634
			DrawList();
635
			Open_Dir(#path,WITH_REDRAW);
635
			Open_Dir(#path,WITH_REDRAW);
636
		}
636
		}
637
	}
637
	}
638
}
638
}
639
 
639
 
640
 
640
 
641
void List_ReDraw()
641
void List_ReDraw()
642
{
642
{
643
	int all_lines_h;
643
	int all_lines_h;
644
	dword j;
644
	dword j;
645
	static int old_cur_y, old_first;
645
	static int old_cur_y, old_first;
646
 
646
 
647
	files.CheckDoesValuesOkey(); //prevent some shit
647
	files.CheckDoesValuesOkey(); //prevent some shit
648
 
648
 
649
	if (list_full_redraw) || (old_first != files.first)
649
	if (list_full_redraw) || (old_first != files.first)
650
	{
650
	{
651
		old_cur_y = files.cur_y;
651
		old_cur_y = files.cur_y;
652
		old_first = files.first;
652
		old_first = files.first;
653
		list_full_redraw = false;
653
		list_full_redraw = false;
654
		goto _ALL_LIST_REDRAW;
654
		goto _ALL_LIST_REDRAW;
655
	}
655
	}
656
	if (old_cur_y != files.cur_y)
656
	if (old_cur_y != files.cur_y)
657
	{
657
	{
658
		if (old_cur_y-files.first
658
		if (old_cur_y-files.first
659
		Line_ReDraw(col.selec, files.cur_y-files.first);
659
		Line_ReDraw(col.selec, files.cur_y-files.first);
660
		old_cur_y = files.cur_y;
660
		old_cur_y = files.cur_y;
661
		return;
661
		return;
662
	}
662
	}
663
 
663
 
664
	_ALL_LIST_REDRAW:
664
	_ALL_LIST_REDRAW:
665
 
665
 
666
	for (j=0; j
666
	for (j=0; j
667
		if (files.cur_y-files.first!=j) Line_ReDraw(col.list_bg, j); 
667
		if (files.cur_y-files.first!=j) Line_ReDraw(col.list_bg, j); 
668
		else Line_ReDraw(col.selec, files.cur_y-files.first);		
668
		else Line_ReDraw(col.selec, files.cur_y-files.first);		
669
	}
669
	}
670
	//in the bottom
670
	//in the bottom
671
	all_lines_h = j * files.item_h;
671
	all_lines_h = j * files.item_h;
672
	DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h, col.list_bg);
672
	DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h, col.list_bg);
673
	DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h,col.list_vert_line);
673
	DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h,col.list_vert_line);
674
	DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h,col.list_vert_line);
674
	DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h,col.list_vert_line);
675
	Scroll();
675
	Scroll();
676
 
676
 
677
	if (del_active) Del_Form();
677
	if (del_active) Del_Form();
678
	if (new_element_active) && (col.selec != 0xCCCccc) NewElement_Form(new_element_active, #new_element_name);
678
	if (new_element_active) && (col.selec != 0xCCCccc) NewElement_Form(new_element_active, #new_element_name);
679
}
679
}
680
 
680
 
681
bool file_name_is_8_3(dword name)
681
bool file_name_is_8_3(dword name)
682
{
682
{
683
	int name_len = strlen(name);
683
	int name_len = strlen(name);
684
	int dot_pos = strrchr(name, '.');
684
	int dot_pos = strrchr(name, '.');
685
	if (name_len<=12) 
685
	if (name_len<=12) 
686
	{
686
	{
687
		if (dot_pos) {
687
		if (dot_pos) {
688
			if (name_len - dot_pos > 3) return false;
688
			if (name_len - dot_pos > 3) return false;
689
		}
689
		}
690
		else {
690
		else {
691
			if (name_len>8) return false; 
691
			if (name_len>8) return false; 
692
		}
692
		}
693
		return true;
693
		return true;
694
	}
694
	}
695
	return false;
695
	return false;
696
}
696
}
697
 
697
 
698
void Line_ReDraw(dword bgcol, filenum){
698
void Line_ReDraw(dword bgcol, filenum){
699
	dword text_col=col.list_gb_text,
699
	dword text_col=col.list_gb_text,
700
		  ext1, attr,
700
		  ext1, attr,
701
		  file_offet,
701
		  file_offet,
702
		  file_name_off,
702
		  file_name_off,
703
		  file_size=0,
703
		  file_size=0,
704
		  y=filenum*files.item_h+files.y,
704
		  y=filenum*files.item_h+files.y,
705
		  icon_y = files.item_h-icon_size/2+1+y;
705
		  icon_y = files.item_h-icon_size/2+1+y;
706
		  BDVK file;
706
		  BDVK file;
707
		  char temp_path[sizeof(file_path)];
707
		  char temp_path[sizeof(file_path)];
708
	char label_file_name[4096];
708
	char label_file_name[4096];
709
	if (filenum==-1) return;
709
	if (filenum==-1) return;
710
	DrawBar(files.x,y,4,files.item_h,bgcol);
710
	DrawBar(files.x,y,4,files.item_h,bgcol);
711
	DrawBar(files.x+4,y,icon_size,icon_y-y,bgcol);
711
	DrawBar(files.x+4,y,icon_size,icon_y-y,bgcol);
712
	if (files.item_h>icon_size) DrawBar(files.x+4,icon_y+icon_size-1,icon_size,y+files.item_h-icon_y-icon_size+1,bgcol);
712
	if (files.item_h>icon_size) DrawBar(files.x+4,icon_y+icon_size-1,icon_size,y+files.item_h-icon_y-icon_size+1,bgcol);
713
	if (colored_lines.checked) && (bgcol!=col.selec) && (filenum%2) bgcol=col.odd_line;
713
	if (colored_lines.checked) && (bgcol!=col.selec) && (filenum%2) bgcol=col.odd_line;
714
	DrawBar(files.x+icon_size+4,y,files.w-icon_size-4,files.item_h,bgcol);
714
	DrawBar(files.x+icon_size+4,y,files.w-icon_size-4,files.item_h,bgcol);
715
 
715
 
716
	file_offet = file_mas[filenum+files.first]*304 + buf+32;
716
	file_offet = file_mas[filenum+files.first]*304 + buf+32;
717
	attr = ESDWORD[file_offet];
717
	attr = ESDWORD[file_offet];
718
	file.selected = ESBYTE[file_offet+7];
718
	file.selected = ESBYTE[file_offet+7];
719
	file.sizelo   = ESDWORD[file_offet+32];
719
	file.sizelo   = ESDWORD[file_offet+32];
720
	file.sizehi   = ESDWORD[file_offet+36];
720
	file.sizehi   = ESDWORD[file_offet+36];
721
	file_name_off = file_offet+40;
721
	file_name_off = file_offet+40;
722
	sprintf(#temp_path,"%s/%s",#path,file_name_off);
722
	sprintf(#temp_path,"%s/%s",#path,file_name_off);
723
 
723
 
724
	if (! TestBit(attr, 4) ) //file or folder?
724
	if (! TestBit(attr, 4) ) //file or folder?
725
	{	
725
	{	
726
		ext1 = strrchr(file_name_off,'.') + file_name_off;
726
		ext1 = strrchr(file_name_off,'.') + file_name_off;
727
		if (ext1==file_name_off) ext1 = NULL; //if no extension then show nothing
727
		if (ext1==file_name_off) ext1 = NULL; //if no extension then show nothing
728
		file_size = ConvertSize64(file.sizelo, file.sizehi);
728
		file_size = ConvertSize64(file.sizelo, file.sizehi);
729
		if (ext1) && (strlen(ext1)<9) WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
729
		if (ext1) && (strlen(ext1)<9) WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
730
	}
730
	}
731
	else
731
	else
732
	{
732
	{
733
		if (!strcmp(file_name_off,"..")) ext1=""; else {
733
		if (!strcmp(file_name_off,"..")) ext1=""; else {
734
			ext1="";
734
			ext1="";
735
			WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
735
			WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
736
		}
736
		}
737
		if (chrnum(#path, '/')==1) file_size = GetDeviceSizeLabel(#temp_path);
737
		if (chrnum(#path, '/')==1) file_size = GetDeviceSizeLabel(#temp_path);
738
	}
738
	}
739
	if (file_size) WriteText(7-strlen(file_size)*6+files.x+files.w-58, 
739
	if (file_size) WriteText(7-strlen(file_size)*6+files.x+files.w-58, 
740
			files.text_y+y+1, files.font_type, col.list_gb_text, file_size);
740
			files.text_y+y+1, files.font_type, col.list_gb_text, file_size);
741
	DrawIconByExtension(#temp_path, ext1, files.x+4, icon_y, bgcol);
741
	DrawIconByExtension(#temp_path, ext1, files.x+4, icon_y, bgcol);
742
 
742
 
743
	if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=col.list_text_hidden; //system or hiden?
743
	if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=col.list_text_hidden; //system or hiden?
744
	if (bgcol==col.selec)
744
	if (bgcol==col.selec)
745
	{
745
	{
746
		file_name_is_8_3(file_name_off);
746
		file_name_is_8_3(file_name_off);
747
		itdir = TestBit(attr, 4);
747
		itdir = TestBit(attr, 4);
748
		strcpy(#file_name, file_name_off);
748
		strcpy(#file_name, file_name_off);
749
		if (!strcmp(#path,"/")) sprintf(#file_path,"%s%s",#path,file_name_off);
749
		if (!strcmp(#path,"/")) sprintf(#file_path,"%s%s",#path,file_name_off);
750
			else sprintf(#file_path,"%s/%s",#path,file_name_off);
750
			else sprintf(#file_path,"%s/%s",#path,file_name_off);
751
		if (text_col==col.list_text_hidden) {
751
		if (text_col==col.list_text_hidden) {
752
			text_col=MixColors(col.selec_text, col.list_text_hidden, 65); 
752
			text_col=MixColors(col.selec_text, col.list_text_hidden, 65); 
753
		} else text_col=col.selec_text;
753
		} else text_col=col.selec_text;
754
	}
754
	}
755
	if (file.selected) text_col=0xFF0000;
755
	if (file.selected) text_col=0xFF0000;
756
	if (kfont.size.pt==9) || (!kfont.font)
756
	if (kfont.size.pt==9) || (!kfont.font)
757
	{
757
	{
758
		if (Form.width>=480)
758
		if (Form.width>=480)
759
		{
759
		{
760
			FileShow.start_x = files.x + 23;
760
			FileShow.start_x = files.x + 23;
761
			FileShow.font_color = text_col;
761
			FileShow.font_color = text_col;
762
			FileShow.area_size_x = files.w - 164;
762
			FileShow.area_size_x = files.w - 164;
763
			FileShow.text_pointer = file_name_off;
763
			FileShow.text_pointer = file_name_off;
764
			FileShow.start_y = files.text_y + y - 3;
764
			FileShow.start_y = files.text_y + y - 3;
765
			PathShow_prepare stdcall(#FileShow);
765
			PathShow_prepare stdcall(#FileShow);
766
			PathShow_draw stdcall(#FileShow);
766
			PathShow_draw stdcall(#FileShow);
767
		}		
767
		}		
768
	}
768
	}
769
	else
769
	else
770
	{
770
	{
771
		strcpy(#label_file_name, file_name_off);
771
		strcpy(#label_file_name, file_name_off);
772
		if (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w)
772
		if (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w)
773
		{
773
		{
774
			while (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w) {
774
			while (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w) {
775
				ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL;
775
				ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL;
776
			}
776
			}
777
			strcpy(#label_file_name+strlen(#label_file_name)-2, "...");			
777
			strcpy(#label_file_name+strlen(#label_file_name)-2, "...");			
778
		}
778
		}
779
		kfont.WriteIntoWindow(files.x + icon_size+7, files.item_h - kfont.height / 2 + y, 
779
		kfont.WriteIntoWindow(files.x + icon_size+7, files.item_h - kfont.height / 2 + y, 
780
			bgcol, text_col, kfont.size.pt, #label_file_name);
780
			bgcol, text_col, kfont.size.pt, #label_file_name);
781
	}
781
	}
782
	DrawBar(files.x+files.w-141,y,1,files.item_h,col.list_vert_line); //gray line 1
782
	DrawBar(files.x+files.w-141,y,1,files.item_h,col.list_vert_line); //gray line 1
783
	DrawBar(files.x+files.w-68,y,1,files.item_h,col.list_vert_line); //gray line 2
783
	DrawBar(files.x+files.w-68,y,1,files.item_h,col.list_vert_line); //gray line 2
784
}
784
}
785
 
785
 
786
 
786
 
787
void Open_Dir(dword dir_path, redraw){
787
void Open_Dir(dword dir_path, redraw){
788
	int errornum, maxcount, i;
788
	int errornum, maxcount, i;
789
	if (redraw!=ONLY_SHOW)
789
	if (redraw!=ONLY_SHOW)
790
	{
790
	{
791
		selected_count = 0;
791
		selected_count = 0;
792
		if (buf) free(buf);
792
		if (buf) free(buf);
793
		errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
793
		errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
794
		if (errornum)
794
		if (errornum)
795
		{
795
		{
796
			history.add(#path);
796
			history.add(#path);
797
			EventHistoryGoBack();
797
			EventHistoryGoBack();
798
			Write_Error(errornum);
798
			Write_Error(errornum);
799
			return;
799
			return;
800
		}
800
		}
801
		maxcount = sizeof(file_mas)/sizeof(dword)-1;
801
		maxcount = sizeof(file_mas)/sizeof(dword)-1;
802
		if (files.count>maxcount) files.count = maxcount;
802
		if (files.count>maxcount) files.count = maxcount;
803
		if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
803
		if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
804
	}
804
	}
805
	if (files.count!=-1)
805
	if (files.count!=-1)
806
	{
806
	{
807
		if(!_not_draw) if (show_breadcrumb.checked) DrawBreadCrumbs(); else DrawPathBar();
807
		if(!_not_draw) if (show_breadcrumb.checked) DrawBreadCrumbs(); else DrawPathBar();
808
		history.add(#path);
808
		history.add(#path);
809
		SystemDiscs.Draw();
809
		SystemDiscs.Draw();
810
		files.visible = files.h / files.item_h;
810
		files.visible = files.h / files.item_h;
811
		if (files.count < files.visible) files.visible = files.count;
811
		if (files.count < files.visible) files.visible = files.count;
812
		if (!strncmp(dir_path, "/rd/1/",5)) 
812
		if (!strncmp(dir_path, "/rd/1/",5)) 
813
			dir_at_fat16 = true; else dir_at_fat16 = false; 
813
			dir_at_fat16 = true; else dir_at_fat16 = false; 
814
		if (redraw!=ONLY_SHOW) Sorting();
814
		if (redraw!=ONLY_SHOW) Sorting();
815
		list_full_redraw = true;
815
		list_full_redraw = true;
816
		if (redraw!=ONLY_OPEN)&&(!_not_draw) {DrawStatusBar(); List_ReDraw();}
816
		if (redraw!=ONLY_OPEN)&&(!_not_draw) {DrawStatusBar(); List_ReDraw();}
817
		SetCurDir(dir_path);
817
		SetCurDir(dir_path);
818
	}
818
	}
819
	if (files.count==-1) && (redraw!=ONLY_OPEN) 
819
	if (files.count==-1) && (redraw!=ONLY_OPEN) 
820
	{
820
	{
821
		files.KeyHome();
821
		files.KeyHome();
822
		if(!_not_draw) { list_full_redraw=true; DrawStatusBar(); List_ReDraw(); }
822
		if(!_not_draw) { list_full_redraw=true; DrawStatusBar(); List_ReDraw(); }
823
	}
823
	}
824
}
824
}
825
 
825
 
826
inline Sorting()
826
inline Sorting()
827
{
827
{
828
	dword d=0, f=1;
828
	dword d=0, f=1;
829
	int j=0;
829
	int j=0;
830
	dword file_off;
830
	dword file_off;
831
 
831
 
832
	if (!strcmp(#path,"/")) //do not sort root folder
832
	if (!strcmp(#path,"/")) //do not sort root folder
833
	{
833
	{
834
		for(d=1;d
834
		for(d=1;d
835
		count_dir = d;
835
		count_dir = d;
836
		return;
836
		return;
837
	}
837
	}
838
	for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
838
	for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
839
	{
839
	{
840
		if (dir_at_fat16) && (file_name_is_8_3(file_off+40)) strttl(file_off+40);
840
		if (dir_at_fat16) && (file_name_is_8_3(file_off+40)) strttl(file_off+40);
841
		if (TestBit(ESDWORD[file_off],4)) //directory?
841
		if (TestBit(ESDWORD[file_off],4)) //directory?
842
		{
842
		{
843
			file_mas[d]=j;
843
			file_mas[d]=j;
844
			d++;
844
			d++;
845
		}
845
		}
846
		else
846
		else
847
		{
847
		{
848
			file_mas[files.count-f]=j;
848
			file_mas[files.count-f]=j;
849
			f++;
849
			f++;
850
		}
850
		}
851
	}
851
	}
852
	count_dir = d;
852
	count_dir = d;
853
	//sorting: files first, then folders
853
	//sorting: files first, then folders
854
	Sort_by_Name(0,d-1);
854
	Sort_by_Name(0,d-1);
855
	if (sort_type==1) Sort_by_Name(d,files.count-1);
855
	if (sort_type==1) Sort_by_Name(d,files.count-1);
856
	else if (sort_type==2) Sort_by_Type(d,files.count-1);
856
	else if (sort_type==2) Sort_by_Type(d,files.count-1);
857
	else if (sort_type==3) Sort_by_Size(d,files.count-1);
857
	else if (sort_type==3) Sort_by_Size(d,files.count-1);
858
	//reversed sorting
858
	//reversed sorting
859
	if (sort_desc) {
859
	if (sort_desc) {
860
		for (j=0; j
860
		for (j=0; j
861
		//if (sort_type==1) for (j=0; j
861
		//if (sort_type==1) for (j=0; j
862
	}
862
	}
863
	//make ".." first item in list
863
	//make ".." first item in list
864
	if (d>0) && (strncmp(file_mas[0]*304+buf+72,"..",2)!=0)
864
	if (d>0) && (strncmp(file_mas[0]*304+buf+72,"..",2)!=0)
865
		for(d--; d>0; d--;) if (!strncmp(file_mas[d]*304+buf+72,"..",2)) {file_mas[d]>
865
		for(d--; d>0; d--;) if (!strncmp(file_mas[d]*304+buf+72,"..",2)) {file_mas[d]>
866
}
866
}
867
 
867
 
868
 
868
 
869
void Del_Form()
869
void Del_Form()
870
{
870
{
871
	byte f_count[128];
871
	byte f_count[128];
872
	int dform_x = files.w - 220 / 2 + files.x;
872
	int dform_x = files.w - 220 / 2 + files.x;
873
	if (selected_count==0) && (!strncmp(#file_name,"..",2)) return;
873
	if (selected_count==0) && (!strncmp(#file_name,"..",2)) return;
874
	else
874
	else
875
	{
875
	{
876
		if (!files.count) return;
876
		if (!files.count) return;
877
		DrawEolitePopup(T_YES, T_NO);
877
		DrawEolitePopup(T_YES, T_NO);
878
		WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,sc.work_text,T_DELETE_FILE);
878
		WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,sc.work_text,T_DELETE_FILE);
879
		if (selected_count)
879
		if (selected_count)
880
		{
880
		{
881
			sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,selected_count,DEL_MORE_FILES_2);
881
			sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,selected_count,DEL_MORE_FILES_2);
882
			WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,sc.work_text,#f_count);
882
			WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,sc.work_text,#f_count);
883
		}
883
		}
884
		else
884
		else
885
		{
885
		{
886
			if (strlen(#file_name)<28) 
886
			if (strlen(#file_name)<28) 
887
			{
887
			{
888
				WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,sc.work_text,"?");
888
				WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,sc.work_text,"?");
889
				WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,sc.work_text,#file_name);
889
				WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,sc.work_text,#file_name);
890
			}
890
			}
891
			else
891
			else
892
			{
892
			{
893
				WriteText(164+dform_x,190,0x80,0,"...?");
893
				WriteText(164+dform_x,190,0x80,0,"...?");
894
				ESI = 24;
894
				ESI = 24;
895
				WriteText(dform_x+20,190,0,0,#file_name);
895
				WriteText(dform_x+20,190,0,0,#file_name);
896
			}
896
			}
897
		}		
897
		}		
898
		del_active=1;
898
		del_active=1;
899
	}
899
	}
900
}
900
}
901
 
901
 
902
void SelectFileByName(dword that_file)
902
void SelectFileByName(dword that_file)
903
{
903
{
904
	int ind;
904
	int ind;
905
	files.KeyHome();
905
	files.KeyHome();
906
	Open_Dir(#path,ONLY_OPEN);
906
	Open_Dir(#path,ONLY_OPEN);
907
	if (dir_at_fat16) && (file_name_is_8_3(that_file)) strttl(that_file);
907
	if (dir_at_fat16) && (file_name_is_8_3(that_file)) strttl(that_file);
908
	for (ind=files.count-1; ind>=0; ind--;) { if (!strcmp(file_mas[ind]*304+buf+72,that_file)) break; }
908
	for (ind=files.count-1; ind>=0; ind--;) { if (!strcmp(file_mas[ind]*304+buf+72,that_file)) break; }
909
	files.cur_y = ind - 1;
909
	files.cur_y = ind - 1;
910
	files.KeyDown();
910
	files.KeyDown();
911
	DrawStatusBar();
911
	DrawStatusBar();
912
	List_ReDraw();
912
	List_ReDraw();
913
}
913
}
914
 
914
 
915
 
915
 
916
void Dir_Up()
916
void Dir_Up()
917
{
917
{
918
	int iii;
918
	int iii;
919
	char old_folder_name[4096];
919
	char old_folder_name[4096];
920
	iii=strlen(#path)-1;
920
	iii=strlen(#path)-1;
921
	if (iii==0) return;
921
	if (iii==0) return;
922
	iii = strrchr(#path, '/');
922
	iii = strrchr(#path, '/');
923
	strcpy(#old_folder_name, #path+iii);
923
	strcpy(#old_folder_name, #path+iii);
924
	if (iii>1) path[iii-1]=NULL; else path[iii]=NULL;
924
	if (iii>1) path[iii-1]=NULL; else path[iii]=NULL;
925
	SelectFileByName(#old_folder_name);
925
	SelectFileByName(#old_folder_name);
926
}
926
}
927
 
927
 
928
void Open(byte rez)
928
void Open(byte rez)
929
{
929
{
930
	byte temp[4096];
930
	byte temp[4096];
931
	selected_count = 0;
931
	selected_count = 0;
932
	if (rez)
932
	if (rez)
933
	{
933
	{
934
		if (!strncmp(#file_name,"..",3)) return;
934
		if (!strncmp(#file_name,"..",3)) return;
935
		strcpy(#temp, #file_path);
935
		strcpy(#temp, #file_path);
936
		RunProgram(I_Path, #temp);
936
		RunProgram(I_Path, #temp);
937
		return;
937
		return;
938
	}
938
	}
939
	if (!files.count) return;
939
	if (!files.count) return;
940
	if (!itdir)
940
	if (!itdir)
941
	{
941
	{
942
		if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
942
		if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
943
	} 
943
	} 
944
	else
944
	else
945
	{
945
	{
946
		if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
946
		if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
947
		strcpy(#path, #file_path);
947
		strcpy(#path, #file_path);
948
		files.first=files.cur_y=0;
948
		files.first=files.cur_y=0;
949
		Open_Dir(#path,WITH_REDRAW);
949
		Open_Dir(#path,WITH_REDRAW);
950
	}
950
	}
951
}
951
}
952
 
952
 
953
inline fastcall void EventHistoryGoBack()
953
inline fastcall void EventHistoryGoBack()
954
{
954
{
955
	char cur_folder[4096];
955
	char cur_folder[4096];
956
	strcpy(#cur_folder, #path);
956
	strcpy(#cur_folder, #path);
957
	if (history.back()) {
957
	if (history.back()) {
958
		strcpy(#path, history.current());
958
		strcpy(#path, history.current());
959
		SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
959
		SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
960
	}
960
	}
961
}
961
}
962
 
962
 
963
void ShowOpenWithDialog()
963
void ShowOpenWithDialog()
964
{
964
{
965
	byte open_param[4097];
965
	byte open_param[4097];
966
	sprintf(#open_param,"~%s",#file_path);
966
	sprintf(#open_param,"~%s",#file_path);
967
	RunProgram("/sys/@open", #open_param);
967
	RunProgram("/sys/@open", #open_param);
968
}
968
}
969
 
969
 
970
void NewElement()
970
void NewElement()
971
{
971
{
972
	BDVK element_info;
972
	BDVK element_info;
973
	byte del_rezult, copy_rezult, info_result;
973
	byte del_rezult, copy_rezult, info_result;
974
 
974
 
975
	sprintf(#temp,"%s/%s",#path,new_file_ed.text);
975
	sprintf(#temp,"%s/%s",#path,new_file_ed.text);
976
	info_result = GetFileInfo(#temp, #element_info);
976
	info_result = GetFileInfo(#temp, #element_info);
977
	switch(new_element_active)
977
	switch(new_element_active)
978
	{
978
	{
979
		case CREATE_FILE:
979
		case CREATE_FILE:
980
			if (info_result==5)
980
			if (info_result==5)
981
			{
981
			{
982
				CreateFile(0, 0, #temp);
982
				CreateFile(0, 0, #temp);
983
				if (EAX)
983
				if (EAX)
984
				{
984
				{
985
					if (EAX==5) notify(NOT_CREATE_FILE);
985
					if (EAX==5) notify(NOT_CREATE_FILE);
986
					else Write_Error(EAX);
986
					else Write_Error(EAX);
987
				}
987
				}
988
			}
988
			}
989
			else
989
			else
990
			{
990
			{
991
				notify(FS_ITEM_ALREADY_EXISTS);
991
				notify(FS_ITEM_ALREADY_EXISTS);
992
			}
992
			}
993
			break;
993
			break;
994
		case CREATE_FOLDER:
994
		case CREATE_FOLDER:
995
			if (info_result==5)
995
			if (info_result==5)
996
			{
996
			{
997
				CreateDir(#temp);
997
				CreateDir(#temp);
998
				if (EAX)
998
				if (EAX)
999
				{
999
				{
1000
					if (EAX==5) notify(NOT_CREATE_FOLDER);
1000
					if (EAX==5) notify(NOT_CREATE_FOLDER);
1001
					else Write_Error(EAX);
1001
					else Write_Error(EAX);
1002
				}
1002
				}
1003
			}
1003
			}
1004
			else
1004
			else
1005
			{
1005
			{
1006
				notify(FS_ITEM_ALREADY_EXISTS);
1006
				notify(FS_ITEM_ALREADY_EXISTS);
1007
			}
1007
			}
1008
			break;
1008
			break;
1009
		case RENAME_ITEM:
1009
		case RENAME_ITEM:
1010
			if (info_result==5)
1010
			if (info_result==5)
1011
			{
1011
			{
1012
				if (itdir)
1012
				if (itdir)
1013
				{
1013
				{
1014
					//rename only empty folders
1014
					//rename only empty folders
1015
					if (del_rezult = DeleteFile(#file_path))
1015
					if (del_rezult = DeleteFile(#file_path))
1016
					{
1016
					{
1017
						Write_Error(del_rezult);
1017
						Write_Error(del_rezult);
1018
						return;
1018
						return;
1019
					}
1019
					}
1020
					if (CreateDir(#temp)) CreateDir(#file_path);
1020
					if (CreateDir(#temp)) CreateDir(#file_path);
1021
					Open_Dir(#path,WITH_REDRAW);
1021
					Open_Dir(#path,WITH_REDRAW);
1022
					SelectFileByName(new_file_ed.text);
1022
					SelectFileByName(new_file_ed.text);
1023
				}
1023
				}
1024
				else
1024
				else
1025
				{
1025
				{
1026
					if (copy_rezult = CopyFile(#file_path,#temp))
1026
					if (copy_rezult = CopyFile(#file_path,#temp))
1027
					{
1027
					{
1028
						Write_Error(copy_rezult);
1028
						Write_Error(copy_rezult);
1029
					}
1029
					}
1030
					else
1030
					else
1031
					{
1031
					{
1032
						DeleteFile(#file_path);
1032
						DeleteFile(#file_path);
1033
						SelectFileByName(new_file_ed.text);
1033
						SelectFileByName(new_file_ed.text);
1034
					}
1034
					}
1035
				}
1035
				}
1036
			}
1036
			}
1037
			else
1037
			else
1038
			{
1038
			{
1039
				notify(FS_ITEM_ALREADY_EXISTS);
1039
				notify(FS_ITEM_ALREADY_EXISTS);
1040
			}
1040
			}
1041
	}
1041
	}
1042
	Open_Dir(#path,WITH_REDRAW);
1042
	Open_Dir(#path,WITH_REDRAW);
1043
	SelectFileByName(new_file_ed.text);
1043
	SelectFileByName(new_file_ed.text);
1044
	EventClosePopinForm();
1044
	EventClosePopinForm();
1045
}
1045
}
1046
 
1046
 
1047
void NewElement_Form(byte crt, dword strng)
1047
void NewElement_Form(byte crt, dword strng)
1048
{
1048
{
1049
	int dform_x=files.w-220/2+files.x;
1049
	int dform_x=files.w-220/2+files.x;
1050
	if (!new_element_active)
1050
	if (!new_element_active)
1051
	{
1051
	{
1052
		new_element_active = crt;
1052
		new_element_active = crt;
1053
		strcpy(#new_element_name, strng);
1053
		strcpy(#new_element_name, strng);
1054
		EditBox_UpdateText(#new_file_ed, ed_focus+ed_always_focus);
1054
		EditBox_UpdateText(#new_file_ed, ed_focus+ed_always_focus);
1055
	}
1055
	}
1056
	if (new_element_active==3) DrawEolitePopup(T_RENAME, T_CANCEL);
1056
	if (new_element_active==3) DrawEolitePopup(T_RENAME, T_CANCEL);
1057
	else DrawEolitePopup(T_CREATE, T_CANCEL);
1057
	else DrawEolitePopup(T_CREATE, T_CANCEL);
1058
	new_file_ed.left = dform_x+10;
1058
	new_file_ed.left = dform_x+10;
1059
	DrawEditBox(#new_file_ed);
1059
	DrawEditBox(#new_file_ed);
1060
}
1060
}
1061
 
1061
 
1062
void FnProcess(byte N)
1062
void FnProcess(byte N)
1063
{
1063
{
1064
	switch(N)
1064
	switch(N)
1065
	{
1065
	{
1066
		case 1:
1066
		case 1:
1067
			if (!active_about) {
1067
			if (!active_about) {
1068
				about_stak = malloc(4096);
1068
				about_stak = malloc(4096);
1069
				about_thread_id = CreateThread(#about_dialog,about_stak+4092);
1069
				about_thread_id = CreateThread(#about_dialog,about_stak+4092);
1070
				break;
1070
				break;
1071
			} else {
1071
			} else {
1072
				ActivateWindow(GetProcessSlot(about_thread_id));
1072
				ActivateWindow(GetProcessSlot(about_thread_id));
1073
			}
1073
			}
1074
			break;
1074
			break;
1075
		case 2:
1075
		case 2:
1076
			if (files.count) NewElement_Form(RENAME_ITEM, #file_name);
1076
			if (files.count) NewElement_Form(RENAME_ITEM, #file_name);
1077
			break;
1077
			break;
1078
		case 3:
1078
		case 3:
1079
			if (files.count) && (!itdir) RunProgram("/sys/tinypad", #file_path);
1079
			if (files.count) && (!itdir) RunProgram("/sys/tinypad", #file_path);
1080
			break;
1080
			break;
1081
		case 4:
1081
		case 4:
1082
			if (files.count) && (!itdir) RunProgram("/sys/develop/heed", #file_path);
1082
			if (files.count) && (!itdir) RunProgram("/sys/develop/heed", #file_path);
1083
			break;
1083
			break;
1084
		case 5: //refresh cur dir & devs
1084
		case 5: //refresh cur dir & devs
1085
			if (two_panels.checked)
1085
			if (two_panels.checked)
1086
			{
1086
			{
1087
				DrawFilePanels();
1087
				DrawFilePanels();
1088
			}
1088
			}
1089
			else 
1089
			else 
1090
			{
1090
			{
1091
				Tip(56, T_DEVICES, 55, "-");
1091
				Tip(56, T_DEVICES, 55, "-");
1092
				Open_Dir(#path,WITH_REDRAW);
1092
				Open_Dir(#path,WITH_REDRAW);
1093
				pause(10);
1093
				pause(10);
1094
				SystemDiscs.Get();
1094
				SystemDiscs.Get();
1095
				Open_Dir(#path,WITH_REDRAW);
1095
				Open_Dir(#path,WITH_REDRAW);
1096
				DrawDeviceAndActionsLeftPanel();				
1096
				DrawDeviceAndActionsLeftPanel();				
1097
			}
1097
			}
1098
			break;
1098
			break;
1099
		case 6:
1099
		case 6:
1100
			NewElement_Form(CREATE_FOLDER, T_NEW_FOLDER);
1100
			NewElement_Form(CREATE_FOLDER, T_NEW_FOLDER);
1101
			break;
1101
			break;
1102
		case 7:
1102
		case 7:
1103
			NewElement_Form(CREATE_FILE, T_NEW_FILE);
1103
			NewElement_Form(CREATE_FILE, T_NEW_FILE);
1104
			break;
1104
			break;
1105
		case 8:
1105
		case 8:
1106
			EventShowProperties();
1106
			EventShowProperties();
1107
			break;
1107
			break;
1108
		case 10: //F10
1108
		case 10: //F10
1109
			if (!active_settings) 
1109
			if (!active_settings) 
1110
			{
1110
			{
1111
				settings_stak = malloc(4096);
1111
				settings_stak = malloc(4096);
1112
				settings_window = CreateThread(#settings_dialog, settings_stak+4092);
1112
				settings_window = CreateThread(#settings_dialog, settings_stak+4092);
1113
				break;
1113
				break;
1114
			}
1114
			}
1115
			else
1115
			else
1116
			{
1116
			{
1117
				ActivateWindow(GetProcessSlot(settings_window));
1117
				ActivateWindow(GetProcessSlot(settings_window));
1118
			}
1118
			}
1119
			break;
1119
			break;
1120
	}
1120
	}
1121
}
1121
}
1122
 
1122
 
1123
void ChangeActivePanel()
1123
void ChangeActivePanel()
1124
{
1124
{
1125
	llist_copy(#files_active, #files_inactive);
1125
	llist_copy(#files_active, #files_inactive);
1126
	llist_copy(#files_inactive, #files);
1126
	llist_copy(#files_inactive, #files);
1127
	strcpy(#active_path, #inactive_path);
1127
	strcpy(#active_path, #inactive_path);
1128
	strcpy(#inactive_path, #path);
1128
	strcpy(#inactive_path, #path);
1129
	DrawFilePanels();
1129
	DrawFilePanels();
1130
}
1130
}
1131
 
1131
 
1132
void EventSelectAllFiles(dword state)
1132
void EventSelectAllFiles(dword state)
1133
{
1133
{
1134
	int i;
1134
	int i;
1135
	for (i=0; i
1135
	for (i=0; i
1136
	List_ReDraw();
1136
	List_ReDraw();
1137
	DrawStatusBar();
1137
	DrawStatusBar();
1138
}
1138
}
1139
 
1139
 
1140
void EventSelectFileByKeyPress()
1140
void EventSelectFileByKeyPress()
1141
{
1141
{
1142
	int i;
1142
	int i;
1143
	for (i=files.cur_y+1; i
1143
	for (i=files.cur_y+1; i
1144
	{
1144
	{
1145
		strcpy(#temp, file_mas[i]*304+buf+72);
1145
		strcpy(#temp, file_mas[i]*304+buf+72);
1146
		if (temp[0]==key_ascii) || (temp[0]==key_ascii-32)
1146
		if (temp[0]==key_ascii) || (temp[0]==key_ascii-32)
1147
		{
1147
		{
1148
			files.cur_y = i - 1;
1148
			files.cur_y = i - 1;
1149
			files.KeyDown();
1149
			files.KeyDown();
1150
			List_ReDraw();
1150
			List_ReDraw();
1151
			return;
1151
			return;
1152
		}
1152
		}
1153
	}
1153
	}
1154
}
1154
}
1155
 
1155
 
1156
dword GetDeviceSizeLabel(dword path)
1156
dword GetDeviceSizeLabel(dword path)
1157
{
1157
{
1158
	BDVK bdvk;
1158
	BDVK bdvk;
1159
	char cdname[8];
1159
	char cdname[8];
1160
	if (ESBYTE[path+1] == '/') path++;
1160
	if (ESBYTE[path+1] == '/') path++;
1161
	if (ESBYTE[path+1] == 'c') && (ESBYTE[path+2] == 'd')
1161
	if (ESBYTE[path+1] == 'c') && (ESBYTE[path+2] == 'd')
1162
		&& (ESBYTE[path+4] == 0) return 0;
1162
		&& (ESBYTE[path+4] == 0) return 0;
1163
	GetFileInfo(path, #bdvk);
1163
	GetFileInfo(path, #bdvk);
1164
	return ConvertSize64(bdvk.sizelo, bdvk.sizehi);
1164
	return ConvertSize64(bdvk.sizelo, bdvk.sizehi);
1165
}
1165
}
1166
 
1166
 
1167
int GetRealFileCountInFolder(dword folder_path)
1167
int GetRealFileCountInFolder(dword folder_path)
1168
{
1168
{
1169
	int fcount;
1169
	int fcount;
1170
	dword countbuf;
1170
	dword countbuf;
1171
 
1171
 
1172
	GetDir(#countbuf, #fcount, folder_path, DIRS_NOROOT);
1172
	GetDir(#countbuf, #fcount, folder_path, DIRS_NOROOT);
1173
	if (countbuf) free(countbuf);
1173
	if (countbuf) free(countbuf);
1174
 
1174
 
1175
	return fcount;
1175
	return fcount;
1176
}
1176
}
1177
 
1177
 
1178
void EventRefreshDisksAndFolders()
1178
void EventRefreshDisksAndFolders()
1179
{
1179
{
1180
	if(GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
1180
	if(GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
1181
		FnProcess(5);
1181
		FnProcess(5);
1182
	}
1182
	}
1183
	if(two_panels.checked)
1183
	if(two_panels.checked)
1184
	{
1184
	{
1185
		if(GetRealFileCountInFolder(#inactive_path) != files_inactive.count) {
1185
		if(GetRealFileCountInFolder(#inactive_path) != files_inactive.count) {
1186
			ChangeActivePanel();
1186
			ChangeActivePanel();
1187
			Open_Dir(#path,WITH_REDRAW);
1187
			Open_Dir(#path,WITH_REDRAW);
1188
			ChangeActivePanel();
1188
			ChangeActivePanel();
1189
		}
1189
		}
1190
		if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
1190
		if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
1191
	}
1191
	}
1192
	else
1192
	else
1193
	{
1193
	{
1194
		if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
1194
		if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
1195
	}
1195
	}
1196
}
1196
}
1197
 
1197
 
1198
void EventSort(dword id)
1198
void EventSort(dword id)
1199
{
1199
{
1200
	char selected_filename[256];
1200
	char selected_filename[256];
1201
	if (sort_type == id) sort_desc ^= 1;
1201
	if (sort_type == id) sort_desc ^= 1;
1202
	else sort_type = id;
1202
	else sort_type = id;
1203
	strcpy(#selected_filename, #file_name);
1203
	strcpy(#selected_filename, #file_name);
1204
	DrawList();
1204
	DrawList();
1205
	Open_Dir(#path,WITH_REDRAW);
1205
	Open_Dir(#path,WITH_REDRAW);
1206
	SelectFileByName(#selected_filename);
1206
	SelectFileByName(#selected_filename);
1207
}
1207
}
1208
 
1208
 
1209
void EventHistoryGoForward()
1209
void EventHistoryGoForward()
1210
{
1210
{
1211
	if (history.forward()) {
1211
	if (history.forward()) {
1212
		strcpy(#path, history.current());
1212
		strcpy(#path, history.current());
1213
		files.KeyHome();
1213
		files.KeyHome();
1214
		Open_Dir(#path,WITH_REDRAW);
1214
		Open_Dir(#path,WITH_REDRAW);
1215
	}
1215
	}
1216
}
1216
}
1217
 
1217
 
1218
void EventOpenNewEolite()
1218
void EventOpenNewEolite()
1219
{
1219
{
1220
	RunProgram(I_Path, #path);
1220
	RunProgram(I_Path, #path);
1221
}
1221
}
1222
 
1222
 
1223
void EventOpenConsoleHere()
1223
void EventOpenConsoleHere()
1224
{
1224
{
1225
	sprintf(#param, "pwd cd %s", #path);
1225
	sprintf(#param, "pwd cd %s", #path);
1226
	RunProgram("/sys/shell", #param);
1226
	RunProgram("/sys/shell", #param);
1227
}
1227
}
1228
 
1228
 
1229
void ProceedMouseGestures()
1229
void ProceedMouseGestures()
1230
{
1230
{
1231
	char stats;
1231
	char stats;
1232
	signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
1232
	signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
1233
	if (!mouse.mkm) && (stats>0) stats = 0;
1233
	if (!mouse.mkm) && (stats>0) stats = 0;
1234
	if (mouse.mkm) && (!stats)
1234
	if (mouse.mkm) && (!stats)
1235
	{
1235
	{
1236
		x_old = mouse.x;
1236
		x_old = mouse.x;
1237
		y_old = mouse.y;
1237
		y_old = mouse.y;
1238
		stats = 1;
1238
		stats = 1;
1239
	}
1239
	}
1240
	if (mouse.mkm) && (stats==1)
1240
	if (mouse.mkm) && (stats==1)
1241
	{
1241
	{
1242
		dif_x = mouse.x-x_old;
1242
		dif_x = mouse.x-x_old;
1243
		dif_y = mouse.y-y_old;
1243
		dif_y = mouse.y-y_old;
1244
		adif_x = fabs(dif_x);
1244
		adif_x = fabs(dif_x);
1245
		adif_y = fabs(dif_y);
1245
		adif_y = fabs(dif_y);
1246
		
1246
		
1247
		if (adif_x>adif_y) {
1247
		if (adif_x>adif_y) {
1248
			if (dif_x > 150) {
1248
			if (dif_x > 150) {
1249
				EventHistoryGoForward();
1249
				EventHistoryGoForward();
1250
				stats = 0;
1250
				stats = 0;
1251
			}
1251
			}
1252
			if (dif_x < -150) {
1252
			if (dif_x < -150) {
1253
				EventHistoryGoBack();
1253
				EventHistoryGoBack();
1254
				stats = 0;
1254
				stats = 0;
1255
			}
1255
			}
1256
		} else {
1256
		} else {
1257
			if (dif_y < -100) {
1257
			if (dif_y < -100) {
1258
				Dir_Up();
1258
				Dir_Up();
1259
				stats = 0;
1259
				stats = 0;
1260
			}
1260
			}
1261
		}
1261
		}
1262
	}
1262
	}
1263
}
1263
}
1264
 
1264
 
1265
void EventPaste() {
1265
void EventPaste() {
1266
	char paste_line[4096+6];
1266
	char paste_line[4096+6];
1267
	sprintf(#paste_line, "-v%i %s", cut_active, #path);
1267
	sprintf(#paste_line, "-v%i %s", cut_active, #path);
1268
	RunProgram(#program_path, #paste_line);
1268
	RunProgram(#program_path, #paste_line);
1269
	EventClosePopinForm();
1269
	EventClosePopinForm();
1270
}
1270
}
1271
 
1271
 
1272
void EventDelete() 
1272
void EventDelete() 
1273
char line_param[4096+5];
1273
char line_param[4096+5];
1274
{
1274
{
1275
	EventClosePopinForm();
1275
	EventClosePopinForm();
1276
	if (!selected_count) {
1276
	if (!selected_count) {
1277
		sprintf(#line_param, "-d %s", #file_path);
1277
		sprintf(#line_param, "-d %s", #file_path);
1278
		RunProgram(#program_path, #line_param);
1278
		RunProgram(#program_path, #line_param);
1279
	} else {
1279
	} else {
1280
		delete_stak = malloc(40000);
1280
		delete_stak = malloc(40000);
1281
		CreateThread(#DeleteSelectedElements,delete_stak+40000-4);
1281
		CreateThread(#DeleteSelectedElements,delete_stak+40000-4);
1282
	}
1282
	}
1283
}
1283
}
1284
 
1284
 
1285
void EventClosePopinForm()
1285
void EventClosePopinForm()
1286
{
1286
{
1287
	del_active=0;
1287
	del_active=0;
1288
	new_element_active = 0;
1288
	new_element_active = 0;
1289
	draw_window();
1289
	draw_window();
1290
	DeleteButton(POPUP_BTN1);
1290
	DeleteButton(POPUP_BTN1);
1291
	DeleteButton(POPUP_BTN2);
1291
	DeleteButton(POPUP_BTN2);
1292
}
1292
}
1293
 
1293
 
1294
void EventShowProperties()
1294
void EventShowProperties()
1295
char line_param[4096+5];
1295
char line_param[4096+5];
1296
{
1296
{
1297
	if (!selected_count) {
1297
	if (!selected_count) {
1298
		sprintf(#line_param, "-p %s", #file_path);
1298
		sprintf(#line_param, "-p %s", #file_path);
1299
		RunProgram(#program_path, #line_param);
1299
		RunProgram(#program_path, #line_param);
1300
	} else {
1300
	} else {
1301
		properties_stak = malloc(8096);
1301
		properties_stak = malloc(8096);
1302
		CreateThread(#properties_dialog, properties_stak+8092);
1302
		CreateThread(#properties_dialog, properties_stak+8092);
1303
	}
1303
	}
1304
}
1304
}
1305
 
1305
 
1306
stop:
1306
stop:
1307
>
1307
>
1308
>
1308
>
1309
>
1309
>
1310
>
1310
>
1311
>
1311
>
1312
>
1312
>