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