Subversion Repositories Kolibri OS

Rev

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