Subversion Repositories Kolibri OS

Rev

Rev 7398 | Rev 7447 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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