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