Subversion Repositories Kolibri OS

Rev

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

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