Subversion Repositories Kolibri OS

Rev

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

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