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