Subversion Repositories Kolibri OS

Rev

Rev 7813 | Rev 7819 | 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(80);
  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 51:
  346.                                                 EventShowBurgerMenu();
  347.                                                 break;
  348.                                 case 52...60: //Actions
  349.                                                 FnProcess(id-50);
  350.                                                 break;
  351.                                 case 61: // Set path as default
  352.                                                 SetDefaultPath(#path);
  353.                                                 break;
  354.                                 case 100...120:
  355.                                         SystemDiscs.Click(id-100);
  356.                                         break;
  357.                                 case BREADCRUMB_ID...360:
  358.                                         ClickOnBreadCrumb(id-BREADCRUMB_ID);
  359.                                         break;
  360.                         }
  361.                         break;
  362.                        
  363. //Key pressed-----------------------------------------------------------------------------
  364.                 case evKey:
  365.                         GetKeys();
  366.  
  367.                         if (Form.status_window>2) break;
  368.  
  369.                         if (new_element_active) || (del_active)
  370.                         {
  371.                                 if (del_active)
  372.                                 {
  373.                                         if (key_scancode == SCAN_CODE_ENTER) Del_File(true);
  374.                                         if (key_scancode == SCAN_CODE_ESC) Del_File(false);
  375.                                 }
  376.                                 if (new_element_active)
  377.                                 {
  378.                                         if (key_scancode == SCAN_CODE_ENTER) NewElement(true);
  379.                                         if (key_scancode == SCAN_CODE_ESC) NewElement(false);
  380.                                         EAX = key_editbox;
  381.                                         edit_box_key stdcall (#new_file_ed);
  382.                                 }
  383.                                 break;
  384.                         }
  385.  
  386.                         if (files.ProcessKey(key_scancode))
  387.                         {
  388.                                 List_ReDraw();
  389.                                 break;
  390.                         }
  391.  
  392.                         if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
  393.                         {
  394.                                 switch(key_scancode)
  395.                                 {
  396.                                         case SCAN_CODE_F1...SCAN_CODE_F3:
  397.                                                         EventSort(key_scancode - 58);
  398.                                                         break;
  399.                                         case SCAN_CODE_1...SCAN_CODE_10:
  400.                                                         key_scancode-=2;
  401.                                                         if (key_scancode >= SystemDiscs.list.count) break;
  402.                                                         if (!two_panels.checked)
  403.                                                         {
  404.                                                                 DrawRectangle(17,key_scancode*16+74,159,16, 0); //display click
  405.                                                                 pause(7);                                                                              
  406.                                                         }
  407.                                                         SystemDiscs.Click(key_scancode);
  408.                                                         break;
  409.                                         case SCAN_CODE_KEY_X:
  410.                                                         Copy(#file_path, CUT);
  411.                                                         break;                                         
  412.                                         case SCAN_CODE_KEY_C:
  413.                                                         Copy(#file_path, NOCUT);
  414.                                                         break;
  415.                                         case SCAN_CODE_KEY_G:
  416.                                                         EventOpenConsoleHere();
  417.                                                         break;
  418.                                         case SCAN_CODE_KEY_V:
  419.                                                         Paste();
  420.                                                         break;
  421.                                         case SCAN_CODE_KEY_D: //set image as bg
  422.                                                         strlcpy(#temp, "\\S__",4);
  423.                                                         strcat(#temp, #file_path);
  424.                                                         RunProgram("/sys/media/kiv", #temp);
  425.                                                         break;
  426.                                         case SCAN_CODE_KEY_N:
  427.                                                         EventOpenNewEolite();
  428.                                                         break;
  429.                                         case SCAN_CODE_KEY_M:
  430.                                                         Open_Dir(#inactive_path,WITH_REDRAW);
  431.                                                         break;
  432.                                         case SCAN_CODE_ENTER:
  433.                                                         if (!itdir) ShowOpenWithDialog();
  434.                                                         else Open(1);
  435.                                                         break;
  436.                                         case SCAN_CODE_KEY_A:
  437.                                                         EventSelectAllFiles(true);
  438.                                                         break;
  439.                                         case SCAN_CODE_KEY_U: //unselect all files
  440.                                                         EventSelectAllFiles(false);
  441.                                                         break;
  442.                                 }
  443.                                 break;
  444.                         }
  445.  
  446.                         switch (key_scancode)
  447.                         {
  448.                                         case SCAN_CODE_BS:
  449.                                                         //EventHistoryGoBack();
  450.                                                         Dir_Up();
  451.                                                         break;
  452.                                         case SCAN_CODE_ENTER:
  453.                                                         Open(0);
  454.                                                         break;
  455.                                         case SCAN_CODE_TAB:
  456.                                                         if (!two_panels.checked) break;
  457.                                                         if (active_panel==1) active_panel=2; else active_panel=1;
  458.                                                         ChangeActivePanel();
  459.                                                         DrawFilePanels();
  460.                                                         break;
  461.                                         case SCAN_CODE_MENU:
  462.                                                         mouse.x = files.x+15;
  463.                                                         mouse.y = files.cur_y - files.first * files.item_h + files.y + 5;
  464.                                                         EventShowListMenu();
  465.                                                         break;
  466.                                         case SCAN_CODE_DEL:
  467.                                                         Del_Form();
  468.                                                         break;
  469.                                         case SCAN_CODE_INS:
  470.                                                         if (getElementSelectedFlag(files.cur_y) == true) setElementSelectedFlag(files.cur_y, false);
  471.                                                         else setElementSelectedFlag(files.cur_y, true);
  472.                                                         files.KeyDown();
  473.                                                         List_ReDraw();
  474.                                                         DrawStatusBar();
  475.                                                         break;
  476.                                         case SCAN_CODE_F1...SCAN_CODE_F10:
  477.                                                         FnProcess(key_scancode-58);
  478.                                                         break;
  479.                                         default:
  480.                                                         EventSelectFileByKeyPress();
  481.                         }                        
  482.                 break;
  483.                 case evIPC:
  484.                 case evReDraw:
  485.                         draw_window();
  486.                         if (CheckActiveProcess(Form.ID)) && (GetMenuClick()) break;
  487.                         if (action_buf==OPERATION_END)
  488.                         {
  489.                                 FnProcess(5);
  490.                                 if (copy_stak) SelectFileByName(#copy_to+strrchr(#copy_to,'/'));
  491.                                 action_buf=0;
  492.                         }
  493.                 break;
  494.                 default:
  495.                         if (Form.status_window>2) break;
  496.                         EventRefreshDisksAndFolders();
  497.         }
  498.        
  499.         if(cmd_free)
  500.         {
  501.                 if(cmd_free==2) about_stak=free(about_stak);
  502.                 else if(cmd_free==3) properties_stak=free(properties_stak);
  503.                 else if(cmd_free==4) settings_stak=free(settings_stak);
  504.                 else if(cmd_free==5) copy_stak=free(copy_stak);
  505.                 else if(cmd_free==6) delete_stak=free(delete_stak);
  506.                 cmd_free = false;
  507.         }
  508. }
  509.  
  510. void draw_window()
  511. {
  512.         dword i;
  513.         if (show_status_bar.checked) status_bar_h = STATUS_BAR_H; else status_bar_h = 0;
  514.         DefineAndDrawWindow(Form.left+rand_n,Form.top+rand_n,Form.width,Form.height,0x73,NULL,TITLE,0);
  515.         GetProcessInfo(#Form, SelfInfo);
  516.         if (Form.status_window>2) return;
  517.         if (Form.height < 350) { MoveSize(OLD,OLD,OLD,350); return; }
  518.         if (!two_panels.checked) && (Form.width < 480) { MoveSize(OLD,OLD,480,OLD); return; }
  519.         if ( two_panels.checked) && (Form.width < 573) { MoveSize(OLD,OLD,573,OLD); return; }
  520.         GetProcessInfo(#Form, SelfInfo);
  521.         SetAppColors();
  522.         ESDWORD[#toolbar_pal] = sc.work;
  523.         ESDWORD[#toolbar_pal+4] = MixColors(0, sc.work, 35);
  524.         PutPaletteImage(#toolbar, 246, 34, 0, 0, 8, #toolbar_pal);
  525.         DrawBar(127, 8, 1, 25, sc.work_graph);
  526.         for (i=0; i<3; i++) DefineHiddenButton(toolbar_buttons_x[i]+2,7,31-5,29-5,21+i);
  527.         for (i=3; i<6; i++) DefineHiddenButton(toolbar_buttons_x[i],  5,31,  29,  21+i);
  528.         DrawBar(246,0, Form.cwidth - 246, 34, sc.work);
  529.         DrawDot(Form.cwidth-17,12);
  530.         DrawDot(Form.cwidth-17,12+6);
  531.         DrawDot(Form.cwidth-17,12+12);
  532.         DefineHiddenButton(Form.cwidth-24,7,20,25,51+BT_NOFRAME); //dots
  533.         //main rectangles
  534.         DrawRectangle(1,40,Form.cwidth-3,Form.cheight - 42-status_bar_h,sc.work_graph);
  535.         DrawRectangle(0,39,Form.cwidth-1,-show_status_bar.checked*status_bar_h + Form.cheight - 40,col.work_gradient[4]); //bg
  536.         for (i=0; i<6; i++) DrawBar(0, 34+i, Form.cwidth, 1, MixColors(sc.work_dark, sc.work, i*10));
  537.         llist_copy(#files_active, #files);
  538.         strcpy(#active_path, #path);
  539.         DrawStatusBar();
  540.         if (selected_count==0) Open_Dir(#path,ONLY_OPEN); //if there are no selected files -> refresh folder [L001]
  541.         DrawFilePanels();
  542. }
  543.  
  544. void DrawList()
  545. {
  546.         word sorting_arrow_x;
  547.         dword sorting_arrow_t = "\x19";
  548.         if (sort_desc) sorting_arrow_t = "\x18";
  549.         DrawFlatButtonSmall(files.x, files.y-17,     files.w - 141,16,31,T_FILE);
  550.         DrawFlatButtonSmall(files.x + files.w - 141, files.y-17,73,16,32,T_TYPE);
  551.         DrawFlatButtonSmall(files.x + files.w -  68, files.y-17,68,16,33,T_SIZE);
  552.         DrawFlatButtonSmall(files.x + files.w,       files.y-17,16,16, 0,"\x18");
  553.         DrawFlatButtonSmall(files.x + files.w,files.y+files.h-16,16,16,0,"\x19");
  554.         if (sort_type==1) sorting_arrow_x = files.w - 141 / 2 + files.x + 18;
  555.         if (sort_type==2) sorting_arrow_x = files.x + files.w - 90;
  556.         if (sort_type==3) sorting_arrow_x = strlen(T_SIZE)*3-30+files.x+files.w;
  557.         WriteText(sorting_arrow_x,files.y-12,0x80, sc.work_text, sorting_arrow_t);
  558.         DrawBar(files.x+files.w,files.y,1,files.h,sc.work_graph);
  559.         if (two_panels.checked) && (files.x<5) DrawBar(files.x+files.w+16,files.y,1,files.h,sc.work_graph);    
  560. }
  561.  
  562. void DrawStatusBar()
  563. {
  564.         char status_bar_str[80];
  565.         int go_up_folder_exists=0;
  566.         if (!show_status_bar.checked) return;
  567.         if (files.count>0) && (strcmp(file_mas[0]*304+buf+72,"..")==0) go_up_folder_exists=1;
  568.         DrawBar(0, Form.cheight - status_bar_h, Form.cwidth,  status_bar_h, sc.work);
  569.         sprintf(#status_bar_str, T_STATUS_EVEMENTS, count_dir-go_up_folder_exists, files.count-count_dir);
  570.         WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str);
  571.         if (selected_count) {
  572.                 sprintf(#status_bar_str, T_STATUS_SELECTED, selected_count);
  573.                 WriteText(Form.cwidth - calc(strlen(#status_bar_str)*6)-6,Form.cheight - 13,
  574.                         0x80,sc.work_text,#status_bar_str);
  575.         }
  576. }
  577.  
  578. void DrawFilePanels()
  579. {
  580.         int files_y;
  581.         if (!two_panels.checked)
  582.         {
  583.                 DrawDeviceAndActionsLeftPanel();
  584.                 files.SetSizes(192, 57, Form.cwidth - 210, Form.cheight - 59 - status_bar_h, files.item_h);
  585.                 DrawList();
  586.                 Open_Dir(#path,ONLY_SHOW);
  587.         }
  588.         else
  589.         {
  590.                 SystemDiscs.Get();
  591.                 llist_copy(#files, #files_inactive);
  592.                 strcpy(#path, #inactive_path);
  593.                 col.selec = col.selec_inactive;
  594.                 SystemDiscs.Draw();
  595.                 files_y = files.y;
  596.  
  597.                 if (active_panel==1)
  598.                 {
  599.                         llist_copy(#files, #files_inactive);
  600.                         strcpy(#path, #inactive_path);
  601.                         col.selec = col.selec_inactive; //this is a bad code: need to use some var to set inactive panel for DrawList();
  602.                         files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
  603.                         DrawList();
  604.                         Open_Dir(#path,WITH_REDRAW);
  605.                         llist_copy(#files, #files_active);
  606.                         strcpy(#path, #active_path);
  607.                         col.selec = col.selec_active;
  608.                         files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
  609.                         DrawList();
  610.                         Open_Dir(#path,WITH_REDRAW);
  611.                 }
  612.                 if (active_panel==2)
  613.                 {
  614.                         files.SetSizes(2, files_y, Form.cwidth/2-2-17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
  615.                         DrawList();
  616.                         Open_Dir(#path,WITH_REDRAW);
  617.                         llist_copy(#files, #files_active);
  618.                         strcpy(#path, #active_path);
  619.                         col.selec = col.selec_active;
  620.                         files.SetSizes(Form.cwidth/2, files_y, Form.cwidth/2 -17, Form.cheight-files_y-2 - status_bar_h, files.item_h);
  621.                         DrawList();
  622.                         Open_Dir(#path,WITH_REDRAW);
  623.                 }
  624.         }
  625. }
  626.  
  627.  
  628. void List_ReDraw()
  629. {
  630.         int all_lines_h;
  631.         dword j;
  632.         static int old_cur_y, old_first;
  633.  
  634.         files.CheckDoesValuesOkey(); //prevent some shit
  635.  
  636.         if (list_full_redraw) || (old_first != files.first)
  637.         {
  638.                 old_cur_y = files.cur_y;
  639.                 old_first = files.first;
  640.                 list_full_redraw = false;
  641.                 goto _ALL_LIST_REDRAW;
  642.         }
  643.         if (old_cur_y != files.cur_y)
  644.         {
  645.                 if (old_cur_y-files.first<files.visible) Line_ReDraw(col.list_bg, old_cur_y-files.first);
  646.                 Line_ReDraw(col.selec, files.cur_y-files.first);
  647.                 old_cur_y = files.cur_y;
  648.                 return;
  649.         }
  650.  
  651.         _ALL_LIST_REDRAW:
  652.  
  653.         for (j=0; j<files.visible; j++) {
  654.                 if (files.cur_y-files.first!=j) Line_ReDraw(col.list_bg, j);
  655.                 else Line_ReDraw(col.selec, files.cur_y-files.first);          
  656.         }
  657.         //in the bottom
  658.         all_lines_h = j * files.item_h;
  659.         DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h, col.list_bg);
  660.         DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h,col.list_vert_line);
  661.         DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h,col.list_vert_line);
  662.         Scroll();
  663.  
  664.         if (del_active) Del_Form();
  665.         if (new_element_active) && (col.selec != 0xCCCccc) NewElement_Form(new_element_active, #new_element_name);
  666. }
  667.  
  668. bool file_name_is_8_3(dword name)
  669. {
  670.         int name_len = strlen(name);
  671.         int dot_pos = strrchr(name, '.');
  672.         if (name_len<=12)
  673.         {
  674.                 if (dot_pos) {
  675.                         if (name_len - dot_pos > 3) return false;
  676.                 }
  677.                 else {
  678.                         if (name_len>8) return false;
  679.                 }
  680.                 return true;
  681.         }
  682.         return false;
  683. }
  684.  
  685. void Line_ReDraw(dword bgcol, filenum){
  686.         dword text_col=col.list_gb_text,
  687.                   ext1, attr,
  688.                   file_offet,
  689.                   file_name_off,
  690.                   file_size=0,
  691.                   y=filenum*files.item_h+files.y,
  692.                   icon_y = files.item_h-icon_size/2+1+y;
  693.                   BDVK file;
  694.                   char temp_path[sizeof(file_path)];
  695.         char label_file_name[4096];
  696.         if (filenum==-1) return;
  697.         DrawBar(files.x,y,4,files.item_h,bgcol);
  698.         DrawBar(files.x+4,y,icon_size,icon_y-y,bgcol);
  699.         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);
  700.         if (colored_lines.checked) && (bgcol!=col.selec) && (filenum%2) bgcol=col.odd_line;
  701.         DrawBar(files.x+icon_size+4,y,files.w-icon_size-4,files.item_h,bgcol);
  702.  
  703.         file_offet = file_mas[filenum+files.first]*304 + buf+32;
  704.         attr = ESDWORD[file_offet];
  705.         file.selected = ESBYTE[file_offet+7];
  706.         file.sizelo   = ESDWORD[file_offet+32];
  707.         file.sizehi   = ESDWORD[file_offet+36];
  708.         file_name_off = file_offet+40;
  709.         sprintf(#temp_path,"%s/%s",#path,file_name_off);
  710.  
  711.         if (! TestBit(attr, 4) ) //file or folder?
  712.         {      
  713.                 ext1 = strrchr(file_name_off,'.') + file_name_off;
  714.                 if (ext1==file_name_off) ext1 = NULL; //if no extension then show nothing
  715.                 file_size = ConvertSize64(file.sizelo, file.sizehi);
  716.                 if (ext1) && (strlen(ext1)<9) WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
  717.         }
  718.         else
  719.         {
  720.                 if (!strcmp(file_name_off,"..")) ext1="<up>"; else {
  721.                         ext1="<DIR>";
  722.                         WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, col.list_gb_text, ext1);
  723.                 }
  724.                 if (chrnum(#path, '/')==1) file_size = GetDeviceSizeLabel(#temp_path);
  725.         }
  726.         if (file_size) WriteText(7-strlen(file_size)*6+files.x+files.w-58,
  727.                         files.text_y+y+1, files.font_type, col.list_gb_text, file_size);
  728.         DrawIconByExtension(#temp_path, ext1, files.x+4, icon_y, bgcol);
  729.  
  730.         if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=col.list_text_hidden; //system or hiden?
  731.         if (bgcol==col.selec)
  732.         {
  733.                 file_name_is_8_3(file_name_off);
  734.                 itdir = TestBit(attr, 4);
  735.                 strcpy(#file_name, file_name_off);
  736.                 if (!strcmp(#path,"/")) sprintf(#file_path,"%s%s",#path,file_name_off);
  737.                         else sprintf(#file_path,"%s/%s",#path,file_name_off);
  738.                 if (text_col==col.list_text_hidden) {
  739.                         text_col=MixColors(col.selec_text, col.list_text_hidden, 65);
  740.                 } else text_col=col.selec_text;
  741.         }
  742.         if (file.selected) text_col=0xFF0000;
  743.         if (kfont.size.pt==9) || (!kfont.font)
  744.         {
  745.                 if (Form.width>=480)
  746.                 {
  747.                         FileShow.start_x = files.x + 23;
  748.                         FileShow.font_color = text_col;
  749.                         FileShow.area_size_x = files.w - 164;
  750.                         FileShow.text_pointer = file_name_off;
  751.                         FileShow.start_y = files.text_y + y - 3;
  752.                         PathShow_prepare stdcall(#FileShow);
  753.                         PathShow_draw stdcall(#FileShow);
  754.                 }              
  755.         }
  756.         else
  757.         {
  758.                 strcpy(#label_file_name, file_name_off);
  759.                 if (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w)
  760.                 {
  761.                         while (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w) {
  762.                                 ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL;
  763.                         }
  764.                         strcpy(#label_file_name+strlen(#label_file_name)-2, "...");                    
  765.                 }
  766.                 kfont.WriteIntoWindow(files.x + icon_size+7, files.item_h - kfont.height / 2 + y,
  767.                         bgcol, text_col, kfont.size.pt, #label_file_name);
  768.         }
  769.         DrawBar(files.x+files.w-141,y,1,files.item_h,col.list_vert_line); //gray line 1
  770.         DrawBar(files.x+files.w-68,y,1,files.item_h,col.list_vert_line); //gray line 2
  771. }
  772.  
  773.  
  774. void Open_Dir(dword dir_path, redraw){
  775.         int errornum, maxcount, i;
  776.         if (redraw!=ONLY_SHOW)
  777.         {
  778.                 selected_count = 0;
  779.                 if (buf) free(buf);
  780.                 errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT);
  781.                 if (errornum)
  782.                 {
  783.                         history.add(#path);
  784.                         EventHistoryGoBack();
  785.                         Write_Error(errornum);
  786.                         return;
  787.                 }
  788.                 maxcount = sizeof(file_mas)/sizeof(dword)-1;
  789.                 if (files.count>maxcount) files.count = maxcount;
  790.                 if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
  791.         }
  792.         if (files.count!=-1)
  793.         {
  794.                 if(!_not_draw) if (show_breadcrumb.checked) DrawBreadCrumbs(); else DrawPathBar();
  795.                 history.add(#path);
  796.                 SystemDiscs.Draw();
  797.                 files.visible = files.h / files.item_h;
  798.                 if (files.count < files.visible) files.visible = files.count;
  799.                 if (!strncmp(dir_path, "/rd/1/",5))
  800.                         dir_at_fat16 = true; else dir_at_fat16 = false;
  801.                 if (redraw!=ONLY_SHOW) Sorting();
  802.                 list_full_redraw = true;
  803.                 if (redraw!=ONLY_OPEN)&&(!_not_draw) {DrawStatusBar(); List_ReDraw();}
  804.                 SetCurDir(dir_path);
  805.         }
  806.         if (files.count==-1) && (redraw!=ONLY_OPEN)
  807.         {
  808.                 files.KeyHome();
  809.                 if(!_not_draw) { list_full_redraw=true; DrawStatusBar(); List_ReDraw(); }
  810.         }
  811. }
  812.  
  813. inline Sorting()
  814. {
  815.         dword d=0, f=1;
  816.         int j=0;
  817.         dword file_off;
  818.  
  819.         if (!strcmp(#path,"/")) //do not sort root folder
  820.         {
  821.                 for(d=1;d<files.count;d++;) file_mas[d]=d;
  822.                 count_dir = d;
  823.                 return;
  824.         }
  825.         for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
  826.         {
  827.                 if (dir_at_fat16) && (file_name_is_8_3(file_off+40)) strttl(file_off+40);
  828.                 if (TestBit(ESDWORD[file_off],4)) //directory?
  829.                 {
  830.                         file_mas[d]=j;
  831.                         d++;
  832.                 }
  833.                 else
  834.                 {
  835.                         file_mas[files.count-f]=j;
  836.                         f++;
  837.                 }
  838.         }
  839.         count_dir = d;
  840.         //sorting: files first, then folders
  841.         Sort_by_Name(0,d-1);
  842.         if (sort_type==1) Sort_by_Name(d,files.count-1);
  843.         else if (sort_type==2) Sort_by_Type(d,files.count-1);
  844.         else if (sort_type==3) Sort_by_Size(d,files.count-1);
  845.         //reversed sorting
  846.         if (sort_desc) {
  847.                 for (j=0; j<f/2; j++) file_mas[files.count-j-1]><file_mas[d+j];
  848.                 //if (sort_type==1) for (j=0; j<d/2; j++) file_mas[d-j]><file_mas[j];
  849.         }
  850.         //make ".." first item in list
  851.         if (d>0) && (strncmp(file_mas[0]*304+buf+72,"..",2)!=0)
  852.                 for(d--; d>0; d--;) if (!strncmp(file_mas[d]*304+buf+72,"..",2)) {file_mas[d]><file_mas[0]; break;}
  853. }
  854.  
  855.  
  856. void Del_Form()
  857. {
  858.         byte f_count[128];
  859.         int dform_x = files.w - 220 / 2 + files.x;
  860.         if (selected_count==0) && (!strncmp(#file_name,"..",2)) return;
  861.         else
  862.         {
  863.                 if (!files.count) return;
  864.                 DrawEolitePopup(T_YES, T_NO);
  865.                 WriteText(-strlen(T_DELETE_FILE)*3+110+dform_x,175,0x80,sc.work_text,T_DELETE_FILE);
  866.                 if (selected_count)
  867.                 {
  868.                         sprintf(#f_count,"%s%d%s",DEL_MORE_FILES_1,selected_count,DEL_MORE_FILES_2);
  869.                         WriteText(-strlen(#f_count)*3+110+dform_x,190,0x80,sc.work_text,#f_count);
  870.                 }
  871.                 else
  872.                 {
  873.                         if (strlen(#file_name)<28)
  874.                         {
  875.                                 WriteText(strlen(#file_name)*3+110+dform_x+2,190,0x80,sc.work_text,"?");
  876.                                 WriteText(-strlen(#file_name)*3+110+dform_x,190,0x80,sc.work_text,#file_name);
  877.                         }
  878.                         else
  879.                         {
  880.                                 WriteText(164+dform_x,190,0x80,0,"...?");
  881.                                 ESI = 24;
  882.                                 WriteText(dform_x+20,190,0,0,#file_name);
  883.                         }
  884.                 }              
  885.                 del_active=1;
  886.         }
  887. }
  888.  
  889. void SelectFileByName(dword that_file)
  890. {
  891.         int ind;
  892.         files.KeyHome();
  893.         Open_Dir(#path,ONLY_OPEN);
  894.         if (dir_at_fat16) && (file_name_is_8_3(that_file)) strttl(that_file);
  895.         for (ind=files.count-1; ind>=0; ind--;) { if (!strcmp(file_mas[ind]*304+buf+72,that_file)) break; }
  896.         files.cur_y = ind - 1;
  897.         files.KeyDown();
  898.         DrawStatusBar();
  899.         List_ReDraw();
  900. }
  901.  
  902.  
  903. void Dir_Up()
  904. {
  905.         int iii;
  906.         char old_folder_name[4096];
  907.         iii=strlen(#path)-1;
  908.         if (iii==0) return;
  909.         iii = strrchr(#path, '/');
  910.         strcpy(#old_folder_name, #path+iii);
  911.         if (iii>1) path[iii-1]=NULL; else path[iii]=NULL;
  912.         SelectFileByName(#old_folder_name);
  913. }
  914.  
  915. void Open(byte rez)
  916. {
  917.         byte temp[4096];
  918.         selected_count = 0;
  919.         if (rez)
  920.         {
  921.                 if (!strncmp(#file_name,"..",3)) return;
  922.                 strcpy(#temp, #file_path);
  923.                 RunProgram(I_Path, #temp);
  924.                 return;
  925.         }
  926.         if (!files.count) return;
  927.         if (!itdir)
  928.         {
  929.                 if (strrchr(#file_name, '.')==0) RunProgram(#file_path, ""); else RunProgram("/sys/@open", #file_path);
  930.         }
  931.         else
  932.         {
  933.                 if (!strncmp(#file_name,"..",3)) { Dir_Up(); return; }
  934.                 strcpy(#path, #file_path);
  935.                 files.first=files.cur_y=0;
  936.                 Open_Dir(#path,WITH_REDRAW);
  937.         }
  938. }
  939.  
  940. inline fastcall void EventHistoryGoBack()
  941. {
  942.         char cur_folder[4096];
  943.         strcpy(#cur_folder, #path);
  944.         if (history.back()) {
  945.                 strcpy(#path, history.current());
  946.                 SelectFileByName(#cur_folder+strrchr(#cur_folder,'/'));
  947.         }
  948. }
  949.  
  950. void ShowOpenWithDialog()
  951. {
  952.         byte open_param[4097];
  953.         sprintf(#open_param,"~%s",#file_path);
  954.         RunProgram("/sys/@open", #open_param);
  955. }
  956.  
  957. void NewElement(byte newf)
  958. {
  959.         BDVK element_info;
  960.         byte del_rezult, copy_rezult, info_result;
  961.         if (newf)
  962.         {
  963.                 sprintf(#temp,"%s/%s",#path,new_file_ed.text);
  964.                 info_result = GetFileInfo(#temp, #element_info);
  965.                 switch(new_element_active)
  966.                 {
  967.                         case CREATE_FILE:
  968.                                 if (info_result==5)
  969.                                 {
  970.                                         CreateFile(0, 0, #temp);
  971.                                         if (EAX)
  972.                                         {
  973.                                                 if (EAX==5) notify(NOT_CREATE_FILE);
  974.                                                 else Write_Error(EAX);
  975.                                         }
  976.                                 }
  977.                                 else
  978.                                 {
  979.                                         notify(FS_ITEM_ALREADY_EXISTS);
  980.                                 }
  981.                                 break;
  982.                         case CREATE_FOLDER:
  983.                                 if (info_result==5)
  984.                                 {
  985.                                         CreateDir(#temp);
  986.                                         if (EAX)
  987.                                         {
  988.                                                 if (EAX==5) notify(NOT_CREATE_FOLDER);
  989.                                                 else Write_Error(EAX);
  990.                                         }
  991.                                 }
  992.                                 else
  993.                                 {
  994.                                         notify(FS_ITEM_ALREADY_EXISTS);
  995.                                 }
  996.                                 break;
  997.                         case RENAME_ITEM:
  998.                                 if (info_result==5)
  999.                                 {
  1000.                                         if (itdir)
  1001.                                         {
  1002.                                                 //rename only empty folders
  1003.                                                 if (del_rezult = DeleteFile(#file_path))
  1004.                                                 {
  1005.                                                         Write_Error(del_rezult);
  1006.                                                         return;
  1007.                                                 }
  1008.                                                 if (CreateDir(#temp)) CreateDir(#file_path);
  1009.                                                 Open_Dir(#path,WITH_REDRAW);
  1010.                                                 SelectFileByName(new_file_ed.text);
  1011.                                         }
  1012.                                         else
  1013.                                         {
  1014.                                                 if (copy_rezult = CopyFile(#file_path,#temp))
  1015.                                                 {
  1016.                                                         Write_Error(copy_rezult);
  1017.                                                 }
  1018.                                                 else
  1019.                                                 {
  1020.                                                         DeleteFile(#file_path);
  1021.                                                         SelectFileByName(new_file_ed.text);
  1022.                                                 }
  1023.                                         }
  1024.                                 }
  1025.                                 else
  1026.                                 {
  1027.                                         notify(FS_ITEM_ALREADY_EXISTS);
  1028.                                 }
  1029.                 }
  1030.                 new_element_active = 0;
  1031.                 Open_Dir(#path,WITH_REDRAW);
  1032.                 SelectFileByName(new_file_ed.text);
  1033.         }
  1034.         new_element_active = 0;
  1035.         Open_Dir(#path,WITH_REDRAW);
  1036. }
  1037.  
  1038. void NewElement_Form(byte crt, dword strng)
  1039. {
  1040.         int dform_x=files.w-220/2+files.x;
  1041.         if (!new_element_active)
  1042.         {
  1043.                 new_element_active = crt;
  1044.                 strcpy(#new_element_name, strng);
  1045.                 EditBox_UpdateText(#new_file_ed, ed_focus+ed_always_focus);
  1046.         }
  1047.         if (new_element_active==3) DrawEolitePopup(T_RENAME, T_CANCEL);
  1048.         else DrawEolitePopup(T_CREATE, T_CANCEL);
  1049.         new_file_ed.left = dform_x+10;
  1050.         DrawEditBox(#new_file_ed);
  1051. }
  1052.  
  1053. void FnProcess(byte N)
  1054. {
  1055.         switch(N)
  1056.         {
  1057.                 case 1:
  1058.                         if (!active_about) {
  1059.                                 about_stak = malloc(4096);
  1060.                                 about_thread_id = CreateThread(#about_dialog,about_stak+4092);
  1061.                                 break;
  1062.                         } else {
  1063.                                 ActivateWindow(GetProcessSlot(about_thread_id));
  1064.                         }
  1065.                         break;
  1066.                 case 2:
  1067.                         if (files.count) NewElement_Form(RENAME_ITEM, #file_name);
  1068.                         break;
  1069.                 case 3:
  1070.                         if (files.count) && (!itdir) RunProgram("/sys/tinypad", #file_path);
  1071.                         break;
  1072.                 case 4:
  1073.                         if (files.count) && (!itdir) RunProgram("/sys/develop/heed", #file_path);
  1074.                         break;
  1075.                 case 5: //refresh cur dir & devs
  1076.                         if (two_panels.checked)
  1077.                         {
  1078.                                 DrawFilePanels();
  1079.                         }
  1080.                         else
  1081.                         {
  1082.                                 Tip(56, T_DEVICES, 55, "-");
  1083.                                 Open_Dir(#path,WITH_REDRAW);
  1084.                                 pause(10);
  1085.                                 SystemDiscs.Get();
  1086.                                 Open_Dir(#path,WITH_REDRAW);
  1087.                                 DrawDeviceAndActionsLeftPanel();                               
  1088.                         }
  1089.                         break;
  1090.                 case 6:
  1091.                         NewElement_Form(CREATE_FOLDER, T_NEW_FOLDER);
  1092.                         break;
  1093.                 case 7:
  1094.                         NewElement_Form(CREATE_FILE, T_NEW_FILE);
  1095.                         break;
  1096.                 case 8:
  1097.                         properties_stak = malloc(8096);
  1098.                         CreateThread(#properties_dialog, properties_stak+8092);
  1099.                         break;
  1100.                 case 10: //F10
  1101.                         if (!active_settings)
  1102.                         {
  1103.                                 settings_stak = malloc(4096);
  1104.                                 settings_window = CreateThread(#settings_dialog, settings_stak+4092);
  1105.                                 break;
  1106.                         }
  1107.                         else
  1108.                         {
  1109.                                 ActivateWindow(GetProcessSlot(settings_window));
  1110.                         }
  1111.                         break;
  1112.         }
  1113. }
  1114.  
  1115. void ChangeActivePanel()
  1116. {
  1117.         llist_copy(#files_active, #files_inactive);
  1118.         llist_copy(#files_inactive, #files);
  1119.         strcpy(#active_path, #inactive_path);
  1120.         strcpy(#inactive_path, #path);
  1121.         DrawFilePanels();
  1122. }
  1123.  
  1124. void EventSelectAllFiles(dword state)
  1125. {
  1126.         int i;
  1127.         for (i=0; i<files.count; i++) setElementSelectedFlag(i, state);
  1128.         List_ReDraw();
  1129.         DrawStatusBar();
  1130. }
  1131.  
  1132. void EventSelectFileByKeyPress()
  1133. {
  1134.         int i;
  1135.         for (i=files.cur_y+1; i<files.count; i++)
  1136.         {
  1137.                 strcpy(#temp, file_mas[i]*304+buf+72);
  1138.                 if (temp[0]==key_ascii) || (temp[0]==key_ascii-32)
  1139.                 {
  1140.                         files.cur_y = i - 1;
  1141.                         files.KeyDown();
  1142.                         List_ReDraw();
  1143.                         return;
  1144.                 }
  1145.         }
  1146. }
  1147.  
  1148. dword GetDeviceSizeLabel(dword path)
  1149. {
  1150.         BDVK bdvk;
  1151.         char cdname[8];
  1152.         if (ESBYTE[path+1] == '/') path++;
  1153.         if (ESBYTE[path+1] == 'c') && (ESBYTE[path+2] == 'd')
  1154.                 && (ESBYTE[path+4] == 0) return 0;
  1155.         GetFileInfo(path, #bdvk);
  1156.         return ConvertSize64(bdvk.sizelo, bdvk.sizehi);
  1157. }
  1158.  
  1159. int GetRealFileCountInFolder(dword folder_path)
  1160. {
  1161.         int fcount;
  1162.         dword countbuf;
  1163.  
  1164.         GetDir(#countbuf, #fcount, folder_path, DIRS_NOROOT);
  1165.         if (countbuf) free(countbuf);
  1166.  
  1167.         return fcount;
  1168. }
  1169.  
  1170. void EventRefreshDisksAndFolders()
  1171. {
  1172.         if(GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
  1173.                 FnProcess(5);
  1174.         }
  1175.         if(two_panels.checked)
  1176.         {
  1177.                 if(GetRealFileCountInFolder(#inactive_path) != files_inactive.count) {
  1178.                         ChangeActivePanel();
  1179.                         Open_Dir(#path,WITH_REDRAW);
  1180.                         ChangeActivePanel();
  1181.                 }
  1182.                 if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
  1183.         }
  1184.         else
  1185.         {
  1186.                 if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
  1187.         }
  1188. }
  1189.  
  1190. void EventSort(dword id)
  1191. {
  1192.         char selected_filename[256];
  1193.         if (sort_type == id) sort_desc ^= 1;
  1194.         else sort_type = id;
  1195.         strcpy(#selected_filename, #file_name);
  1196.         DrawList();
  1197.         Open_Dir(#path,WITH_REDRAW);
  1198.         SelectFileByName(#selected_filename);
  1199. }
  1200.  
  1201. void EventHistoryGoForward()
  1202. {
  1203.         if (history.forward()) {
  1204.                 strcpy(#path, history.current());
  1205.                 files.KeyHome();
  1206.                 Open_Dir(#path,WITH_REDRAW);
  1207.         }
  1208. }
  1209.  
  1210. void EventOpenNewEolite()
  1211. {
  1212.         RunProgram(I_Path, #path);
  1213. }
  1214.  
  1215. void EventOpenConsoleHere()
  1216. {
  1217.         sprintf(#param, "pwd cd %s", #path);
  1218.         RunProgram("/sys/shell", #param);
  1219. }
  1220.  
  1221. void ProceedMouseGestures()
  1222. {
  1223.         char stats;
  1224.         signed x_old, y_old, dif_x, dif_y, adif_x, adif_y;
  1225.         if (!mouse.mkm) && (stats>0) stats = 0;
  1226.         if (mouse.mkm) && (!stats)
  1227.         {
  1228.                 x_old = mouse.x;
  1229.                 y_old = mouse.y;
  1230.                 stats = 1;
  1231.         }
  1232.         if (mouse.mkm) && (stats==1)
  1233.         {
  1234.                 dif_x = mouse.x-x_old;
  1235.                 dif_y = mouse.y-y_old;
  1236.                 adif_x = fabs(dif_x);
  1237.                 adif_y = fabs(dif_y);
  1238.                
  1239.                 if (adif_x>adif_y) {
  1240.                         if (dif_x > 150) {
  1241.                                 EventHistoryGoForward();
  1242.                                 stats = 0;
  1243.                         }
  1244.                         if (dif_x < -150) {
  1245.                                 EventHistoryGoBack();
  1246.                                 stats = 0;
  1247.                         }
  1248.                 } else {
  1249.                         if (dif_y < -100) {
  1250.                                 Dir_Up();
  1251.                                 stats = 0;
  1252.                         }
  1253.                 }
  1254.         }
  1255. }
  1256.  
  1257. stop:
  1258.