Subversion Repositories Kolibri OS

Rev

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

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