Subversion Repositories Kolibri OS

Rev

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