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