Subversion Repositories Kolibri OS

Rev

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