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