Subversion Repositories Kolibri OS

Rev

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

  1. //Leency & Veliant 2008-2013
  2. //GNU GPL licence.
  3.  
  4. //êîïèðîâàòü ÷åðåç ïîòîê
  5.  
  6. //libraries
  7. #define MEMSIZE 0xA0000
  8. #include "..\lib\kolibri.h"
  9. #include "..\lib\strings.h"
  10. #include "..\lib\mem.h"
  11. #include "..\lib\dll.h"
  12. #include "..\lib\lib.obj\box_lib.h"
  13. #include "..\lib\file_system.h"
  14. #include "..\lib\figures.h"
  15. #include "..\lib\encoding.h"
  16. #include "..\lib\list_box.h"
  17. #include "..\lib\copyf.h"
  18. //images
  19. #include "imgs\toolbar.txt"
  20. #include "imgs\left_p.txt"
  21.  
  22. //for OpenDir
  23. #define ONLY_SHOW       0
  24. #define WITH_REDRAW     1
  25. #define ONLY_OPEN       2
  26.  
  27. #define TITLE "Eolite File Manager v1.77"
  28. #define ABOUT_TITLE "Eolite v1.77"
  29. dword col_work    = 0xE4DFE1;
  30. dword col_border  = 0x819FC5;
  31. dword col_padding = 0xC8C9C9;
  32. dword col_selec   = 0x94AECE;
  33. dword col_lpanel  = 0x00699C;
  34.  
  35. int toolbar_buttons_x[7]={9,46,85,134,167,203};
  36. char tmp_disk_del_param[3]="d0";
  37. struct path_string { char Item[4096]; };
  38.  
  39. llist files;
  40.  
  41. byte
  42.         path[4096],
  43.         file_path[4096],
  44.         file_name[256],
  45.         copy_file[4096],
  46.         temp[4096];      
  47. byte
  48.         cut_active,
  49.         rename_active,
  50.         del_active;
  51. byte
  52.         show_dev_name=1,
  53.         sort_num=2,
  54.         isdir;
  55.  
  56. proc_info Form;
  57. mouse m;
  58. int mouse_dd, scroll_used, scroll_size;
  59. dword buf, off;
  60. dword file_mas[6898];
  61. int j, i;
  62.  
  63. edit_box edit2= {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xffffff,0,248,#file_name,#mouse_dd,64,6,6};
  64. PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0};
  65. PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
  66.  
  67. #include "include\some_code.h"
  68. #include "include\about_dialog.h"
  69. #include "include\sorting.h"
  70. #include "include\icons_f.h"
  71. #include "include\ini.h"
  72. #include "include\left_panel.h"
  73. #include "include\history.h"
  74. #include "include\file_menu.h"
  75.  
  76. void main()
  77. {
  78.         word key, id, can_show, can_select;
  79.  
  80.         files.line_h=18;
  81.         mem_Init();
  82.         if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/box_lib.obj");
  83.         SystemDiscsGet();
  84.         GetIni(1);     
  85.         if (param)
  86.         {
  87.                 strcpy(#path, #param);
  88.                 if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //add "/" to the end of the string
  89.         }
  90.         else
  91.                 strcpy(#path, "/rd/1/");               
  92.         Open_Dir(#path,ONLY_OPEN);
  93.         SetEventMask(0x27);
  94.         loop() switch(WaitEvent())
  95.         {
  96.                 case evMouse:
  97.                         IF (del_active) break;         
  98.                         id=GetProcessSlot(Form.ID);
  99.                         IF (id<>GetActiveProcess()) || (Form.status_window>2) break;
  100.                         IF (rename_active) { edit_box_mouse stdcall(#edit2); break; }
  101.                        
  102.                         m.get();
  103.  
  104.                         if (m.x > files.x) && (m.x < files.x + files.w) && (m.y > files.y) && (m.y < files.y+files.h)
  105.                         {
  106.                                 if (m.lkm) can_select = 1;
  107.                                 if (m.pkm)
  108.                                 {
  109.                                         can_show = 1;
  110.                                         if (m.y - 57 / files.line_h != files.current) can_select = 1;
  111.                                 }
  112.                         }
  113.  
  114.                         //select/open file {
  115.                         if (!m.lkm) && (!m.pkm) && (can_select)
  116.                         {
  117.                                 can_select = 0;
  118.                                 if (m.y<57) break;
  119.                                 id = m.y - 57 / files.line_h;
  120.                                 if (files.current!=id) FileList_ReDraw(id-files.current);
  121.                                 else Open();
  122.                         };
  123.                         // } select/open file
  124.  
  125.                         //file menu {
  126.                         if (!m.pkm) && (!m.lkm) && (can_show)
  127.                         {
  128.                                 can_show = 0;
  129.                                 if (m.y<57) break;
  130.                                 SwitchToAnotherThread();
  131.                                 CreateThread(#FileMenu,#stak2);
  132.                                 break;
  133.                         }
  134.                         // } file menu
  135.  
  136.  
  137.                         if (m.vert)
  138.                         {
  139.                                 files.MouseScroll(m.vert);
  140.                                 List_ReDraw();
  141.                                 break;
  142.                         }
  143.  
  144.                         if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>40) && (m.y<57)
  145.                         {
  146.                                 IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),41,14,14,0xC7C7C7,0xFFFFFF);
  147.                                 WHILE (m.lkm==1) && (files.first>0)
  148.                                 {
  149.                                         pause(8);
  150.                                         files.first--;
  151.                                         List_ReDraw();
  152.                                         m.get();
  153.                                 }
  154.                                 DrawRectangle3D(onLeft(26,0),41,14,14,0xFFFFFF,0xC7C7C7);
  155.                         }
  156.  
  157.                         if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>onTop(22,0)+1) && (m.y<onTop(22,0)+16)
  158.                         {
  159.                                 IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xC7C7C7,0xFFFFFF);
  160.                                 while (m.lkm==1) && (files.first<files.count-files.visible)
  161.                                 {
  162.                                         pause(8);
  163.                                         files.first++;
  164.                                         List_ReDraw();
  165.                                         m.get();
  166.                                 }
  167.                                 DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xFFFFFF,0xC7C7C7);
  168.                         }
  169.  
  170.                         //Scrooll
  171.                         if (!m.lkm) && (scroll_used) { scroll_used=NULL; Scroll(); }
  172.                         if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>56) && (m.y<Form.height) && (m.lkm) && (!scroll_used) {scroll_used=1;Scroll();}
  173.                        
  174.                         if (scroll_used)
  175.                         {
  176.                                 IF (scroll_size/2+57>m.y) || (m.y<0) || (m.y>4000) m.y=scroll_size/2+57; //anee eo?ni? iaa ieiii
  177.                                 id=files.first;
  178.                                 j= scroll_size/2;
  179.                                 files.first = m.y -j -57 * files.count;
  180.                                 files.first /= onTop(22,57);
  181.                                 IF (files.visible+files.first>files.count) files.first=files.count-files.visible;
  182.                                 IF (id<>files.first) List_ReDraw();
  183.                         }
  184.                         break;  
  185. //Button pressed-----------------------------------------------------------------------------
  186.                 case evButton:
  187.                         id=GetButtonID();
  188.                         IF (id==1) ExitProcess();
  189.  
  190.                         IF (del_active)
  191.                         {
  192.                                 IF (id==301) || (id==302) Del_File(302-id);
  193.                                 break;
  194.                         }
  195.                         switch(id)
  196.                         {
  197.                                 case 21: //Back
  198.                                                 GoBack();
  199.                                                 break;
  200.                                 case 22: //Forward
  201.                                                 if (HistoryPath(GO_FORWARD))
  202.                                                 {
  203.                                                         files.first=files.current=NULL; //aaa?o nienea
  204.                                                         Open_Dir(#path,WITH_REDRAW);
  205.                                                 }
  206.                                                 break;
  207.                                 case 23: //up!
  208.                                                 Dir_Up();
  209.                                                 break;
  210.                                 case 24: //cut
  211.                                                 key=24;
  212.                                 case 25: //copy
  213.                                                 goto CTRLC_MARK;
  214.                                 case 26: //paste
  215.                                                 Paste();
  216.                                                 break;
  217.                                 case 31...33: //sort
  218.                                                 IF(sort_num==1) DrawFilledBar(onLeft(192,168)/2+210,42,6,10);
  219.                                                 IF(sort_num==2) DrawFilledBar(onLeft(115,0),42,6,10);
  220.                                                 IF(sort_num==3) DrawFilledBar(onLeft(44,0),42,6,10);
  221.                                                 sort_num=id-30;
  222.                                                 Open_Dir(#path,WITH_REDRAW);
  223.                                                 break;
  224.                                 case 78: //rescan devices
  225.                                                 Tip(56, "Devices", 78, "-");
  226.                                                 pause(10);
  227.                                                 GetIni(1);
  228.                                                 SystemDiscsGet();
  229.                                                 Open_Dir(#path,WITH_REDRAW);
  230.                                                 DrawLeftPanel();
  231.                                                 break;
  232.                                 case 50...60: //Actions
  233.                                                 ActionsProcess(id-50);
  234.                                                 break;
  235.                                 case 100...120:
  236.                                         DEVICE_MARK:
  237.                                                 DrawRectangle3D(17,id-100*16+74,159,16, 0, 0); //auaaeaiea
  238.                                                 strcpy(#path, #disk_list[id-100].Item);
  239.                                                 files.first=files.current=0;
  240.                                                 Open_Dir(#path,1);
  241.                                                 pause(5);
  242.                                                 DrawRectangle3D(17,id-100*16+74,159,16, 0xFFFFFF, 0xFFFFFF);
  243.                                                 break;
  244.                                 case 130...160:
  245.                                                 tmp_disk_del_param[1]=disk_list[id-130].Item[4];
  246.                                                 RunProgram("/sys/tmpdisk", #tmp_disk_del_param);
  247.                                                 pause(10);
  248.                                                 SystemDiscsGet();
  249.                                                 Open_Dir(#path,WITH_REDRAW);
  250.                                                 DrawLeftPanel();
  251.                                                 break;
  252.                         }
  253.                         break;
  254. //Key pressed-----------------------------------------------------------------------------
  255.                 case evKey:
  256.                         key = GetKey();
  257.                         if (Form.status_window>2) break;
  258.                         IF (del_active)
  259.                         {
  260.                                 IF (key==013) Del_File(true);
  261.                                 IF (key==027) Del_File(false);
  262.                                 break;
  263.                         }
  264.                         IF (edit2.flags<>64) && (key<>13) && (key<>27)
  265.                         {
  266.                                 EAX=key<<8;
  267.                                 edit_box_key stdcall (#edit2);
  268.                                 break;
  269.                         }
  270.                         switch (key)
  271.                         {
  272.                                         case 209...217:
  273.                                                         id=key-110;
  274.                                                         IF (id-100>=disc_num) break;
  275.                                                         GOTO DEVICE_MARK;
  276.                                         case 008:
  277.                                                         //GoBack();
  278.                                                         Dir_Up();
  279.                                                         break;
  280.                                         case 004: //Ctrl+D set as bg
  281.                                                         strcpy(#temp, "\\S__");
  282.                                                         strcat(#temp, #file_path);
  283.                                                         RunProgram("/sys/media/kiv", #temp);
  284.                                                         break;
  285.                                         case 014: //Ctrl+N new window
  286.                                                         IF (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD);
  287.                                                         RunProgram("/sys/File Managers/Eolite", #path);
  288.                                                         break;
  289.                                         case 024: //Ctrl+X
  290.                                         case 003: //Ctrl+C
  291.                                                         CTRLC_MARK:
  292.                                                         IF (isdir) break;
  293.                                                         strcpy(#copy_file, #file_path);
  294.                                                         IF (key==24) cut_active=1; ELSE cut_active=0;
  295.                                                         break;
  296.                                         case 022: //Ctrl+V
  297.                                                         Paste();
  298.                                                         break;
  299.                                         case 027: //Esc
  300.                                                         IF (rename_active==1) ReName(false);
  301.                                                         break;
  302.                                         case 013: //Enter
  303.                                                         IF (rename_active==1) {ReName(true); break;}
  304.                                                         Open();
  305.                                                         break;
  306.                                         case 178: //up
  307.                                                         FileList_ReDraw(-1);
  308.                                                         break;
  309.                                         case 177: //down
  310.                                                         FileList_ReDraw(1);
  311.                                                         break;
  312.                                         case 180: //home
  313.                                                         files.first=0;
  314.                                                         files.current=0;
  315.                                                         List_ReDraw();
  316.                                                         break;
  317.                                         case 181: //end
  318.                                                         files.first=files.count-files.visible;
  319.                                                         files.current=files.visible-1;
  320.                                                         List_ReDraw();
  321.                                                         break;
  322.                                         case 183: //Page Down
  323.                                                         FileList_ReDraw(files.visible-1);
  324.                                                         break;
  325.                                         case 184: //Page Up
  326.                                                         FileList_ReDraw(-files.visible+1);
  327.                                                         break;
  328.                                         case 182: //del
  329.                                                         Del_Form();
  330.                                                         break;
  331.                                         case 050...059: //F1-F10
  332.                                                         ActionsProcess(key-49);
  333.                                                         break;
  334.                                         default:    
  335.                                                         for (i=files.current+files.first+1; i<files.count; i++)
  336.                                                         {
  337.                                                                 strcpy(#temp, file_mas[i]*304+buf+72);
  338.                                                                 IF (temp[0]==key) || (temp[0]==key-32)
  339.                                                                 {
  340.                                                                         FileList_ReDraw(i-files.current-files.first);
  341.                                                                         break;
  342.                                                                 }
  343.                                                         }
  344.                         }                        
  345.                         break;
  346.                 case evReDraw:
  347.                         DefineAndDrawWindow(40,20,550,500,0x73,col_work,TITLE);
  348.                         GetProcessInfo(#Form, SelfInfo);
  349.                         if (Form.status_window>2) break;
  350.                         files.SetSizes(192, 57, onLeft(192,27), onTop(57,6), disc_num*16+195,files.line_h);
  351.                         if (Form.height < files.min_h) MoveSize(OLD,OLD,OLD,files.min_h);
  352.                         if (Form.width<480) MoveSize(OLD,OLD,480,OLD);
  353.                         draw_window();
  354.         }
  355. }
  356.  
  357.  
  358. inline fastcall void draw_window()
  359. {      
  360.         //toolbar
  361.         PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal);
  362.         for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,col_work);
  363.         for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,col_work);
  364.         DrawBar(246,0,onLeft(246,60),12, col_work); //ôîí íàä ïîëîñîé àäðåñà
  365.         DrawBar(246,29,onLeft(246,60),5,col_work);  //ôîí ïîä ïîëîñîé àäðåñà
  366.         DrawRectangle3D(246,12,onLeft(66,246),16,col_border,col_border);
  367.         DefineButton(onLeft(34,0),6,27,28,51+BT_HIDE+BT_NOFRAME,col_work); //about
  368.         PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal);
  369.         //main rectangles
  370.         DrawRectangle3D(1,40,Form.cwidth-3,onTop(46,0),col_border,col_border);
  371.         DrawRectangle3D(0,39,Form.cwidth-1,onTop(44,0),col_palette[4],col_palette[4]); //bg
  372.         for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]);
  373.         DrawLeftPanel();
  374.         //ListBox
  375.         DrawFlatButton(files.x,40,onLeft(files.x,168),16,31,col_work,"File");
  376.         DrawFlatButton(onLeft(168,0),40,73,16,32,col_work,"Type");
  377.         DrawFlatButton(onLeft(95,0),40,68,16,33,col_work,"Size");
  378.         DrawBar(onLeft(27,0),57,1,onTop(22,57),col_border); //line to the left from the scroll
  379.         DrawFlatButton(onLeft(27,0),40,16,16,0,col_work,"\x18");
  380.         DrawFlatButton(onLeft(27,0),onTop(22,0),16,16,0,col_work,"\x19");
  381.         Open_Dir(#path,ONLY_SHOW);
  382.         if (del_active) Del_Form();
  383. }
  384.  
  385.  
  386. void KEdit()
  387. {
  388.         if (Form.width<480) return;
  389.         PathShow.area_size_x = Form.cwidth-306;
  390.         DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff);
  391.         PathShow_prepare stdcall(#PathShow);
  392.         PathShow_draw stdcall(#PathShow);
  393. }
  394.  
  395.  
  396. void FileList_ReDraw(int cur)
  397. {
  398.         if (cur<=0) //up
  399.         {
  400.                 IF (files.first==0) && (files.current<=0) return;
  401.                 IF (-cur-1<files.current)
  402.                 {
  403.                         Line_ReDraw(0xFFFFFF, files.current);
  404.                         files.current+=cur;
  405.                         Line_ReDraw(col_selec, files.current);
  406.                         return;
  407.                 }
  408.                 ELSE
  409.                 {
  410.                         IF (-cur<files.first) files.first+=cur; ELSE files.first=0;
  411.                         files.current=0;
  412.                         List_ReDraw();
  413.                         return;
  414.                 }
  415.         }
  416.         else  //down
  417.         {
  418.                 IF (files.first==files.count-files.visible) && (files.current==files.visible-1) return;
  419.                 IF (files.visible-files.current>cur)
  420.                 {
  421.                         Line_ReDraw(0xFFFFFF, files.current);
  422.                         files.current+=cur;
  423.                         Line_ReDraw(col_selec, files.current);
  424.                         return;
  425.                 }
  426.                 else
  427.                 {
  428.                         IF(files.first+files.current+cur>=files.count)
  429.                         {
  430.                                 files.first=files.count-files.visible;
  431.                                 files.current=cur-files.first+files.current;
  432.                                 }
  433.                         ELSE
  434.                         {
  435.                                 files.first+=cur+files.current-files.visible+1;
  436.                                 files.current=files.visible-1;
  437.                         }
  438.                        
  439.                         IF (files.current<0) || (files.current>files.visible)
  440.                         {
  441.                                 files.current=files.visible-1;
  442.                         }
  443.                         List_ReDraw();
  444.                 }
  445.         }
  446. }
  447.  
  448.  
  449.  
  450.  
  451. void List_ReDraw()
  452. {
  453.         int paint_y;
  454.         //åñëè ìû â êîíöå ñïèñêà ôàéëîâ ðàçâåðí¸ì îêíî ïîÿâÿòüñÿ ïóñòÿå áåëûå êíîïêè
  455.         //ýòî åñëè âûäåëåíèå ïîñëå ñõëîïûâàíèÿ îêíà çà êàäðîì
  456.         if (files.count-files.first<files.visible) || (files.current>files.visible-1)
  457.         { files.first=files.count-files.visible; files.current=files.visible-1; }
  458.  
  459.         for (j=0; j<files.visible; j++) if (files.current<>j) Line_ReDraw(0xFFFFFF, j); else Line_ReDraw(col_selec, files.current);
  460.         //in the bottom
  461.         paint_y = j * files.line_h + files.y;
  462.         DrawBar(files.x,paint_y,files.w,onTop(paint_y,6),0xFFFFFF);
  463.         DrawBar(onLeft(168,0),paint_y,1,onTop(paint_y,6),col_work);
  464.         DrawBar(onLeft(95,0),paint_y,1,onTop(paint_y,6),col_work);
  465.         Scroll();
  466. }
  467.  
  468. void Line_ReDraw(dword color, filenum){
  469.         dword text_col=0, name_len=0, y=filenum*files.line_h+57;
  470.         IF (rename_active==1) ReName(false);
  471.         DrawBar(192,y,3,files.line_h,color);
  472.         DrawBar(192+19,y,onLeft(46,192),files.line_h,color); DrawBar(195,y+17,16,1,color);
  473.         if (files.line_h>18) DrawBar(195,y+18,16,files.line_h-18,color);
  474.         if (files.line_h>15) DrawBar(195,y,16,files.line_h-15,color);
  475.  
  476.         off=file_mas[filenum+files.first]*304 + buf+72;
  477.  
  478.         if (!TestBit(ESDWORD[off-40], 4)) //file or folder?
  479.         {      
  480.                 strcpy(#temp, off);
  481.                 Put_icon(#temp+_strrchr(#temp,'.'), files.line_h/2-7+y, color);
  482.                 WriteText(7-strlen(ConvertMemSize(ESDWORD[off-8]))*6+onLeft(75,0),files.line_h-6/2+y,0x80,0,ConvertMemSize(ESDWORD[off-8])); //size
  483.         }
  484.         else
  485.                 if (!strcmp("..",off))
  486.                         Put_icon("..", files.line_h/2-7+y, color);
  487.                 else
  488.                         Put_icon("<DIR>", files.line_h/2-7+y, color);
  489.         if (TestBit(ESDWORD[off-40],1)) || (TestBit(ESDWORD[off-40],2)) text_col=0xA6A6B7; //system or hiden?
  490.         if (color<>0xFFFfff)
  491.         {
  492.                 isdir=TestBit(ESDWORD[off-40], 4);             
  493.                 strcpy(#file_name, off);
  494.                 strcpy(#file_path, #path);
  495.                 strcat(#file_path, #file_name);
  496.                 if (text_col==0xA6A6B7) text_col=0xFFFFFF;
  497.         }
  498.         if (Form.width>=480)
  499.         {
  500.                 FileShow.font_color = text_col;
  501.                 FileShow.area_size_x = Form.width - 380;
  502.                 FileShow.text_pointer = off;
  503.                 FileShow.start_y = files.line_h/2-3+y;
  504.                 PathShow_prepare stdcall(#FileShow);
  505.                 PathShow_draw stdcall(#FileShow);
  506.         }
  507.         DrawBar(onLeft(168,0),y,1,files.line_h,col_work); //gray line 1
  508.         DrawBar(onLeft(95,0),y,1,files.line_h,col_work); //gray line 2
  509. }
  510.  
  511.  
  512. void Open_Dir(dword temp_, redraw){
  513.         int errornum, count;
  514.         char path_[4096],
  515.         somelen=strlen(temp_)-1;
  516.  
  517.         if (redraw<>ONLY_SHOW)
  518.         {
  519.                 strcpy(#path_, temp_);
  520.                 if (somelen) path_[somelen]=NULL;
  521.                
  522.                 if (buf) free(buf);
  523.         buf = malloc(32);
  524.                 errornum=ReadDir(0, buf, #path_);
  525.                 if (errornum<>0)
  526.                 {
  527.                         HistoryPath(ADD_NEW_PATH);
  528.                         GoBack();
  529.                         Write_Error(errornum);
  530.                         return;
  531.                 }
  532.         files.count = ESDWORD[buf+8];
  533.         buf = realloc(buf, files.count * 304 + 32);
  534.                 ReadDir(files.count, buf, #path_);
  535.                 files.count=EBX;
  536.                 count = sizeof(file_mas)/sizeof(dword)-1;
  537.                 if (files.count>count) files.count=count;
  538.                
  539.         }
  540.         if (files.count<>-1)
  541.         {
  542.                 KEdit();
  543.                 HistoryPath(ADD_NEW_PATH);
  544.                 IF (!strcmp(".",buf+72)) {files.count--; memmov(buf,buf+304,files.count*304);} //oeeuo?oai yeaiaio "."
  545.                 files.visible=onTop(6,57)/files.line_h;
  546.                 IF (files.count<files.visible) files.visible=files.count;
  547.                 IF (sort_num==1) WriteText(Form.width+60/2,45,0x80,0x4E78AC,"\x19");
  548.                 IF (sort_num==2) WriteText(Form.width-115,45,0x80,0x4E78AC,"\x19");
  549.                 IF (sort_num==3) WriteText(Form.width-44,45,0x80,0x4E78AC,"\x19");
  550.                 IF (redraw<>ONLY_SHOW) Sorting();
  551.                 IF (redraw<>ONLY_OPEN) List_ReDraw();
  552.         }
  553.         IF (files.count==-1) && (redraw<>ONLY_OPEN) {files.visible=files.count=0; List_ReDraw();}
  554. }
  555.  
  556.  
  557.  
  558. inline Sorting()
  559. {
  560.         dword k=0, l=1;
  561.         int i;
  562.         if (!strcmp(#path,"/")) //do not sort
  563.         {
  564.                 FOR(k=1;k<files.count;k++;) file_mas[k]=k;
  565.                 return;
  566.         }
  567.         FOR (j=files.count-1, off=files.count-1*304+buf+32; j>=0; j--, off-=304;)  //files | folders
  568.         {
  569.                 strttl(off+40);
  570.                 if (TestBit(ESDWORD[off],4)) //isdir?
  571.                 {
  572.                         file_mas[k]=j;
  573.                         k++;
  574.                 }
  575.                 else
  576.                 {
  577.                         file_mas[files.count-l]=j;
  578.                         l++;
  579.                 }
  580.         }
  581.         //sorting: files first, then folders
  582.         Sort_by_Name(0,k-1);
  583.         IF (sort_num==1) Sort_by_Name(k,files.count-1);
  584.         IF (sort_num==2) Sort_by_Type(k,files.count-1);
  585.         IF (sort_num==3) Sort_by_Size(k,files.count-1);
  586.         //".." should be first
  587.         IF (k>0) && (strcmp(file_mas[0]*304+buf+72,"..")<>0) FOR(k--; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) file_mas[k]><file_mas[0];
  588. }
  589.  
  590.  
  591. void Del_Form()
  592. {
  593.         int dform_x=Form.width/2-13;
  594.         //oeia ieii
  595.         if (!files.count) return;
  596.         DrawFlatButton(dform_x,160,200,80,0,col_work, ""); //oi?ia
  597.         WriteText(dform_x+19,175,0x80,0,"Do you really want to delete");
  598.         IF (strlen(#file_name)<28)
  599.                 {
  600.                         WriteText(strlen(#file_name)*6+dform_x+20,190,0x80,0,"?");
  601.                         WriteText(dform_x+20,190,0x80,0,#file_name); //ieoai eiy
  602.                 }
  603.         ELSE
  604.                 {
  605.                         WriteText(164+dform_x,190,0x80,0,"...?");
  606.                         ESI = 24;
  607.                         WriteText(dform_x+20,190,0,0,#file_name); //ieoai eiy
  608.                 }
  609.         //eiiii?ee
  610.         DrawFlatButton(dform_x+20,208,70,20,301,0xFFB6B5,"Yes");
  611.         DrawFlatButton(dform_x+111,208,70,20,302,0xC6DFC6,"No");
  612.         del_active=1;
  613. }
  614.  
  615.        
  616. void Del_File(byte dodel)
  617. {    
  618.         int del_rezult;
  619.         IF (dodel==true)
  620.         {
  621.                 del_rezult = DeleteFile(#file_path);
  622.                 IF (del_rezult<>0)
  623.                 {
  624.                         Write_Error(del_rezult);
  625.                         IF ( isdir) ShowMessage("Error. Folder isn't empty.");
  626.                         IF (!isdir) ShowMessage("Error. Filesystem read-only.");
  627.                 }
  628.         }
  629.         del_active=0;
  630.         DeleteButton(301); DeleteButton(302);
  631.         Open_Dir(#path,1);
  632. }    
  633.  
  634. void Paste()
  635. {
  636.         char new_copy_path[4096];
  637.         int copy_rezult;
  638.        
  639.         IF (!copy_file) return;
  640.         strcpy(#new_copy_path, #path);
  641.         strcat(#new_copy_path, #copy_file+strrchr(#copy_file,'/'));
  642.         if (!strcmp(#copy_file,#new_copy_path))
  643.         {
  644.                 strcpy(#new_copy_path, #path);
  645.                 strcat(#new_copy_path, "new_");
  646.                 strcat(#new_copy_path, #copy_file+strrchr(#copy_file,'/'));
  647.         }
  648.         copy_rezult = CopyFile(#copy_file,#new_copy_path);
  649.         IF (copy_rezult!=0)
  650.         {
  651.                 Write_Error(copy_rezult);
  652.                 return;
  653.         }
  654.         IF (cut_active)
  655.         {
  656.                 strcpy(#file_path, #copy_file);
  657.                 Del_File(true);
  658.                 copy_file=NULL;
  659.                 cut_active=false;
  660.         }
  661.         SelectFile(#new_copy_path+strrchr(#new_copy_path,'/'));
  662. }
  663.  
  664.  
  665. void ReName(byte rename)
  666. {
  667.         int del_rezult, copy_rezult;
  668.         char edit_name[256];
  669.         rename_active=0;
  670.         edit2.flags=64;
  671.         if (rename==true)
  672.         {
  673.                 strcpy(#temp, #path);
  674.                 strcpy(#edit_name, #file_name); //save edit name to select it later
  675.                 strcat(#temp, #file_name);
  676.                 if (strcmp(#file_path,#temp)<>0) && (file_name)
  677.                 IF (isdir)
  678.                 {
  679.                         del_rezult = DeleteFile(#file_path);
  680.                         IF (del_rezult!=0)
  681.                         {
  682.                                 Write_Error(del_rezult);
  683.                                 ShowMessage("Error. Folder isn't empty.");
  684.                                 return;
  685.                         }
  686.                         ELSE CreateDir(#temp);
  687.                         Open_Dir(#path,1);
  688.                 }
  689.                 ELSE
  690.                 {
  691.                         copy_rezult = CopyFile(#file_path,#temp);
  692.                         if (copy_rezult!=0) Write_Error(copy_rezult); else Del_File(true);
  693.                 }
  694.                 SelectFile(#edit_name);
  695.         }
  696.         Line_ReDraw(col_selec,files.current);
  697. }
  698.  
  699.  
  700. void SelectFile(dword that_file)
  701. {
  702.         files.first=files.current=0;
  703.         Open_Dir(#path,ONLY_OPEN);
  704.         strttl(that_file);
  705.         for (i=files.count-1; i>=0; i--;)
  706.                 if (!strcmp(file_mas[i]*304+buf+72,that_file)) break;
  707.         FileList_ReDraw(i);
  708.         List_ReDraw();
  709. }
  710.  
  711.  
  712. void Dir_Up()
  713. {
  714.         char cur_folder[4096];
  715.         i=strlen(#path)-1;
  716.         if (i==0) return;
  717.         path[i]=0x00;
  718.         i = strrchr(#path, '/');
  719.         strcpy(#cur_folder, #path+i);
  720.         path[i]=0x00;
  721.         SelectFile(#cur_folder);
  722. }
  723.  
  724. void Open()
  725. {
  726.         if (!isdir)
  727.         {
  728.                 GetIni(0);
  729.         }
  730.         else
  731.         {
  732.                 if (!strcmp(#file_name,"..")) { Dir_Up(); return; }
  733.                 strcpy(#path, #file_path);
  734.                 if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //need "/" in the end
  735.                 files.first=files.current=0;
  736.                 Open_Dir(#path,1);
  737.         }
  738. }
  739.  
  740.  
  741. inline fastcall void GoBack()
  742. {
  743.         char cur_folder[4096];
  744.         strcpy(#cur_folder, GetCurrentFolder());
  745.         if (HistoryPath(GO_BACK)) SelectFile(#cur_folder);
  746. }
  747.  
  748. void ActionsProcess(char N)
  749. {
  750.         switch(N)
  751.         {
  752.                 case 1:
  753.                         SwitchToAnotherThread();
  754.                         CreateThread(#about_dialog,#stak1);
  755.                         break;
  756.                 case 2:
  757.                         if (!files.count) break;
  758.                         DeleteButton(files.current+201);
  759.                         edit2.flags=100000000000010b; //set active
  760.                         edit2.width=onLeft(24,217);
  761.                         edit2.top=files.current*files.line_h+59;
  762.                         edit2.size=edit2.pos=strlen(#file_name);
  763.                         edit_box_draw  stdcall (#edit2);
  764.                         DrawBar(213,files.current*files.line_h+58,edit2.width+1,1,0xFFFFCC); //bg
  765.                         rename_active=1;
  766.                         break;
  767.                 case 3:
  768.                         IF (!isdir) RunProgram("/sys/tinypad", #file_path);
  769.                         break;
  770.                 case 4:
  771.                         IF (!isdir) RunProgram("/sys/develop/heed", #file_path);
  772.                         break;
  773.                 case 5:
  774.                         Open_Dir(#path,1);
  775.                         break;
  776.                 case 6:
  777.                         strcpy(#temp, #path);
  778.                         strcat(#temp, "New folder");
  779.                         CreateDir(#temp);
  780.                         if (!EAX){
  781.                                 SelectFile("New folder");
  782.                                 ActionsProcess(2);
  783.                         }
  784.                         else
  785.                         {
  786.                                 Write_Error(EAX);
  787.                                 ShowMessage("Folder can not be created.");
  788.                         }
  789.                         break;
  790.                 case 7:
  791.                         strcpy(#temp, #path);
  792.                         strcat(#temp, "New file");
  793.                         WriteFile(0, 0, #temp);
  794.                         if (!EAX){
  795.                                 SelectFile("New file");
  796.                                 ActionsProcess(2);
  797.                         }
  798.                         else
  799.                         {
  800.                                 Write_Error(EAX);
  801.                                 ShowMessage("File can not be created.");
  802.                         }
  803.                         break;
  804.                 case 10: //F10
  805.                         RunProgram(EDITOR_PATH, abspath("Eolite.ini"));
  806.                         break;
  807.         }
  808. }
  809.  
  810. void copyf_Action() {
  811.         return;
  812. }
  813.  
  814. stop:
  815.  
  816. char stak1[512];
  817. char stak2[512];