Subversion Repositories Kolibri OS

Rev

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

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