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