Subversion Repositories Kolibri OS

Rev

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

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