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