Subversion Repositories Kolibri OS

Rev

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